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

26,908 lines 924.0 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 === React50.startTransition || (didWarnOld18Alpha = true, console.error(
104 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
105 ));
106 var value = getSnapshot();
107 if (!didWarnUncachedGetSnapshot) {
108 var cachedValue = getSnapshot();
109 objectIs(value, cachedValue) || (console.error(
110 "The result of getSnapshot should be cached to avoid an infinite loop"
111 ), didWarnUncachedGetSnapshot = true);
112 }
113 cachedValue = useState36({
114 inst: { value, getSnapshot }
115 });
116 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
117 useLayoutEffect5(
118 function() {
119 inst.value = value;
120 inst.getSnapshot = getSnapshot;
121 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
122 },
123 [subscribe2, value, getSnapshot]
124 );
125 useEffect31(
126 function() {
127 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
128 return subscribe2(function() {
129 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
130 });
131 },
132 [subscribe2]
133 );
134 useDebugValue2(value);
135 return value;
136 }
137 function checkIfSnapshotChanged(inst) {
138 var latestGetSnapshot = inst.getSnapshot;
139 inst = inst.value;
140 try {
141 var nextValue = latestGetSnapshot();
142 return !objectIs(inst, nextValue);
143 } catch (error) {
144 return true;
145 }
146 }
147 function useSyncExternalStore$1(subscribe2, getSnapshot) {
148 return getSnapshot();
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React50 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React50.useState, useEffect31 = React50.useEffect, useLayoutEffect5 = React50.useLayoutEffect, useDebugValue2 = React50.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
152 exports.useSyncExternalStore = void 0 !== React50.useSyncExternalStore ? React50.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 React50 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React50.useRef, useEffect31 = React50.useEffect, useMemo43 = React50.useMemo, useDebugValue2 = React50.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef46(null);
182 if (null === instRef.current) {
183 var inst = { hasValue: false, value: null };
184 instRef.current = inst;
185 } else inst = instRef.current;
186 instRef = useMemo43(
187 function() {
188 function memoizedSelector(nextSnapshot) {
189 if (!hasMemo) {
190 hasMemo = true;
191 memoizedSnapshot = nextSnapshot;
192 nextSnapshot = selector2(nextSnapshot);
193 if (void 0 !== isEqual && inst.hasValue) {
194 var currentSelection = inst.value;
195 if (isEqual(currentSelection, nextSnapshot))
196 return memoizedSelection = currentSelection;
197 }
198 return memoizedSelection = nextSnapshot;
199 }
200 currentSelection = memoizedSelection;
201 if (objectIs(memoizedSnapshot, nextSnapshot))
202 return currentSelection;
203 var nextSelection = selector2(nextSnapshot);
204 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
205 return memoizedSnapshot = nextSnapshot, currentSelection;
206 memoizedSnapshot = nextSnapshot;
207 return memoizedSelection = nextSelection;
208 }
209 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
210 return [
211 function() {
212 return memoizedSelector(getSnapshot());
213 },
214 null === maybeGetServerSnapshot ? void 0 : function() {
215 return memoizedSelector(maybeGetServerSnapshot());
216 }
217 ];
218 },
219 [getSnapshot, getServerSnapshot, selector2, isEqual]
220 );
221 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
222 useEffect31(
223 function() {
224 inst.hasValue = true;
225 inst.value = value;
226 },
227 [value]
228 );
229 useDebugValue2(value);
230 return value;
231 };
232 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
233 })();
234 }
235 });
236
237 // node_modules/use-sync-external-store/shim/with-selector.js
238 var require_with_selector = __commonJS({
239 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
240 "use strict";
241 if (false) {
242 module.exports = null;
243 } else {
244 module.exports = require_with_selector_development();
245 }
246 }
247 });
248
249 // package-external:@wordpress/i18n
250 var require_i18n = __commonJS({
251 "package-external:@wordpress/i18n"(exports, module) {
252 module.exports = window.wp.i18n;
253 }
254 });
255
256 // package-external:@wordpress/primitives
257 var require_primitives = __commonJS({
258 "package-external:@wordpress/primitives"(exports, module) {
259 module.exports = window.wp.primitives;
260 }
261 });
262
263 // package-external:@wordpress/theme
264 var require_theme = __commonJS({
265 "package-external:@wordpress/theme"(exports, module) {
266 module.exports = window.wp.theme;
267 }
268 });
269
270 // package-external:@wordpress/components
271 var require_components = __commonJS({
272 "package-external:@wordpress/components"(exports, module) {
273 module.exports = window.wp.components;
274 }
275 });
276
277 // package-external:@wordpress/keycodes
278 var require_keycodes = __commonJS({
279 "package-external:@wordpress/keycodes"(exports, module) {
280 module.exports = window.wp.keycodes;
281 }
282 });
283
284 // node_modules/remove-accents/index.js
285 var require_remove_accents = __commonJS({
286 "node_modules/remove-accents/index.js"(exports, module) {
287 var characterMap = {
288 "\xC0": "A",
289 "\xC1": "A",
290 "\xC2": "A",
291 "\xC3": "A",
292 "\xC4": "A",
293 "\xC5": "A",
294 "\u1EA4": "A",
295 "\u1EAE": "A",
296 "\u1EB2": "A",
297 "\u1EB4": "A",
298 "\u1EB6": "A",
299 "\xC6": "AE",
300 "\u1EA6": "A",
301 "\u1EB0": "A",
302 "\u0202": "A",
303 "\u1EA2": "A",
304 "\u1EA0": "A",
305 "\u1EA8": "A",
306 "\u1EAA": "A",
307 "\u1EAC": "A",
308 "\xC7": "C",
309 "\u1E08": "C",
310 "\xC8": "E",
311 "\xC9": "E",
312 "\xCA": "E",
313 "\xCB": "E",
314 "\u1EBE": "E",
315 "\u1E16": "E",
316 "\u1EC0": "E",
317 "\u1E14": "E",
318 "\u1E1C": "E",
319 "\u0206": "E",
320 "\u1EBA": "E",
321 "\u1EBC": "E",
322 "\u1EB8": "E",
323 "\u1EC2": "E",
324 "\u1EC4": "E",
325 "\u1EC6": "E",
326 "\xCC": "I",
327 "\xCD": "I",
328 "\xCE": "I",
329 "\xCF": "I",
330 "\u1E2E": "I",
331 "\u020A": "I",
332 "\u1EC8": "I",
333 "\u1ECA": "I",
334 "\xD0": "D",
335 "\xD1": "N",
336 "\xD2": "O",
337 "\xD3": "O",
338 "\xD4": "O",
339 "\xD5": "O",
340 "\xD6": "O",
341 "\xD8": "O",
342 "\u1ED0": "O",
343 "\u1E4C": "O",
344 "\u1E52": "O",
345 "\u020E": "O",
346 "\u1ECE": "O",
347 "\u1ECC": "O",
348 "\u1ED4": "O",
349 "\u1ED6": "O",
350 "\u1ED8": "O",
351 "\u1EDC": "O",
352 "\u1EDE": "O",
353 "\u1EE0": "O",
354 "\u1EDA": "O",
355 "\u1EE2": "O",
356 "\xD9": "U",
357 "\xDA": "U",
358 "\xDB": "U",
359 "\xDC": "U",
360 "\u1EE6": "U",
361 "\u1EE4": "U",
362 "\u1EEC": "U",
363 "\u1EEE": "U",
364 "\u1EF0": "U",
365 "\xDD": "Y",
366 "\xE0": "a",
367 "\xE1": "a",
368 "\xE2": "a",
369 "\xE3": "a",
370 "\xE4": "a",
371 "\xE5": "a",
372 "\u1EA5": "a",
373 "\u1EAF": "a",
374 "\u1EB3": "a",
375 "\u1EB5": "a",
376 "\u1EB7": "a",
377 "\xE6": "ae",
378 "\u1EA7": "a",
379 "\u1EB1": "a",
380 "\u0203": "a",
381 "\u1EA3": "a",
382 "\u1EA1": "a",
383 "\u1EA9": "a",
384 "\u1EAB": "a",
385 "\u1EAD": "a",
386 "\xE7": "c",
387 "\u1E09": "c",
388 "\xE8": "e",
389 "\xE9": "e",
390 "\xEA": "e",
391 "\xEB": "e",
392 "\u1EBF": "e",
393 "\u1E17": "e",
394 "\u1EC1": "e",
395 "\u1E15": "e",
396 "\u1E1D": "e",
397 "\u0207": "e",
398 "\u1EBB": "e",
399 "\u1EBD": "e",
400 "\u1EB9": "e",
401 "\u1EC3": "e",
402 "\u1EC5": "e",
403 "\u1EC7": "e",
404 "\xEC": "i",
405 "\xED": "i",
406 "\xEE": "i",
407 "\xEF": "i",
408 "\u1E2F": "i",
409 "\u020B": "i",
410 "\u1EC9": "i",
411 "\u1ECB": "i",
412 "\xF0": "d",
413 "\xF1": "n",
414 "\xF2": "o",
415 "\xF3": "o",
416 "\xF4": "o",
417 "\xF5": "o",
418 "\xF6": "o",
419 "\xF8": "o",
420 "\u1ED1": "o",
421 "\u1E4D": "o",
422 "\u1E53": "o",
423 "\u020F": "o",
424 "\u1ECF": "o",
425 "\u1ECD": "o",
426 "\u1ED5": "o",
427 "\u1ED7": "o",
428 "\u1ED9": "o",
429 "\u1EDD": "o",
430 "\u1EDF": "o",
431 "\u1EE1": "o",
432 "\u1EDB": "o",
433 "\u1EE3": "o",
434 "\xF9": "u",
435 "\xFA": "u",
436 "\xFB": "u",
437 "\xFC": "u",
438 "\u1EE7": "u",
439 "\u1EE5": "u",
440 "\u1EED": "u",
441 "\u1EEF": "u",
442 "\u1EF1": "u",
443 "\xFD": "y",
444 "\xFF": "y",
445 "\u0100": "A",
446 "\u0101": "a",
447 "\u0102": "A",
448 "\u0103": "a",
449 "\u0104": "A",
450 "\u0105": "a",
451 "\u0106": "C",
452 "\u0107": "c",
453 "\u0108": "C",
454 "\u0109": "c",
455 "\u010A": "C",
456 "\u010B": "c",
457 "\u010C": "C",
458 "\u010D": "c",
459 "C\u0306": "C",
460 "c\u0306": "c",
461 "\u010E": "D",
462 "\u010F": "d",
463 "\u0110": "D",
464 "\u0111": "d",
465 "\u0112": "E",
466 "\u0113": "e",
467 "\u0114": "E",
468 "\u0115": "e",
469 "\u0116": "E",
470 "\u0117": "e",
471 "\u0118": "E",
472 "\u0119": "e",
473 "\u011A": "E",
474 "\u011B": "e",
475 "\u011C": "G",
476 "\u01F4": "G",
477 "\u011D": "g",
478 "\u01F5": "g",
479 "\u011E": "G",
480 "\u011F": "g",
481 "\u0120": "G",
482 "\u0121": "g",
483 "\u0122": "G",
484 "\u0123": "g",
485 "\u0124": "H",
486 "\u0125": "h",
487 "\u0126": "H",
488 "\u0127": "h",
489 "\u1E2A": "H",
490 "\u1E2B": "h",
491 "\u0128": "I",
492 "\u0129": "i",
493 "\u012A": "I",
494 "\u012B": "i",
495 "\u012C": "I",
496 "\u012D": "i",
497 "\u012E": "I",
498 "\u012F": "i",
499 "\u0130": "I",
500 "\u0131": "i",
501 "\u0132": "IJ",
502 "\u0133": "ij",
503 "\u0134": "J",
504 "\u0135": "j",
505 "\u0136": "K",
506 "\u0137": "k",
507 "\u1E30": "K",
508 "\u1E31": "k",
509 "K\u0306": "K",
510 "k\u0306": "k",
511 "\u0139": "L",
512 "\u013A": "l",
513 "\u013B": "L",
514 "\u013C": "l",
515 "\u013D": "L",
516 "\u013E": "l",
517 "\u013F": "L",
518 "\u0140": "l",
519 "\u0141": "l",
520 "\u0142": "l",
521 "\u1E3E": "M",
522 "\u1E3F": "m",
523 "M\u0306": "M",
524 "m\u0306": "m",
525 "\u0143": "N",
526 "\u0144": "n",
527 "\u0145": "N",
528 "\u0146": "n",
529 "\u0147": "N",
530 "\u0148": "n",
531 "\u0149": "n",
532 "N\u0306": "N",
533 "n\u0306": "n",
534 "\u014C": "O",
535 "\u014D": "o",
536 "\u014E": "O",
537 "\u014F": "o",
538 "\u0150": "O",
539 "\u0151": "o",
540 "\u0152": "OE",
541 "\u0153": "oe",
542 "P\u0306": "P",
543 "p\u0306": "p",
544 "\u0154": "R",
545 "\u0155": "r",
546 "\u0156": "R",
547 "\u0157": "r",
548 "\u0158": "R",
549 "\u0159": "r",
550 "R\u0306": "R",
551 "r\u0306": "r",
552 "\u0212": "R",
553 "\u0213": "r",
554 "\u015A": "S",
555 "\u015B": "s",
556 "\u015C": "S",
557 "\u015D": "s",
558 "\u015E": "S",
559 "\u0218": "S",
560 "\u0219": "s",
561 "\u015F": "s",
562 "\u0160": "S",
563 "\u0161": "s",
564 "\u0162": "T",
565 "\u0163": "t",
566 "\u021B": "t",
567 "\u021A": "T",
568 "\u0164": "T",
569 "\u0165": "t",
570 "\u0166": "T",
571 "\u0167": "t",
572 "T\u0306": "T",
573 "t\u0306": "t",
574 "\u0168": "U",
575 "\u0169": "u",
576 "\u016A": "U",
577 "\u016B": "u",
578 "\u016C": "U",
579 "\u016D": "u",
580 "\u016E": "U",
581 "\u016F": "u",
582 "\u0170": "U",
583 "\u0171": "u",
584 "\u0172": "U",
585 "\u0173": "u",
586 "\u0216": "U",
587 "\u0217": "u",
588 "V\u0306": "V",
589 "v\u0306": "v",
590 "\u0174": "W",
591 "\u0175": "w",
592 "\u1E82": "W",
593 "\u1E83": "w",
594 "X\u0306": "X",
595 "x\u0306": "x",
596 "\u0176": "Y",
597 "\u0177": "y",
598 "\u0178": "Y",
599 "Y\u0306": "Y",
600 "y\u0306": "y",
601 "\u0179": "Z",
602 "\u017A": "z",
603 "\u017B": "Z",
604 "\u017C": "z",
605 "\u017D": "Z",
606 "\u017E": "z",
607 "\u017F": "s",
608 "\u0192": "f",
609 "\u01A0": "O",
610 "\u01A1": "o",
611 "\u01AF": "U",
612 "\u01B0": "u",
613 "\u01CD": "A",
614 "\u01CE": "a",
615 "\u01CF": "I",
616 "\u01D0": "i",
617 "\u01D1": "O",
618 "\u01D2": "o",
619 "\u01D3": "U",
620 "\u01D4": "u",
621 "\u01D5": "U",
622 "\u01D6": "u",
623 "\u01D7": "U",
624 "\u01D8": "u",
625 "\u01D9": "U",
626 "\u01DA": "u",
627 "\u01DB": "U",
628 "\u01DC": "u",
629 "\u1EE8": "U",
630 "\u1EE9": "u",
631 "\u1E78": "U",
632 "\u1E79": "u",
633 "\u01FA": "A",
634 "\u01FB": "a",
635 "\u01FC": "AE",
636 "\u01FD": "ae",
637 "\u01FE": "O",
638 "\u01FF": "o",
639 "\xDE": "TH",
640 "\xFE": "th",
641 "\u1E54": "P",
642 "\u1E55": "p",
643 "\u1E64": "S",
644 "\u1E65": "s",
645 "X\u0301": "X",
646 "x\u0301": "x",
647 "\u0403": "\u0413",
648 "\u0453": "\u0433",
649 "\u040C": "\u041A",
650 "\u045C": "\u043A",
651 "A\u030B": "A",
652 "a\u030B": "a",
653 "E\u030B": "E",
654 "e\u030B": "e",
655 "I\u030B": "I",
656 "i\u030B": "i",
657 "\u01F8": "N",
658 "\u01F9": "n",
659 "\u1ED2": "O",
660 "\u1ED3": "o",
661 "\u1E50": "O",
662 "\u1E51": "o",
663 "\u1EEA": "U",
664 "\u1EEB": "u",
665 "\u1E80": "W",
666 "\u1E81": "w",
667 "\u1EF2": "Y",
668 "\u1EF3": "y",
669 "\u0200": "A",
670 "\u0201": "a",
671 "\u0204": "E",
672 "\u0205": "e",
673 "\u0208": "I",
674 "\u0209": "i",
675 "\u020C": "O",
676 "\u020D": "o",
677 "\u0210": "R",
678 "\u0211": "r",
679 "\u0214": "U",
680 "\u0215": "u",
681 "B\u030C": "B",
682 "b\u030C": "b",
683 "\u010C\u0323": "C",
684 "\u010D\u0323": "c",
685 "\xCA\u030C": "E",
686 "\xEA\u030C": "e",
687 "F\u030C": "F",
688 "f\u030C": "f",
689 "\u01E6": "G",
690 "\u01E7": "g",
691 "\u021E": "H",
692 "\u021F": "h",
693 "J\u030C": "J",
694 "\u01F0": "j",
695 "\u01E8": "K",
696 "\u01E9": "k",
697 "M\u030C": "M",
698 "m\u030C": "m",
699 "P\u030C": "P",
700 "p\u030C": "p",
701 "Q\u030C": "Q",
702 "q\u030C": "q",
703 "\u0158\u0329": "R",
704 "\u0159\u0329": "r",
705 "\u1E66": "S",
706 "\u1E67": "s",
707 "V\u030C": "V",
708 "v\u030C": "v",
709 "W\u030C": "W",
710 "w\u030C": "w",
711 "X\u030C": "X",
712 "x\u030C": "x",
713 "Y\u030C": "Y",
714 "y\u030C": "y",
715 "A\u0327": "A",
716 "a\u0327": "a",
717 "B\u0327": "B",
718 "b\u0327": "b",
719 "\u1E10": "D",
720 "\u1E11": "d",
721 "\u0228": "E",
722 "\u0229": "e",
723 "\u0190\u0327": "E",
724 "\u025B\u0327": "e",
725 "\u1E28": "H",
726 "\u1E29": "h",
727 "I\u0327": "I",
728 "i\u0327": "i",
729 "\u0197\u0327": "I",
730 "\u0268\u0327": "i",
731 "M\u0327": "M",
732 "m\u0327": "m",
733 "O\u0327": "O",
734 "o\u0327": "o",
735 "Q\u0327": "Q",
736 "q\u0327": "q",
737 "U\u0327": "U",
738 "u\u0327": "u",
739 "X\u0327": "X",
740 "x\u0327": "x",
741 "Z\u0327": "Z",
742 "z\u0327": "z",
743 "\u0439": "\u0438",
744 "\u0419": "\u0418",
745 "\u0451": "\u0435",
746 "\u0401": "\u0415"
747 };
748 var chars = Object.keys(characterMap).join("|");
749 var allAccents = new RegExp(chars, "g");
750 var firstAccent = new RegExp(chars, "");
751 function matcher(match2) {
752 return characterMap[match2];
753 }
754 var removeAccents3 = function(string) {
755 return string.replace(allAccents, matcher);
756 };
757 var hasAccents = function(string) {
758 return !!string.match(firstAccent);
759 };
760 module.exports = removeAccents3;
761 module.exports.has = hasAccents;
762 module.exports.remove = removeAccents3;
763 }
764 });
765
766 // node_modules/fast-deep-equal/es6/index.js
767 var require_es6 = __commonJS({
768 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
769 "use strict";
770 module.exports = function equal(a2, b2) {
771 if (a2 === b2) return true;
772 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
773 if (a2.constructor !== b2.constructor) return false;
774 var length, i2, keys;
775 if (Array.isArray(a2)) {
776 length = a2.length;
777 if (length != b2.length) return false;
778 for (i2 = length; i2-- !== 0; )
779 if (!equal(a2[i2], b2[i2])) return false;
780 return true;
781 }
782 if (a2 instanceof Map && b2 instanceof Map) {
783 if (a2.size !== b2.size) return false;
784 for (i2 of a2.entries())
785 if (!b2.has(i2[0])) return false;
786 for (i2 of a2.entries())
787 if (!equal(i2[1], b2.get(i2[0]))) return false;
788 return true;
789 }
790 if (a2 instanceof Set && b2 instanceof Set) {
791 if (a2.size !== b2.size) return false;
792 for (i2 of a2.entries())
793 if (!b2.has(i2[0])) return false;
794 return true;
795 }
796 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
797 length = a2.length;
798 if (length != b2.length) return false;
799 for (i2 = length; i2-- !== 0; )
800 if (a2[i2] !== b2[i2]) return false;
801 return true;
802 }
803 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
804 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
805 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
806 keys = Object.keys(a2);
807 length = keys.length;
808 if (length !== Object.keys(b2).length) return false;
809 for (i2 = length; i2-- !== 0; )
810 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
811 for (i2 = length; i2-- !== 0; ) {
812 var key = keys[i2];
813 if (!equal(a2[key], b2[key])) return false;
814 }
815 return true;
816 }
817 return a2 !== a2 && b2 !== b2;
818 };
819 }
820 });
821
822 // package-external:@wordpress/date
823 var require_date = __commonJS({
824 "package-external:@wordpress/date"(exports, module) {
825 module.exports = window.wp.date;
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // package-external:@wordpress/deprecated
837 var require_deprecated = __commonJS({
838 "package-external:@wordpress/deprecated"(exports, module) {
839 module.exports = window.wp.deprecated;
840 }
841 });
842
843 // package-external:@wordpress/editor
844 var require_editor = __commonJS({
845 "package-external:@wordpress/editor"(exports, module) {
846 module.exports = window.wp.editor;
847 }
848 });
849
850 // package-external:@wordpress/patterns
851 var require_patterns = __commonJS({
852 "package-external:@wordpress/patterns"(exports, module) {
853 module.exports = window.wp.patterns;
854 }
855 });
856
857 // package-external:@wordpress/block-editor
858 var require_block_editor = __commonJS({
859 "package-external:@wordpress/block-editor"(exports, module) {
860 module.exports = window.wp.blockEditor;
861 }
862 });
863
864 // routes/pattern-list/stage.tsx
865 import {
866 useParams,
867 useNavigate,
868 useSearch,
869 Link,
870 useInvalidate
871 } from "@wordpress/route";
872
873 // node_modules/dequal/dist/index.mjs
874 var has = Object.prototype.hasOwnProperty;
875 function find(iter, tar, key) {
876 for (key of iter.keys()) {
877 if (dequal(key, tar)) return key;
878 }
879 }
880 function dequal(foo, bar) {
881 var ctor, len, tmp;
882 if (foo === bar) return true;
883 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
884 if (ctor === Date) return foo.getTime() === bar.getTime();
885 if (ctor === RegExp) return foo.toString() === bar.toString();
886 if (ctor === Array) {
887 if ((len = foo.length) === bar.length) {
888 while (len-- && dequal(foo[len], bar[len])) ;
889 }
890 return len === -1;
891 }
892 if (ctor === Set) {
893 if (foo.size !== bar.size) {
894 return false;
895 }
896 for (len of foo) {
897 tmp = len;
898 if (tmp && typeof tmp === "object") {
899 tmp = find(bar, tmp);
900 if (!tmp) return false;
901 }
902 if (!bar.has(tmp)) return false;
903 }
904 return true;
905 }
906 if (ctor === Map) {
907 if (foo.size !== bar.size) {
908 return false;
909 }
910 for (len of foo) {
911 tmp = len[0];
912 if (tmp && typeof tmp === "object") {
913 tmp = find(bar, tmp);
914 if (!tmp) return false;
915 }
916 if (!dequal(len[1], bar.get(tmp))) {
917 return false;
918 }
919 }
920 return true;
921 }
922 if (ctor === ArrayBuffer) {
923 foo = new Uint8Array(foo);
924 bar = new Uint8Array(bar);
925 } else if (ctor === DataView) {
926 if ((len = foo.byteLength) === bar.byteLength) {
927 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
928 }
929 return len === -1;
930 }
931 if (ArrayBuffer.isView(foo)) {
932 if ((len = foo.byteLength) === bar.byteLength) {
933 while (len-- && foo[len] === bar[len]) ;
934 }
935 return len === -1;
936 }
937 if (!ctor || typeof foo === "object") {
938 len = 0;
939 for (ctor in foo) {
940 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
941 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
942 }
943 return Object.keys(bar).length === len;
944 }
945 }
946 return foo !== foo && bar !== bar;
947 }
948
949 // packages/views/build-module/use-view.mjs
950 var import_element = __toESM(require_element(), 1);
951 var import_data = __toESM(require_data(), 1);
952 var import_preferences = __toESM(require_preferences(), 1);
953
954 // packages/views/build-module/preference-keys.mjs
955 function generatePreferenceKey(kind, name, slug) {
956 return `dataviews-${kind}-${name}-${slug}`;
957 }
958
959 // packages/views/build-module/filter-utils.mjs
960 var SCALAR_VALUES = [
961 "titleField",
962 "mediaField",
963 "descriptionField",
964 "showTitle",
965 "showMedia",
966 "showDescription",
967 "showLevels",
968 "infiniteScrollEnabled"
969 ];
970 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
971 if (!activeViewOverrides) {
972 return view;
973 }
974 let result = view;
975 for (const key of SCALAR_VALUES) {
976 if (key in activeViewOverrides) {
977 result = { ...result, [key]: activeViewOverrides[key] };
978 }
979 }
980 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
981 const activeFields = new Set(
982 activeViewOverrides.filters.map((f2) => f2.field)
983 );
984 const preserved = (view.filters ?? []).filter(
985 (f2) => !activeFields.has(f2.field)
986 );
987 result = {
988 ...result,
989 filters: [...preserved, ...activeViewOverrides.filters]
990 };
991 }
992 if (activeViewOverrides.sort) {
993 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
994 if (isDefaultSort) {
995 result = {
996 ...result,
997 sort: activeViewOverrides.sort
998 };
999 }
1000 }
1001 if (activeViewOverrides.layout) {
1002 result = {
1003 ...result,
1004 layout: {
1005 ...result.layout,
1006 ...activeViewOverrides.layout
1007 }
1008 };
1009 }
1010 if (activeViewOverrides.groupBy) {
1011 result = {
1012 ...result,
1013 groupBy: activeViewOverrides.groupBy
1014 };
1015 }
1016 return result;
1017 }
1018 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
1019 if (!activeViewOverrides) {
1020 return view;
1021 }
1022 let result = view;
1023 for (const key of SCALAR_VALUES) {
1024 if (key in activeViewOverrides) {
1025 const { [key]: _, ...rest } = result;
1026 result = rest;
1027 }
1028 }
1029 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
1030 const activeFields = new Set(
1031 activeViewOverrides.filters.map((f2) => f2.field)
1032 );
1033 result = {
1034 ...result,
1035 filters: (view.filters ?? []).filter(
1036 (f2) => !activeFields.has(f2.field)
1037 )
1038 };
1039 }
1040 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
1041 result = {
1042 ...result,
1043 sort: defaultView?.sort
1044 };
1045 }
1046 if (activeViewOverrides.layout && "layout" in result && result.layout) {
1047 const layout = { ...result.layout };
1048 for (const key of Object.keys(activeViewOverrides.layout)) {
1049 delete layout[key];
1050 }
1051 result = {
1052 ...result,
1053 layout: Object.keys(layout).length > 0 ? layout : void 0
1054 };
1055 }
1056 if (activeViewOverrides.groupBy && "groupBy" in result) {
1057 const { groupBy: _, ...rest } = result;
1058 result = rest;
1059 }
1060 return result;
1061 }
1062
1063 // packages/views/build-module/use-view.mjs
1064 function omit(obj, keys) {
1065 const result = { ...obj };
1066 for (const key of keys) {
1067 delete result[key];
1068 }
1069 return result;
1070 }
1071 function useView(config) {
1072 const {
1073 kind,
1074 name,
1075 slug,
1076 defaultView,
1077 activeViewOverrides,
1078 queryParams,
1079 onChangeQueryParams
1080 } = config;
1081 const preferenceKey = generatePreferenceKey(kind, name, slug);
1082 const persistedView = (0, import_data.useSelect)(
1083 (select2) => {
1084 return select2(import_preferences.store).get(
1085 "core/views",
1086 preferenceKey
1087 );
1088 },
1089 [preferenceKey]
1090 );
1091 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1092 const baseView = (0, import_element.useMemo)(
1093 () => persistedView ?? defaultView ?? {},
1094 [persistedView, defaultView]
1095 );
1096 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1097 const search = queryParams?.search ?? baseView.search ?? "";
1098 const combinedOverrides = (0, import_element.useMemo)(() => {
1099 const rawDefaults = config.defaultLayouts?.[baseView.type];
1100 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1101 return { ...layoutTypeDefaults, ...activeViewOverrides };
1102 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1103 const view = (0, import_element.useMemo)(() => {
1104 return mergeActiveViewOverrides(
1105 {
1106 ...baseView,
1107 page,
1108 search
1109 },
1110 combinedOverrides,
1111 defaultView
1112 );
1113 }, [baseView, page, search, combinedOverrides, defaultView]);
1114 const isModified = !!persistedView;
1115 const updateView = (0, import_element.useCallback)(
1116 (newView) => {
1117 const urlParams = {
1118 page: newView?.page,
1119 search: newView?.search
1120 };
1121 const preferenceView = stripActiveViewOverrides(
1122 omit(newView, ["page", "search"]),
1123 combinedOverrides,
1124 defaultView
1125 );
1126 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1127 onChangeQueryParams(urlParams);
1128 }
1129 const comparableBaseView = stripActiveViewOverrides(
1130 baseView,
1131 combinedOverrides,
1132 defaultView
1133 );
1134 const comparableDefaultView = stripActiveViewOverrides(
1135 defaultView,
1136 combinedOverrides,
1137 defaultView
1138 );
1139 if (!dequal(comparableBaseView, preferenceView)) {
1140 if (dequal(preferenceView, comparableDefaultView)) {
1141 set2("core/views", preferenceKey, void 0);
1142 } else {
1143 set2("core/views", preferenceKey, preferenceView);
1144 }
1145 }
1146 },
1147 [
1148 onChangeQueryParams,
1149 page,
1150 search,
1151 baseView,
1152 defaultView,
1153 combinedOverrides,
1154 set2,
1155 preferenceKey
1156 ]
1157 );
1158 const resetToDefault = (0, import_element.useCallback)(() => {
1159 set2("core/views", preferenceKey, void 0);
1160 }, [preferenceKey, set2]);
1161 return {
1162 view,
1163 isModified,
1164 updateView,
1165 resetToDefault
1166 };
1167 }
1168
1169 // packages/views/build-module/load-view.mjs
1170 var import_data2 = __toESM(require_data(), 1);
1171 var import_preferences2 = __toESM(require_preferences(), 1);
1172
1173 // packages/views/build-module/use-view-config.mjs
1174 var import_data3 = __toESM(require_data(), 1);
1175 var import_core_data = __toESM(require_core_data(), 1);
1176
1177 // packages/views/build-module/lock-unlock.mjs
1178 var import_private_apis = __toESM(require_private_apis(), 1);
1179 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1180 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1181 "@wordpress/views"
1182 );
1183
1184 // node_modules/clsx/dist/clsx.mjs
1185 function r(e2) {
1186 var t2, f2, n2 = "";
1187 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1188 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1189 var o2 = e2.length;
1190 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1191 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1192 return n2;
1193 }
1194 function clsx() {
1195 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1196 return n2;
1197 }
1198 var clsx_default = clsx;
1199
1200 // packages/dataviews/build-module/dataviews/index.mjs
1201 var import_element75 = __toESM(require_element(), 1);
1202 var import_compose13 = __toESM(require_compose(), 1);
1203
1204 // node_modules/@base-ui/utils/esm/safeReact.js
1205 var React2 = __toESM(require_react(), 1);
1206 var SafeReact = {
1207 ...React2
1208 };
1209
1210 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1211 var React3 = __toESM(require_react(), 1);
1212 var UNINITIALIZED = {};
1213 function useRefWithInit(init2, initArg) {
1214 const ref = React3.useRef(UNINITIALIZED);
1215 if (ref.current === UNINITIALIZED) {
1216 ref.current = init2(initArg);
1217 }
1218 return ref;
1219 }
1220
1221 // node_modules/@base-ui/utils/esm/useStableCallback.js
1222 var useInsertionEffect = SafeReact.useInsertionEffect;
1223 var useSafeInsertionEffect = (
1224 // React 17 doesn't have useInsertionEffect.
1225 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1226 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1227 );
1228 function useStableCallback(callback) {
1229 const stable = useRefWithInit(createStableCallback).current;
1230 stable.next = callback;
1231 useSafeInsertionEffect(stable.effect);
1232 return stable.trampoline;
1233 }
1234 function createStableCallback() {
1235 const stable = {
1236 next: void 0,
1237 callback: assertNotCalled,
1238 trampoline: (...args) => stable.callback?.(...args),
1239 effect: () => {
1240 stable.callback = stable.next;
1241 }
1242 };
1243 return stable;
1244 }
1245 function assertNotCalled() {
1246 if (true) {
1247 throw (
1248 /* minify-error-disabled */
1249 new Error("Base UI: Cannot call an event handler while rendering.")
1250 );
1251 }
1252 }
1253
1254 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1255 var React4 = __toESM(require_react(), 1);
1256 var noop = () => {
1257 };
1258 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1259
1260 // node_modules/@base-ui/utils/esm/warn.js
1261 var set;
1262 if (true) {
1263 set = /* @__PURE__ */ new Set();
1264 }
1265 function warn(...messages) {
1266 if (true) {
1267 const messageKey = messages.join(" ");
1268 if (!set.has(messageKey)) {
1269 set.add(messageKey);
1270 console.warn(`Base UI: ${messageKey}`);
1271 }
1272 }
1273 }
1274
1275 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1276 var React5 = __toESM(require_react(), 1);
1277 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1278 if (true) DirectionContext.displayName = "DirectionContext";
1279 function useDirection() {
1280 const context = React5.useContext(DirectionContext);
1281 return context?.direction ?? "ltr";
1282 }
1283
1284 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1285 var React8 = __toESM(require_react(), 1);
1286
1287 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1288 function useMergedRefs(a2, b2, c2, d2) {
1289 const forkRef = useRefWithInit(createForkRef).current;
1290 if (didChange(forkRef, a2, b2, c2, d2)) {
1291 update(forkRef, [a2, b2, c2, d2]);
1292 }
1293 return forkRef.callback;
1294 }
1295 function useMergedRefsN(refs) {
1296 const forkRef = useRefWithInit(createForkRef).current;
1297 if (didChangeN(forkRef, refs)) {
1298 update(forkRef, refs);
1299 }
1300 return forkRef.callback;
1301 }
1302 function createForkRef() {
1303 return {
1304 callback: null,
1305 cleanup: null,
1306 refs: []
1307 };
1308 }
1309 function didChange(forkRef, a2, b2, c2, d2) {
1310 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1311 }
1312 function didChangeN(forkRef, newRefs) {
1313 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1314 }
1315 function update(forkRef, refs) {
1316 forkRef.refs = refs;
1317 if (refs.every((ref) => ref == null)) {
1318 forkRef.callback = null;
1319 return;
1320 }
1321 forkRef.callback = (instance) => {
1322 if (forkRef.cleanup) {
1323 forkRef.cleanup();
1324 forkRef.cleanup = null;
1325 }
1326 if (instance != null) {
1327 const cleanupCallbacks = Array(refs.length).fill(null);
1328 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1329 const ref = refs[i2];
1330 if (ref == null) {
1331 continue;
1332 }
1333 switch (typeof ref) {
1334 case "function": {
1335 const refCleanup = ref(instance);
1336 if (typeof refCleanup === "function") {
1337 cleanupCallbacks[i2] = refCleanup;
1338 }
1339 break;
1340 }
1341 case "object": {
1342 ref.current = instance;
1343 break;
1344 }
1345 default:
1346 }
1347 }
1348 forkRef.cleanup = () => {
1349 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1350 const ref = refs[i2];
1351 if (ref == null) {
1352 continue;
1353 }
1354 switch (typeof ref) {
1355 case "function": {
1356 const cleanupCallback = cleanupCallbacks[i2];
1357 if (typeof cleanupCallback === "function") {
1358 cleanupCallback();
1359 } else {
1360 ref(null);
1361 }
1362 break;
1363 }
1364 case "object": {
1365 ref.current = null;
1366 break;
1367 }
1368 default:
1369 }
1370 }
1371 };
1372 }
1373 };
1374 }
1375
1376 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1377 var React7 = __toESM(require_react(), 1);
1378
1379 // node_modules/@base-ui/utils/esm/reactVersion.js
1380 var React6 = __toESM(require_react(), 1);
1381 var majorVersion = parseInt(React6.version, 10);
1382 function isReactVersionAtLeast(reactVersionToCheck) {
1383 return majorVersion >= reactVersionToCheck;
1384 }
1385
1386 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1387 function getReactElementRef(element) {
1388 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1389 return null;
1390 }
1391 const reactElement = element;
1392 const propsWithRef = reactElement.props;
1393 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1394 }
1395
1396 // node_modules/@base-ui/utils/esm/mergeObjects.js
1397 function mergeObjects(a2, b2) {
1398 if (a2 && !b2) {
1399 return a2;
1400 }
1401 if (!a2 && b2) {
1402 return b2;
1403 }
1404 if (a2 || b2) {
1405 return {
1406 ...a2,
1407 ...b2
1408 };
1409 }
1410 return void 0;
1411 }
1412
1413 // node_modules/@base-ui/utils/esm/empty.js
1414 function NOOP() {
1415 }
1416 var EMPTY_ARRAY = Object.freeze([]);
1417 var EMPTY_OBJECT = Object.freeze({});
1418
1419 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1420 function getStateAttributesProps(state, customMapping) {
1421 const props = {};
1422 for (const key in state) {
1423 const value = state[key];
1424 if (customMapping?.hasOwnProperty(key)) {
1425 const customProps = customMapping[key](value);
1426 if (customProps != null) {
1427 Object.assign(props, customProps);
1428 }
1429 continue;
1430 }
1431 if (value === true) {
1432 props[`data-${key.toLowerCase()}`] = "";
1433 } else if (value) {
1434 props[`data-${key.toLowerCase()}`] = value.toString();
1435 }
1436 }
1437 return props;
1438 }
1439
1440 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1441 function resolveClassName(className, state) {
1442 return typeof className === "function" ? className(state) : className;
1443 }
1444
1445 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1446 function resolveStyle(style, state) {
1447 return typeof style === "function" ? style(state) : style;
1448 }
1449
1450 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1451 var EMPTY_PROPS = {};
1452 function mergeProps(a2, b2, c2, d2, e2) {
1453 if (!c2 && !d2 && !e2 && !a2) {
1454 return createInitialMergedProps(b2);
1455 }
1456 let merged = createInitialMergedProps(a2);
1457 if (b2) {
1458 merged = mergeInto(merged, b2);
1459 }
1460 if (c2) {
1461 merged = mergeInto(merged, c2);
1462 }
1463 if (d2) {
1464 merged = mergeInto(merged, d2);
1465 }
1466 if (e2) {
1467 merged = mergeInto(merged, e2);
1468 }
1469 return merged;
1470 }
1471 function mergePropsN(props) {
1472 if (props.length === 0) {
1473 return EMPTY_PROPS;
1474 }
1475 if (props.length === 1) {
1476 return createInitialMergedProps(props[0]);
1477 }
1478 let merged = createInitialMergedProps(props[0]);
1479 for (let i2 = 1; i2 < props.length; i2 += 1) {
1480 merged = mergeInto(merged, props[i2]);
1481 }
1482 return merged;
1483 }
1484 function createInitialMergedProps(inputProps) {
1485 if (isPropsGetter(inputProps)) {
1486 return {
1487 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1488 };
1489 }
1490 return copyInitialProps(inputProps);
1491 }
1492 function mergeInto(merged, inputProps) {
1493 if (isPropsGetter(inputProps)) {
1494 return resolvePropsGetter(inputProps, merged);
1495 }
1496 return mutablyMergeInto(merged, inputProps);
1497 }
1498 function copyInitialProps(inputProps) {
1499 const copiedProps = {
1500 ...inputProps
1501 };
1502 for (const propName in copiedProps) {
1503 const propValue = copiedProps[propName];
1504 if (isEventHandler(propName, propValue)) {
1505 copiedProps[propName] = wrapEventHandler(propValue);
1506 }
1507 }
1508 return copiedProps;
1509 }
1510 function mutablyMergeInto(mergedProps, externalProps) {
1511 if (!externalProps) {
1512 return mergedProps;
1513 }
1514 for (const propName in externalProps) {
1515 const externalPropValue = externalProps[propName];
1516 switch (propName) {
1517 case "style": {
1518 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1519 break;
1520 }
1521 case "className": {
1522 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1523 break;
1524 }
1525 default: {
1526 if (isEventHandler(propName, externalPropValue)) {
1527 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1528 } else {
1529 mergedProps[propName] = externalPropValue;
1530 }
1531 }
1532 }
1533 }
1534 return mergedProps;
1535 }
1536 function isEventHandler(key, value) {
1537 const code0 = key.charCodeAt(0);
1538 const code1 = key.charCodeAt(1);
1539 const code2 = key.charCodeAt(2);
1540 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1541 }
1542 function isPropsGetter(inputProps) {
1543 return typeof inputProps === "function";
1544 }
1545 function resolvePropsGetter(inputProps, previousProps) {
1546 if (isPropsGetter(inputProps)) {
1547 return inputProps(previousProps);
1548 }
1549 return inputProps ?? EMPTY_PROPS;
1550 }
1551 function mergeEventHandlers(ourHandler, theirHandler) {
1552 if (!theirHandler) {
1553 return ourHandler;
1554 }
1555 if (!ourHandler) {
1556 return wrapEventHandler(theirHandler);
1557 }
1558 return (...args) => {
1559 const event = args[0];
1560 if (isSyntheticEvent(event)) {
1561 const baseUIEvent = event;
1562 makeEventPreventable(baseUIEvent);
1563 const result2 = theirHandler(...args);
1564 if (!baseUIEvent.baseUIHandlerPrevented) {
1565 ourHandler?.(...args);
1566 }
1567 return result2;
1568 }
1569 const result = theirHandler(...args);
1570 ourHandler?.(...args);
1571 return result;
1572 };
1573 }
1574 function wrapEventHandler(handler) {
1575 if (!handler) {
1576 return handler;
1577 }
1578 return (...args) => {
1579 const event = args[0];
1580 if (isSyntheticEvent(event)) {
1581 makeEventPreventable(event);
1582 }
1583 return handler(...args);
1584 };
1585 }
1586 function makeEventPreventable(event) {
1587 event.preventBaseUIHandler = () => {
1588 event.baseUIHandlerPrevented = true;
1589 };
1590 return event;
1591 }
1592 function mergeClassNames(ourClassName, theirClassName) {
1593 if (theirClassName) {
1594 if (ourClassName) {
1595 return theirClassName + " " + ourClassName;
1596 }
1597 return theirClassName;
1598 }
1599 return ourClassName;
1600 }
1601 function isSyntheticEvent(event) {
1602 return event != null && typeof event === "object" && "nativeEvent" in event;
1603 }
1604
1605 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1606 var import_react = __toESM(require_react(), 1);
1607 function useRenderElement(element, componentProps, params = {}) {
1608 const renderProp = componentProps.render;
1609 const outProps = useRenderElementProps(componentProps, params);
1610 if (params.enabled === false) {
1611 return null;
1612 }
1613 const state = params.state ?? EMPTY_OBJECT;
1614 return evaluateRenderProp(element, renderProp, outProps, state);
1615 }
1616 function useRenderElementProps(componentProps, params = {}) {
1617 const {
1618 className: classNameProp,
1619 style: styleProp,
1620 render: renderProp
1621 } = componentProps;
1622 const {
1623 state = EMPTY_OBJECT,
1624 ref,
1625 props,
1626 stateAttributesMapping: stateAttributesMapping3,
1627 enabled = true
1628 } = params;
1629 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1630 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1631 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1632 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1633 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1634 if (typeof document !== "undefined") {
1635 if (!enabled) {
1636 useMergedRefs(null, null);
1637 } else if (Array.isArray(ref)) {
1638 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1639 } else {
1640 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1641 }
1642 }
1643 if (!enabled) {
1644 return EMPTY_OBJECT;
1645 }
1646 if (className !== void 0) {
1647 outProps.className = mergeClassNames(outProps.className, className);
1648 }
1649 if (style !== void 0) {
1650 outProps.style = mergeObjects(outProps.style, style);
1651 }
1652 return outProps;
1653 }
1654 function resolveRenderFunctionProps(props) {
1655 if (Array.isArray(props)) {
1656 return mergePropsN(props);
1657 }
1658 return mergeProps(void 0, props);
1659 }
1660 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1661 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1662 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1663 function evaluateRenderProp(element, render4, props, state) {
1664 if (render4) {
1665 if (typeof render4 === "function") {
1666 if (true) {
1667 warnIfRenderPropLooksLikeComponent(render4);
1668 }
1669 return render4(props, state);
1670 }
1671 const mergedProps = mergeProps(props, render4.props);
1672 mergedProps.ref = props.ref;
1673 let newElement = render4;
1674 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1675 const children = React8.Children.toArray(render4);
1676 newElement = children[0];
1677 }
1678 if (true) {
1679 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1680 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1681 }
1682 }
1683 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1684 }
1685 if (element) {
1686 if (typeof element === "string") {
1687 return renderTag(element, props);
1688 }
1689 }
1690 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1691 }
1692 function warnIfRenderPropLooksLikeComponent(renderFn) {
1693 const functionName = renderFn.name;
1694 if (functionName.length === 0) {
1695 return;
1696 }
1697 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1698 return;
1699 }
1700 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1701 return;
1702 }
1703 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1704 }
1705 function renderTag(Tag, props) {
1706 if (Tag === "button") {
1707 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1708 type: "button",
1709 ...props,
1710 key: props.key
1711 });
1712 }
1713 if (Tag === "img") {
1714 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1715 alt: "",
1716 ...props,
1717 key: props.key
1718 });
1719 }
1720 return /* @__PURE__ */ React8.createElement(Tag, props);
1721 }
1722
1723 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1724 var reason_parts_exports = {};
1725 __export(reason_parts_exports, {
1726 cancelOpen: () => cancelOpen,
1727 chipRemovePress: () => chipRemovePress,
1728 clearPress: () => clearPress,
1729 closePress: () => closePress,
1730 closeWatcher: () => closeWatcher,
1731 decrementPress: () => decrementPress,
1732 disabled: () => disabled,
1733 drag: () => drag,
1734 escapeKey: () => escapeKey,
1735 focusOut: () => focusOut,
1736 imperativeAction: () => imperativeAction,
1737 incrementPress: () => incrementPress,
1738 initial: () => initial,
1739 inputBlur: () => inputBlur,
1740 inputChange: () => inputChange,
1741 inputClear: () => inputClear,
1742 inputPaste: () => inputPaste,
1743 inputPress: () => inputPress,
1744 itemPress: () => itemPress,
1745 keyboard: () => keyboard,
1746 linkPress: () => linkPress,
1747 listNavigation: () => listNavigation,
1748 missing: () => missing,
1749 none: () => none,
1750 outsidePress: () => outsidePress,
1751 pointer: () => pointer,
1752 scrub: () => scrub,
1753 siblingOpen: () => siblingOpen,
1754 swipe: () => swipe,
1755 trackPress: () => trackPress,
1756 triggerFocus: () => triggerFocus,
1757 triggerHover: () => triggerHover,
1758 triggerPress: () => triggerPress,
1759 wheel: () => wheel,
1760 windowResize: () => windowResize
1761 });
1762 var none = "none";
1763 var triggerPress = "trigger-press";
1764 var triggerHover = "trigger-hover";
1765 var triggerFocus = "trigger-focus";
1766 var outsidePress = "outside-press";
1767 var itemPress = "item-press";
1768 var closePress = "close-press";
1769 var linkPress = "link-press";
1770 var clearPress = "clear-press";
1771 var chipRemovePress = "chip-remove-press";
1772 var trackPress = "track-press";
1773 var incrementPress = "increment-press";
1774 var decrementPress = "decrement-press";
1775 var inputChange = "input-change";
1776 var inputClear = "input-clear";
1777 var inputBlur = "input-blur";
1778 var inputPaste = "input-paste";
1779 var inputPress = "input-press";
1780 var focusOut = "focus-out";
1781 var escapeKey = "escape-key";
1782 var closeWatcher = "close-watcher";
1783 var listNavigation = "list-navigation";
1784 var keyboard = "keyboard";
1785 var pointer = "pointer";
1786 var drag = "drag";
1787 var wheel = "wheel";
1788 var scrub = "scrub";
1789 var cancelOpen = "cancel-open";
1790 var siblingOpen = "sibling-open";
1791 var disabled = "disabled";
1792 var missing = "missing";
1793 var initial = "initial";
1794 var imperativeAction = "imperative-action";
1795 var swipe = "swipe";
1796 var windowResize = "window-resize";
1797
1798 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1799 function createChangeEventDetails(reason, event, trigger, customProperties) {
1800 let canceled = false;
1801 let allowPropagation = false;
1802 const custom = customProperties ?? EMPTY_OBJECT;
1803 const details = {
1804 reason,
1805 event: event ?? new Event("base-ui"),
1806 cancel() {
1807 canceled = true;
1808 },
1809 allowPropagation() {
1810 allowPropagation = true;
1811 },
1812 get isCanceled() {
1813 return canceled;
1814 },
1815 get isPropagationAllowed() {
1816 return allowPropagation;
1817 },
1818 trigger,
1819 ...custom
1820 };
1821 return details;
1822 }
1823
1824 // node_modules/@base-ui/utils/esm/useId.js
1825 var React9 = __toESM(require_react(), 1);
1826 var globalId = 0;
1827 function useGlobalId(idOverride, prefix = "mui") {
1828 const [defaultId, setDefaultId] = React9.useState(idOverride);
1829 const id = idOverride || defaultId;
1830 React9.useEffect(() => {
1831 if (defaultId == null) {
1832 globalId += 1;
1833 setDefaultId(`${prefix}-${globalId}`);
1834 }
1835 }, [defaultId, prefix]);
1836 return id;
1837 }
1838 var maybeReactUseId = SafeReact.useId;
1839 function useId(idOverride, prefix) {
1840 if (maybeReactUseId !== void 0) {
1841 const reactId = maybeReactUseId();
1842 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1843 }
1844 return useGlobalId(idOverride, prefix);
1845 }
1846
1847 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1848 function useBaseUiId(idOverride) {
1849 return useId(idOverride, "base-ui");
1850 }
1851
1852 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1853 var React11 = __toESM(require_react(), 1);
1854
1855 // node_modules/@base-ui/utils/esm/useOnMount.js
1856 var React10 = __toESM(require_react(), 1);
1857 var EMPTY = [];
1858 function useOnMount(fn) {
1859 React10.useEffect(fn, EMPTY);
1860 }
1861
1862 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1863 var EMPTY2 = null;
1864 var LAST_RAF = globalThis.requestAnimationFrame;
1865 var Scheduler = class {
1866 /* This implementation uses an array as a backing data-structure for frame callbacks.
1867 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1868 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1869 * be much more efficient if there is a call pattern that alterns as
1870 * "request-cancel-request-cancel-…".
1871 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1872 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1873 callbacks = [];
1874 callbacksCount = 0;
1875 nextId = 1;
1876 startId = 1;
1877 isScheduled = false;
1878 tick = (timestamp) => {
1879 this.isScheduled = false;
1880 const currentCallbacks = this.callbacks;
1881 const currentCallbacksCount = this.callbacksCount;
1882 this.callbacks = [];
1883 this.callbacksCount = 0;
1884 this.startId = this.nextId;
1885 if (currentCallbacksCount > 0) {
1886 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1887 currentCallbacks[i2]?.(timestamp);
1888 }
1889 }
1890 };
1891 request(fn) {
1892 const id = this.nextId;
1893 this.nextId += 1;
1894 this.callbacks.push(fn);
1895 this.callbacksCount += 1;
1896 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1897 if (!this.isScheduled || didRAFChange) {
1898 requestAnimationFrame(this.tick);
1899 this.isScheduled = true;
1900 }
1901 return id;
1902 }
1903 cancel(id) {
1904 const index2 = id - this.startId;
1905 if (index2 < 0 || index2 >= this.callbacks.length) {
1906 return;
1907 }
1908 this.callbacks[index2] = null;
1909 this.callbacksCount -= 1;
1910 }
1911 };
1912 var scheduler = new Scheduler();
1913 var AnimationFrame = class _AnimationFrame {
1914 static create() {
1915 return new _AnimationFrame();
1916 }
1917 static request(fn) {
1918 return scheduler.request(fn);
1919 }
1920 static cancel(id) {
1921 return scheduler.cancel(id);
1922 }
1923 currentId = EMPTY2;
1924 /**
1925 * Executes `fn` after `delay`, clearing any previously scheduled call.
1926 */
1927 request(fn) {
1928 this.cancel();
1929 this.currentId = scheduler.request(() => {
1930 this.currentId = EMPTY2;
1931 fn();
1932 });
1933 }
1934 cancel = () => {
1935 if (this.currentId !== EMPTY2) {
1936 scheduler.cancel(this.currentId);
1937 this.currentId = EMPTY2;
1938 }
1939 };
1940 disposeEffect = () => {
1941 return this.cancel;
1942 };
1943 };
1944 function useAnimationFrame() {
1945 const timeout = useRefWithInit(AnimationFrame.create).current;
1946 useOnMount(timeout.disposeEffect);
1947 return timeout;
1948 }
1949
1950 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1951 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1952 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1953 const [mounted, setMounted] = React11.useState(open);
1954 if (open && !mounted) {
1955 setMounted(true);
1956 setTransitionStatus("starting");
1957 }
1958 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1959 setTransitionStatus("ending");
1960 }
1961 if (!open && !mounted && transitionStatus === "ending") {
1962 setTransitionStatus(void 0);
1963 }
1964 useIsoLayoutEffect(() => {
1965 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1966 const frame = AnimationFrame.request(() => {
1967 setTransitionStatus("ending");
1968 });
1969 return () => {
1970 AnimationFrame.cancel(frame);
1971 };
1972 }
1973 return void 0;
1974 }, [open, mounted, transitionStatus, deferEndingState]);
1975 useIsoLayoutEffect(() => {
1976 if (!open || enableIdleState) {
1977 return void 0;
1978 }
1979 const frame = AnimationFrame.request(() => {
1980 setTransitionStatus(void 0);
1981 });
1982 return () => {
1983 AnimationFrame.cancel(frame);
1984 };
1985 }, [enableIdleState, open]);
1986 useIsoLayoutEffect(() => {
1987 if (!open || !enableIdleState) {
1988 return void 0;
1989 }
1990 if (open && mounted && transitionStatus !== "idle") {
1991 setTransitionStatus("starting");
1992 }
1993 const frame = AnimationFrame.request(() => {
1994 setTransitionStatus("idle");
1995 });
1996 return () => {
1997 AnimationFrame.cancel(frame);
1998 };
1999 }, [enableIdleState, open, mounted, transitionStatus]);
2000 return {
2001 mounted,
2002 setMounted,
2003 transitionStatus
2004 };
2005 }
2006
2007 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
2008 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2009 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2010 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2011 return TransitionStatusDataAttributes2;
2012 })({});
2013 var STARTING_HOOK = {
2014 [TransitionStatusDataAttributes.startingStyle]: ""
2015 };
2016 var ENDING_HOOK = {
2017 [TransitionStatusDataAttributes.endingStyle]: ""
2018 };
2019 var transitionStatusMapping = {
2020 transitionStatus(value) {
2021 if (value === "starting") {
2022 return STARTING_HOOK;
2023 }
2024 if (value === "ending") {
2025 return ENDING_HOOK;
2026 }
2027 return null;
2028 }
2029 };
2030
2031 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2032 function hasWindow() {
2033 return typeof window !== "undefined";
2034 }
2035 function getNodeName(node) {
2036 if (isNode(node)) {
2037 return (node.nodeName || "").toLowerCase();
2038 }
2039 return "#document";
2040 }
2041 function getWindow(node) {
2042 var _node$ownerDocument;
2043 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2044 }
2045 function getDocumentElement(node) {
2046 var _ref;
2047 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2048 }
2049 function isNode(value) {
2050 if (!hasWindow()) {
2051 return false;
2052 }
2053 return value instanceof Node || value instanceof getWindow(value).Node;
2054 }
2055 function isElement(value) {
2056 if (!hasWindow()) {
2057 return false;
2058 }
2059 return value instanceof Element || value instanceof getWindow(value).Element;
2060 }
2061 function isHTMLElement(value) {
2062 if (!hasWindow()) {
2063 return false;
2064 }
2065 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2066 }
2067 function isShadowRoot(value) {
2068 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2069 return false;
2070 }
2071 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2072 }
2073 function isOverflowElement(element) {
2074 const {
2075 overflow,
2076 overflowX,
2077 overflowY,
2078 display
2079 } = getComputedStyle2(element);
2080 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2081 }
2082 function isTableElement(element) {
2083 return /^(table|td|th)$/.test(getNodeName(element));
2084 }
2085 function isTopLayer(element) {
2086 try {
2087 if (element.matches(":popover-open")) {
2088 return true;
2089 }
2090 } catch (_e) {
2091 }
2092 try {
2093 return element.matches(":modal");
2094 } catch (_e) {
2095 return false;
2096 }
2097 }
2098 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2099 var containRe = /paint|layout|strict|content/;
2100 var isNotNone = (value) => !!value && value !== "none";
2101 var isWebKitValue;
2102 function isContainingBlock(elementOrCss) {
2103 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2104 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
2105 }
2106 function getContainingBlock(element) {
2107 let currentNode = getParentNode(element);
2108 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2109 if (isContainingBlock(currentNode)) {
2110 return currentNode;
2111 } else if (isTopLayer(currentNode)) {
2112 return null;
2113 }
2114 currentNode = getParentNode(currentNode);
2115 }
2116 return null;
2117 }
2118 function isWebKit() {
2119 if (isWebKitValue == null) {
2120 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2121 }
2122 return isWebKitValue;
2123 }
2124 function isLastTraversableNode(node) {
2125 return /^(html|body|#document)$/.test(getNodeName(node));
2126 }
2127 function getComputedStyle2(element) {
2128 return getWindow(element).getComputedStyle(element);
2129 }
2130 function getNodeScroll(element) {
2131 if (isElement(element)) {
2132 return {
2133 scrollLeft: element.scrollLeft,
2134 scrollTop: element.scrollTop
2135 };
2136 }
2137 return {
2138 scrollLeft: element.scrollX,
2139 scrollTop: element.scrollY
2140 };
2141 }
2142 function getParentNode(node) {
2143 if (getNodeName(node) === "html") {
2144 return node;
2145 }
2146 const result = (
2147 // Step into the shadow DOM of the parent of a slotted node.
2148 node.assignedSlot || // DOM Element detected.
2149 node.parentNode || // ShadowRoot detected.
2150 isShadowRoot(node) && node.host || // Fallback.
2151 getDocumentElement(node)
2152 );
2153 return isShadowRoot(result) ? result.host : result;
2154 }
2155 function getNearestOverflowAncestor(node) {
2156 const parentNode = getParentNode(node);
2157 if (isLastTraversableNode(parentNode)) {
2158 return node.ownerDocument ? node.ownerDocument.body : node.body;
2159 }
2160 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2161 return parentNode;
2162 }
2163 return getNearestOverflowAncestor(parentNode);
2164 }
2165 function getOverflowAncestors(node, list, traverseIframes) {
2166 var _node$ownerDocument2;
2167 if (list === void 0) {
2168 list = [];
2169 }
2170 if (traverseIframes === void 0) {
2171 traverseIframes = true;
2172 }
2173 const scrollableAncestor = getNearestOverflowAncestor(node);
2174 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2175 const win = getWindow(scrollableAncestor);
2176 if (isBody) {
2177 const frameElement = getFrameElement(win);
2178 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2179 } else {
2180 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2181 }
2182 }
2183 function getFrameElement(win) {
2184 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2185 }
2186
2187 // node_modules/@base-ui/utils/esm/detectBrowser.js
2188 var hasNavigator = typeof navigator !== "undefined";
2189 var nav = getNavigatorData();
2190 var platform = getPlatform();
2191 var userAgent = getUserAgent();
2192 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2193 var isIOS = (
2194 // iPads can claim to be MacIntel
2195 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2196 );
2197 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2198 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2199 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2200 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2201 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2202 var isJSDOM = userAgent.includes("jsdom/");
2203 function getNavigatorData() {
2204 if (!hasNavigator) {
2205 return {
2206 platform: "",
2207 maxTouchPoints: -1
2208 };
2209 }
2210 const uaData = navigator.userAgentData;
2211 if (uaData?.platform) {
2212 return {
2213 platform: uaData.platform,
2214 maxTouchPoints: navigator.maxTouchPoints
2215 };
2216 }
2217 return {
2218 platform: navigator.platform ?? "",
2219 maxTouchPoints: navigator.maxTouchPoints ?? -1
2220 };
2221 }
2222 function getUserAgent() {
2223 if (!hasNavigator) {
2224 return "";
2225 }
2226 const uaData = navigator.userAgentData;
2227 if (uaData && Array.isArray(uaData.brands)) {
2228 return uaData.brands.map(({
2229 brand,
2230 version: version2
2231 }) => `${brand}/${version2}`).join(" ");
2232 }
2233 return navigator.userAgent;
2234 }
2235 function getPlatform() {
2236 if (!hasNavigator) {
2237 return "";
2238 }
2239 const uaData = navigator.userAgentData;
2240 if (uaData?.platform) {
2241 return uaData.platform;
2242 }
2243 return navigator.platform ?? "";
2244 }
2245
2246 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2247 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2248 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2249
2250 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2251 function activeElement(doc) {
2252 let element = doc.activeElement;
2253 while (element?.shadowRoot?.activeElement != null) {
2254 element = element.shadowRoot.activeElement;
2255 }
2256 return element;
2257 }
2258 function contains(parent, child) {
2259 if (!parent || !child) {
2260 return false;
2261 }
2262 const rootNode = child.getRootNode?.();
2263 if (parent.contains(child)) {
2264 return true;
2265 }
2266 if (rootNode && isShadowRoot(rootNode)) {
2267 let next = child;
2268 while (next) {
2269 if (parent === next) {
2270 return true;
2271 }
2272 next = next.parentNode || next.host;
2273 }
2274 }
2275 return false;
2276 }
2277 function getTarget(event) {
2278 if ("composedPath" in event) {
2279 return event.composedPath()[0];
2280 }
2281 return event.target;
2282 }
2283
2284 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2285 function isTargetInsideEnabledTrigger(target, triggerElements) {
2286 if (!isElement(target)) {
2287 return false;
2288 }
2289 const targetElement = target;
2290 if (triggerElements.hasElement(targetElement)) {
2291 return !targetElement.hasAttribute("data-trigger-disabled");
2292 }
2293 for (const [, trigger] of triggerElements.entries()) {
2294 if (contains(trigger, targetElement)) {
2295 return !trigger.hasAttribute("data-trigger-disabled");
2296 }
2297 }
2298 return false;
2299 }
2300 function isEventTargetWithin(event, node) {
2301 if (node == null) {
2302 return false;
2303 }
2304 if ("composedPath" in event) {
2305 return event.composedPath().includes(node);
2306 }
2307 const eventAgain = event;
2308 return eventAgain.target != null && node.contains(eventAgain.target);
2309 }
2310 function isRootElement(element) {
2311 return element.matches("html,body");
2312 }
2313 function isTypeableElement(element) {
2314 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2315 }
2316 function isInteractiveElement(element) {
2317 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2318 }
2319 function matchesFocusVisible(element) {
2320 if (!element || isJSDOM) {
2321 return true;
2322 }
2323 try {
2324 return element.matches(":focus-visible");
2325 } catch (_e) {
2326 return true;
2327 }
2328 }
2329
2330 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2331 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2332 const directChildren = nodes.filter((node) => node.parentId === id);
2333 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2334 }
2335
2336 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2337 function isReactEvent(event) {
2338 return "nativeEvent" in event;
2339 }
2340 function isMouseLikePointerType(pointerType, strict) {
2341 const values = ["mouse", "pen"];
2342 if (!strict) {
2343 values.push("", void 0);
2344 }
2345 return values.includes(pointerType);
2346 }
2347 function isClickLikeEvent(event) {
2348 const type = event.type;
2349 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2350 }
2351
2352 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2353 var sides = ["top", "right", "bottom", "left"];
2354 var min = Math.min;
2355 var max = Math.max;
2356 var round = Math.round;
2357 var floor = Math.floor;
2358 var createCoords = (v2) => ({
2359 x: v2,
2360 y: v2
2361 });
2362 var oppositeSideMap = {
2363 left: "right",
2364 right: "left",
2365 bottom: "top",
2366 top: "bottom"
2367 };
2368 function clamp(start, value, end) {
2369 return max(start, min(value, end));
2370 }
2371 function evaluate(value, param) {
2372 return typeof value === "function" ? value(param) : value;
2373 }
2374 function getSide(placement) {
2375 return placement.split("-")[0];
2376 }
2377 function getAlignment(placement) {
2378 return placement.split("-")[1];
2379 }
2380 function getOppositeAxis(axis) {
2381 return axis === "x" ? "y" : "x";
2382 }
2383 function getAxisLength(axis) {
2384 return axis === "y" ? "height" : "width";
2385 }
2386 function getSideAxis(placement) {
2387 const firstChar = placement[0];
2388 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2389 }
2390 function getAlignmentAxis(placement) {
2391 return getOppositeAxis(getSideAxis(placement));
2392 }
2393 function getAlignmentSides(placement, rects, rtl) {
2394 if (rtl === void 0) {
2395 rtl = false;
2396 }
2397 const alignment = getAlignment(placement);
2398 const alignmentAxis = getAlignmentAxis(placement);
2399 const length = getAxisLength(alignmentAxis);
2400 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2401 if (rects.reference[length] > rects.floating[length]) {
2402 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2403 }
2404 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2405 }
2406 function getExpandedPlacements(placement) {
2407 const oppositePlacement = getOppositePlacement(placement);
2408 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2409 }
2410 function getOppositeAlignmentPlacement(placement) {
2411 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2412 }
2413 var lrPlacement = ["left", "right"];
2414 var rlPlacement = ["right", "left"];
2415 var tbPlacement = ["top", "bottom"];
2416 var btPlacement = ["bottom", "top"];
2417 function getSideList(side, isStart, rtl) {
2418 switch (side) {
2419 case "top":
2420 case "bottom":
2421 if (rtl) return isStart ? rlPlacement : lrPlacement;
2422 return isStart ? lrPlacement : rlPlacement;
2423 case "left":
2424 case "right":
2425 return isStart ? tbPlacement : btPlacement;
2426 default:
2427 return [];
2428 }
2429 }
2430 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2431 const alignment = getAlignment(placement);
2432 let list = getSideList(getSide(placement), direction === "start", rtl);
2433 if (alignment) {
2434 list = list.map((side) => side + "-" + alignment);
2435 if (flipAlignment) {
2436 list = list.concat(list.map(getOppositeAlignmentPlacement));
2437 }
2438 }
2439 return list;
2440 }
2441 function getOppositePlacement(placement) {
2442 const side = getSide(placement);
2443 return oppositeSideMap[side] + placement.slice(side.length);
2444 }
2445 function expandPaddingObject(padding) {
2446 return {
2447 top: 0,
2448 right: 0,
2449 bottom: 0,
2450 left: 0,
2451 ...padding
2452 };
2453 }
2454 function getPaddingObject(padding) {
2455 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2456 top: padding,
2457 right: padding,
2458 bottom: padding,
2459 left: padding
2460 };
2461 }
2462 function rectToClientRect(rect) {
2463 const {
2464 x: x2,
2465 y: y2,
2466 width,
2467 height
2468 } = rect;
2469 return {
2470 width,
2471 height,
2472 top: y2,
2473 left: x2,
2474 right: x2 + width,
2475 bottom: y2 + height,
2476 x: x2,
2477 y: y2
2478 };
2479 }
2480
2481 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2482 function isHiddenByStyles(styles) {
2483 return styles.visibility === "hidden" || styles.visibility === "collapse";
2484 }
2485 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2486 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2487 return false;
2488 }
2489 if (typeof element.checkVisibility === "function") {
2490 return element.checkVisibility();
2491 }
2492 return styles.display !== "none" && styles.display !== "contents";
2493 }
2494
2495 // node_modules/@base-ui/utils/esm/owner.js
2496 function ownerDocument(node) {
2497 return node?.ownerDocument || document;
2498 }
2499
2500 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2501 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2502 function getParentElement(element) {
2503 const assignedSlot = element.assignedSlot;
2504 if (assignedSlot) {
2505 return assignedSlot;
2506 }
2507 if (element.parentElement) {
2508 return element.parentElement;
2509 }
2510 const rootNode = element.getRootNode();
2511 return isShadowRoot(rootNode) ? rootNode.host : null;
2512 }
2513 function getDetailsSummary(details) {
2514 for (const child of Array.from(details.children)) {
2515 if (getNodeName(child) === "summary") {
2516 return child;
2517 }
2518 }
2519 return null;
2520 }
2521 function isWithinOpenDetailsSummary(element, details) {
2522 const summary = getDetailsSummary(details);
2523 return !!summary && (element === summary || contains(summary, element));
2524 }
2525 function isFocusableCandidate(element) {
2526 const nodeName = element ? getNodeName(element) : "";
2527 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
2528 }
2529 function isFocusableElement(element) {
2530 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2531 return false;
2532 }
2533 for (let current = element; current; current = getParentElement(current)) {
2534 const isAncestor = current !== element;
2535 const isSlot = getNodeName(current) === "slot";
2536 if (current.hasAttribute("inert")) {
2537 return false;
2538 }
2539 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2540 return false;
2541 }
2542 }
2543 return true;
2544 }
2545 function isVisibleInTabbableTree(element, isAncestor) {
2546 const styles = getComputedStyle2(element);
2547 if (!isAncestor) {
2548 return isElementVisible(element, styles);
2549 }
2550 return styles.display !== "none";
2551 }
2552 function getTabIndex(element) {
2553 const tabIndex = element.tabIndex;
2554 if (tabIndex < 0) {
2555 const nodeName = getNodeName(element);
2556 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2557 return 0;
2558 }
2559 }
2560 return tabIndex;
2561 }
2562 function getNamedRadioInput(element) {
2563 if (getNodeName(element) !== "input") {
2564 return null;
2565 }
2566 const input = element;
2567 return input.type === "radio" && input.name !== "" ? input : null;
2568 }
2569 function isTabbableRadio(element, candidates) {
2570 const input = getNamedRadioInput(element);
2571 if (!input) {
2572 return true;
2573 }
2574 const checkedRadio = candidates.find((candidate) => {
2575 const radio = getNamedRadioInput(candidate);
2576 return radio?.name === input.name && radio.form === input.form && radio.checked;
2577 });
2578 if (checkedRadio) {
2579 return checkedRadio === input;
2580 }
2581 return candidates.find((candidate) => {
2582 const radio = getNamedRadioInput(candidate);
2583 return radio?.name === input.name && radio.form === input.form;
2584 }) === input;
2585 }
2586 function getComposedChildren(container) {
2587 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2588 const assignedElements = container.assignedElements({
2589 flatten: true
2590 });
2591 if (assignedElements.length > 0) {
2592 return assignedElements;
2593 }
2594 }
2595 if (isHTMLElement(container) && container.shadowRoot) {
2596 return Array.from(container.shadowRoot.children);
2597 }
2598 return Array.from(container.children);
2599 }
2600 function appendCandidates(container, list) {
2601 getComposedChildren(container).forEach((child) => {
2602 if (isFocusableCandidate(child)) {
2603 list.push(child);
2604 }
2605 appendCandidates(child, list);
2606 });
2607 }
2608 function appendMatchingElements(container, selector2, list) {
2609 getComposedChildren(container).forEach((child) => {
2610 if (isHTMLElement(child) && child.matches(selector2)) {
2611 list.push(child);
2612 }
2613 appendMatchingElements(child, selector2, list);
2614 });
2615 }
2616 function focusable(container) {
2617 const candidates = [];
2618 appendCandidates(container, candidates);
2619 return candidates.filter(isFocusableElement);
2620 }
2621 function tabbable(container) {
2622 const candidates = focusable(container);
2623 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2624 }
2625 function getTabbableIn(container, dir) {
2626 const list = tabbable(container);
2627 const len = list.length;
2628 if (len === 0) {
2629 return void 0;
2630 }
2631 const active = activeElement(ownerDocument(container));
2632 const index2 = list.indexOf(active);
2633 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2634 return list[nextIndex];
2635 }
2636 function getNextTabbable(referenceElement) {
2637 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2638 }
2639 function getPreviousTabbable(referenceElement) {
2640 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2641 }
2642 function isOutsideEvent(event, container) {
2643 const containerElement = container || event.currentTarget;
2644 const relatedTarget = event.relatedTarget;
2645 return !relatedTarget || !contains(containerElement, relatedTarget);
2646 }
2647 function disableFocusInside(container) {
2648 const tabbableElements = tabbable(container);
2649 tabbableElements.forEach((element) => {
2650 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2651 element.setAttribute("tabindex", "-1");
2652 });
2653 }
2654 function enableFocusInside(container) {
2655 const elements = [];
2656 appendMatchingElements(container, "[data-tabindex]", elements);
2657 elements.forEach((element) => {
2658 const tabindex = element.dataset.tabindex;
2659 delete element.dataset.tabindex;
2660 if (tabindex) {
2661 element.setAttribute("tabindex", tabindex);
2662 } else {
2663 element.removeAttribute("tabindex");
2664 }
2665 });
2666 }
2667
2668 // node_modules/@base-ui/utils/esm/addEventListener.js
2669 function addEventListener(target, type, listener, options) {
2670 target.addEventListener(type, listener, options);
2671 return () => {
2672 target.removeEventListener(type, listener, options);
2673 };
2674 }
2675
2676 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2677 function useValueAsRef(value) {
2678 const latest = useRefWithInit(createLatestRef, value).current;
2679 latest.next = value;
2680 useIsoLayoutEffect(latest.effect);
2681 return latest;
2682 }
2683 function createLatestRef(value) {
2684 const latest = {
2685 current: value,
2686 next: value,
2687 effect: () => {
2688 latest.current = latest.next;
2689 }
2690 };
2691 return latest;
2692 }
2693
2694 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2695 var React12 = __toESM(require_react(), 1);
2696
2697 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2698 var ReactDOM = __toESM(require_react_dom(), 1);
2699
2700 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2701 function resolveRef(maybeRef) {
2702 if (maybeRef == null) {
2703 return maybeRef;
2704 }
2705 return "current" in maybeRef ? maybeRef.current : maybeRef;
2706 }
2707
2708 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2709 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2710 const frame = useAnimationFrame();
2711 return useStableCallback((fnToExecute, signal = null) => {
2712 frame.cancel();
2713 const element = resolveRef(elementOrRef);
2714 if (element == null) {
2715 return;
2716 }
2717 const resolvedElement = element;
2718 const done = () => {
2719 ReactDOM.flushSync(fnToExecute);
2720 };
2721 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2722 fnToExecute();
2723 return;
2724 }
2725 function exec() {
2726 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2727 if (!signal?.aborted) {
2728 done();
2729 }
2730 }).catch(() => {
2731 if (treatAbortedAsFinished) {
2732 if (!signal?.aborted) {
2733 done();
2734 }
2735 return;
2736 }
2737 const currentAnimations = resolvedElement.getAnimations();
2738 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2739 exec();
2740 }
2741 });
2742 }
2743 if (waitForStartingStyleRemoved) {
2744 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2745 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2746 frame.request(exec);
2747 return;
2748 }
2749 const attributeObserver = new MutationObserver(() => {
2750 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2751 attributeObserver.disconnect();
2752 exec();
2753 }
2754 });
2755 attributeObserver.observe(resolvedElement, {
2756 attributes: true,
2757 attributeFilter: [startingStyleAttribute]
2758 });
2759 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2760 once: true
2761 });
2762 return;
2763 }
2764 frame.request(exec);
2765 });
2766 }
2767
2768 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2769 function useOpenChangeComplete(parameters) {
2770 const {
2771 enabled = true,
2772 open,
2773 ref,
2774 onComplete: onCompleteParam
2775 } = parameters;
2776 const onComplete = useStableCallback(onCompleteParam);
2777 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2778 React12.useEffect(() => {
2779 if (!enabled) {
2780 return void 0;
2781 }
2782 const abortController = new AbortController();
2783 runOnceAnimationsFinish(onComplete, abortController.signal);
2784 return () => {
2785 abortController.abort();
2786 };
2787 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2788 }
2789
2790 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2791 var React13 = __toESM(require_react(), 1);
2792 function useOnFirstRender(fn) {
2793 const ref = React13.useRef(true);
2794 if (ref.current) {
2795 ref.current = false;
2796 fn();
2797 }
2798 }
2799
2800 // node_modules/@base-ui/utils/esm/useTimeout.js
2801 var EMPTY3 = 0;
2802 var Timeout = class _Timeout {
2803 static create() {
2804 return new _Timeout();
2805 }
2806 currentId = EMPTY3;
2807 /**
2808 * Executes `fn` after `delay`, clearing any previously scheduled call.
2809 */
2810 start(delay, fn) {
2811 this.clear();
2812 this.currentId = setTimeout(() => {
2813 this.currentId = EMPTY3;
2814 fn();
2815 }, delay);
2816 }
2817 isStarted() {
2818 return this.currentId !== EMPTY3;
2819 }
2820 clear = () => {
2821 if (this.currentId !== EMPTY3) {
2822 clearTimeout(this.currentId);
2823 this.currentId = EMPTY3;
2824 }
2825 };
2826 disposeEffect = () => {
2827 return this.clear;
2828 };
2829 };
2830 function useTimeout() {
2831 const timeout = useRefWithInit(Timeout.create).current;
2832 useOnMount(timeout.disposeEffect);
2833 return timeout;
2834 }
2835
2836 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2837 var React14 = __toESM(require_react(), 1);
2838
2839 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2840 function resolveValue(value, pointerType) {
2841 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2842 return 0;
2843 }
2844 if (typeof value === "function") {
2845 return value();
2846 }
2847 return value;
2848 }
2849 function getDelay(value, prop, pointerType) {
2850 const result = resolveValue(value, pointerType);
2851 if (typeof result === "number") {
2852 return result;
2853 }
2854 return result?.[prop];
2855 }
2856 function getRestMs(value) {
2857 if (typeof value === "function") {
2858 return value();
2859 }
2860 return value;
2861 }
2862 function isClickLikeOpenEvent(openEventType, interactedInside) {
2863 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2864 }
2865 function isHoverOpenEvent(openEventType) {
2866 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2867 }
2868
2869 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2870 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2871 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2872 hasProvider: false,
2873 timeoutMs: 0,
2874 delayRef: {
2875 current: 0
2876 },
2877 initialDelayRef: {
2878 current: 0
2879 },
2880 timeout: new Timeout(),
2881 currentIdRef: {
2882 current: null
2883 },
2884 currentContextRef: {
2885 current: null
2886 }
2887 });
2888 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2889 function FloatingDelayGroup(props) {
2890 const {
2891 children,
2892 delay,
2893 timeoutMs = 0
2894 } = props;
2895 const delayRef = React14.useRef(delay);
2896 const initialDelayRef = React14.useRef(delay);
2897 const currentIdRef = React14.useRef(null);
2898 const currentContextRef = React14.useRef(null);
2899 const timeout = useTimeout();
2900 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2901 value: React14.useMemo(() => ({
2902 hasProvider: true,
2903 delayRef,
2904 initialDelayRef,
2905 currentIdRef,
2906 timeoutMs,
2907 currentContextRef,
2908 timeout
2909 }), [timeoutMs, timeout]),
2910 children
2911 });
2912 }
2913 function useDelayGroup(context, options = {
2914 open: false
2915 }) {
2916 const {
2917 open
2918 } = options;
2919 const store = "rootStore" in context ? context.rootStore : context;
2920 const floatingId = store.useState("floatingId");
2921 const groupContext = React14.useContext(FloatingDelayGroupContext);
2922 const {
2923 currentIdRef,
2924 delayRef,
2925 timeoutMs,
2926 initialDelayRef,
2927 currentContextRef,
2928 hasProvider,
2929 timeout
2930 } = groupContext;
2931 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2932 useIsoLayoutEffect(() => {
2933 function unset() {
2934 setIsInstantPhase(false);
2935 currentContextRef.current?.setIsInstantPhase(false);
2936 currentIdRef.current = null;
2937 currentContextRef.current = null;
2938 delayRef.current = initialDelayRef.current;
2939 }
2940 if (!currentIdRef.current) {
2941 return void 0;
2942 }
2943 if (!open && currentIdRef.current === floatingId) {
2944 setIsInstantPhase(false);
2945 if (timeoutMs) {
2946 const closingId = floatingId;
2947 timeout.start(timeoutMs, () => {
2948 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2949 return;
2950 }
2951 unset();
2952 });
2953 return () => {
2954 timeout.clear();
2955 };
2956 }
2957 unset();
2958 }
2959 return void 0;
2960 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2961 useIsoLayoutEffect(() => {
2962 if (!open) {
2963 return;
2964 }
2965 const prevContext = currentContextRef.current;
2966 const prevId = currentIdRef.current;
2967 timeout.clear();
2968 currentContextRef.current = {
2969 onOpenChange: store.setOpen,
2970 setIsInstantPhase
2971 };
2972 currentIdRef.current = floatingId;
2973 delayRef.current = {
2974 open: 0,
2975 close: getDelay(initialDelayRef.current, "close")
2976 };
2977 if (prevId !== null && prevId !== floatingId) {
2978 setIsInstantPhase(true);
2979 prevContext?.setIsInstantPhase(true);
2980 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2981 } else {
2982 setIsInstantPhase(false);
2983 prevContext?.setIsInstantPhase(false);
2984 }
2985 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2986 useIsoLayoutEffect(() => {
2987 return () => {
2988 currentContextRef.current = null;
2989 };
2990 }, [currentContextRef]);
2991 return React14.useMemo(() => ({
2992 hasProvider,
2993 delayRef,
2994 isInstantPhase
2995 }), [hasProvider, delayRef, isInstantPhase]);
2996 }
2997
2998 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2999 function mergeCleanups(...cleanups) {
3000 return () => {
3001 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3002 const cleanup = cleanups[i2];
3003 if (cleanup) {
3004 cleanup();
3005 }
3006 }
3007 };
3008 }
3009
3010 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3011 var React15 = __toESM(require_react(), 1);
3012
3013 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3014 var visuallyHiddenBase = {
3015 clipPath: "inset(50%)",
3016 overflow: "hidden",
3017 whiteSpace: "nowrap",
3018 border: 0,
3019 padding: 0,
3020 width: 1,
3021 height: 1,
3022 margin: -1
3023 };
3024 var visuallyHidden = {
3025 ...visuallyHiddenBase,
3026 position: "fixed",
3027 top: 0,
3028 left: 0
3029 };
3030 var visuallyHiddenInput = {
3031 ...visuallyHiddenBase,
3032 position: "absolute"
3033 };
3034
3035 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3036 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3037 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
3038 const [role, setRole] = React15.useState();
3039 useIsoLayoutEffect(() => {
3040 if (isSafari) {
3041 setRole("button");
3042 }
3043 }, []);
3044 const restProps = {
3045 tabIndex: 0,
3046 // Role is only for VoiceOver
3047 role
3048 };
3049 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3050 ...props,
3051 ref,
3052 style: visuallyHidden,
3053 "aria-hidden": role ? void 0 : true,
3054 ...restProps,
3055 "data-base-ui-focus-guard": ""
3056 });
3057 });
3058 if (true) FocusGuard.displayName = "FocusGuard";
3059
3060 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3061 function createAttribute(name) {
3062 return `data-base-ui-${name}`;
3063 }
3064
3065 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3066 var React16 = __toESM(require_react(), 1);
3067 var ReactDOM2 = __toESM(require_react_dom(), 1);
3068
3069 // node_modules/@base-ui/react/esm/internals/constants.js
3070 var DISABLED_TRANSITIONS_STYLE = {
3071 style: {
3072 transition: "none"
3073 }
3074 };
3075 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3076 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3077 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3078 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3079 var POPUP_COLLISION_AVOIDANCE = {
3080 fallbackAxisSide: "end"
3081 };
3082 var ownerVisuallyHidden = {
3083 clipPath: "inset(50%)",
3084 position: "fixed",
3085 top: 0,
3086 left: 0
3087 };
3088
3089 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3090 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3091 var PortalContext = /* @__PURE__ */ React16.createContext(null);
3092 if (true) PortalContext.displayName = "PortalContext";
3093 var usePortalContext = () => React16.useContext(PortalContext);
3094 var attr = createAttribute("portal");
3095 function useFloatingPortalNode(props = {}) {
3096 const {
3097 ref,
3098 container: containerProp,
3099 componentProps = EMPTY_OBJECT,
3100 elementProps
3101 } = props;
3102 const uniqueId = useId();
3103 const portalContext = usePortalContext();
3104 const parentPortalNode = portalContext?.portalNode;
3105 const [containerElement, setContainerElement] = React16.useState(null);
3106 const [portalNode, setPortalNode] = React16.useState(null);
3107 const setPortalNodeRef = useStableCallback((node) => {
3108 if (node !== null) {
3109 setPortalNode(node);
3110 }
3111 });
3112 const containerRef = React16.useRef(null);
3113 useIsoLayoutEffect(() => {
3114 if (containerProp === null) {
3115 if (containerRef.current) {
3116 containerRef.current = null;
3117 setPortalNode(null);
3118 setContainerElement(null);
3119 }
3120 return;
3121 }
3122 if (uniqueId == null) {
3123 return;
3124 }
3125 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3126 if (resolvedContainer == null) {
3127 if (containerRef.current) {
3128 containerRef.current = null;
3129 setPortalNode(null);
3130 setContainerElement(null);
3131 }
3132 return;
3133 }
3134 if (containerRef.current !== resolvedContainer) {
3135 containerRef.current = resolvedContainer;
3136 setPortalNode(null);
3137 setContainerElement(resolvedContainer);
3138 }
3139 }, [containerProp, parentPortalNode, uniqueId]);
3140 const portalElement = useRenderElement("div", componentProps, {
3141 ref: [ref, setPortalNodeRef],
3142 props: [{
3143 id: uniqueId,
3144 [attr]: ""
3145 }, elementProps]
3146 });
3147 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3148 return {
3149 portalNode,
3150 portalSubtree
3151 };
3152 }
3153 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3154 const {
3155 render: render4,
3156 className,
3157 style,
3158 children,
3159 container,
3160 renderGuards,
3161 ...elementProps
3162 } = componentProps;
3163 const {
3164 portalNode,
3165 portalSubtree
3166 } = useFloatingPortalNode({
3167 container,
3168 ref: forwardedRef,
3169 componentProps,
3170 elementProps
3171 });
3172 const beforeOutsideRef = React16.useRef(null);
3173 const afterOutsideRef = React16.useRef(null);
3174 const beforeInsideRef = React16.useRef(null);
3175 const afterInsideRef = React16.useRef(null);
3176 const [focusManagerState, setFocusManagerState] = React16.useState(null);
3177 const focusInsideDisabledRef = React16.useRef(false);
3178 const modal = focusManagerState?.modal;
3179 const open = focusManagerState?.open;
3180 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3181 React16.useEffect(() => {
3182 if (!portalNode || modal) {
3183 return void 0;
3184 }
3185 function onFocus(event) {
3186 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3187 if (event.type === "focusin") {
3188 if (focusInsideDisabledRef.current) {
3189 enableFocusInside(portalNode);
3190 focusInsideDisabledRef.current = false;
3191 }
3192 } else {
3193 disableFocusInside(portalNode);
3194 focusInsideDisabledRef.current = true;
3195 }
3196 }
3197 }
3198 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3199 }, [portalNode, modal]);
3200 React16.useEffect(() => {
3201 if (!portalNode || open !== false) {
3202 return;
3203 }
3204 enableFocusInside(portalNode);
3205 focusInsideDisabledRef.current = false;
3206 }, [open, portalNode]);
3207 const portalContextValue = React16.useMemo(() => ({
3208 beforeOutsideRef,
3209 afterOutsideRef,
3210 beforeInsideRef,
3211 afterInsideRef,
3212 portalNode,
3213 setFocusManagerState
3214 }), [portalNode]);
3215 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
3216 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3217 value: portalContextValue,
3218 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3219 "data-type": "outside",
3220 ref: beforeOutsideRef,
3221 onFocus: (event) => {
3222 if (isOutsideEvent(event, portalNode)) {
3223 beforeInsideRef.current?.focus();
3224 } else {
3225 const domReference = focusManagerState ? focusManagerState.domReference : null;
3226 const prevTabbable = getPreviousTabbable(domReference);
3227 prevTabbable?.focus();
3228 }
3229 }
3230 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3231 "aria-owns": portalNode.id,
3232 style: ownerVisuallyHidden
3233 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3234 "data-type": "outside",
3235 ref: afterOutsideRef,
3236 onFocus: (event) => {
3237 if (isOutsideEvent(event, portalNode)) {
3238 afterInsideRef.current?.focus();
3239 } else {
3240 const domReference = focusManagerState ? focusManagerState.domReference : null;
3241 const nextTabbable = getNextTabbable(domReference);
3242 nextTabbable?.focus();
3243 if (focusManagerState?.closeOnFocusOut) {
3244 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3245 }
3246 }
3247 }
3248 })]
3249 })]
3250 });
3251 });
3252 if (true) FloatingPortal.displayName = "FloatingPortal";
3253
3254 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3255 var React17 = __toESM(require_react(), 1);
3256
3257 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3258 function createEventEmitter() {
3259 const map = /* @__PURE__ */ new Map();
3260 return {
3261 emit(event, data) {
3262 map.get(event)?.forEach((listener) => listener(data));
3263 },
3264 on(event, listener) {
3265 if (!map.has(event)) {
3266 map.set(event, /* @__PURE__ */ new Set());
3267 }
3268 map.get(event).add(listener);
3269 },
3270 off(event, listener) {
3271 map.get(event)?.delete(listener);
3272 }
3273 };
3274 }
3275
3276 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3277 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3278 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3279 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3280 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3281 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3282 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3283 var useFloatingTree = (externalTree) => {
3284 const contextTree = React17.useContext(FloatingTreeContext);
3285 return externalTree ?? contextTree;
3286 };
3287
3288 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3289 var React18 = __toESM(require_react(), 1);
3290 function createVirtualElement(domElement, data) {
3291 let offsetX = null;
3292 let offsetY = null;
3293 let isAutoUpdateEvent = false;
3294 return {
3295 contextElement: domElement || void 0,
3296 getBoundingClientRect() {
3297 const domRect = domElement?.getBoundingClientRect() || {
3298 width: 0,
3299 height: 0,
3300 x: 0,
3301 y: 0
3302 };
3303 const isXAxis = data.axis === "x" || data.axis === "both";
3304 const isYAxis = data.axis === "y" || data.axis === "both";
3305 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3306 let width = domRect.width;
3307 let height = domRect.height;
3308 let x2 = domRect.x;
3309 let y2 = domRect.y;
3310 if (offsetX == null && data.x && isXAxis) {
3311 offsetX = domRect.x - data.x;
3312 }
3313 if (offsetY == null && data.y && isYAxis) {
3314 offsetY = domRect.y - data.y;
3315 }
3316 x2 -= offsetX || 0;
3317 y2 -= offsetY || 0;
3318 width = 0;
3319 height = 0;
3320 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3321 width = data.axis === "y" ? domRect.width : 0;
3322 height = data.axis === "x" ? domRect.height : 0;
3323 x2 = isXAxis && data.x != null ? data.x : x2;
3324 y2 = isYAxis && data.y != null ? data.y : y2;
3325 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3326 height = data.axis === "x" ? domRect.height : height;
3327 width = data.axis === "y" ? domRect.width : width;
3328 }
3329 isAutoUpdateEvent = true;
3330 return {
3331 width,
3332 height,
3333 x: x2,
3334 y: y2,
3335 top: y2,
3336 right: x2 + width,
3337 bottom: y2 + height,
3338 left: x2
3339 };
3340 }
3341 };
3342 }
3343 function isMouseBasedEvent(event) {
3344 return event != null && event.clientX != null;
3345 }
3346 function useClientPoint(context, props = {}) {
3347 const {
3348 enabled = true,
3349 axis = "both"
3350 } = props;
3351 const store = "rootStore" in context ? context.rootStore : context;
3352 const open = store.useState("open");
3353 const floating = store.useState("floatingElement");
3354 const domReference = store.useState("domReferenceElement");
3355 const dataRef = store.context.dataRef;
3356 const initialRef = React18.useRef(false);
3357 const cleanupListenerRef = React18.useRef(null);
3358 const [pointerType, setPointerType] = React18.useState();
3359 const [reactive, setReactive] = React18.useState([]);
3360 const resetReference = useStableCallback((reference2) => {
3361 store.set("positionReference", reference2);
3362 });
3363 const setReference = useStableCallback((newX, newY, referenceElement) => {
3364 if (initialRef.current) {
3365 return;
3366 }
3367 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3368 return;
3369 }
3370 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3371 x: newX,
3372 y: newY,
3373 axis,
3374 dataRef,
3375 pointerType
3376 }));
3377 });
3378 const handleReferenceEnterOrMove = useStableCallback((event) => {
3379 if (!open) {
3380 setReference(event.clientX, event.clientY, event.currentTarget);
3381 } else if (!cleanupListenerRef.current) {
3382 setReference(event.clientX, event.clientY, event.currentTarget);
3383 setReactive([]);
3384 }
3385 });
3386 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3387 React18.useEffect(() => {
3388 if (!enabled) {
3389 resetReference(domReference);
3390 return void 0;
3391 }
3392 if (!openCheck) {
3393 return void 0;
3394 }
3395 function cleanupListener() {
3396 cleanupListenerRef.current?.();
3397 cleanupListenerRef.current = null;
3398 }
3399 const win = getWindow(floating);
3400 function handleMouseMove(event) {
3401 const target = getTarget(event);
3402 if (!contains(floating, target)) {
3403 setReference(event.clientX, event.clientY);
3404 } else {
3405 cleanupListener();
3406 }
3407 }
3408 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3409 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3410 } else {
3411 resetReference(domReference);
3412 }
3413 return cleanupListener;
3414 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3415 React18.useEffect(() => () => {
3416 store.set("positionReference", null);
3417 }, [store]);
3418 React18.useEffect(() => {
3419 if (enabled && !floating) {
3420 initialRef.current = false;
3421 }
3422 }, [enabled, floating]);
3423 React18.useEffect(() => {
3424 if (!enabled && open) {
3425 initialRef.current = true;
3426 }
3427 }, [enabled, open]);
3428 const reference = React18.useMemo(() => {
3429 function setPointerTypeRef(event) {
3430 setPointerType(event.pointerType);
3431 }
3432 return {
3433 onPointerDown: setPointerTypeRef,
3434 onPointerEnter: setPointerTypeRef,
3435 onMouseMove: handleReferenceEnterOrMove,
3436 onMouseEnter: handleReferenceEnterOrMove
3437 };
3438 }, [handleReferenceEnterOrMove]);
3439 return React18.useMemo(() => enabled ? {
3440 reference,
3441 trigger: reference
3442 } : {}, [enabled, reference]);
3443 }
3444
3445 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3446 var React19 = __toESM(require_react(), 1);
3447 var bubbleHandlerKeys = {
3448 intentional: "onClick",
3449 sloppy: "onPointerDown"
3450 };
3451 function alwaysFalse() {
3452 return false;
3453 }
3454 function normalizeProp(normalizable) {
3455 return {
3456 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3457 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3458 };
3459 }
3460 function useDismiss(context, props = {}) {
3461 const {
3462 enabled = true,
3463 escapeKey: escapeKey2 = true,
3464 outsidePress: outsidePressProp = true,
3465 outsidePressEvent = "sloppy",
3466 referencePress = alwaysFalse,
3467 referencePressEvent = "sloppy",
3468 bubbles,
3469 externalTree
3470 } = props;
3471 const store = "rootStore" in context ? context.rootStore : context;
3472 const open = store.useState("open");
3473 const floatingElement = store.useState("floatingElement");
3474 const {
3475 dataRef
3476 } = store.context;
3477 const tree = useFloatingTree(externalTree);
3478 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3479 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3480 const outsidePressEnabled = outsidePress2 !== false;
3481 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3482 const {
3483 escapeKey: escapeKeyBubbles,
3484 outsidePress: outsidePressBubbles
3485 } = normalizeProp(bubbles);
3486 const pressStartedInsideRef = React19.useRef(false);
3487 const pressStartPreventedRef = React19.useRef(false);
3488 const suppressNextOutsideClickRef = React19.useRef(false);
3489 const isComposingRef = React19.useRef(false);
3490 const currentPointerTypeRef = React19.useRef("");
3491 const touchStateRef = React19.useRef(null);
3492 const cancelDismissOnEndTimeout = useTimeout();
3493 const clearInsideReactTreeTimeout = useTimeout();
3494 const clearInsideReactTree = useStableCallback(() => {
3495 clearInsideReactTreeTimeout.clear();
3496 dataRef.current.insideReactTree = false;
3497 });
3498 const hasBlockingChild = useStableCallback((bubbleKey) => {
3499 const nodeId = dataRef.current.floatingContext?.nodeId;
3500 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3501 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3502 });
3503 const isEventWithinOwnElements = useStableCallback((event) => {
3504 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3505 });
3506 const closeOnReferencePress = useStableCallback((event) => {
3507 if (!referencePress()) {
3508 return;
3509 }
3510 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3511 });
3512 const closeOnEscapeKeyDown = useStableCallback((event) => {
3513 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3514 return;
3515 }
3516 if (isComposingRef.current) {
3517 return;
3518 }
3519 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3520 return;
3521 }
3522 const native = isReactEvent(event) ? event.nativeEvent : event;
3523 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3524 store.setOpen(false, eventDetails);
3525 if (!eventDetails.isCanceled) {
3526 event.preventDefault();
3527 }
3528 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3529 event.stopPropagation();
3530 }
3531 });
3532 const markInsideReactTree = useStableCallback(() => {
3533 dataRef.current.insideReactTree = true;
3534 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3535 });
3536 const markPressStartedInsideReactTree = useStableCallback((event) => {
3537 if (!open || !enabled || event.button !== 0) {
3538 return;
3539 }
3540 const target = getTarget(event.nativeEvent);
3541 if (!contains(store.select("floatingElement"), target)) {
3542 return;
3543 }
3544 if (!pressStartedInsideRef.current) {
3545 pressStartedInsideRef.current = true;
3546 pressStartPreventedRef.current = false;
3547 }
3548 });
3549 const markInsidePressStartPrevented = useStableCallback((event) => {
3550 if (!open || !enabled) {
3551 return;
3552 }
3553 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3554 return;
3555 }
3556 if (pressStartedInsideRef.current) {
3557 pressStartPreventedRef.current = true;
3558 }
3559 });
3560 React19.useEffect(() => {
3561 if (!open || !enabled) {
3562 return void 0;
3563 }
3564 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3565 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3566 const compositionTimeout = new Timeout();
3567 const preventedPressSuppressionTimeout = new Timeout();
3568 function handleCompositionStart() {
3569 compositionTimeout.clear();
3570 isComposingRef.current = true;
3571 }
3572 function handleCompositionEnd() {
3573 compositionTimeout.start(
3574 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3575 // Only apply to WebKit for the test to remain 0ms.
3576 isWebKit() ? 5 : 0,
3577 () => {
3578 isComposingRef.current = false;
3579 }
3580 );
3581 }
3582 function suppressImmediateOutsideClickAfterPreventedStart() {
3583 suppressNextOutsideClickRef.current = true;
3584 preventedPressSuppressionTimeout.start(0, () => {
3585 suppressNextOutsideClickRef.current = false;
3586 });
3587 }
3588 function resetPressStartState() {
3589 pressStartedInsideRef.current = false;
3590 pressStartPreventedRef.current = false;
3591 }
3592 function getOutsidePressEvent() {
3593 const type = currentPointerTypeRef.current;
3594 const computedType = type === "pen" || !type ? "mouse" : type;
3595 const outsidePressEventValue = getOutsidePressEventProp();
3596 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3597 if (typeof resolved === "string") {
3598 return resolved;
3599 }
3600 return resolved[computedType];
3601 }
3602 function shouldIgnoreEvent(event) {
3603 const computedOutsidePressEvent = getOutsidePressEvent();
3604 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3605 }
3606 function isEventWithinFloatingTree(event) {
3607 const nodeId = dataRef.current.floatingContext?.nodeId;
3608 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3609 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3610 }
3611 function closeOnPressOutside(event) {
3612 if (shouldIgnoreEvent(event)) {
3613 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3614 preventedPressSuppressionTimeout.clear();
3615 suppressNextOutsideClickRef.current = false;
3616 }
3617 clearInsideReactTree();
3618 return;
3619 }
3620 if (dataRef.current.insideReactTree) {
3621 clearInsideReactTree();
3622 return;
3623 }
3624 const target = getTarget(event);
3625 const inertSelector = `[${createAttribute("inert")}]`;
3626 const targetRoot = isElement(target) ? target.getRootNode() : null;
3627 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3628 const triggers = store.context.triggerElements;
3629 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3630 return;
3631 }
3632 let targetRootAncestor = isElement(target) ? target : null;
3633 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3634 const nextParent = getParentNode(targetRootAncestor);
3635 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3636 break;
3637 }
3638 targetRootAncestor = nextParent;
3639 }
3640 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3641 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3642 // element was injected after the floating element rendered.
3643 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3644 return;
3645 }
3646 if (isHTMLElement(target) && !("touches" in event)) {
3647 const lastTraversableNode = isLastTraversableNode(target);
3648 const style = getComputedStyle2(target);
3649 const scrollRe = /auto|scroll/;
3650 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3651 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3652 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3653 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3654 const isRTL7 = style.direction === "rtl";
3655 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3656 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3657 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3658 return;
3659 }
3660 }
3661 if (isEventWithinFloatingTree(event)) {
3662 return;
3663 }
3664 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3665 preventedPressSuppressionTimeout.clear();
3666 suppressNextOutsideClickRef.current = false;
3667 return;
3668 }
3669 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3670 return;
3671 }
3672 if (hasBlockingChild("__outsidePressBubbles")) {
3673 return;
3674 }
3675 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3676 clearInsideReactTree();
3677 }
3678 function handlePointerDown(event) {
3679 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3680 return;
3681 }
3682 closeOnPressOutside(event);
3683 }
3684 function handleTouchStart(event) {
3685 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3686 return;
3687 }
3688 const touch = event.touches[0];
3689 if (touch) {
3690 touchStateRef.current = {
3691 startTime: Date.now(),
3692 startX: touch.clientX,
3693 startY: touch.clientY,
3694 dismissOnTouchEnd: false,
3695 dismissOnMouseDown: true
3696 };
3697 cancelDismissOnEndTimeout.start(1e3, () => {
3698 if (touchStateRef.current) {
3699 touchStateRef.current.dismissOnTouchEnd = false;
3700 touchStateRef.current.dismissOnMouseDown = false;
3701 }
3702 });
3703 }
3704 }
3705 function addTargetEventListenerOnce(event, listener) {
3706 const target = getTarget(event);
3707 if (!target) {
3708 return;
3709 }
3710 const unsubscribe2 = addEventListener(target, event.type, () => {
3711 listener(event);
3712 unsubscribe2();
3713 });
3714 }
3715 function handleTouchStartCapture(event) {
3716 currentPointerTypeRef.current = "touch";
3717 addTargetEventListenerOnce(event, handleTouchStart);
3718 }
3719 function closeOnPressOutsideCapture(event) {
3720 cancelDismissOnEndTimeout.clear();
3721 if (event.type === "pointerdown") {
3722 currentPointerTypeRef.current = event.pointerType;
3723 }
3724 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3725 return;
3726 }
3727 addTargetEventListenerOnce(event, (targetEvent) => {
3728 if (targetEvent.type === "pointerdown") {
3729 handlePointerDown(targetEvent);
3730 } else {
3731 closeOnPressOutside(targetEvent);
3732 }
3733 });
3734 }
3735 function handlePressEndCapture(event) {
3736 if (!pressStartedInsideRef.current) {
3737 return;
3738 }
3739 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3740 resetPressStartState();
3741 if (getOutsidePressEvent() !== "intentional") {
3742 return;
3743 }
3744 if (event.type === "pointercancel") {
3745 if (pressStartedInsideDefaultPrevented) {
3746 suppressImmediateOutsideClickAfterPreventedStart();
3747 }
3748 return;
3749 }
3750 if (isEventWithinFloatingTree(event)) {
3751 return;
3752 }
3753 if (pressStartedInsideDefaultPrevented) {
3754 suppressImmediateOutsideClickAfterPreventedStart();
3755 return;
3756 }
3757 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3758 return;
3759 }
3760 preventedPressSuppressionTimeout.clear();
3761 suppressNextOutsideClickRef.current = true;
3762 clearInsideReactTree();
3763 }
3764 function handleTouchMove(event) {
3765 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3766 return;
3767 }
3768 const touch = event.touches[0];
3769 if (!touch) {
3770 return;
3771 }
3772 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3773 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3774 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3775 if (distance > 5) {
3776 touchStateRef.current.dismissOnTouchEnd = true;
3777 }
3778 if (distance > 10) {
3779 closeOnPressOutside(event);
3780 cancelDismissOnEndTimeout.clear();
3781 touchStateRef.current = null;
3782 }
3783 }
3784 function handleTouchMoveCapture(event) {
3785 addTargetEventListenerOnce(event, handleTouchMove);
3786 }
3787 function handleTouchEnd(event) {
3788 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3789 return;
3790 }
3791 if (touchStateRef.current.dismissOnTouchEnd) {
3792 closeOnPressOutside(event);
3793 }
3794 cancelDismissOnEndTimeout.clear();
3795 touchStateRef.current = null;
3796 }
3797 function handleTouchEndCapture(event) {
3798 addTargetEventListenerOnce(event, handleTouchEnd);
3799 }
3800 const doc = ownerDocument(floatingElement);
3801 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true)));
3802 return () => {
3803 unsubscribe();
3804 compositionTimeout.clear();
3805 preventedPressSuppressionTimeout.clear();
3806 resetPressStartState();
3807 suppressNextOutsideClickRef.current = false;
3808 };
3809 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3810 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3811 const reference = React19.useMemo(() => ({
3812 onKeyDown: closeOnEscapeKeyDown,
3813 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3814 ...referencePressEvent !== "intentional" && {
3815 onClick: closeOnReferencePress
3816 }
3817 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3818 const floating = React19.useMemo(() => ({
3819 onKeyDown: closeOnEscapeKeyDown,
3820 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3821 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3822 // See https://github.com/mui/base-ui/pull/3379
3823 onPointerDown: markInsidePressStartPrevented,
3824 onMouseDown: markInsidePressStartPrevented,
3825 onClickCapture: markInsideReactTree,
3826 onMouseDownCapture(event) {
3827 markInsideReactTree();
3828 markPressStartedInsideReactTree(event);
3829 },
3830 onPointerDownCapture(event) {
3831 markInsideReactTree();
3832 markPressStartedInsideReactTree(event);
3833 },
3834 onMouseUpCapture: markInsideReactTree,
3835 onTouchEndCapture: markInsideReactTree,
3836 onTouchMoveCapture: markInsideReactTree
3837 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3838 return React19.useMemo(() => enabled ? {
3839 reference,
3840 floating,
3841 trigger: reference
3842 } : {}, [enabled, reference, floating]);
3843 }
3844
3845 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3846 var React26 = __toESM(require_react(), 1);
3847
3848 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3849 function computeCoordsFromPlacement(_ref, placement, rtl) {
3850 let {
3851 reference,
3852 floating
3853 } = _ref;
3854 const sideAxis = getSideAxis(placement);
3855 const alignmentAxis = getAlignmentAxis(placement);
3856 const alignLength = getAxisLength(alignmentAxis);
3857 const side = getSide(placement);
3858 const isVertical = sideAxis === "y";
3859 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3860 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3861 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3862 let coords;
3863 switch (side) {
3864 case "top":
3865 coords = {
3866 x: commonX,
3867 y: reference.y - floating.height
3868 };
3869 break;
3870 case "bottom":
3871 coords = {
3872 x: commonX,
3873 y: reference.y + reference.height
3874 };
3875 break;
3876 case "right":
3877 coords = {
3878 x: reference.x + reference.width,
3879 y: commonY
3880 };
3881 break;
3882 case "left":
3883 coords = {
3884 x: reference.x - floating.width,
3885 y: commonY
3886 };
3887 break;
3888 default:
3889 coords = {
3890 x: reference.x,
3891 y: reference.y
3892 };
3893 }
3894 switch (getAlignment(placement)) {
3895 case "start":
3896 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3897 break;
3898 case "end":
3899 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3900 break;
3901 }
3902 return coords;
3903 }
3904 async function detectOverflow(state, options) {
3905 var _await$platform$isEle;
3906 if (options === void 0) {
3907 options = {};
3908 }
3909 const {
3910 x: x2,
3911 y: y2,
3912 platform: platform3,
3913 rects,
3914 elements,
3915 strategy
3916 } = state;
3917 const {
3918 boundary = "clippingAncestors",
3919 rootBoundary = "viewport",
3920 elementContext = "floating",
3921 altBoundary = false,
3922 padding = 0
3923 } = evaluate(options, state);
3924 const paddingObject = getPaddingObject(padding);
3925 const altContext = elementContext === "floating" ? "reference" : "floating";
3926 const element = elements[altBoundary ? altContext : elementContext];
3927 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3928 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)),
3929 boundary,
3930 rootBoundary,
3931 strategy
3932 }));
3933 const rect = elementContext === "floating" ? {
3934 x: x2,
3935 y: y2,
3936 width: rects.floating.width,
3937 height: rects.floating.height
3938 } : rects.reference;
3939 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3940 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3941 x: 1,
3942 y: 1
3943 } : {
3944 x: 1,
3945 y: 1
3946 };
3947 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3948 elements,
3949 rect,
3950 offsetParent,
3951 strategy
3952 }) : rect);
3953 return {
3954 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3955 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3956 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3957 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3958 };
3959 }
3960 var MAX_RESET_COUNT = 50;
3961 var computePosition = async (reference, floating, config) => {
3962 const {
3963 placement = "bottom",
3964 strategy = "absolute",
3965 middleware = [],
3966 platform: platform3
3967 } = config;
3968 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3969 ...platform3,
3970 detectOverflow
3971 };
3972 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3973 let rects = await platform3.getElementRects({
3974 reference,
3975 floating,
3976 strategy
3977 });
3978 let {
3979 x: x2,
3980 y: y2
3981 } = computeCoordsFromPlacement(rects, placement, rtl);
3982 let statefulPlacement = placement;
3983 let resetCount = 0;
3984 const middlewareData = {};
3985 for (let i2 = 0; i2 < middleware.length; i2++) {
3986 const currentMiddleware = middleware[i2];
3987 if (!currentMiddleware) {
3988 continue;
3989 }
3990 const {
3991 name,
3992 fn
3993 } = currentMiddleware;
3994 const {
3995 x: nextX,
3996 y: nextY,
3997 data,
3998 reset
3999 } = await fn({
4000 x: x2,
4001 y: y2,
4002 initialPlacement: placement,
4003 placement: statefulPlacement,
4004 strategy,
4005 middlewareData,
4006 rects,
4007 platform: platformWithDetectOverflow,
4008 elements: {
4009 reference,
4010 floating
4011 }
4012 });
4013 x2 = nextX != null ? nextX : x2;
4014 y2 = nextY != null ? nextY : y2;
4015 middlewareData[name] = {
4016 ...middlewareData[name],
4017 ...data
4018 };
4019 if (reset && resetCount < MAX_RESET_COUNT) {
4020 resetCount++;
4021 if (typeof reset === "object") {
4022 if (reset.placement) {
4023 statefulPlacement = reset.placement;
4024 }
4025 if (reset.rects) {
4026 rects = reset.rects === true ? await platform3.getElementRects({
4027 reference,
4028 floating,
4029 strategy
4030 }) : reset.rects;
4031 }
4032 ({
4033 x: x2,
4034 y: y2
4035 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4036 }
4037 i2 = -1;
4038 }
4039 }
4040 return {
4041 x: x2,
4042 y: y2,
4043 placement: statefulPlacement,
4044 strategy,
4045 middlewareData
4046 };
4047 };
4048 var flip = function(options) {
4049 if (options === void 0) {
4050 options = {};
4051 }
4052 return {
4053 name: "flip",
4054 options,
4055 async fn(state) {
4056 var _middlewareData$arrow, _middlewareData$flip;
4057 const {
4058 placement,
4059 middlewareData,
4060 rects,
4061 initialPlacement,
4062 platform: platform3,
4063 elements
4064 } = state;
4065 const {
4066 mainAxis: checkMainAxis = true,
4067 crossAxis: checkCrossAxis = true,
4068 fallbackPlacements: specifiedFallbackPlacements,
4069 fallbackStrategy = "bestFit",
4070 fallbackAxisSideDirection = "none",
4071 flipAlignment = true,
4072 ...detectOverflowOptions
4073 } = evaluate(options, state);
4074 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4075 return {};
4076 }
4077 const side = getSide(placement);
4078 const initialSideAxis = getSideAxis(initialPlacement);
4079 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4080 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4081 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4082 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4083 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4084 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4085 }
4086 const placements2 = [initialPlacement, ...fallbackPlacements];
4087 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4088 const overflows = [];
4089 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4090 if (checkMainAxis) {
4091 overflows.push(overflow[side]);
4092 }
4093 if (checkCrossAxis) {
4094 const sides2 = getAlignmentSides(placement, rects, rtl);
4095 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4096 }
4097 overflowsData = [...overflowsData, {
4098 placement,
4099 overflows
4100 }];
4101 if (!overflows.every((side2) => side2 <= 0)) {
4102 var _middlewareData$flip2, _overflowsData$filter;
4103 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4104 const nextPlacement = placements2[nextIndex];
4105 if (nextPlacement) {
4106 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4107 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4108 // overflows the main axis.
4109 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4110 return {
4111 data: {
4112 index: nextIndex,
4113 overflows: overflowsData
4114 },
4115 reset: {
4116 placement: nextPlacement
4117 }
4118 };
4119 }
4120 }
4121 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
4122 if (!resetPlacement) {
4123 switch (fallbackStrategy) {
4124 case "bestFit": {
4125 var _overflowsData$filter2;
4126 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4127 if (hasFallbackAxisSideDirection) {
4128 const currentSideAxis = getSideAxis(d2.placement);
4129 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4130 // reading directions favoring greater width.
4131 currentSideAxis === "y";
4132 }
4133 return true;
4134 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
4135 if (placement2) {
4136 resetPlacement = placement2;
4137 }
4138 break;
4139 }
4140 case "initialPlacement":
4141 resetPlacement = initialPlacement;
4142 break;
4143 }
4144 }
4145 if (placement !== resetPlacement) {
4146 return {
4147 reset: {
4148 placement: resetPlacement
4149 }
4150 };
4151 }
4152 }
4153 return {};
4154 }
4155 };
4156 };
4157 function getSideOffsets(overflow, rect) {
4158 return {
4159 top: overflow.top - rect.height,
4160 right: overflow.right - rect.width,
4161 bottom: overflow.bottom - rect.height,
4162 left: overflow.left - rect.width
4163 };
4164 }
4165 function isAnySideFullyClipped(overflow) {
4166 return sides.some((side) => overflow[side] >= 0);
4167 }
4168 var hide = function(options) {
4169 if (options === void 0) {
4170 options = {};
4171 }
4172 return {
4173 name: "hide",
4174 options,
4175 async fn(state) {
4176 const {
4177 rects,
4178 platform: platform3
4179 } = state;
4180 const {
4181 strategy = "referenceHidden",
4182 ...detectOverflowOptions
4183 } = evaluate(options, state);
4184 switch (strategy) {
4185 case "referenceHidden": {
4186 const overflow = await platform3.detectOverflow(state, {
4187 ...detectOverflowOptions,
4188 elementContext: "reference"
4189 });
4190 const offsets = getSideOffsets(overflow, rects.reference);
4191 return {
4192 data: {
4193 referenceHiddenOffsets: offsets,
4194 referenceHidden: isAnySideFullyClipped(offsets)
4195 }
4196 };
4197 }
4198 case "escaped": {
4199 const overflow = await platform3.detectOverflow(state, {
4200 ...detectOverflowOptions,
4201 altBoundary: true
4202 });
4203 const offsets = getSideOffsets(overflow, rects.floating);
4204 return {
4205 data: {
4206 escapedOffsets: offsets,
4207 escaped: isAnySideFullyClipped(offsets)
4208 }
4209 };
4210 }
4211 default: {
4212 return {};
4213 }
4214 }
4215 }
4216 };
4217 };
4218 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4219 async function convertValueToCoords(state, options) {
4220 const {
4221 placement,
4222 platform: platform3,
4223 elements
4224 } = state;
4225 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4226 const side = getSide(placement);
4227 const alignment = getAlignment(placement);
4228 const isVertical = getSideAxis(placement) === "y";
4229 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4230 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4231 const rawValue = evaluate(options, state);
4232 let {
4233 mainAxis,
4234 crossAxis,
4235 alignmentAxis
4236 } = typeof rawValue === "number" ? {
4237 mainAxis: rawValue,
4238 crossAxis: 0,
4239 alignmentAxis: null
4240 } : {
4241 mainAxis: rawValue.mainAxis || 0,
4242 crossAxis: rawValue.crossAxis || 0,
4243 alignmentAxis: rawValue.alignmentAxis
4244 };
4245 if (alignment && typeof alignmentAxis === "number") {
4246 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4247 }
4248 return isVertical ? {
4249 x: crossAxis * crossAxisMulti,
4250 y: mainAxis * mainAxisMulti
4251 } : {
4252 x: mainAxis * mainAxisMulti,
4253 y: crossAxis * crossAxisMulti
4254 };
4255 }
4256 var offset = function(options) {
4257 if (options === void 0) {
4258 options = 0;
4259 }
4260 return {
4261 name: "offset",
4262 options,
4263 async fn(state) {
4264 var _middlewareData$offse, _middlewareData$arrow;
4265 const {
4266 x: x2,
4267 y: y2,
4268 placement,
4269 middlewareData
4270 } = state;
4271 const diffCoords = await convertValueToCoords(state, options);
4272 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4273 return {};
4274 }
4275 return {
4276 x: x2 + diffCoords.x,
4277 y: y2 + diffCoords.y,
4278 data: {
4279 ...diffCoords,
4280 placement
4281 }
4282 };
4283 }
4284 };
4285 };
4286 var shift = function(options) {
4287 if (options === void 0) {
4288 options = {};
4289 }
4290 return {
4291 name: "shift",
4292 options,
4293 async fn(state) {
4294 const {
4295 x: x2,
4296 y: y2,
4297 placement,
4298 platform: platform3
4299 } = state;
4300 const {
4301 mainAxis: checkMainAxis = true,
4302 crossAxis: checkCrossAxis = false,
4303 limiter = {
4304 fn: (_ref) => {
4305 let {
4306 x: x3,
4307 y: y3
4308 } = _ref;
4309 return {
4310 x: x3,
4311 y: y3
4312 };
4313 }
4314 },
4315 ...detectOverflowOptions
4316 } = evaluate(options, state);
4317 const coords = {
4318 x: x2,
4319 y: y2
4320 };
4321 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4322 const crossAxis = getSideAxis(getSide(placement));
4323 const mainAxis = getOppositeAxis(crossAxis);
4324 let mainAxisCoord = coords[mainAxis];
4325 let crossAxisCoord = coords[crossAxis];
4326 if (checkMainAxis) {
4327 const minSide = mainAxis === "y" ? "top" : "left";
4328 const maxSide = mainAxis === "y" ? "bottom" : "right";
4329 const min2 = mainAxisCoord + overflow[minSide];
4330 const max2 = mainAxisCoord - overflow[maxSide];
4331 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4332 }
4333 if (checkCrossAxis) {
4334 const minSide = crossAxis === "y" ? "top" : "left";
4335 const maxSide = crossAxis === "y" ? "bottom" : "right";
4336 const min2 = crossAxisCoord + overflow[minSide];
4337 const max2 = crossAxisCoord - overflow[maxSide];
4338 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4339 }
4340 const limitedCoords = limiter.fn({
4341 ...state,
4342 [mainAxis]: mainAxisCoord,
4343 [crossAxis]: crossAxisCoord
4344 });
4345 return {
4346 ...limitedCoords,
4347 data: {
4348 x: limitedCoords.x - x2,
4349 y: limitedCoords.y - y2,
4350 enabled: {
4351 [mainAxis]: checkMainAxis,
4352 [crossAxis]: checkCrossAxis
4353 }
4354 }
4355 };
4356 }
4357 };
4358 };
4359 var limitShift = function(options) {
4360 if (options === void 0) {
4361 options = {};
4362 }
4363 return {
4364 options,
4365 fn(state) {
4366 const {
4367 x: x2,
4368 y: y2,
4369 placement,
4370 rects,
4371 middlewareData
4372 } = state;
4373 const {
4374 offset: offset4 = 0,
4375 mainAxis: checkMainAxis = true,
4376 crossAxis: checkCrossAxis = true
4377 } = evaluate(options, state);
4378 const coords = {
4379 x: x2,
4380 y: y2
4381 };
4382 const crossAxis = getSideAxis(placement);
4383 const mainAxis = getOppositeAxis(crossAxis);
4384 let mainAxisCoord = coords[mainAxis];
4385 let crossAxisCoord = coords[crossAxis];
4386 const rawOffset = evaluate(offset4, state);
4387 const computedOffset = typeof rawOffset === "number" ? {
4388 mainAxis: rawOffset,
4389 crossAxis: 0
4390 } : {
4391 mainAxis: 0,
4392 crossAxis: 0,
4393 ...rawOffset
4394 };
4395 if (checkMainAxis) {
4396 const len = mainAxis === "y" ? "height" : "width";
4397 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4398 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4399 if (mainAxisCoord < limitMin) {
4400 mainAxisCoord = limitMin;
4401 } else if (mainAxisCoord > limitMax) {
4402 mainAxisCoord = limitMax;
4403 }
4404 }
4405 if (checkCrossAxis) {
4406 var _middlewareData$offse, _middlewareData$offse2;
4407 const len = mainAxis === "y" ? "width" : "height";
4408 const isOriginSide = originSides.has(getSide(placement));
4409 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
4410 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
4411 if (crossAxisCoord < limitMin) {
4412 crossAxisCoord = limitMin;
4413 } else if (crossAxisCoord > limitMax) {
4414 crossAxisCoord = limitMax;
4415 }
4416 }
4417 return {
4418 [mainAxis]: mainAxisCoord,
4419 [crossAxis]: crossAxisCoord
4420 };
4421 }
4422 };
4423 };
4424 var size = function(options) {
4425 if (options === void 0) {
4426 options = {};
4427 }
4428 return {
4429 name: "size",
4430 options,
4431 async fn(state) {
4432 var _state$middlewareData, _state$middlewareData2;
4433 const {
4434 placement,
4435 rects,
4436 platform: platform3,
4437 elements
4438 } = state;
4439 const {
4440 apply = () => {
4441 },
4442 ...detectOverflowOptions
4443 } = evaluate(options, state);
4444 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4445 const side = getSide(placement);
4446 const alignment = getAlignment(placement);
4447 const isYAxis = getSideAxis(placement) === "y";
4448 const {
4449 width,
4450 height
4451 } = rects.floating;
4452 let heightSide;
4453 let widthSide;
4454 if (side === "top" || side === "bottom") {
4455 heightSide = side;
4456 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4457 } else {
4458 widthSide = side;
4459 heightSide = alignment === "end" ? "top" : "bottom";
4460 }
4461 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4462 const maximumClippingWidth = width - overflow.left - overflow.right;
4463 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4464 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4465 const noShift = !state.middlewareData.shift;
4466 let availableHeight = overflowAvailableHeight;
4467 let availableWidth = overflowAvailableWidth;
4468 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4469 availableWidth = maximumClippingWidth;
4470 }
4471 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4472 availableHeight = maximumClippingHeight;
4473 }
4474 if (noShift && !alignment) {
4475 const xMin = max(overflow.left, 0);
4476 const xMax = max(overflow.right, 0);
4477 const yMin = max(overflow.top, 0);
4478 const yMax = max(overflow.bottom, 0);
4479 if (isYAxis) {
4480 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4481 } else {
4482 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4483 }
4484 }
4485 await apply({
4486 ...state,
4487 availableWidth,
4488 availableHeight
4489 });
4490 const nextDimensions = await platform3.getDimensions(elements.floating);
4491 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4492 return {
4493 reset: {
4494 rects: true
4495 }
4496 };
4497 }
4498 return {};
4499 }
4500 };
4501 };
4502
4503 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4504 function getCssDimensions(element) {
4505 const css = getComputedStyle2(element);
4506 let width = parseFloat(css.width) || 0;
4507 let height = parseFloat(css.height) || 0;
4508 const hasOffset = isHTMLElement(element);
4509 const offsetWidth = hasOffset ? element.offsetWidth : width;
4510 const offsetHeight = hasOffset ? element.offsetHeight : height;
4511 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4512 if (shouldFallback) {
4513 width = offsetWidth;
4514 height = offsetHeight;
4515 }
4516 return {
4517 width,
4518 height,
4519 $: shouldFallback
4520 };
4521 }
4522 function unwrapElement(element) {
4523 return !isElement(element) ? element.contextElement : element;
4524 }
4525 function getScale(element) {
4526 const domElement = unwrapElement(element);
4527 if (!isHTMLElement(domElement)) {
4528 return createCoords(1);
4529 }
4530 const rect = domElement.getBoundingClientRect();
4531 const {
4532 width,
4533 height,
4534 $: $2
4535 } = getCssDimensions(domElement);
4536 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4537 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4538 if (!x2 || !Number.isFinite(x2)) {
4539 x2 = 1;
4540 }
4541 if (!y2 || !Number.isFinite(y2)) {
4542 y2 = 1;
4543 }
4544 return {
4545 x: x2,
4546 y: y2
4547 };
4548 }
4549 var noOffsets = /* @__PURE__ */ createCoords(0);
4550 function getVisualOffsets(element) {
4551 const win = getWindow(element);
4552 if (!isWebKit() || !win.visualViewport) {
4553 return noOffsets;
4554 }
4555 return {
4556 x: win.visualViewport.offsetLeft,
4557 y: win.visualViewport.offsetTop
4558 };
4559 }
4560 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4561 if (isFixed === void 0) {
4562 isFixed = false;
4563 }
4564 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4565 return false;
4566 }
4567 return isFixed;
4568 }
4569 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4570 if (includeScale === void 0) {
4571 includeScale = false;
4572 }
4573 if (isFixedStrategy === void 0) {
4574 isFixedStrategy = false;
4575 }
4576 const clientRect = element.getBoundingClientRect();
4577 const domElement = unwrapElement(element);
4578 let scale = createCoords(1);
4579 if (includeScale) {
4580 if (offsetParent) {
4581 if (isElement(offsetParent)) {
4582 scale = getScale(offsetParent);
4583 }
4584 } else {
4585 scale = getScale(element);
4586 }
4587 }
4588 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4589 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4590 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4591 let width = clientRect.width / scale.x;
4592 let height = clientRect.height / scale.y;
4593 if (domElement) {
4594 const win = getWindow(domElement);
4595 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4596 let currentWin = win;
4597 let currentIFrame = getFrameElement(currentWin);
4598 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4599 const iframeScale = getScale(currentIFrame);
4600 const iframeRect = currentIFrame.getBoundingClientRect();
4601 const css = getComputedStyle2(currentIFrame);
4602 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4603 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4604 x2 *= iframeScale.x;
4605 y2 *= iframeScale.y;
4606 width *= iframeScale.x;
4607 height *= iframeScale.y;
4608 x2 += left;
4609 y2 += top;
4610 currentWin = getWindow(currentIFrame);
4611 currentIFrame = getFrameElement(currentWin);
4612 }
4613 }
4614 return rectToClientRect({
4615 width,
4616 height,
4617 x: x2,
4618 y: y2
4619 });
4620 }
4621 function getWindowScrollBarX(element, rect) {
4622 const leftScroll = getNodeScroll(element).scrollLeft;
4623 if (!rect) {
4624 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4625 }
4626 return rect.left + leftScroll;
4627 }
4628 function getHTMLOffset(documentElement, scroll) {
4629 const htmlRect = documentElement.getBoundingClientRect();
4630 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4631 const y2 = htmlRect.top + scroll.scrollTop;
4632 return {
4633 x: x2,
4634 y: y2
4635 };
4636 }
4637 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4638 let {
4639 elements,
4640 rect,
4641 offsetParent,
4642 strategy
4643 } = _ref;
4644 const isFixed = strategy === "fixed";
4645 const documentElement = getDocumentElement(offsetParent);
4646 const topLayer = elements ? isTopLayer(elements.floating) : false;
4647 if (offsetParent === documentElement || topLayer && isFixed) {
4648 return rect;
4649 }
4650 let scroll = {
4651 scrollLeft: 0,
4652 scrollTop: 0
4653 };
4654 let scale = createCoords(1);
4655 const offsets = createCoords(0);
4656 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4657 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4658 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4659 scroll = getNodeScroll(offsetParent);
4660 }
4661 if (isOffsetParentAnElement) {
4662 const offsetRect = getBoundingClientRect(offsetParent);
4663 scale = getScale(offsetParent);
4664 offsets.x = offsetRect.x + offsetParent.clientLeft;
4665 offsets.y = offsetRect.y + offsetParent.clientTop;
4666 }
4667 }
4668 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4669 return {
4670 width: rect.width * scale.x,
4671 height: rect.height * scale.y,
4672 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4673 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4674 };
4675 }
4676 function getClientRects(element) {
4677 return Array.from(element.getClientRects());
4678 }
4679 function getDocumentRect(element) {
4680 const html = getDocumentElement(element);
4681 const scroll = getNodeScroll(element);
4682 const body = element.ownerDocument.body;
4683 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4684 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4685 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4686 const y2 = -scroll.scrollTop;
4687 if (getComputedStyle2(body).direction === "rtl") {
4688 x2 += max(html.clientWidth, body.clientWidth) - width;
4689 }
4690 return {
4691 width,
4692 height,
4693 x: x2,
4694 y: y2
4695 };
4696 }
4697 var SCROLLBAR_MAX = 25;
4698 function getViewportRect(element, strategy) {
4699 const win = getWindow(element);
4700 const html = getDocumentElement(element);
4701 const visualViewport = win.visualViewport;
4702 let width = html.clientWidth;
4703 let height = html.clientHeight;
4704 let x2 = 0;
4705 let y2 = 0;
4706 if (visualViewport) {
4707 width = visualViewport.width;
4708 height = visualViewport.height;
4709 const visualViewportBased = isWebKit();
4710 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4711 x2 = visualViewport.offsetLeft;
4712 y2 = visualViewport.offsetTop;
4713 }
4714 }
4715 const windowScrollbarX = getWindowScrollBarX(html);
4716 if (windowScrollbarX <= 0) {
4717 const doc = html.ownerDocument;
4718 const body = doc.body;
4719 const bodyStyles = getComputedStyle(body);
4720 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4721 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4722 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4723 width -= clippingStableScrollbarWidth;
4724 }
4725 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4726 width += windowScrollbarX;
4727 }
4728 return {
4729 width,
4730 height,
4731 x: x2,
4732 y: y2
4733 };
4734 }
4735 function getInnerBoundingClientRect(element, strategy) {
4736 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4737 const top = clientRect.top + element.clientTop;
4738 const left = clientRect.left + element.clientLeft;
4739 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4740 const width = element.clientWidth * scale.x;
4741 const height = element.clientHeight * scale.y;
4742 const x2 = left * scale.x;
4743 const y2 = top * scale.y;
4744 return {
4745 width,
4746 height,
4747 x: x2,
4748 y: y2
4749 };
4750 }
4751 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4752 let rect;
4753 if (clippingAncestor === "viewport") {
4754 rect = getViewportRect(element, strategy);
4755 } else if (clippingAncestor === "document") {
4756 rect = getDocumentRect(getDocumentElement(element));
4757 } else if (isElement(clippingAncestor)) {
4758 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4759 } else {
4760 const visualOffsets = getVisualOffsets(element);
4761 rect = {
4762 x: clippingAncestor.x - visualOffsets.x,
4763 y: clippingAncestor.y - visualOffsets.y,
4764 width: clippingAncestor.width,
4765 height: clippingAncestor.height
4766 };
4767 }
4768 return rectToClientRect(rect);
4769 }
4770 function hasFixedPositionAncestor(element, stopNode) {
4771 const parentNode = getParentNode(element);
4772 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4773 return false;
4774 }
4775 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4776 }
4777 function getClippingElementAncestors(element, cache) {
4778 const cachedResult = cache.get(element);
4779 if (cachedResult) {
4780 return cachedResult;
4781 }
4782 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4783 let currentContainingBlockComputedStyle = null;
4784 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4785 let currentNode = elementIsFixed ? getParentNode(element) : element;
4786 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4787 const computedStyle = getComputedStyle2(currentNode);
4788 const currentNodeIsContaining = isContainingBlock(currentNode);
4789 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4790 currentContainingBlockComputedStyle = null;
4791 }
4792 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4793 if (shouldDropCurrentNode) {
4794 result = result.filter((ancestor) => ancestor !== currentNode);
4795 } else {
4796 currentContainingBlockComputedStyle = computedStyle;
4797 }
4798 currentNode = getParentNode(currentNode);
4799 }
4800 cache.set(element, result);
4801 return result;
4802 }
4803 function getClippingRect(_ref) {
4804 let {
4805 element,
4806 boundary,
4807 rootBoundary,
4808 strategy
4809 } = _ref;
4810 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4811 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4812 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4813 let top = firstRect.top;
4814 let right = firstRect.right;
4815 let bottom = firstRect.bottom;
4816 let left = firstRect.left;
4817 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4818 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4819 top = max(rect.top, top);
4820 right = min(rect.right, right);
4821 bottom = min(rect.bottom, bottom);
4822 left = max(rect.left, left);
4823 }
4824 return {
4825 width: right - left,
4826 height: bottom - top,
4827 x: left,
4828 y: top
4829 };
4830 }
4831 function getDimensions(element) {
4832 const {
4833 width,
4834 height
4835 } = getCssDimensions(element);
4836 return {
4837 width,
4838 height
4839 };
4840 }
4841 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4842 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4843 const documentElement = getDocumentElement(offsetParent);
4844 const isFixed = strategy === "fixed";
4845 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4846 let scroll = {
4847 scrollLeft: 0,
4848 scrollTop: 0
4849 };
4850 const offsets = createCoords(0);
4851 function setLeftRTLScrollbarOffset() {
4852 offsets.x = getWindowScrollBarX(documentElement);
4853 }
4854 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4855 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4856 scroll = getNodeScroll(offsetParent);
4857 }
4858 if (isOffsetParentAnElement) {
4859 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4860 offsets.x = offsetRect.x + offsetParent.clientLeft;
4861 offsets.y = offsetRect.y + offsetParent.clientTop;
4862 } else if (documentElement) {
4863 setLeftRTLScrollbarOffset();
4864 }
4865 }
4866 if (isFixed && !isOffsetParentAnElement && documentElement) {
4867 setLeftRTLScrollbarOffset();
4868 }
4869 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4870 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4871 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4872 return {
4873 x: x2,
4874 y: y2,
4875 width: rect.width,
4876 height: rect.height
4877 };
4878 }
4879 function isStaticPositioned(element) {
4880 return getComputedStyle2(element).position === "static";
4881 }
4882 function getTrueOffsetParent(element, polyfill) {
4883 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4884 return null;
4885 }
4886 if (polyfill) {
4887 return polyfill(element);
4888 }
4889 let rawOffsetParent = element.offsetParent;
4890 if (getDocumentElement(element) === rawOffsetParent) {
4891 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4892 }
4893 return rawOffsetParent;
4894 }
4895 function getOffsetParent(element, polyfill) {
4896 const win = getWindow(element);
4897 if (isTopLayer(element)) {
4898 return win;
4899 }
4900 if (!isHTMLElement(element)) {
4901 let svgOffsetParent = getParentNode(element);
4902 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4903 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4904 return svgOffsetParent;
4905 }
4906 svgOffsetParent = getParentNode(svgOffsetParent);
4907 }
4908 return win;
4909 }
4910 let offsetParent = getTrueOffsetParent(element, polyfill);
4911 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4912 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4913 }
4914 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4915 return win;
4916 }
4917 return offsetParent || getContainingBlock(element) || win;
4918 }
4919 var getElementRects = async function(data) {
4920 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4921 const getDimensionsFn = this.getDimensions;
4922 const floatingDimensions = await getDimensionsFn(data.floating);
4923 return {
4924 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4925 floating: {
4926 x: 0,
4927 y: 0,
4928 width: floatingDimensions.width,
4929 height: floatingDimensions.height
4930 }
4931 };
4932 };
4933 function isRTL(element) {
4934 return getComputedStyle2(element).direction === "rtl";
4935 }
4936 var platform2 = {
4937 convertOffsetParentRelativeRectToViewportRelativeRect,
4938 getDocumentElement,
4939 getClippingRect,
4940 getOffsetParent,
4941 getElementRects,
4942 getClientRects,
4943 getDimensions,
4944 getScale,
4945 isElement,
4946 isRTL
4947 };
4948 function rectsAreEqual(a2, b2) {
4949 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4950 }
4951 function observeMove(element, onMove) {
4952 let io = null;
4953 let timeoutId;
4954 const root = getDocumentElement(element);
4955 function cleanup() {
4956 var _io;
4957 clearTimeout(timeoutId);
4958 (_io = io) == null || _io.disconnect();
4959 io = null;
4960 }
4961 function refresh(skip, threshold) {
4962 if (skip === void 0) {
4963 skip = false;
4964 }
4965 if (threshold === void 0) {
4966 threshold = 1;
4967 }
4968 cleanup();
4969 const elementRectForRootMargin = element.getBoundingClientRect();
4970 const {
4971 left,
4972 top,
4973 width,
4974 height
4975 } = elementRectForRootMargin;
4976 if (!skip) {
4977 onMove();
4978 }
4979 if (!width || !height) {
4980 return;
4981 }
4982 const insetTop = floor(top);
4983 const insetRight = floor(root.clientWidth - (left + width));
4984 const insetBottom = floor(root.clientHeight - (top + height));
4985 const insetLeft = floor(left);
4986 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4987 const options = {
4988 rootMargin,
4989 threshold: max(0, min(1, threshold)) || 1
4990 };
4991 let isFirstUpdate = true;
4992 function handleObserve(entries) {
4993 const ratio = entries[0].intersectionRatio;
4994 if (ratio !== threshold) {
4995 if (!isFirstUpdate) {
4996 return refresh();
4997 }
4998 if (!ratio) {
4999 timeoutId = setTimeout(() => {
5000 refresh(false, 1e-7);
5001 }, 1e3);
5002 } else {
5003 refresh(false, ratio);
5004 }
5005 }
5006 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5007 refresh();
5008 }
5009 isFirstUpdate = false;
5010 }
5011 try {
5012 io = new IntersectionObserver(handleObserve, {
5013 ...options,
5014 // Handle <iframe>s
5015 root: root.ownerDocument
5016 });
5017 } catch (_e) {
5018 io = new IntersectionObserver(handleObserve, options);
5019 }
5020 io.observe(element);
5021 }
5022 refresh(true);
5023 return cleanup;
5024 }
5025 function autoUpdate(reference, floating, update2, options) {
5026 if (options === void 0) {
5027 options = {};
5028 }
5029 const {
5030 ancestorScroll = true,
5031 ancestorResize = true,
5032 elementResize = typeof ResizeObserver === "function",
5033 layoutShift = typeof IntersectionObserver === "function",
5034 animationFrame = false
5035 } = options;
5036 const referenceEl = unwrapElement(reference);
5037 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5038 ancestors.forEach((ancestor) => {
5039 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5040 passive: true
5041 });
5042 ancestorResize && ancestor.addEventListener("resize", update2);
5043 });
5044 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5045 let reobserveFrame = -1;
5046 let resizeObserver = null;
5047 if (elementResize) {
5048 resizeObserver = new ResizeObserver((_ref) => {
5049 let [firstEntry] = _ref;
5050 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5051 resizeObserver.unobserve(floating);
5052 cancelAnimationFrame(reobserveFrame);
5053 reobserveFrame = requestAnimationFrame(() => {
5054 var _resizeObserver;
5055 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5056 });
5057 }
5058 update2();
5059 });
5060 if (referenceEl && !animationFrame) {
5061 resizeObserver.observe(referenceEl);
5062 }
5063 if (floating) {
5064 resizeObserver.observe(floating);
5065 }
5066 }
5067 let frameId;
5068 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5069 if (animationFrame) {
5070 frameLoop();
5071 }
5072 function frameLoop() {
5073 const nextRefRect = getBoundingClientRect(reference);
5074 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5075 update2();
5076 }
5077 prevRefRect = nextRefRect;
5078 frameId = requestAnimationFrame(frameLoop);
5079 }
5080 update2();
5081 return () => {
5082 var _resizeObserver2;
5083 ancestors.forEach((ancestor) => {
5084 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5085 ancestorResize && ancestor.removeEventListener("resize", update2);
5086 });
5087 cleanupIo == null || cleanupIo();
5088 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5089 resizeObserver = null;
5090 if (animationFrame) {
5091 cancelAnimationFrame(frameId);
5092 }
5093 };
5094 }
5095 var offset2 = offset;
5096 var shift2 = shift;
5097 var flip2 = flip;
5098 var size2 = size;
5099 var hide2 = hide;
5100 var limitShift2 = limitShift;
5101 var computePosition2 = (reference, floating, options) => {
5102 const cache = /* @__PURE__ */ new Map();
5103 const mergedOptions = {
5104 platform: platform2,
5105 ...options
5106 };
5107 const platformWithCache = {
5108 ...mergedOptions.platform,
5109 _c: cache
5110 };
5111 return computePosition(reference, floating, {
5112 ...mergedOptions,
5113 platform: platformWithCache
5114 });
5115 };
5116
5117 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5118 var React20 = __toESM(require_react(), 1);
5119 var import_react2 = __toESM(require_react(), 1);
5120 var ReactDOM3 = __toESM(require_react_dom(), 1);
5121 var isClient = typeof document !== "undefined";
5122 var noop2 = function noop3() {
5123 };
5124 var index = isClient ? import_react2.useLayoutEffect : noop2;
5125 function deepEqual(a2, b2) {
5126 if (a2 === b2) {
5127 return true;
5128 }
5129 if (typeof a2 !== typeof b2) {
5130 return false;
5131 }
5132 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5133 return true;
5134 }
5135 let length;
5136 let i2;
5137 let keys;
5138 if (a2 && b2 && typeof a2 === "object") {
5139 if (Array.isArray(a2)) {
5140 length = a2.length;
5141 if (length !== b2.length) return false;
5142 for (i2 = length; i2-- !== 0; ) {
5143 if (!deepEqual(a2[i2], b2[i2])) {
5144 return false;
5145 }
5146 }
5147 return true;
5148 }
5149 keys = Object.keys(a2);
5150 length = keys.length;
5151 if (length !== Object.keys(b2).length) {
5152 return false;
5153 }
5154 for (i2 = length; i2-- !== 0; ) {
5155 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5156 return false;
5157 }
5158 }
5159 for (i2 = length; i2-- !== 0; ) {
5160 const key = keys[i2];
5161 if (key === "_owner" && a2.$$typeof) {
5162 continue;
5163 }
5164 if (!deepEqual(a2[key], b2[key])) {
5165 return false;
5166 }
5167 }
5168 return true;
5169 }
5170 return a2 !== a2 && b2 !== b2;
5171 }
5172 function getDPR(element) {
5173 if (typeof window === "undefined") {
5174 return 1;
5175 }
5176 const win = element.ownerDocument.defaultView || window;
5177 return win.devicePixelRatio || 1;
5178 }
5179 function roundByDPR(element, value) {
5180 const dpr = getDPR(element);
5181 return Math.round(value * dpr) / dpr;
5182 }
5183 function useLatestRef(value) {
5184 const ref = React20.useRef(value);
5185 index(() => {
5186 ref.current = value;
5187 });
5188 return ref;
5189 }
5190 function useFloating(options) {
5191 if (options === void 0) {
5192 options = {};
5193 }
5194 const {
5195 placement = "bottom",
5196 strategy = "absolute",
5197 middleware = [],
5198 platform: platform3,
5199 elements: {
5200 reference: externalReference,
5201 floating: externalFloating
5202 } = {},
5203 transform = true,
5204 whileElementsMounted,
5205 open
5206 } = options;
5207 const [data, setData] = React20.useState({
5208 x: 0,
5209 y: 0,
5210 strategy,
5211 placement,
5212 middlewareData: {},
5213 isPositioned: false
5214 });
5215 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5216 if (!deepEqual(latestMiddleware, middleware)) {
5217 setLatestMiddleware(middleware);
5218 }
5219 const [_reference, _setReference] = React20.useState(null);
5220 const [_floating, _setFloating] = React20.useState(null);
5221 const setReference = React20.useCallback((node) => {
5222 if (node !== referenceRef.current) {
5223 referenceRef.current = node;
5224 _setReference(node);
5225 }
5226 }, []);
5227 const setFloating = React20.useCallback((node) => {
5228 if (node !== floatingRef.current) {
5229 floatingRef.current = node;
5230 _setFloating(node);
5231 }
5232 }, []);
5233 const referenceEl = externalReference || _reference;
5234 const floatingEl = externalFloating || _floating;
5235 const referenceRef = React20.useRef(null);
5236 const floatingRef = React20.useRef(null);
5237 const dataRef = React20.useRef(data);
5238 const hasWhileElementsMounted = whileElementsMounted != null;
5239 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5240 const platformRef = useLatestRef(platform3);
5241 const openRef = useLatestRef(open);
5242 const update2 = React20.useCallback(() => {
5243 if (!referenceRef.current || !floatingRef.current) {
5244 return;
5245 }
5246 const config = {
5247 placement,
5248 strategy,
5249 middleware: latestMiddleware
5250 };
5251 if (platformRef.current) {
5252 config.platform = platformRef.current;
5253 }
5254 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5255 const fullData = {
5256 ...data2,
5257 // The floating element's position may be recomputed while it's closed
5258 // but still mounted (such as when transitioning out). To ensure
5259 // `isPositioned` will be `false` initially on the next open, avoid
5260 // setting it to `true` when `open === false` (must be specified).
5261 isPositioned: openRef.current !== false
5262 };
5263 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5264 dataRef.current = fullData;
5265 ReactDOM3.flushSync(() => {
5266 setData(fullData);
5267 });
5268 }
5269 });
5270 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5271 index(() => {
5272 if (open === false && dataRef.current.isPositioned) {
5273 dataRef.current.isPositioned = false;
5274 setData((data2) => ({
5275 ...data2,
5276 isPositioned: false
5277 }));
5278 }
5279 }, [open]);
5280 const isMountedRef = React20.useRef(false);
5281 index(() => {
5282 isMountedRef.current = true;
5283 return () => {
5284 isMountedRef.current = false;
5285 };
5286 }, []);
5287 index(() => {
5288 if (referenceEl) referenceRef.current = referenceEl;
5289 if (floatingEl) floatingRef.current = floatingEl;
5290 if (referenceEl && floatingEl) {
5291 if (whileElementsMountedRef.current) {
5292 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5293 }
5294 update2();
5295 }
5296 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5297 const refs = React20.useMemo(() => ({
5298 reference: referenceRef,
5299 floating: floatingRef,
5300 setReference,
5301 setFloating
5302 }), [setReference, setFloating]);
5303 const elements = React20.useMemo(() => ({
5304 reference: referenceEl,
5305 floating: floatingEl
5306 }), [referenceEl, floatingEl]);
5307 const floatingStyles = React20.useMemo(() => {
5308 const initialStyles = {
5309 position: strategy,
5310 left: 0,
5311 top: 0
5312 };
5313 if (!elements.floating) {
5314 return initialStyles;
5315 }
5316 const x2 = roundByDPR(elements.floating, data.x);
5317 const y2 = roundByDPR(elements.floating, data.y);
5318 if (transform) {
5319 return {
5320 ...initialStyles,
5321 transform: "translate(" + x2 + "px, " + y2 + "px)",
5322 ...getDPR(elements.floating) >= 1.5 && {
5323 willChange: "transform"
5324 }
5325 };
5326 }
5327 return {
5328 position: strategy,
5329 left: x2,
5330 top: y2
5331 };
5332 }, [strategy, transform, elements.floating, data.x, data.y]);
5333 return React20.useMemo(() => ({
5334 ...data,
5335 update: update2,
5336 refs,
5337 elements,
5338 floatingStyles
5339 }), [data, update2, refs, elements, floatingStyles]);
5340 }
5341 var offset3 = (options, deps) => {
5342 const result = offset2(options);
5343 return {
5344 name: result.name,
5345 fn: result.fn,
5346 options: [options, deps]
5347 };
5348 };
5349 var shift3 = (options, deps) => {
5350 const result = shift2(options);
5351 return {
5352 name: result.name,
5353 fn: result.fn,
5354 options: [options, deps]
5355 };
5356 };
5357 var limitShift3 = (options, deps) => {
5358 const result = limitShift2(options);
5359 return {
5360 fn: result.fn,
5361 options: [options, deps]
5362 };
5363 };
5364 var flip3 = (options, deps) => {
5365 const result = flip2(options);
5366 return {
5367 name: result.name,
5368 fn: result.fn,
5369 options: [options, deps]
5370 };
5371 };
5372 var size3 = (options, deps) => {
5373 const result = size2(options);
5374 return {
5375 name: result.name,
5376 fn: result.fn,
5377 options: [options, deps]
5378 };
5379 };
5380 var hide3 = (options, deps) => {
5381 const result = hide2(options);
5382 return {
5383 name: result.name,
5384 fn: result.fn,
5385 options: [options, deps]
5386 };
5387 };
5388
5389 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5390 var React25 = __toESM(require_react(), 1);
5391
5392 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5393 var React24 = __toESM(require_react(), 1);
5394
5395 // node_modules/@base-ui/utils/esm/store/createSelector.js
5396 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5397 if (other.length > 0) {
5398 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5399 }
5400 let selector2;
5401 if (a2 && b2 && c2 && d2 && e2 && f2) {
5402 selector2 = (state, a1, a22, a3) => {
5403 const va = a2(state, a1, a22, a3);
5404 const vb = b2(state, a1, a22, a3);
5405 const vc = c2(state, a1, a22, a3);
5406 const vd = d2(state, a1, a22, a3);
5407 const ve = e2(state, a1, a22, a3);
5408 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5409 };
5410 } else if (a2 && b2 && c2 && d2 && e2) {
5411 selector2 = (state, a1, a22, a3) => {
5412 const va = a2(state, a1, a22, a3);
5413 const vb = b2(state, a1, a22, a3);
5414 const vc = c2(state, a1, a22, a3);
5415 const vd = d2(state, a1, a22, a3);
5416 return e2(va, vb, vc, vd, a1, a22, a3);
5417 };
5418 } else if (a2 && b2 && c2 && d2) {
5419 selector2 = (state, a1, a22, a3) => {
5420 const va = a2(state, a1, a22, a3);
5421 const vb = b2(state, a1, a22, a3);
5422 const vc = c2(state, a1, a22, a3);
5423 return d2(va, vb, vc, a1, a22, a3);
5424 };
5425 } else if (a2 && b2 && c2) {
5426 selector2 = (state, a1, a22, a3) => {
5427 const va = a2(state, a1, a22, a3);
5428 const vb = b2(state, a1, a22, a3);
5429 return c2(va, vb, a1, a22, a3);
5430 };
5431 } else if (a2 && b2) {
5432 selector2 = (state, a1, a22, a3) => {
5433 const va = a2(state, a1, a22, a3);
5434 return b2(va, a1, a22, a3);
5435 };
5436 } else if (a2) {
5437 selector2 = a2;
5438 } else {
5439 throw (
5440 /* minify-error-disabled */
5441 new Error("Missing arguments")
5442 );
5443 }
5444 return selector2;
5445 };
5446
5447 // node_modules/@base-ui/utils/esm/store/useStore.js
5448 var React22 = __toESM(require_react(), 1);
5449 var import_shim = __toESM(require_shim(), 1);
5450 var import_with_selector = __toESM(require_with_selector(), 1);
5451
5452 // node_modules/@base-ui/utils/esm/fastHooks.js
5453 var React21 = __toESM(require_react(), 1);
5454 var hooks = [];
5455 var currentInstance = void 0;
5456 function getInstance() {
5457 return currentInstance;
5458 }
5459 function register(hook) {
5460 hooks.push(hook);
5461 }
5462 function fastComponent(fn) {
5463 const FastComponent = (props, forwardedRef) => {
5464 const instance = useRefWithInit(createInstance).current;
5465 let result;
5466 try {
5467 currentInstance = instance;
5468 for (const hook of hooks) {
5469 hook.before(instance);
5470 }
5471 result = fn(props, forwardedRef);
5472 for (const hook of hooks) {
5473 hook.after(instance);
5474 }
5475 instance.didInitialize = true;
5476 } finally {
5477 currentInstance = void 0;
5478 }
5479 return result;
5480 };
5481 FastComponent.displayName = fn.displayName || fn.name;
5482 return FastComponent;
5483 }
5484 function fastComponentRef(fn) {
5485 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5486 }
5487 function createInstance() {
5488 return {
5489 didInitialize: false
5490 };
5491 }
5492
5493 // node_modules/@base-ui/utils/esm/store/useStore.js
5494 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5495 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5496 function useStore(store, selector2, a1, a2, a3) {
5497 return useStoreImplementation(store, selector2, a1, a2, a3);
5498 }
5499 function useStoreR19(store, selector2, a1, a2, a3) {
5500 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5501 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5502 }
5503 register({
5504 before(instance) {
5505 instance.syncIndex = 0;
5506 if (!instance.didInitialize) {
5507 instance.syncTick = 1;
5508 instance.syncHooks = [];
5509 instance.didChangeStore = true;
5510 instance.getSnapshot = () => {
5511 let didChange2 = false;
5512 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5513 const hook = instance.syncHooks[i2];
5514 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5515 if (hook.didChange || !Object.is(hook.value, value)) {
5516 didChange2 = true;
5517 hook.value = value;
5518 hook.didChange = false;
5519 }
5520 }
5521 if (didChange2) {
5522 instance.syncTick += 1;
5523 }
5524 return instance.syncTick;
5525 };
5526 }
5527 },
5528 after(instance) {
5529 if (instance.syncHooks.length > 0) {
5530 if (instance.didChangeStore) {
5531 instance.didChangeStore = false;
5532 instance.subscribe = (onStoreChange) => {
5533 const stores = /* @__PURE__ */ new Set();
5534 for (const hook of instance.syncHooks) {
5535 stores.add(hook.store);
5536 }
5537 const unsubscribes = [];
5538 for (const store of stores) {
5539 unsubscribes.push(store.subscribe(onStoreChange));
5540 }
5541 return () => {
5542 for (const unsubscribe of unsubscribes) {
5543 unsubscribe();
5544 }
5545 };
5546 };
5547 }
5548 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5549 }
5550 }
5551 });
5552 function useStoreFast(store, selector2, a1, a2, a3) {
5553 const instance = getInstance();
5554 if (!instance) {
5555 return useStoreR19(store, selector2, a1, a2, a3);
5556 }
5557 const index2 = instance.syncIndex;
5558 instance.syncIndex += 1;
5559 let hook;
5560 if (!instance.didInitialize) {
5561 hook = {
5562 store,
5563 selector: selector2,
5564 a1,
5565 a2,
5566 a3,
5567 value: selector2(store.getSnapshot(), a1, a2, a3),
5568 didChange: false
5569 };
5570 instance.syncHooks.push(hook);
5571 } else {
5572 hook = instance.syncHooks[index2];
5573 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5574 if (hook.store !== store) {
5575 instance.didChangeStore = true;
5576 }
5577 hook.store = store;
5578 hook.selector = selector2;
5579 hook.a1 = a1;
5580 hook.a2 = a2;
5581 hook.a3 = a3;
5582 hook.didChange = true;
5583 }
5584 }
5585 return hook.value;
5586 }
5587 function useStoreLegacy(store, selector2, a1, a2, a3) {
5588 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5589 }
5590
5591 // node_modules/@base-ui/utils/esm/store/Store.js
5592 var Store = class {
5593 /**
5594 * The current state of the store.
5595 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5596 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
5597 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5598 *
5599 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5600 */
5601 // Internal state to handle recursive `setState()` calls
5602 constructor(state) {
5603 this.state = state;
5604 this.listeners = /* @__PURE__ */ new Set();
5605 this.updateTick = 0;
5606 }
5607 /**
5608 * Registers a listener that will be called whenever the store's state changes.
5609 *
5610 * @param fn The listener function to be called on state changes.
5611 * @returns A function to unsubscribe the listener.
5612 */
5613 subscribe = (fn) => {
5614 this.listeners.add(fn);
5615 return () => {
5616 this.listeners.delete(fn);
5617 };
5618 };
5619 /**
5620 * Returns the current state of the store.
5621 */
5622 getSnapshot = () => {
5623 return this.state;
5624 };
5625 /**
5626 * Updates the entire store's state and notifies all registered listeners.
5627 *
5628 * @param newState The new state to set for the store.
5629 */
5630 setState(newState) {
5631 if (this.state === newState) {
5632 return;
5633 }
5634 this.state = newState;
5635 this.updateTick += 1;
5636 const currentTick = this.updateTick;
5637 for (const listener of this.listeners) {
5638 if (currentTick !== this.updateTick) {
5639 return;
5640 }
5641 listener(newState);
5642 }
5643 }
5644 /**
5645 * Merges the provided changes into the current state and notifies listeners if there are changes.
5646 *
5647 * @param changes An object containing the changes to apply to the current state.
5648 */
5649 update(changes) {
5650 for (const key in changes) {
5651 if (!Object.is(this.state[key], changes[key])) {
5652 this.setState({
5653 ...this.state,
5654 ...changes
5655 });
5656 return;
5657 }
5658 }
5659 }
5660 /**
5661 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5662 *
5663 * @param key The key in the store's state to update.
5664 * @param value The new value to set for the specified key.
5665 */
5666 set(key, value) {
5667 if (!Object.is(this.state[key], value)) {
5668 this.setState({
5669 ...this.state,
5670 [key]: value
5671 });
5672 }
5673 }
5674 /**
5675 * Gives the state a new reference and updates all registered listeners.
5676 */
5677 notifyAll() {
5678 const newState = {
5679 ...this.state
5680 };
5681 this.setState(newState);
5682 }
5683 use(selector2, a1, a2, a3) {
5684 return useStore(this, selector2, a1, a2, a3);
5685 }
5686 };
5687
5688 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5689 var React23 = __toESM(require_react(), 1);
5690 var ReactStore = class extends Store {
5691 /**
5692 * Creates a new ReactStore instance.
5693 *
5694 * @param state Initial state of the store.
5695 * @param context Non-reactive context values.
5696 * @param selectors Optional selectors for use with `useState`.
5697 */
5698 constructor(state, context = {}, selectors3) {
5699 super(state);
5700 this.context = context;
5701 this.selectors = selectors3;
5702 }
5703 /**
5704 * Non-reactive values such as refs, callbacks, etc.
5705 */
5706 /**
5707 * Synchronizes a single external value into the store.
5708 *
5709 * Note that the while the value in `state` is updated immediately, the value returned
5710 * by `useState` is updated before the next render (similarly to React's `useState`).
5711 */
5712 useSyncedValue(key, value) {
5713 React23.useDebugValue(key);
5714 const store = this;
5715 useIsoLayoutEffect(() => {
5716 if (store.state[key] !== value) {
5717 store.set(key, value);
5718 }
5719 }, [store, key, value]);
5720 }
5721 /**
5722 * Synchronizes a single external value into the store and
5723 * cleans it up (sets to `undefined`) on unmount.
5724 *
5725 * Note that the while the value in `state` is updated immediately, the value returned
5726 * by `useState` is updated before the next render (similarly to React's `useState`).
5727 */
5728 useSyncedValueWithCleanup(key, value) {
5729 const store = this;
5730 useIsoLayoutEffect(() => {
5731 if (store.state[key] !== value) {
5732 store.set(key, value);
5733 }
5734 return () => {
5735 store.set(key, void 0);
5736 };
5737 }, [store, key, value]);
5738 }
5739 /**
5740 * Synchronizes multiple external values into the store.
5741 *
5742 * Note that the while the values in `state` are updated immediately, the values returned
5743 * by `useState` are updated before the next render (similarly to React's `useState`).
5744 */
5745 useSyncedValues(statePart) {
5746 const store = this;
5747 if (true) {
5748 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5749 const keys = React23.useRef(Object.keys(statePart)).current;
5750 const nextKeys = Object.keys(statePart);
5751 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5752 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5753 }
5754 }
5755 const dependencies = Object.values(statePart);
5756 useIsoLayoutEffect(() => {
5757 store.update(statePart);
5758 }, [store, ...dependencies]);
5759 }
5760 /**
5761 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5762 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5763 */
5764 useControlledProp(key, controlled) {
5765 React23.useDebugValue(key);
5766 const store = this;
5767 const isControlled = controlled !== void 0;
5768 useIsoLayoutEffect(() => {
5769 if (isControlled && !Object.is(store.state[key], controlled)) {
5770 store.setState({
5771 ...store.state,
5772 [key]: controlled
5773 });
5774 }
5775 }, [store, key, controlled, isControlled]);
5776 if (true) {
5777 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5778 if (!cache.has(key)) {
5779 cache.set(key, isControlled);
5780 }
5781 const previouslyControlled = cache.get(key);
5782 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5783 console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
5784 }
5785 }
5786 }
5787 /** Gets the current value from the store using a selector with the provided key.
5788 *
5789 * @param key Key of the selector to use.
5790 */
5791 select(key, a1, a2, a3) {
5792 const selector2 = this.selectors[key];
5793 return selector2(this.state, a1, a2, a3);
5794 }
5795 /**
5796 * Returns a value from the store's state using a selector function.
5797 * Used to subscribe to specific parts of the state.
5798 * This methods causes a rerender whenever the selected state changes.
5799 *
5800 * @param key Key of the selector to use.
5801 */
5802 useState(key, a1, a2, a3) {
5803 React23.useDebugValue(key);
5804 return useStore(this, this.selectors[key], a1, a2, a3);
5805 }
5806 /**
5807 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5808 * and assigns it to the context.
5809 *
5810 * @param key Key of the event callback. Must be a function in the context.
5811 * @param fn Function to assign.
5812 */
5813 useContextCallback(key, fn) {
5814 React23.useDebugValue(key);
5815 const stableFunction = useStableCallback(fn ?? NOOP);
5816 this.context[key] = stableFunction;
5817 }
5818 /**
5819 * Returns a stable setter function for a specific key in the store's state.
5820 * It's commonly used to pass as a ref callback to React elements.
5821 *
5822 * @param key Key of the state to set.
5823 */
5824 useStateSetter(key) {
5825 const ref = React23.useRef(void 0);
5826 if (ref.current === void 0) {
5827 ref.current = (value) => {
5828 this.set(key, value);
5829 };
5830 }
5831 return ref.current;
5832 }
5833 /**
5834 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5835 *
5836 * @param key Key of the selector to observe.
5837 * @param listener Listener function called when the selector result changes.
5838 */
5839 observe(selector2, listener) {
5840 let selectFn;
5841 if (typeof selector2 === "function") {
5842 selectFn = selector2;
5843 } else {
5844 selectFn = this.selectors[selector2];
5845 }
5846 let prevValue = selectFn(this.state);
5847 listener(prevValue, prevValue, this);
5848 return this.subscribe((nextState) => {
5849 const nextValue = selectFn(nextState);
5850 if (!Object.is(prevValue, nextValue)) {
5851 const oldValue = prevValue;
5852 prevValue = nextValue;
5853 listener(nextValue, oldValue, this);
5854 }
5855 });
5856 }
5857 };
5858
5859 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5860 var selectors = {
5861 open: createSelector((state) => state.open),
5862 transitionStatus: createSelector((state) => state.transitionStatus),
5863 domReferenceElement: createSelector((state) => state.domReferenceElement),
5864 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5865 floatingElement: createSelector((state) => state.floatingElement),
5866 floatingId: createSelector((state) => state.floatingId)
5867 };
5868 var FloatingRootStore = class extends ReactStore {
5869 constructor(options) {
5870 const {
5871 syncOnly,
5872 nested,
5873 onOpenChange,
5874 triggerElements,
5875 ...initialState
5876 } = options;
5877 super({
5878 ...initialState,
5879 positionReference: initialState.referenceElement,
5880 domReferenceElement: initialState.referenceElement
5881 }, {
5882 onOpenChange,
5883 dataRef: {
5884 current: {}
5885 },
5886 events: createEventEmitter(),
5887 nested,
5888 triggerElements
5889 }, selectors);
5890 this.syncOnly = syncOnly;
5891 }
5892 /**
5893 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5894 */
5895 syncOpenEvent = (newOpen, event) => {
5896 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5897 // click events to upgrade a hover-open.
5898 event != null && isClickLikeEvent(event)) {
5899 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5900 }
5901 };
5902 /**
5903 * Runs the root-owned side effects for an open state change.
5904 */
5905 dispatchOpenChange = (newOpen, eventDetails) => {
5906 this.syncOpenEvent(newOpen, eventDetails.event);
5907 const details = {
5908 open: newOpen,
5909 reason: eventDetails.reason,
5910 nativeEvent: eventDetails.event,
5911 nested: this.context.nested,
5912 triggerElement: eventDetails.trigger
5913 };
5914 this.context.events.emit("openchange", details);
5915 };
5916 /**
5917 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5918 *
5919 * @param newOpen The new open state.
5920 * @param eventDetails Details about the event that triggered the open state change.
5921 */
5922 setOpen = (newOpen, eventDetails) => {
5923 if (this.syncOnly) {
5924 this.context.onOpenChange?.(newOpen, eventDetails);
5925 return;
5926 }
5927 this.dispatchOpenChange(newOpen, eventDetails);
5928 this.context.onOpenChange?.(newOpen, eventDetails);
5929 };
5930 };
5931
5932 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5933 function useSyncedFloatingRootContext(options) {
5934 const {
5935 popupStore,
5936 treatPopupAsFloatingElement = false,
5937 floatingRootContext: floatingRootContextProp,
5938 floatingId,
5939 nested,
5940 onOpenChange
5941 } = options;
5942 const open = popupStore.useState("open");
5943 const referenceElement = popupStore.useState("activeTriggerElement");
5944 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5945 const triggerElements = popupStore.context.triggerElements;
5946 const handleOpenChange = onOpenChange;
5947 const internalStoreRef = React24.useRef(null);
5948 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5949 internalStoreRef.current = new FloatingRootStore({
5950 open,
5951 transitionStatus: void 0,
5952 referenceElement,
5953 floatingElement,
5954 triggerElements,
5955 onOpenChange: handleOpenChange,
5956 floatingId,
5957 syncOnly: true,
5958 nested
5959 });
5960 }
5961 const store = floatingRootContextProp ?? internalStoreRef.current;
5962 popupStore.useSyncedValue("floatingId", floatingId);
5963 useIsoLayoutEffect(() => {
5964 const valuesToSync = {
5965 open,
5966 floatingId,
5967 referenceElement,
5968 floatingElement
5969 };
5970 if (isElement(referenceElement)) {
5971 valuesToSync.domReferenceElement = referenceElement;
5972 }
5973 if (store.state.positionReference === store.state.referenceElement) {
5974 valuesToSync.positionReference = referenceElement;
5975 }
5976 store.update(valuesToSync);
5977 }, [open, floatingId, referenceElement, floatingElement, store]);
5978 store.context.onOpenChange = handleOpenChange;
5979 store.context.nested = nested;
5980 return store;
5981 }
5982
5983 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5984 var FOCUSABLE_POPUP_PROPS = {
5985 tabIndex: -1,
5986 [FOCUSABLE_ATTRIBUTE]: ""
5987 };
5988 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5989 const floatingId = useId();
5990 const nested = useFloatingParentNodeId() != null;
5991 const internalStoreRef = React25.useRef(null);
5992 if (externalStore === void 0 && internalStoreRef.current === null) {
5993 internalStoreRef.current = createStore2(floatingId, nested);
5994 }
5995 const store = externalStore ?? internalStoreRef.current;
5996 useSyncedFloatingRootContext({
5997 popupStore: store,
5998 treatPopupAsFloatingElement,
5999 floatingRootContext: store.state.floatingRootContext,
6000 floatingId,
6001 nested,
6002 onOpenChange: store.setOpen
6003 });
6004 return {
6005 store,
6006 internalStore: internalStoreRef.current
6007 };
6008 }
6009 function useTriggerRegistration(id, store) {
6010 const registeredElementIdRef = React25.useRef(null);
6011 const registeredElementRef = React25.useRef(null);
6012 return React25.useCallback((element) => {
6013 if (id === void 0) {
6014 return;
6015 }
6016 let shouldSyncTriggerCount = false;
6017 if (registeredElementIdRef.current !== null) {
6018 const registeredId = registeredElementIdRef.current;
6019 const registeredElement = registeredElementRef.current;
6020 const currentElement = store.context.triggerElements.getById(registeredId);
6021 if (registeredElement && currentElement === registeredElement) {
6022 store.context.triggerElements.delete(registeredId);
6023 shouldSyncTriggerCount = true;
6024 }
6025 registeredElementIdRef.current = null;
6026 registeredElementRef.current = null;
6027 }
6028 if (element !== null) {
6029 registeredElementIdRef.current = id;
6030 registeredElementRef.current = element;
6031 store.context.triggerElements.add(id, element);
6032 shouldSyncTriggerCount = true;
6033 }
6034 if (shouldSyncTriggerCount) {
6035 const triggerCount = store.context.triggerElements.size;
6036 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6037 store.set("triggerCount", triggerCount);
6038 }
6039 }
6040 }, [store, id]);
6041 }
6042 function setOpenTriggerState(state, open, trigger) {
6043 const triggerId = trigger?.id ?? null;
6044 if (triggerId || open) {
6045 state.activeTriggerId = triggerId;
6046 state.activeTriggerElement = trigger ?? null;
6047 }
6048 }
6049 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6050 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6051 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6052 const registerTrigger = useStableCallback((element) => {
6053 baseRegisterTrigger(element);
6054 if (!element) {
6055 return;
6056 }
6057 const open = store.select("open");
6058 const activeTriggerId = store.select("activeTriggerId");
6059 if (activeTriggerId === triggerId) {
6060 store.update({
6061 activeTriggerElement: element,
6062 ...open ? stateUpdates : null
6063 });
6064 return;
6065 }
6066 if (activeTriggerId == null && open) {
6067 store.update({
6068 activeTriggerId: triggerId,
6069 activeTriggerElement: element,
6070 ...stateUpdates
6071 });
6072 }
6073 });
6074 useIsoLayoutEffect(() => {
6075 if (isMountedByThisTrigger) {
6076 store.update({
6077 activeTriggerElement: triggerElementRef.current,
6078 ...stateUpdates
6079 });
6080 }
6081 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6082 return {
6083 registerTrigger,
6084 isMountedByThisTrigger
6085 };
6086 }
6087 function useImplicitActiveTrigger(store) {
6088 const open = store.useState("open");
6089 const reactiveTriggerCount = store.useState("triggerCount");
6090 useIsoLayoutEffect(() => {
6091 if (!open) {
6092 if (store.state.triggerCount !== 0) {
6093 store.set("triggerCount", 0);
6094 }
6095 return;
6096 }
6097 const triggerCount = store.context.triggerElements.size;
6098 const stateUpdates = {};
6099 if (store.state.triggerCount !== triggerCount) {
6100 stateUpdates.triggerCount = triggerCount;
6101 }
6102 if (!store.select("activeTriggerId") && triggerCount === 1) {
6103 const iteratorResult = store.context.triggerElements.entries().next();
6104 if (!iteratorResult.done) {
6105 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6106 stateUpdates.activeTriggerId = implicitTriggerId;
6107 stateUpdates.activeTriggerElement = implicitTriggerElement;
6108 }
6109 }
6110 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
6111 store.update(stateUpdates);
6112 }
6113 }, [open, store, reactiveTriggerCount]);
6114 }
6115 function useOpenStateTransitions(open, store, onUnmount) {
6116 const {
6117 mounted,
6118 setMounted,
6119 transitionStatus
6120 } = useTransitionStatus(open);
6121 store.useSyncedValues({
6122 mounted,
6123 transitionStatus
6124 });
6125 const forceUnmount = useStableCallback(() => {
6126 setMounted(false);
6127 store.update({
6128 activeTriggerId: null,
6129 activeTriggerElement: null,
6130 mounted: false,
6131 preventUnmountingOnClose: false
6132 });
6133 onUnmount?.();
6134 store.context.onOpenChangeComplete?.(false);
6135 });
6136 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6137 useOpenChangeComplete({
6138 enabled: mounted && !open && !preventUnmountingOnClose,
6139 open,
6140 ref: store.context.popupRef,
6141 onComplete() {
6142 if (!open) {
6143 forceUnmount();
6144 }
6145 }
6146 });
6147 return {
6148 forceUnmount,
6149 transitionStatus
6150 };
6151 }
6152 function usePopupInteractionProps(store, statePart) {
6153 store.useSyncedValues(statePart);
6154 useIsoLayoutEffect(() => () => {
6155 store.update({
6156 activeTriggerProps: EMPTY_OBJECT,
6157 inactiveTriggerProps: EMPTY_OBJECT,
6158 popupProps: EMPTY_OBJECT
6159 });
6160 }, [store]);
6161 }
6162
6163 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6164 var PopupTriggerMap = class {
6165 constructor() {
6166 this.elementsSet = /* @__PURE__ */ new Set();
6167 this.idMap = /* @__PURE__ */ new Map();
6168 }
6169 /**
6170 * Adds a trigger element with the given ID.
6171 *
6172 * Note: The provided element is assumed to not be registered under multiple IDs.
6173 */
6174 add(id, element) {
6175 const existingElement = this.idMap.get(id);
6176 if (existingElement === element) {
6177 return;
6178 }
6179 if (existingElement !== void 0) {
6180 this.elementsSet.delete(existingElement);
6181 }
6182 this.elementsSet.add(element);
6183 this.idMap.set(id, element);
6184 if (true) {
6185 if (this.elementsSet.size !== this.idMap.size) {
6186 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6187 }
6188 }
6189 }
6190 /**
6191 * Removes the trigger element with the given ID.
6192 */
6193 delete(id) {
6194 const element = this.idMap.get(id);
6195 if (element) {
6196 this.elementsSet.delete(element);
6197 this.idMap.delete(id);
6198 }
6199 }
6200 /**
6201 * Whether the given element is registered as a trigger.
6202 */
6203 hasElement(element) {
6204 return this.elementsSet.has(element);
6205 }
6206 /**
6207 * Whether there is a registered trigger element matching the given predicate.
6208 */
6209 hasMatchingElement(predicate) {
6210 for (const element of this.elementsSet) {
6211 if (predicate(element)) {
6212 return true;
6213 }
6214 }
6215 return false;
6216 }
6217 /**
6218 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6219 */
6220 getById(id) {
6221 return this.idMap.get(id);
6222 }
6223 /**
6224 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6225 */
6226 entries() {
6227 return this.idMap.entries();
6228 }
6229 /**
6230 * Returns an iterable of all registered trigger elements.
6231 */
6232 elements() {
6233 return this.elementsSet.values();
6234 }
6235 /**
6236 * Returns the number of registered trigger elements.
6237 */
6238 get size() {
6239 return this.idMap.size;
6240 }
6241 };
6242
6243 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6244 function getEmptyRootContext() {
6245 return new FloatingRootStore({
6246 open: false,
6247 transitionStatus: void 0,
6248 floatingElement: null,
6249 referenceElement: null,
6250 triggerElements: new PopupTriggerMap(),
6251 floatingId: void 0,
6252 syncOnly: false,
6253 nested: false,
6254 onOpenChange: void 0
6255 });
6256 }
6257
6258 // node_modules/@base-ui/react/esm/utils/popups/store.js
6259 function createInitialPopupStoreState() {
6260 return {
6261 open: false,
6262 openProp: void 0,
6263 mounted: false,
6264 transitionStatus: void 0,
6265 floatingRootContext: getEmptyRootContext(),
6266 floatingId: void 0,
6267 triggerCount: 0,
6268 preventUnmountingOnClose: false,
6269 payload: void 0,
6270 activeTriggerId: null,
6271 activeTriggerElement: null,
6272 triggerIdProp: void 0,
6273 popupElement: null,
6274 positionerElement: null,
6275 activeTriggerProps: EMPTY_OBJECT,
6276 inactiveTriggerProps: EMPTY_OBJECT,
6277 popupProps: EMPTY_OBJECT
6278 };
6279 }
6280 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6281 return new FloatingRootStore({
6282 open: false,
6283 transitionStatus: void 0,
6284 floatingElement: null,
6285 referenceElement: null,
6286 triggerElements,
6287 floatingId,
6288 syncOnly: true,
6289 nested,
6290 onOpenChange: void 0
6291 });
6292 }
6293 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6294 var openSelector = createSelector((state) => state.openProp ?? state.open);
6295 var popupIdSelector = createSelector((state) => {
6296 const popupId = state.popupElement?.id ?? state.floatingId;
6297 return popupId || void 0;
6298 });
6299 function triggerOwnsOpenPopup(state, triggerId) {
6300 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6301 }
6302 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6303 if (triggerOwnsOpenPopup(state, triggerId)) {
6304 return true;
6305 }
6306 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6307 }
6308 var popupStoreSelectors = {
6309 open: openSelector,
6310 mounted: createSelector((state) => state.mounted),
6311 transitionStatus: createSelector((state) => state.transitionStatus),
6312 floatingRootContext: createSelector((state) => state.floatingRootContext),
6313 triggerCount: createSelector((state) => state.triggerCount),
6314 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6315 payload: createSelector((state) => state.payload),
6316 activeTriggerId: activeTriggerIdSelector,
6317 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6318 popupId: popupIdSelector,
6319 /**
6320 * Whether the trigger with the given ID was used to open the popup.
6321 */
6322 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6323 /**
6324 * Whether the popup is open and was activated by a trigger with the given ID.
6325 */
6326 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6327 /**
6328 * Whether the popup is mounted and was activated by a trigger with the given ID.
6329 */
6330 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6331 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6332 /**
6333 * Popup id for the trigger that currently owns the open popup.
6334 */
6335 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6336 popupProps: createSelector((state) => state.popupProps),
6337 popupElement: createSelector((state) => state.popupElement),
6338 positionerElement: createSelector((state) => state.positionerElement)
6339 };
6340
6341 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6342 function useFloatingRootContext(options) {
6343 const {
6344 open = false,
6345 onOpenChange,
6346 elements = {}
6347 } = options;
6348 const floatingId = useId();
6349 const nested = useFloatingParentNodeId() != null;
6350 if (true) {
6351 const optionDomReference = elements.reference;
6352 if (optionDomReference && !isElement(optionDomReference)) {
6353 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6354 }
6355 }
6356 const store = useRefWithInit(() => new FloatingRootStore({
6357 open,
6358 transitionStatus: void 0,
6359 onOpenChange,
6360 referenceElement: elements.reference ?? null,
6361 floatingElement: elements.floating ?? null,
6362 triggerElements: new PopupTriggerMap(),
6363 floatingId,
6364 syncOnly: false,
6365 nested
6366 })).current;
6367 useIsoLayoutEffect(() => {
6368 const valuesToSync = {
6369 open,
6370 floatingId
6371 };
6372 if (elements.reference !== void 0) {
6373 valuesToSync.referenceElement = elements.reference;
6374 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6375 }
6376 if (elements.floating !== void 0) {
6377 valuesToSync.floatingElement = elements.floating;
6378 }
6379 store.update(valuesToSync);
6380 }, [open, floatingId, elements.reference, elements.floating, store]);
6381 store.context.onOpenChange = onOpenChange;
6382 store.context.nested = nested;
6383 return store;
6384 }
6385
6386 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6387 function useFloating2(options = {}) {
6388 const {
6389 nodeId,
6390 externalTree
6391 } = options;
6392 const internalStore = useFloatingRootContext(options);
6393 const store = options.rootContext || internalStore;
6394 const referenceElement = store.useState("referenceElement");
6395 const floatingElement = store.useState("floatingElement");
6396 const domReferenceElement = store.useState("domReferenceElement");
6397 const open = store.useState("open");
6398 const floatingId = store.useState("floatingId");
6399 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6400 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6401 const [localFloatingElement, setLocalFloatingElement] = React26.useState(void 0);
6402 const domReferenceRef = React26.useRef(null);
6403 const tree = useFloatingTree(externalTree);
6404 const storeElements = React26.useMemo(() => ({
6405 reference: referenceElement,
6406 floating: floatingElement,
6407 domReference: domReferenceElement
6408 }), [referenceElement, floatingElement, domReferenceElement]);
6409 const position = useFloating({
6410 ...options,
6411 elements: {
6412 ...storeElements,
6413 ...positionReference && {
6414 reference: positionReference
6415 }
6416 }
6417 });
6418 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6419 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6420 store.useSyncedValue("referenceElement", localDomReference ?? null);
6421 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6422 store.useSyncedValue("floatingElement", syncedFloatingElement);
6423 const setPositionReference = React26.useCallback((node) => {
6424 const computedPositionReference = isElement(node) ? {
6425 getBoundingClientRect: () => node.getBoundingClientRect(),
6426 getClientRects: () => node.getClientRects(),
6427 contextElement: node
6428 } : node;
6429 setPositionReferenceRaw(computedPositionReference);
6430 position.refs.setReference(computedPositionReference);
6431 }, [position.refs]);
6432 const setReference = React26.useCallback((node) => {
6433 if (isElement(node) || node === null) {
6434 domReferenceRef.current = node;
6435 setLocalDomReference(node);
6436 }
6437 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6438 // `null` to support `positionReference` + an unstable `reference`
6439 // callback ref.
6440 node !== null && !isElement(node)) {
6441 position.refs.setReference(node);
6442 }
6443 }, [position.refs, setLocalDomReference]);
6444 const setFloating = React26.useCallback((node) => {
6445 setLocalFloatingElement(node);
6446 position.refs.setFloating(node);
6447 }, [position.refs]);
6448 const refs = React26.useMemo(() => ({
6449 ...position.refs,
6450 setReference,
6451 setFloating,
6452 setPositionReference,
6453 domReference: domReferenceRef
6454 }), [position.refs, setReference, setFloating, setPositionReference]);
6455 const elements = React26.useMemo(() => ({
6456 ...position.elements,
6457 domReference: domReferenceElement
6458 }), [position.elements, domReferenceElement]);
6459 const context = React26.useMemo(() => ({
6460 ...position,
6461 dataRef: store.context.dataRef,
6462 open,
6463 onOpenChange: store.setOpen,
6464 events: store.context.events,
6465 floatingId,
6466 refs,
6467 elements,
6468 nodeId,
6469 rootStore: store
6470 }), [position, refs, elements, nodeId, store, open, floatingId]);
6471 useIsoLayoutEffect(() => {
6472 if (domReferenceElement) {
6473 domReferenceRef.current = domReferenceElement;
6474 }
6475 }, [domReferenceElement]);
6476 useIsoLayoutEffect(() => {
6477 store.context.dataRef.current.floatingContext = context;
6478 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6479 if (node) {
6480 node.context = context;
6481 }
6482 });
6483 return React26.useMemo(() => ({
6484 ...position,
6485 context,
6486 refs,
6487 elements,
6488 rootStore: store
6489 }), [position, refs, elements, context, store]);
6490 }
6491
6492 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6493 var React27 = __toESM(require_react(), 1);
6494 var isMacSafari = isMac && isSafari;
6495 function useFocus(context, props = {}) {
6496 const {
6497 enabled = true,
6498 delay
6499 } = props;
6500 const store = "rootStore" in context ? context.rootStore : context;
6501 const {
6502 events,
6503 dataRef
6504 } = store.context;
6505 const blockFocusRef = React27.useRef(false);
6506 const blockedReferenceRef = React27.useRef(null);
6507 const keyboardModalityRef = React27.useRef(true);
6508 const timeout = useTimeout();
6509 React27.useEffect(() => {
6510 const domReference = store.select("domReferenceElement");
6511 if (!enabled) {
6512 return void 0;
6513 }
6514 const win = getWindow(domReference);
6515 function onBlur() {
6516 const currentDomReference = store.select("domReferenceElement");
6517 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6518 blockFocusRef.current = true;
6519 }
6520 }
6521 function onKeyDown() {
6522 keyboardModalityRef.current = true;
6523 }
6524 function onPointerDown() {
6525 keyboardModalityRef.current = false;
6526 }
6527 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6528 }, [store, enabled]);
6529 React27.useEffect(() => {
6530 if (!enabled) {
6531 return void 0;
6532 }
6533 function onOpenChangeLocal(details) {
6534 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6535 const referenceElement = store.select("domReferenceElement");
6536 if (isElement(referenceElement)) {
6537 blockedReferenceRef.current = referenceElement;
6538 blockFocusRef.current = true;
6539 }
6540 }
6541 }
6542 events.on("openchange", onOpenChangeLocal);
6543 return () => {
6544 events.off("openchange", onOpenChangeLocal);
6545 };
6546 }, [events, enabled, store]);
6547 const reference = React27.useMemo(() => {
6548 function resetBlockedFocus() {
6549 blockFocusRef.current = false;
6550 blockedReferenceRef.current = null;
6551 }
6552 return {
6553 onMouseLeave() {
6554 resetBlockedFocus();
6555 },
6556 onFocus(event) {
6557 const focusTarget = event.currentTarget;
6558 if (blockFocusRef.current) {
6559 if (blockedReferenceRef.current === focusTarget) {
6560 return;
6561 }
6562 resetBlockedFocus();
6563 }
6564 const target = getTarget(event.nativeEvent);
6565 if (isElement(target)) {
6566 if (isMacSafari && !event.relatedTarget) {
6567 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6568 return;
6569 }
6570 } else if (!matchesFocusVisible(target)) {
6571 return;
6572 }
6573 }
6574 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6575 const {
6576 nativeEvent,
6577 currentTarget
6578 } = event;
6579 const delayValue = typeof delay === "function" ? delay() : delay;
6580 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6581 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6582 return;
6583 }
6584 timeout.start(delayValue, () => {
6585 if (blockFocusRef.current) {
6586 return;
6587 }
6588 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6589 });
6590 },
6591 onBlur(event) {
6592 resetBlockedFocus();
6593 const relatedTarget = event.relatedTarget;
6594 const nativeEvent = event.nativeEvent;
6595 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6596 timeout.start(0, () => {
6597 const domReference = store.select("domReferenceElement");
6598 const activeEl = activeElement(ownerDocument(domReference));
6599 if (!relatedTarget && activeEl === domReference) {
6600 return;
6601 }
6602 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6603 return;
6604 }
6605 const nextFocusedElement = relatedTarget ?? activeEl;
6606 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6607 return;
6608 }
6609 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6610 });
6611 }
6612 };
6613 }, [dataRef, delay, store, timeout]);
6614 return React27.useMemo(() => enabled ? {
6615 reference,
6616 trigger: reference
6617 } : {}, [enabled, reference]);
6618 }
6619
6620 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6621 var React28 = __toESM(require_react(), 1);
6622
6623 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6624 var HoverInteraction = class _HoverInteraction {
6625 constructor() {
6626 this.pointerType = void 0;
6627 this.interactedInside = false;
6628 this.handler = void 0;
6629 this.blockMouseMove = true;
6630 this.performedPointerEventsMutation = false;
6631 this.pointerEventsScopeElement = null;
6632 this.pointerEventsReferenceElement = null;
6633 this.pointerEventsFloatingElement = null;
6634 this.restTimeoutPending = false;
6635 this.openChangeTimeout = new Timeout();
6636 this.restTimeout = new Timeout();
6637 this.handleCloseOptions = void 0;
6638 }
6639 static create() {
6640 return new _HoverInteraction();
6641 }
6642 dispose = () => {
6643 this.openChangeTimeout.clear();
6644 this.restTimeout.clear();
6645 };
6646 disposeEffect = () => {
6647 return this.dispose;
6648 };
6649 };
6650 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6651 function clearSafePolygonPointerEventsMutation(instance) {
6652 if (!instance.performedPointerEventsMutation) {
6653 return;
6654 }
6655 const scopeElement = instance.pointerEventsScopeElement;
6656 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6657 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6658 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6659 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6660 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6661 }
6662 instance.performedPointerEventsMutation = false;
6663 instance.pointerEventsScopeElement = null;
6664 instance.pointerEventsReferenceElement = null;
6665 instance.pointerEventsFloatingElement = null;
6666 }
6667 function applySafePolygonPointerEventsMutation(instance, options) {
6668 const {
6669 scopeElement,
6670 referenceElement,
6671 floatingElement
6672 } = options;
6673 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6674 if (existingOwner && existingOwner !== instance) {
6675 clearSafePolygonPointerEventsMutation(existingOwner);
6676 }
6677 clearSafePolygonPointerEventsMutation(instance);
6678 instance.performedPointerEventsMutation = true;
6679 instance.pointerEventsScopeElement = scopeElement;
6680 instance.pointerEventsReferenceElement = referenceElement;
6681 instance.pointerEventsFloatingElement = floatingElement;
6682 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6683 scopeElement.style.pointerEvents = "none";
6684 referenceElement.style.pointerEvents = "auto";
6685 floatingElement.style.pointerEvents = "auto";
6686 }
6687 function useHoverInteractionSharedState(store) {
6688 const data = store.context.dataRef.current;
6689 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6690 if (!data.hoverInteractionState) {
6691 data.hoverInteractionState = instance;
6692 }
6693 useOnMount(data.hoverInteractionState.disposeEffect);
6694 return data.hoverInteractionState;
6695 }
6696
6697 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6698 function useHoverFloatingInteraction(context, parameters = {}) {
6699 const {
6700 enabled = true,
6701 closeDelay: closeDelayProp = 0,
6702 nodeId: nodeIdProp
6703 } = parameters;
6704 const store = "rootStore" in context ? context.rootStore : context;
6705 const open = store.useState("open");
6706 const floatingElement = store.useState("floatingElement");
6707 const domReferenceElement = store.useState("domReferenceElement");
6708 const {
6709 dataRef
6710 } = store.context;
6711 const tree = useFloatingTree();
6712 const parentId = useFloatingParentNodeId();
6713 const instance = useHoverInteractionSharedState(store);
6714 const childClosedTimeout = useTimeout();
6715 const isClickLikeOpenEvent2 = useStableCallback(() => {
6716 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6717 });
6718 const isHoverOpen = useStableCallback(() => {
6719 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6720 });
6721 const clearPointerEvents = useStableCallback(() => {
6722 clearSafePolygonPointerEventsMutation(instance);
6723 });
6724 useIsoLayoutEffect(() => {
6725 if (!open) {
6726 instance.pointerType = void 0;
6727 instance.restTimeoutPending = false;
6728 instance.interactedInside = false;
6729 clearPointerEvents();
6730 }
6731 }, [open, instance, clearPointerEvents]);
6732 React28.useEffect(() => {
6733 return clearPointerEvents;
6734 }, [clearPointerEvents]);
6735 useIsoLayoutEffect(() => {
6736 if (!enabled) {
6737 return void 0;
6738 }
6739 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6740 const ref = domReferenceElement;
6741 const floatingEl = floatingElement;
6742 const doc = ownerDocument(floatingElement);
6743 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6744 if (parentFloating) {
6745 parentFloating.style.pointerEvents = "";
6746 }
6747 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6748 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6749 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6750 applySafePolygonPointerEventsMutation(instance, {
6751 scopeElement,
6752 referenceElement: ref,
6753 floatingElement: floatingEl
6754 });
6755 return () => {
6756 clearPointerEvents();
6757 };
6758 }
6759 return void 0;
6760 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6761 React28.useEffect(() => {
6762 if (!enabled) {
6763 return void 0;
6764 }
6765 function hasParentChildren() {
6766 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6767 }
6768 function closeWithDelay(event) {
6769 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6770 const close = () => {
6771 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6772 tree?.events.emit("floating.closed", event);
6773 };
6774 if (closeDelay) {
6775 instance.openChangeTimeout.start(closeDelay, close);
6776 } else {
6777 instance.openChangeTimeout.clear();
6778 close();
6779 }
6780 }
6781 function handleInteractInside(event) {
6782 const target = getTarget(event);
6783 if (!isInteractiveElement(target)) {
6784 instance.interactedInside = false;
6785 return;
6786 }
6787 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6788 }
6789 function onFloatingMouseEnter() {
6790 instance.openChangeTimeout.clear();
6791 childClosedTimeout.clear();
6792 tree?.events.off("floating.closed", onNodeClosed);
6793 clearPointerEvents();
6794 }
6795 function onFloatingMouseLeave(event) {
6796 if (hasParentChildren() && tree) {
6797 tree.events.on("floating.closed", onNodeClosed);
6798 return;
6799 }
6800 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6801 return;
6802 }
6803 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6804 const relatedTarget = event.relatedTarget;
6805 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6806 if (isMovingIntoDescendantFloating) {
6807 return;
6808 }
6809 if (instance.handler) {
6810 instance.handler(event);
6811 return;
6812 }
6813 clearPointerEvents();
6814 if (!isClickLikeOpenEvent2()) {
6815 closeWithDelay(event);
6816 }
6817 }
6818 function onNodeClosed(event) {
6819 if (!tree || !parentId || hasParentChildren()) {
6820 return;
6821 }
6822 childClosedTimeout.start(0, () => {
6823 tree.events.off("floating.closed", onNodeClosed);
6824 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6825 tree.events.emit("floating.closed", event);
6826 });
6827 }
6828 const floating = floatingElement;
6829 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6830 tree?.events.off("floating.closed", onNodeClosed);
6831 });
6832 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6833 }
6834
6835 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6836 var React29 = __toESM(require_react(), 1);
6837 var ReactDOM4 = __toESM(require_react_dom(), 1);
6838 var EMPTY_REF = {
6839 current: null
6840 };
6841 function useHoverReferenceInteraction(context, props = {}) {
6842 const {
6843 enabled = true,
6844 delay = 0,
6845 handleClose = null,
6846 mouseOnly = false,
6847 restMs = 0,
6848 move = true,
6849 triggerElementRef = EMPTY_REF,
6850 externalTree,
6851 isActiveTrigger = true,
6852 getHandleCloseContext,
6853 isClosing,
6854 shouldOpen: shouldOpenProp
6855 } = props;
6856 const store = "rootStore" in context ? context.rootStore : context;
6857 const {
6858 dataRef,
6859 events
6860 } = store.context;
6861 const tree = useFloatingTree(externalTree);
6862 const instance = useHoverInteractionSharedState(store);
6863 const isHoverCloseActiveRef = React29.useRef(false);
6864 const handleCloseRef = useValueAsRef(handleClose);
6865 const delayRef = useValueAsRef(delay);
6866 const restMsRef = useValueAsRef(restMs);
6867 const enabledRef = useValueAsRef(enabled);
6868 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6869 const isClosingRef = useValueAsRef(isClosing);
6870 const isClickLikeOpenEvent2 = useStableCallback(() => {
6871 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6872 });
6873 const checkShouldOpen = useStableCallback(() => {
6874 return shouldOpenRef.current?.() !== false;
6875 });
6876 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6877 const allTriggers = store.context.triggerElements;
6878 if (allTriggers.hasElement(currentTarget)) {
6879 return !currentDomReference || !contains(currentDomReference, currentTarget);
6880 }
6881 if (!isElement(target)) {
6882 return false;
6883 }
6884 const targetElement = target;
6885 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6886 });
6887 const cleanupMouseMoveHandler = useStableCallback(() => {
6888 if (!instance.handler) {
6889 return;
6890 }
6891 const doc = ownerDocument(store.select("domReferenceElement"));
6892 doc.removeEventListener("mousemove", instance.handler);
6893 instance.handler = void 0;
6894 });
6895 const clearPointerEvents = useStableCallback(() => {
6896 clearSafePolygonPointerEventsMutation(instance);
6897 });
6898 if (isActiveTrigger) {
6899 instance.handleCloseOptions = handleCloseRef.current?.__options;
6900 }
6901 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6902 React29.useEffect(() => {
6903 if (!enabled) {
6904 return void 0;
6905 }
6906 function onOpenChangeLocal(details) {
6907 if (!details.open) {
6908 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6909 cleanupMouseMoveHandler();
6910 instance.openChangeTimeout.clear();
6911 instance.restTimeout.clear();
6912 instance.blockMouseMove = true;
6913 instance.restTimeoutPending = false;
6914 } else {
6915 isHoverCloseActiveRef.current = false;
6916 }
6917 }
6918 events.on("openchange", onOpenChangeLocal);
6919 return () => {
6920 events.off("openchange", onOpenChangeLocal);
6921 };
6922 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6923 React29.useEffect(() => {
6924 if (!enabled) {
6925 return void 0;
6926 }
6927 function closeWithDelay(event, runElseBranch = true) {
6928 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6929 if (closeDelay) {
6930 instance.openChangeTimeout.start(closeDelay, () => {
6931 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6932 tree?.events.emit("floating.closed", event);
6933 });
6934 } else if (runElseBranch) {
6935 instance.openChangeTimeout.clear();
6936 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6937 tree?.events.emit("floating.closed", event);
6938 }
6939 }
6940 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6941 if (!isElement(trigger)) {
6942 return void 0;
6943 }
6944 function onMouseEnter(event) {
6945 instance.openChangeTimeout.clear();
6946 instance.blockMouseMove = false;
6947 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6948 return;
6949 }
6950 const restMsValue = getRestMs(restMsRef.current);
6951 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6952 const eventTarget = getTarget(event);
6953 const currentTarget = event.currentTarget ?? null;
6954 const currentDomReference = store.select("domReferenceElement");
6955 let triggerNode = currentTarget;
6956 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6957 for (const triggerElement of store.context.triggerElements.elements()) {
6958 if (contains(triggerElement, eventTarget)) {
6959 triggerNode = triggerElement;
6960 break;
6961 }
6962 }
6963 }
6964 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6965 triggerNode = currentDomReference;
6966 }
6967 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6968 const isOpen = store.select("open");
6969 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6970 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6971 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6972 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6973 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6974 const shouldOpen = !isOpen || isOverInactive;
6975 if (shouldOpenImmediately) {
6976 if (checkShouldOpen()) {
6977 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6978 }
6979 return;
6980 }
6981 if (isRestOnlyDelay) {
6982 return;
6983 }
6984 if (openDelay) {
6985 instance.openChangeTimeout.start(openDelay, () => {
6986 if (shouldOpen && checkShouldOpen()) {
6987 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6988 }
6989 });
6990 } else if (shouldOpen) {
6991 if (checkShouldOpen()) {
6992 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6993 }
6994 }
6995 }
6996 function onMouseLeave(event) {
6997 if (isClickLikeOpenEvent2()) {
6998 clearPointerEvents();
6999 return;
7000 }
7001 cleanupMouseMoveHandler();
7002 const domReferenceElement = store.select("domReferenceElement");
7003 const doc = ownerDocument(domReferenceElement);
7004 instance.restTimeout.clear();
7005 instance.restTimeoutPending = false;
7006 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7007 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7008 return;
7009 }
7010 if (handleCloseRef.current && handleCloseContextBase) {
7011 if (!store.select("open")) {
7012 instance.openChangeTimeout.clear();
7013 }
7014 const currentTrigger = triggerElementRef.current;
7015 instance.handler = handleCloseRef.current({
7016 ...handleCloseContextBase,
7017 tree,
7018 x: event.clientX,
7019 y: event.clientY,
7020 onClose() {
7021 clearPointerEvents();
7022 cleanupMouseMoveHandler();
7023 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7024 closeWithDelay(event, true);
7025 }
7026 }
7027 });
7028 doc.addEventListener("mousemove", instance.handler);
7029 instance.handler(event);
7030 return;
7031 }
7032 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7033 if (shouldClose) {
7034 closeWithDelay(event);
7035 }
7036 }
7037 if (move) {
7038 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7039 once: true
7040 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7041 }
7042 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7043 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7044 return React29.useMemo(() => {
7045 if (!enabled) {
7046 return void 0;
7047 }
7048 function setPointerRef(event) {
7049 instance.pointerType = event.pointerType;
7050 }
7051 return {
7052 onPointerDown: setPointerRef,
7053 onPointerEnter: setPointerRef,
7054 onMouseMove(event) {
7055 const {
7056 nativeEvent
7057 } = event;
7058 const trigger = event.currentTarget;
7059 const currentDomReference = store.select("domReferenceElement");
7060 const currentOpen = store.select("open");
7061 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7062 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7063 return;
7064 }
7065 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7066 const floatingElement = store.select("floatingElement");
7067 if (floatingElement) {
7068 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7069 applySafePolygonPointerEventsMutation(instance, {
7070 scopeElement,
7071 referenceElement: trigger,
7072 floatingElement
7073 });
7074 }
7075 }
7076 const restMsValue = getRestMs(restMsRef.current);
7077 if (currentOpen && !isOverInactive || restMsValue === 0) {
7078 return;
7079 }
7080 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7081 return;
7082 }
7083 instance.restTimeout.clear();
7084 function handleMouseMove() {
7085 instance.restTimeoutPending = false;
7086 if (isClickLikeOpenEvent2()) {
7087 return;
7088 }
7089 const latestOpen = store.select("open");
7090 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7091 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7092 }
7093 }
7094 if (instance.pointerType === "touch") {
7095 ReactDOM4.flushSync(() => {
7096 handleMouseMove();
7097 });
7098 } else if (isOverInactive && currentOpen) {
7099 handleMouseMove();
7100 } else {
7101 instance.restTimeoutPending = true;
7102 instance.restTimeout.start(restMsValue, handleMouseMove);
7103 }
7104 }
7105 };
7106 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7107 }
7108
7109 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7110 var CURSOR_SPEED_THRESHOLD = 0.1;
7111 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7112 var POLYGON_BUFFER = 0.5;
7113 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7114 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7115 }
7116 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7117 let isInsideValue = false;
7118 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7119 isInsideValue = !isInsideValue;
7120 }
7121 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7122 isInsideValue = !isInsideValue;
7123 }
7124 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7125 isInsideValue = !isInsideValue;
7126 }
7127 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7128 isInsideValue = !isInsideValue;
7129 }
7130 return isInsideValue;
7131 }
7132 function isInsideRect(pointX, pointY, rect) {
7133 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7134 }
7135 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7136 const minX = Math.min(x1, x2);
7137 const maxX = Math.max(x1, x2);
7138 const minY = Math.min(y1, y2);
7139 const maxY = Math.max(y1, y2);
7140 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7141 }
7142 function safePolygon(options = {}) {
7143 const {
7144 blockPointerEvents = false
7145 } = options;
7146 const timeout = new Timeout();
7147 const fn = ({
7148 x: x2,
7149 y: y2,
7150 placement,
7151 elements,
7152 onClose,
7153 nodeId,
7154 tree
7155 }) => {
7156 const side = placement?.split("-")[0];
7157 let hasLanded = false;
7158 let lastX = null;
7159 let lastY = null;
7160 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7161 function isCursorMovingSlowly(nextX, nextY) {
7162 const currentTime = performance.now();
7163 const elapsedTime = currentTime - lastCursorTime;
7164 if (lastX === null || lastY === null || elapsedTime === 0) {
7165 lastX = nextX;
7166 lastY = nextY;
7167 lastCursorTime = currentTime;
7168 return false;
7169 }
7170 const deltaX = nextX - lastX;
7171 const deltaY = nextY - lastY;
7172 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7173 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7174 lastX = nextX;
7175 lastY = nextY;
7176 lastCursorTime = currentTime;
7177 return distanceSquared < thresholdSquared;
7178 }
7179 function close() {
7180 timeout.clear();
7181 onClose();
7182 }
7183 return function onMouseMove(event) {
7184 timeout.clear();
7185 const domReference = elements.domReference;
7186 const floating = elements.floating;
7187 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7188 return void 0;
7189 }
7190 const {
7191 clientX,
7192 clientY
7193 } = event;
7194 const target = getTarget(event);
7195 const isLeave = event.type === "mouseleave";
7196 const isOverFloatingEl = contains(floating, target);
7197 const isOverReferenceEl = contains(domReference, target);
7198 if (isOverFloatingEl) {
7199 hasLanded = true;
7200 if (!isLeave) {
7201 return void 0;
7202 }
7203 }
7204 if (isOverReferenceEl) {
7205 hasLanded = false;
7206 if (!isLeave) {
7207 hasLanded = true;
7208 return void 0;
7209 }
7210 }
7211 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7212 return void 0;
7213 }
7214 function hasOpenChildNode() {
7215 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7216 }
7217 function closeIfNoOpenChild() {
7218 if (!hasOpenChildNode()) {
7219 close();
7220 }
7221 }
7222 if (hasOpenChildNode()) {
7223 return void 0;
7224 }
7225 const refRect = domReference.getBoundingClientRect();
7226 const rect = floating.getBoundingClientRect();
7227 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7228 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7229 const isFloatingWider = rect.width > refRect.width;
7230 const isFloatingTaller = rect.height > refRect.height;
7231 const left = (isFloatingWider ? refRect : rect).left;
7232 const right = (isFloatingWider ? refRect : rect).right;
7233 const top = (isFloatingTaller ? refRect : rect).top;
7234 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7235 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
7236 closeIfNoOpenChild();
7237 return void 0;
7238 }
7239 let isInsideTroughRect = false;
7240 switch (side) {
7241 case "top":
7242 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7243 break;
7244 case "bottom":
7245 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7246 break;
7247 case "left":
7248 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7249 break;
7250 case "right":
7251 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7252 break;
7253 default:
7254 }
7255 if (isInsideTroughRect) {
7256 return void 0;
7257 }
7258 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7259 closeIfNoOpenChild();
7260 return void 0;
7261 }
7262 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7263 closeIfNoOpenChild();
7264 return void 0;
7265 }
7266 let isInsidePolygon = false;
7267 switch (side) {
7268 case "top": {
7269 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7270 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7271 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7272 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7273 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7274 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7275 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7276 break;
7277 }
7278 case "bottom": {
7279 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7280 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7281 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7282 const cursorPointY = y2 - POLYGON_BUFFER;
7283 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7284 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7285 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7286 break;
7287 }
7288 case "left": {
7289 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7290 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7291 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7292 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7293 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7294 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7295 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7296 break;
7297 }
7298 case "right": {
7299 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7300 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7301 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7302 const cursorPointX = x2 - POLYGON_BUFFER;
7303 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7304 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7305 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7306 break;
7307 }
7308 default:
7309 }
7310 if (!isInsidePolygon) {
7311 closeIfNoOpenChild();
7312 } else if (!hasLanded) {
7313 timeout.start(40, closeIfNoOpenChild);
7314 }
7315 return void 0;
7316 };
7317 };
7318 fn.__options = {
7319 ...options,
7320 blockPointerEvents
7321 };
7322 return fn;
7323 }
7324
7325 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7326 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7327 CommonPopupDataAttributes2["open"] = "data-open";
7328 CommonPopupDataAttributes2["closed"] = "data-closed";
7329 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7330 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7331 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7332 CommonPopupDataAttributes2["side"] = "data-side";
7333 CommonPopupDataAttributes2["align"] = "data-align";
7334 return CommonPopupDataAttributes2;
7335 })({});
7336 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7337 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7338 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7339 return CommonTriggerDataAttributes2;
7340 })({});
7341 var TRIGGER_HOOK = {
7342 [CommonTriggerDataAttributes.popupOpen]: ""
7343 };
7344 var PRESSABLE_TRIGGER_HOOK = {
7345 [CommonTriggerDataAttributes.popupOpen]: "",
7346 [CommonTriggerDataAttributes.pressed]: ""
7347 };
7348 var POPUP_OPEN_HOOK = {
7349 [CommonPopupDataAttributes.open]: ""
7350 };
7351 var POPUP_CLOSED_HOOK = {
7352 [CommonPopupDataAttributes.closed]: ""
7353 };
7354 var ANCHOR_HIDDEN_HOOK = {
7355 [CommonPopupDataAttributes.anchorHidden]: ""
7356 };
7357 var triggerOpenStateMapping = {
7358 open(value) {
7359 if (value) {
7360 return TRIGGER_HOOK;
7361 }
7362 return null;
7363 }
7364 };
7365 var popupStateMapping = {
7366 open(value) {
7367 if (value) {
7368 return POPUP_OPEN_HOOK;
7369 }
7370 return POPUP_CLOSED_HOOK;
7371 },
7372 anchorHidden(value) {
7373 if (value) {
7374 return ANCHOR_HIDDEN_HOOK;
7375 }
7376 return null;
7377 }
7378 };
7379
7380 // node_modules/@base-ui/utils/esm/inertValue.js
7381 function inertValue(value) {
7382 if (isReactVersionAtLeast(19)) {
7383 return value;
7384 }
7385 return value ? "true" : void 0;
7386 }
7387
7388 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7389 var React30 = __toESM(require_react(), 1);
7390
7391 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7392 var baseArrow = (options) => ({
7393 name: "arrow",
7394 options,
7395 async fn(state) {
7396 const {
7397 x: x2,
7398 y: y2,
7399 placement,
7400 rects,
7401 platform: platform3,
7402 elements,
7403 middlewareData
7404 } = state;
7405 const {
7406 element,
7407 padding = 0,
7408 offsetParent = "real"
7409 } = evaluate(options, state) || {};
7410 if (element == null) {
7411 return {};
7412 }
7413 const paddingObject = getPaddingObject(padding);
7414 const coords = {
7415 x: x2,
7416 y: y2
7417 };
7418 const axis = getAlignmentAxis(placement);
7419 const length = getAxisLength(axis);
7420 const arrowDimensions = await platform3.getDimensions(element);
7421 const isYAxis = axis === "y";
7422 const minProp = isYAxis ? "top" : "left";
7423 const maxProp = isYAxis ? "bottom" : "right";
7424 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7425 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7426 const startDiff = coords[axis] - rects.reference[axis];
7427 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7428 let clientSize = elements.floating[clientProp] || rects.floating[length];
7429 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7430 clientSize = elements.floating[clientProp] || rects.floating[length];
7431 }
7432 const centerToReference = endDiff / 2 - startDiff / 2;
7433 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7434 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7435 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7436 const min2 = minPadding;
7437 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7438 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7439 const offset4 = clamp(min2, center, max2);
7440 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7441 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7442 return {
7443 [axis]: coords[axis] + alignmentOffset,
7444 data: {
7445 [axis]: offset4,
7446 centerOffset: center - offset4 - alignmentOffset,
7447 ...shouldAddOffset && {
7448 alignmentOffset
7449 }
7450 },
7451 reset: shouldAddOffset
7452 };
7453 }
7454 });
7455 var arrow4 = (options, deps) => ({
7456 ...baseArrow(options),
7457 options: [options, deps]
7458 });
7459
7460 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7461 var hide4 = {
7462 name: "hide",
7463 async fn(state) {
7464 const {
7465 width,
7466 height,
7467 x: x2,
7468 y: y2
7469 } = state.rects.reference;
7470 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7471 const nativeHideResult = await hide3().fn(state);
7472 return {
7473 data: {
7474 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7475 }
7476 };
7477 }
7478 };
7479
7480 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7481 var DEFAULT_SIDES = {
7482 sideX: "left",
7483 sideY: "top"
7484 };
7485 var adaptiveOrigin = {
7486 name: "adaptiveOrigin",
7487 async fn(state) {
7488 const {
7489 x: rawX,
7490 y: rawY,
7491 rects: {
7492 floating: floatRect
7493 },
7494 elements: {
7495 floating
7496 },
7497 platform: platform3,
7498 strategy,
7499 placement
7500 } = state;
7501 const win = getWindow(floating);
7502 const styles = win.getComputedStyle(floating);
7503 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7504 if (!hasTransition) {
7505 return {
7506 x: rawX,
7507 y: rawY,
7508 data: DEFAULT_SIDES
7509 };
7510 }
7511 const offsetParent = await platform3.getOffsetParent?.(floating);
7512 let offsetDimensions = {
7513 width: 0,
7514 height: 0
7515 };
7516 if (strategy === "fixed" && win?.visualViewport) {
7517 offsetDimensions = {
7518 width: win.visualViewport.width,
7519 height: win.visualViewport.height
7520 };
7521 } else if (offsetParent === win) {
7522 const doc = ownerDocument(floating);
7523 offsetDimensions = {
7524 width: doc.documentElement.clientWidth,
7525 height: doc.documentElement.clientHeight
7526 };
7527 } else if (await platform3.isElement?.(offsetParent)) {
7528 offsetDimensions = await platform3.getDimensions(offsetParent);
7529 }
7530 const currentSide = getSide(placement);
7531 let x2 = rawX;
7532 let y2 = rawY;
7533 if (currentSide === "left") {
7534 x2 = offsetDimensions.width - (rawX + floatRect.width);
7535 }
7536 if (currentSide === "top") {
7537 y2 = offsetDimensions.height - (rawY + floatRect.height);
7538 }
7539 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7540 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7541 return {
7542 x: x2,
7543 y: y2,
7544 data: {
7545 sideX,
7546 sideY
7547 }
7548 };
7549 }
7550 };
7551
7552 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7553 function getLogicalSide(sideParam, renderedSide, isRtl) {
7554 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7555 const logicalRight = isRtl ? "inline-start" : "inline-end";
7556 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7557 return {
7558 top: "top",
7559 right: isLogicalSideParam ? logicalRight : "right",
7560 bottom: "bottom",
7561 left: isLogicalSideParam ? logicalLeft : "left"
7562 }[renderedSide];
7563 }
7564 function getOffsetData(state, sideParam, isRtl) {
7565 const {
7566 rects,
7567 placement
7568 } = state;
7569 const data = {
7570 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7571 align: getAlignment(placement) || "center",
7572 anchor: {
7573 width: rects.reference.width,
7574 height: rects.reference.height
7575 },
7576 positioner: {
7577 width: rects.floating.width,
7578 height: rects.floating.height
7579 }
7580 };
7581 return data;
7582 }
7583 function useAnchorPositioning(params) {
7584 const {
7585 // Public parameters
7586 anchor,
7587 positionMethod = "absolute",
7588 side: sideParam = "bottom",
7589 sideOffset = 0,
7590 align = "center",
7591 alignOffset = 0,
7592 collisionBoundary,
7593 collisionPadding: collisionPaddingParam = 5,
7594 sticky = false,
7595 arrowPadding = 5,
7596 disableAnchorTracking = false,
7597 inline: inlineMiddleware,
7598 // Private parameters
7599 keepMounted = false,
7600 floatingRootContext,
7601 mounted,
7602 collisionAvoidance,
7603 shiftCrossAxis = false,
7604 nodeId,
7605 adaptiveOrigin: adaptiveOrigin2,
7606 lazyFlip = false,
7607 externalTree
7608 } = params;
7609 const [mountSide, setMountSide] = React30.useState(null);
7610 if (!mounted && mountSide !== null) {
7611 setMountSide(null);
7612 }
7613 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7614 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7615 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7616 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7617 const anchorFnCallback = useStableCallback(anchorFn);
7618 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7619 const anchorValueRef = useValueAsRef(anchor);
7620 const mountedRef = useValueAsRef(mounted);
7621 const direction = useDirection();
7622 const isRtl = direction === "rtl";
7623 const side = mountSide || {
7624 top: "top",
7625 right: "right",
7626 bottom: "bottom",
7627 left: "left",
7628 "inline-end": isRtl ? "left" : "right",
7629 "inline-start": isRtl ? "right" : "left"
7630 }[sideParam];
7631 const placement = align === "center" ? side : `${side}-${align}`;
7632 let collisionPadding = collisionPaddingParam;
7633 const bias = 1;
7634 const biasTop = sideParam === "bottom" ? bias : 0;
7635 const biasBottom = sideParam === "top" ? bias : 0;
7636 const biasLeft = sideParam === "right" ? bias : 0;
7637 const biasRight = sideParam === "left" ? bias : 0;
7638 if (typeof collisionPadding === "number") {
7639 collisionPadding = {
7640 top: collisionPadding + biasTop,
7641 right: collisionPadding + biasRight,
7642 bottom: collisionPadding + biasBottom,
7643 left: collisionPadding + biasLeft
7644 };
7645 } else if (collisionPadding) {
7646 collisionPadding = {
7647 top: (collisionPadding.top || 0) + biasTop,
7648 right: (collisionPadding.right || 0) + biasRight,
7649 bottom: (collisionPadding.bottom || 0) + biasBottom,
7650 left: (collisionPadding.left || 0) + biasLeft
7651 };
7652 }
7653 const commonCollisionProps = {
7654 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7655 padding: collisionPadding
7656 };
7657 const arrowRef = React30.useRef(null);
7658 const sideOffsetRef = useValueAsRef(sideOffset);
7659 const alignOffsetRef = useValueAsRef(alignOffset);
7660 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7661 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7662 const middleware = [];
7663 if (inlineMiddleware) {
7664 middleware.push(inlineMiddleware);
7665 }
7666 middleware.push(offset3((state) => {
7667 const data = getOffsetData(state, sideParam, isRtl);
7668 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7669 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7670 return {
7671 mainAxis: sideAxis,
7672 crossAxis: alignAxis,
7673 alignmentAxis: alignAxis
7674 };
7675 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7676 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7677 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7678 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7679 ...commonCollisionProps,
7680 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7681 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7682 padding: {
7683 top: collisionPadding.top + bias,
7684 right: collisionPadding.right + bias,
7685 bottom: collisionPadding.bottom + bias,
7686 left: collisionPadding.left + bias
7687 },
7688 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7689 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7690 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7691 });
7692 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7693 const html = ownerDocument(data.elements.floating).documentElement;
7694 return {
7695 ...commonCollisionProps,
7696 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7697 // for context menus.
7698 rootBoundary: shiftCrossAxis ? {
7699 x: 0,
7700 y: 0,
7701 width: html.clientWidth,
7702 height: html.clientHeight
7703 } : void 0,
7704 mainAxis: collisionAvoidanceAlign !== "none",
7705 crossAxis: crossAxisShiftEnabled,
7706 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7707 if (!arrowRef.current) {
7708 return {};
7709 }
7710 const {
7711 width,
7712 height
7713 } = arrowRef.current.getBoundingClientRect();
7714 const sideAxis = getSideAxis(getSide(limitData.placement));
7715 const arrowSize = sideAxis === "y" ? width : height;
7716 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7717 return {
7718 offset: arrowSize / 2 + offsetAmount / 2
7719 };
7720 })
7721 };
7722 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7723 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7724 middleware.push(shiftMiddleware, flipMiddleware);
7725 } else {
7726 middleware.push(flipMiddleware, shiftMiddleware);
7727 }
7728 middleware.push(size3({
7729 ...commonCollisionProps,
7730 apply({
7731 elements: {
7732 floating
7733 },
7734 availableWidth,
7735 availableHeight,
7736 rects
7737 }) {
7738 if (!mountedRef.current) {
7739 return;
7740 }
7741 const floatingStyle = floating.style;
7742 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7743 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7744 const dpr = getWindow(floating).devicePixelRatio || 1;
7745 const {
7746 x: x3,
7747 y: y3,
7748 width,
7749 height
7750 } = rects.reference;
7751 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7752 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7753 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7754 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7755 }
7756 }), arrow4((state) => ({
7757 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7758 // we'll create a fake element.
7759 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7760 padding: arrowPadding,
7761 offsetParent: "floating"
7762 }), [arrowPadding]), {
7763 name: "transformOrigin",
7764 fn(state) {
7765 const {
7766 elements: elements2,
7767 middlewareData: middlewareData2,
7768 placement: renderedPlacement2,
7769 rects,
7770 y: y3
7771 } = state;
7772 const currentRenderedSide = getSide(renderedPlacement2);
7773 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7774 const arrowEl = arrowRef.current;
7775 const arrowX = middlewareData2.arrow?.x || 0;
7776 const arrowY = middlewareData2.arrow?.y || 0;
7777 const arrowWidth = arrowEl?.clientWidth || 0;
7778 const arrowHeight = arrowEl?.clientHeight || 0;
7779 const transformX = arrowX + arrowWidth / 2;
7780 const transformY = arrowY + arrowHeight / 2;
7781 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7782 const halfAnchorHeight = rects.reference.height / 2;
7783 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7784 const isOverlappingAnchor = shiftY > sideOffsetValue;
7785 const adjacentTransformOrigin = {
7786 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7787 bottom: `${transformX}px ${-sideOffsetValue}px`,
7788 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7789 right: `${-sideOffsetValue}px ${transformY}px`
7790 }[currentRenderedSide];
7791 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7792 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7793 return {};
7794 }
7795 }, hide4, adaptiveOrigin2);
7796 useIsoLayoutEffect(() => {
7797 if (!mounted && floatingRootContext) {
7798 floatingRootContext.update({
7799 referenceElement: null,
7800 floatingElement: null,
7801 domReferenceElement: null,
7802 positionReference: null
7803 });
7804 }
7805 }, [mounted, floatingRootContext]);
7806 const autoUpdateOptions = React30.useMemo(() => ({
7807 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7808 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7809 }), [disableAnchorTracking]);
7810 const {
7811 refs,
7812 elements,
7813 x: x2,
7814 y: y2,
7815 middlewareData,
7816 update: update2,
7817 placement: renderedPlacement,
7818 context,
7819 isPositioned,
7820 floatingStyles: originalFloatingStyles
7821 } = useFloating2({
7822 rootContext: floatingRootContext,
7823 open: keepMounted ? mounted : void 0,
7824 placement,
7825 middleware,
7826 strategy: positionMethod,
7827 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7828 nodeId,
7829 externalTree
7830 });
7831 const {
7832 sideX,
7833 sideY
7834 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7835 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7836 const floatingStyles = React30.useMemo(() => {
7837 const base = adaptiveOrigin2 ? {
7838 position: resolvedPosition,
7839 [sideX]: x2,
7840 [sideY]: y2
7841 } : {
7842 position: resolvedPosition,
7843 ...originalFloatingStyles
7844 };
7845 if (!isPositioned) {
7846 base.opacity = 0;
7847 }
7848 return base;
7849 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7850 const registeredPositionReferenceRef = React30.useRef(null);
7851 useIsoLayoutEffect(() => {
7852 if (!mounted) {
7853 return;
7854 }
7855 const anchorValue = anchorValueRef.current;
7856 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7857 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7858 const finalAnchor = unwrappedElement || null;
7859 if (finalAnchor !== registeredPositionReferenceRef.current) {
7860 refs.setPositionReference(finalAnchor);
7861 registeredPositionReferenceRef.current = finalAnchor;
7862 }
7863 }, [mounted, refs, anchorDep, anchorValueRef]);
7864 React30.useEffect(() => {
7865 if (!mounted) {
7866 return;
7867 }
7868 const anchorValue = anchorValueRef.current;
7869 if (typeof anchorValue === "function") {
7870 return;
7871 }
7872 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7873 refs.setPositionReference(anchorValue.current);
7874 registeredPositionReferenceRef.current = anchorValue.current;
7875 }
7876 }, [mounted, refs, anchorDep, anchorValueRef]);
7877 React30.useEffect(() => {
7878 if (keepMounted && mounted && elements.domReference && elements.floating) {
7879 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7880 }
7881 return void 0;
7882 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7883 const renderedSide = getSide(renderedPlacement);
7884 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7885 const renderedAlign = getAlignment(renderedPlacement) || "center";
7886 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7887 useIsoLayoutEffect(() => {
7888 if (lazyFlip && mounted && isPositioned) {
7889 setMountSide(renderedSide);
7890 }
7891 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7892 const arrowStyles = React30.useMemo(() => ({
7893 position: "absolute",
7894 top: middlewareData.arrow?.y,
7895 left: middlewareData.arrow?.x
7896 }), [middlewareData.arrow]);
7897 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7898 return React30.useMemo(() => ({
7899 positionerStyles: floatingStyles,
7900 arrowStyles,
7901 arrowRef,
7902 arrowUncentered,
7903 side: logicalRenderedSide,
7904 align: renderedAlign,
7905 physicalSide: renderedSide,
7906 anchorHidden,
7907 refs,
7908 context,
7909 isPositioned,
7910 update: update2
7911 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7912 }
7913 function isRef(param) {
7914 return param != null && "current" in param;
7915 }
7916
7917 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7918 function getDisabledMountTransitionStyles(transitionStatus) {
7919 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7920 }
7921
7922 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7923 function usePositioner(componentProps, state, {
7924 styles,
7925 transitionStatus,
7926 props,
7927 refs,
7928 hidden,
7929 inert = false
7930 }) {
7931 const style = {
7932 ...styles
7933 };
7934 if (inert) {
7935 style.pointerEvents = "none";
7936 }
7937 return useRenderElement("div", componentProps, {
7938 state,
7939 ref: refs,
7940 props: [{
7941 role: "presentation",
7942 hidden,
7943 style
7944 }, getDisabledMountTransitionStyles(transitionStatus), props],
7945 stateAttributesMapping: popupStateMapping
7946 });
7947 }
7948
7949 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7950 var React33 = __toESM(require_react(), 1);
7951 var ReactDOM5 = __toESM(require_react_dom(), 1);
7952
7953 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7954 var React31 = __toESM(require_react(), 1);
7955 function usePreviousValue(value) {
7956 const [state, setState] = React31.useState({
7957 current: value,
7958 previous: null
7959 });
7960 if (value !== state.current) {
7961 setState({
7962 current: value,
7963 previous: state.current
7964 });
7965 }
7966 return state.previous;
7967 }
7968
7969 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7970 var React32 = __toESM(require_react(), 1);
7971
7972 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7973 function getCssDimensions2(element) {
7974 const css = getComputedStyle2(element);
7975 let width = parseFloat(css.width) || 0;
7976 let height = parseFloat(css.height) || 0;
7977 const hasOffset = isHTMLElement(element);
7978 const offsetWidth = hasOffset ? element.offsetWidth : width;
7979 const offsetHeight = hasOffset ? element.offsetHeight : height;
7980 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7981 if (shouldFallback) {
7982 width = offsetWidth;
7983 height = offsetHeight;
7984 }
7985 return {
7986 width,
7987 height
7988 };
7989 }
7990
7991 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7992 var DEFAULT_ENABLED = () => true;
7993 function usePopupAutoResize(parameters) {
7994 const {
7995 popupElement,
7996 positionerElement,
7997 content,
7998 mounted,
7999 enabled = DEFAULT_ENABLED,
8000 onMeasureLayout: onMeasureLayoutParam,
8001 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8002 side,
8003 direction
8004 } = parameters;
8005 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8006 const animationFrame = useAnimationFrame();
8007 const committedDimensionsRef = React32.useRef(null);
8008 const liveDimensionsRef = React32.useRef(null);
8009 const isInitialRenderRef = React32.useRef(true);
8010 const restoreAnchoringStylesRef = React32.useRef(NOOP);
8011 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8012 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8013 const anchoringStyles = React32.useMemo(() => {
8014 let isOriginSide = side === "top";
8015 let isPhysicalLeft = side === "left";
8016 if (direction === "rtl") {
8017 isOriginSide = isOriginSide || side === "inline-end";
8018 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8019 } else {
8020 isOriginSide = isOriginSide || side === "inline-start";
8021 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8022 }
8023 return isOriginSide ? {
8024 position: "absolute",
8025 [side === "top" ? "bottom" : "top"]: "0",
8026 [isPhysicalLeft ? "right" : "left"]: "0"
8027 } : EMPTY_OBJECT;
8028 }, [side, direction]);
8029 useIsoLayoutEffect(() => {
8030 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
8031 restoreAnchoringStylesRef.current = NOOP;
8032 isInitialRenderRef.current = true;
8033 committedDimensionsRef.current = null;
8034 liveDimensionsRef.current = null;
8035 return void 0;
8036 }
8037 if (!popupElement || !positionerElement) {
8038 return void 0;
8039 }
8040 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8041 const observer = new ResizeObserver((entries) => {
8042 const entry = entries[0];
8043 if (entry) {
8044 liveDimensionsRef.current = {
8045 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8046 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8047 };
8048 }
8049 });
8050 observer.observe(popupElement);
8051 setPopupCssSize(popupElement, "auto");
8052 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8053 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8054 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8055 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8056 "--available-width": "max-content",
8057 "--available-height": "max-content"
8058 });
8059 function restoreMeasurementOverrides() {
8060 restorePopupPosition();
8061 restorePopupTransform();
8062 restorePositionerAvailableSize();
8063 }
8064 function restoreMeasurementOverridesIncludingScale() {
8065 restoreMeasurementOverrides();
8066 restorePopupScale();
8067 }
8068 onMeasureLayout?.();
8069 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8070 setPositionerCssSize(positionerElement, "max-content");
8071 const dimensions = getCssDimensions2(popupElement);
8072 committedDimensionsRef.current = dimensions;
8073 setPositionerCssSize(positionerElement, dimensions);
8074 restoreMeasurementOverridesIncludingScale();
8075 onMeasureLayoutComplete?.(null, dimensions);
8076 isInitialRenderRef.current = false;
8077 return () => {
8078 observer.disconnect();
8079 restoreAnchoringStylesRef.current();
8080 restoreAnchoringStylesRef.current = NOOP;
8081 };
8082 }
8083 setPopupCssSize(popupElement, "auto");
8084 setPositionerCssSize(positionerElement, "max-content");
8085 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8086 const newDimensions = getCssDimensions2(popupElement);
8087 committedDimensionsRef.current = newDimensions;
8088 if (!previousDimensions) {
8089 setPositionerCssSize(positionerElement, newDimensions);
8090 restoreMeasurementOverridesIncludingScale();
8091 onMeasureLayoutComplete?.(null, newDimensions);
8092 return () => {
8093 observer.disconnect();
8094 animationFrame.cancel();
8095 restoreAnchoringStylesRef.current();
8096 restoreAnchoringStylesRef.current = NOOP;
8097 };
8098 }
8099 setPopupCssSize(popupElement, previousDimensions);
8100 restoreMeasurementOverridesIncludingScale();
8101 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8102 setPositionerCssSize(positionerElement, newDimensions);
8103 const abortController = new AbortController();
8104 animationFrame.request(() => {
8105 setPopupCssSize(popupElement, newDimensions);
8106 runOnceAnimationsFinish(() => {
8107 popupElement.style.setProperty("--popup-width", "auto");
8108 popupElement.style.setProperty("--popup-height", "auto");
8109 }, abortController.signal);
8110 });
8111 return () => {
8112 observer.disconnect();
8113 abortController.abort();
8114 animationFrame.cancel();
8115 restoreAnchoringStylesRef.current();
8116 restoreAnchoringStylesRef.current = NOOP;
8117 };
8118 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8119 }
8120 function overrideElementStyle(element, property, value) {
8121 const originalValue = element.style.getPropertyValue(property);
8122 element.style.setProperty(property, value);
8123 return () => {
8124 element.style.setProperty(property, originalValue);
8125 };
8126 }
8127 function applyElementStyles(element, styles) {
8128 const restorers = [];
8129 for (const [key, value] of Object.entries(styles)) {
8130 restorers.push(overrideElementStyle(element, key, value));
8131 }
8132 return restorers.length ? () => {
8133 restorers.forEach((restore) => restore());
8134 } : NOOP;
8135 }
8136 function setPopupCssSize(popupElement, size4) {
8137 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8138 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8139 popupElement.style.setProperty("--popup-width", width);
8140 popupElement.style.setProperty("--popup-height", height);
8141 }
8142 function setPositionerCssSize(positionerElement, size4) {
8143 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8144 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8145 positionerElement.style.setProperty("--positioner-width", width);
8146 positionerElement.style.setProperty("--positioner-height", height);
8147 }
8148
8149 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8150 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8151 function usePopupViewport(parameters) {
8152 const {
8153 store,
8154 side,
8155 cssVars,
8156 children
8157 } = parameters;
8158 const direction = useDirection();
8159 const activeTrigger = store.useState("activeTriggerElement");
8160 const activeTriggerId = store.useState("activeTriggerId");
8161 const open = store.useState("open");
8162 const payload = store.useState("payload");
8163 const mounted = store.useState("mounted");
8164 const popupElement = store.useState("popupElement");
8165 const positionerElement = store.useState("positionerElement");
8166 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8167 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8168 const capturedNodeRef = React33.useRef(null);
8169 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
8170 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
8171 const currentContainerRef = React33.useRef(null);
8172 const previousContainerRef = React33.useRef(null);
8173 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8174 const cleanupFrame = useAnimationFrame();
8175 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
8176 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
8177 useIsoLayoutEffect(() => {
8178 store.set("hasViewport", true);
8179 return () => {
8180 store.set("hasViewport", false);
8181 };
8182 }, [store]);
8183 const handleMeasureLayout = useStableCallback(() => {
8184 currentContainerRef.current?.style.setProperty("animation", "none");
8185 currentContainerRef.current?.style.setProperty("transition", "none");
8186 previousContainerRef.current?.style.setProperty("display", "none");
8187 });
8188 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8189 currentContainerRef.current?.style.removeProperty("animation");
8190 currentContainerRef.current?.style.removeProperty("transition");
8191 previousContainerRef.current?.style.removeProperty("display");
8192 if (previousDimensions) {
8193 setPreviousContentDimensions(previousDimensions);
8194 }
8195 });
8196 const lastHandledTriggerRef = React33.useRef(null);
8197 useIsoLayoutEffect(() => {
8198 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8199 setPreviousContentNode(capturedNodeRef.current);
8200 setShowStartingStyleAttribute(true);
8201 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8202 setNewTriggerOffset(offset4);
8203 cleanupFrame.request(() => {
8204 ReactDOM5.flushSync(() => {
8205 setShowStartingStyleAttribute(false);
8206 });
8207 onAnimationsFinished(() => {
8208 setPreviousContentNode(null);
8209 setPreviousContentDimensions(null);
8210 capturedNodeRef.current = null;
8211 });
8212 });
8213 lastHandledTriggerRef.current = activeTrigger;
8214 }
8215 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8216 useIsoLayoutEffect(() => {
8217 const source = currentContainerRef.current;
8218 if (!source) {
8219 return;
8220 }
8221 const wrapper = ownerDocument(source).createElement("div");
8222 for (const child of Array.from(source.childNodes)) {
8223 wrapper.appendChild(child.cloneNode(true));
8224 }
8225 capturedNodeRef.current = wrapper;
8226 });
8227 const isTransitioning = previousContentNode != null;
8228 let childrenToRender;
8229 if (!isTransitioning) {
8230 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8231 "data-current": true,
8232 ref: currentContainerRef,
8233 children
8234 }, currentContentKey);
8235 } else {
8236 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
8237 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8238 "data-previous": true,
8239 inert: inertValue(true),
8240 ref: previousContainerRef,
8241 style: {
8242 ...previousContentDimensions ? {
8243 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8244 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8245 } : null,
8246 position: "absolute"
8247 },
8248 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8249 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8250 "data-current": true,
8251 ref: currentContainerRef,
8252 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8253 children
8254 }, currentContentKey)]
8255 });
8256 }
8257 useIsoLayoutEffect(() => {
8258 const container = previousContainerRef.current;
8259 if (!container || !previousContentNode) {
8260 return;
8261 }
8262 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8263 }, [previousContentNode]);
8264 usePopupAutoResize({
8265 popupElement,
8266 positionerElement,
8267 mounted,
8268 content: payload,
8269 onMeasureLayout: handleMeasureLayout,
8270 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8271 side,
8272 direction
8273 });
8274 const state = {
8275 activationDirection: getActivationDirection(newTriggerOffset),
8276 transitioning: isTransitioning
8277 };
8278 return {
8279 children: childrenToRender,
8280 state
8281 };
8282 }
8283 function getActivationDirection(offset4) {
8284 if (!offset4) {
8285 return void 0;
8286 }
8287 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8288 }
8289 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8290 if (value > tolerance) {
8291 return positiveLabel;
8292 }
8293 if (value < -tolerance) {
8294 return negativeLabel;
8295 }
8296 return "";
8297 }
8298 function calculateRelativePosition(from, to) {
8299 const fromRect = from.getBoundingClientRect();
8300 const toRect = to.getBoundingClientRect();
8301 const fromCenter = {
8302 x: fromRect.left + fromRect.width / 2,
8303 y: fromRect.top + fromRect.height / 2
8304 };
8305 const toCenter = {
8306 x: toRect.left + toRect.width / 2,
8307 y: toRect.top + toRect.height / 2
8308 };
8309 return {
8310 horizontal: toCenter.x - fromCenter.x,
8311 vertical: toCenter.y - fromCenter.y
8312 };
8313 }
8314 function usePopupContentKey(activeTriggerId, payload) {
8315 const [contentKey, setContentKey] = React33.useState(0);
8316 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8317 const previousPayloadRef = React33.useRef(payload);
8318 const pendingPayloadUpdateRef = React33.useRef(false);
8319 useIsoLayoutEffect(() => {
8320 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8321 const previousPayload = previousPayloadRef.current;
8322 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8323 const payloadChanged = payload !== previousPayload;
8324 if (triggerIdChanged) {
8325 setContentKey((value) => value + 1);
8326 pendingPayloadUpdateRef.current = !payloadChanged;
8327 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8328 setContentKey((value) => value + 1);
8329 pendingPayloadUpdateRef.current = false;
8330 }
8331 previousActiveTriggerIdRef.current = activeTriggerId;
8332 previousPayloadRef.current = payload;
8333 }, [activeTriggerId, payload]);
8334 return `${activeTriggerId ?? "current"}-${contentKey}`;
8335 }
8336
8337 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8338 var React34 = __toESM(require_react(), 1);
8339 var ReactDOM6 = __toESM(require_react_dom(), 1);
8340 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8341 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8342 const {
8343 children,
8344 container,
8345 className,
8346 render: render4,
8347 style,
8348 ...elementProps
8349 } = componentProps;
8350 const {
8351 portalNode,
8352 portalSubtree
8353 } = useFloatingPortalNode({
8354 container,
8355 ref: forwardedRef,
8356 componentProps,
8357 elementProps
8358 });
8359 if (!portalSubtree && !portalNode) {
8360 return null;
8361 }
8362 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
8363 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8364 });
8365 });
8366 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8367
8368 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8369 var index_parts_exports = {};
8370 __export(index_parts_exports, {
8371 Arrow: () => TooltipArrow,
8372 Handle: () => TooltipHandle,
8373 Popup: () => TooltipPopup,
8374 Portal: () => TooltipPortal,
8375 Positioner: () => TooltipPositioner,
8376 Provider: () => TooltipProvider,
8377 Root: () => TooltipRoot,
8378 Trigger: () => TooltipTrigger,
8379 Viewport: () => TooltipViewport,
8380 createHandle: () => createTooltipHandle
8381 });
8382
8383 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8384 var React37 = __toESM(require_react(), 1);
8385
8386 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8387 var React35 = __toESM(require_react(), 1);
8388 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8389 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8390 function useTooltipRootContext(optional) {
8391 const context = React35.useContext(TooltipRootContext);
8392 if (context === void 0 && !optional) {
8393 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8394 }
8395 return context;
8396 }
8397
8398 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8399 var React36 = __toESM(require_react(), 1);
8400 var ReactDOM7 = __toESM(require_react_dom(), 1);
8401 var selectors2 = {
8402 ...popupStoreSelectors,
8403 disabled: createSelector((state) => state.disabled),
8404 instantType: createSelector((state) => state.instantType),
8405 isInstantPhase: createSelector((state) => state.isInstantPhase),
8406 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8407 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8408 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8409 closeOnClick: createSelector((state) => state.closeOnClick),
8410 closeDelay: createSelector((state) => state.closeDelay),
8411 hasViewport: createSelector((state) => state.hasViewport)
8412 };
8413 var TooltipStore = class _TooltipStore extends ReactStore {
8414 constructor(initialState, floatingId, nested = false) {
8415 const triggerElements = new PopupTriggerMap();
8416 const state = {
8417 ...createInitialState(),
8418 ...initialState
8419 };
8420 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8421 super(state, {
8422 popupRef: /* @__PURE__ */ React36.createRef(),
8423 onOpenChange: void 0,
8424 onOpenChangeComplete: void 0,
8425 triggerElements
8426 }, selectors2);
8427 }
8428 setOpen = (nextOpen, eventDetails) => {
8429 const reason = eventDetails.reason;
8430 const isHover = reason === reason_parts_exports.triggerHover;
8431 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8432 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8433 eventDetails.preventUnmountOnClose = () => {
8434 this.set("preventUnmountingOnClose", true);
8435 };
8436 this.context.onOpenChange?.(nextOpen, eventDetails);
8437 if (eventDetails.isCanceled) {
8438 return;
8439 }
8440 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8441 const changeState = () => {
8442 const updatedState = {
8443 open: nextOpen,
8444 openChangeReason: reason
8445 };
8446 if (isFocusOpen) {
8447 updatedState.instantType = "focus";
8448 } else if (isDismissClose) {
8449 updatedState.instantType = "dismiss";
8450 } else if (reason === reason_parts_exports.triggerHover) {
8451 updatedState.instantType = void 0;
8452 }
8453 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8454 this.update(updatedState);
8455 };
8456 if (isHover) {
8457 ReactDOM7.flushSync(changeState);
8458 } else {
8459 changeState();
8460 }
8461 };
8462 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8463 cancelPendingOpen(event) {
8464 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8465 }
8466 static useStore(externalStore, initialState) {
8467 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8468 return store;
8469 }
8470 };
8471 function createInitialState() {
8472 return {
8473 ...createInitialPopupStoreState(),
8474 disabled: false,
8475 instantType: void 0,
8476 isInstantPhase: false,
8477 trackCursorAxis: "none",
8478 disableHoverablePopup: false,
8479 openChangeReason: null,
8480 closeOnClick: true,
8481 closeDelay: 0,
8482 hasViewport: false
8483 };
8484 }
8485
8486 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8487 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8488 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8489 const {
8490 disabled: disabled2 = false,
8491 defaultOpen = false,
8492 open: openProp,
8493 disableHoverablePopup = false,
8494 trackCursorAxis = "none",
8495 actionsRef,
8496 onOpenChange,
8497 onOpenChangeComplete,
8498 handle,
8499 triggerId: triggerIdProp,
8500 defaultTriggerId: defaultTriggerIdProp = null,
8501 children
8502 } = props;
8503 const store = TooltipStore.useStore(handle?.store, {
8504 open: defaultOpen,
8505 openProp,
8506 activeTriggerId: defaultTriggerIdProp,
8507 triggerIdProp
8508 });
8509 useOnFirstRender(() => {
8510 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8511 store.update({
8512 open: true,
8513 activeTriggerId: defaultTriggerIdProp
8514 });
8515 }
8516 });
8517 store.useControlledProp("openProp", openProp);
8518 store.useControlledProp("triggerIdProp", triggerIdProp);
8519 store.useContextCallback("onOpenChange", onOpenChange);
8520 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8521 const openState = store.useState("open");
8522 const open = !disabled2 && openState;
8523 const activeTriggerId = store.useState("activeTriggerId");
8524 const mounted = store.useState("mounted");
8525 const payload = store.useState("payload");
8526 store.useSyncedValues({
8527 trackCursorAxis,
8528 disableHoverablePopup
8529 });
8530 store.useSyncedValue("disabled", disabled2);
8531 useImplicitActiveTrigger(store);
8532 const {
8533 forceUnmount,
8534 transitionStatus
8535 } = useOpenStateTransitions(open, store);
8536 const isInstantPhase = store.useState("isInstantPhase");
8537 const instantType = store.useState("instantType");
8538 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8539 const previousInstantTypeRef = React37.useRef(null);
8540 useIsoLayoutEffect(() => {
8541 if (openState && disabled2) {
8542 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8543 }
8544 }, [openState, disabled2, store]);
8545 useIsoLayoutEffect(() => {
8546 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8547 if (instantType !== "delay") {
8548 previousInstantTypeRef.current = instantType;
8549 }
8550 store.set("instantType", "delay");
8551 } else if (previousInstantTypeRef.current !== null) {
8552 store.set("instantType", previousInstantTypeRef.current);
8553 previousInstantTypeRef.current = null;
8554 }
8555 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8556 useIsoLayoutEffect(() => {
8557 if (open) {
8558 if (activeTriggerId == null) {
8559 store.set("payload", void 0);
8560 }
8561 }
8562 }, [store, activeTriggerId, open]);
8563 const handleImperativeClose = React37.useCallback(() => {
8564 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8565 }, [store]);
8566 React37.useImperativeHandle(actionsRef, () => ({
8567 unmount: forceUnmount,
8568 close: handleImperativeClose
8569 }), [forceUnmount, handleImperativeClose]);
8570 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8571 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8572 value: store,
8573 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8574 store,
8575 disabled: disabled2,
8576 trackCursorAxis
8577 }), typeof children === "function" ? children({
8578 payload
8579 }) : children]
8580 });
8581 });
8582 if (true) TooltipRoot.displayName = "TooltipRoot";
8583 function TooltipInteractions({
8584 store,
8585 disabled: disabled2,
8586 trackCursorAxis
8587 }) {
8588 const floatingRootContext = store.useState("floatingRootContext");
8589 const dismiss = useDismiss(floatingRootContext, {
8590 enabled: !disabled2,
8591 referencePress: () => store.select("closeOnClick")
8592 });
8593 const clientPoint = useClientPoint(floatingRootContext, {
8594 enabled: !disabled2 && trackCursorAxis !== "none",
8595 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8596 });
8597 const activeTriggerProps = React37.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8598 const inactiveTriggerProps = React37.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8599 const popupProps = React37.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8600 usePopupInteractionProps(store, {
8601 activeTriggerProps,
8602 inactiveTriggerProps,
8603 popupProps
8604 });
8605 return null;
8606 }
8607
8608 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8609 var React39 = __toESM(require_react(), 1);
8610
8611 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8612 var React38 = __toESM(require_react(), 1);
8613 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8614 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8615 function useTooltipProviderContext() {
8616 return React38.useContext(TooltipProviderContext);
8617 }
8618
8619 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8620 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8621 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8622 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8623 return TooltipTriggerDataAttributes2;
8624 })({});
8625
8626 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8627 var OPEN_DELAY = 600;
8628
8629 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8630 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8631 function getTargetElement(event) {
8632 if ("composedPath" in event) {
8633 const path = event.composedPath();
8634 for (let i2 = 0; i2 < path.length; i2 += 1) {
8635 const element = path[i2];
8636 if (isElement(element)) {
8637 return element;
8638 }
8639 }
8640 }
8641 const target = event.target;
8642 if (isElement(target)) {
8643 return target;
8644 }
8645 return null;
8646 }
8647 function closestEnabledTooltipTrigger(element) {
8648 let current = element;
8649 while (current) {
8650 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8651 return current;
8652 }
8653 const parentElement = current.parentElement;
8654 if (parentElement) {
8655 current = parentElement;
8656 continue;
8657 }
8658 const root = current.getRootNode();
8659 current = "host" in root && isElement(root.host) ? root.host : null;
8660 }
8661 return null;
8662 }
8663 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8664 const {
8665 render: render4,
8666 className,
8667 style,
8668 handle,
8669 payload,
8670 disabled: disabledProp,
8671 delay,
8672 closeOnClick = true,
8673 closeDelay,
8674 id: idProp,
8675 ...elementProps
8676 } = componentProps;
8677 const rootContext = useTooltipRootContext(true);
8678 const store = handle?.store ?? rootContext;
8679 if (!store) {
8680 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82));
8681 }
8682 const thisTriggerId = useBaseUiId(idProp);
8683 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8684 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8685 const floatingRootContext = store.useState("floatingRootContext");
8686 const triggerElementRef = React39.useRef(null);
8687 const delayWithDefault = delay ?? OPEN_DELAY;
8688 const closeDelayWithDefault = closeDelay ?? 0;
8689 const {
8690 registerTrigger,
8691 isMountedByThisTrigger
8692 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8693 payload,
8694 closeOnClick,
8695 closeDelay: closeDelayWithDefault
8696 });
8697 const providerContext = useTooltipProviderContext();
8698 const {
8699 delayRef,
8700 isInstantPhase,
8701 hasProvider
8702 } = useDelayGroup(floatingRootContext, {
8703 open: isOpenedByThisTrigger
8704 });
8705 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8706 store.useSyncedValue("isInstantPhase", isInstantPhase);
8707 const rootDisabled = store.useState("disabled");
8708 const disabled2 = disabledProp ?? rootDisabled;
8709 const disabledRef = useValueAsRef(disabled2);
8710 const trackCursorAxis = store.useState("trackCursorAxis");
8711 const disableHoverablePopup = store.useState("disableHoverablePopup");
8712 const isNestedTriggerHoveredRef = React39.useRef(false);
8713 const nestedTriggerOpenTimeout = useTimeout();
8714 const pointerTypeRef = React39.useRef(void 0);
8715 function getOpenDelay() {
8716 const providerDelay = providerContext?.delay;
8717 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8718 let computedOpenDelay = delayWithDefault;
8719 if (hasProvider) {
8720 if (groupOpenValue !== 0) {
8721 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8722 } else {
8723 computedOpenDelay = 0;
8724 }
8725 }
8726 return computedOpenDelay;
8727 }
8728 function isEnabledNestedTriggerTarget(target) {
8729 const triggerEl = triggerElementRef.current;
8730 if (!triggerEl || !target) {
8731 return false;
8732 }
8733 const nearestTrigger = closestEnabledTooltipTrigger(target);
8734 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8735 }
8736 function detectNestedTriggerHover(target) {
8737 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8738 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8739 if (nestedTriggerHovered) {
8740 hoverInteraction.openChangeTimeout.clear();
8741 hoverInteraction.restTimeout.clear();
8742 hoverInteraction.restTimeoutPending = false;
8743 nestedTriggerOpenTimeout.clear();
8744 }
8745 return nestedTriggerHovered;
8746 }
8747 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8748 enabled: !disabled2,
8749 mouseOnly: true,
8750 move: false,
8751 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8752 restMs: getOpenDelay,
8753 delay() {
8754 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8755 let computedCloseDelay = closeDelayWithDefault;
8756 if (closeDelay == null && hasProvider) {
8757 computedCloseDelay = closeValue;
8758 }
8759 return {
8760 close: computedCloseDelay
8761 };
8762 },
8763 triggerElementRef,
8764 isActiveTrigger: isTriggerActive,
8765 isClosing: () => store.select("transitionStatus") === "ending",
8766 shouldOpen() {
8767 return !isNestedTriggerHoveredRef.current;
8768 }
8769 });
8770 const focusProps = useFocus(floatingRootContext, {
8771 enabled: !disabled2
8772 }).reference;
8773 const handleNestedTriggerHover = (event) => {
8774 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8775 const target = getTargetElement(event);
8776 const nestedTriggerHovered = detectNestedTriggerHover(target);
8777 const triggerEl = triggerElementRef.current;
8778 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8779 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8780 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8781 return;
8782 }
8783 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8784 isMouseLikePointerType(pointerTypeRef.current)) {
8785 const open = () => {
8786 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8787 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8788 }
8789 };
8790 const openDelay = getOpenDelay();
8791 if (openDelay === 0) {
8792 nestedTriggerOpenTimeout.clear();
8793 open();
8794 } else {
8795 nestedTriggerOpenTimeout.start(openDelay, open);
8796 }
8797 }
8798 };
8799 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8800 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8801 const state = {
8802 open: isOpenedByThisTrigger
8803 };
8804 const element = useRenderElement("button", componentProps, {
8805 state,
8806 ref: [forwardedRef, registerTrigger, triggerElementRef],
8807 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8808 onMouseOver(event) {
8809 handleNestedTriggerHover(event.nativeEvent);
8810 },
8811 onFocus(event) {
8812 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8813 event.preventBaseUIHandler();
8814 }
8815 },
8816 onMouseLeave() {
8817 isNestedTriggerHoveredRef.current = false;
8818 nestedTriggerOpenTimeout.clear();
8819 pointerTypeRef.current = void 0;
8820 },
8821 onPointerEnter(event) {
8822 pointerTypeRef.current = event.pointerType;
8823 },
8824 onPointerDown(event) {
8825 pointerTypeRef.current = event.pointerType;
8826 store.set("closeOnClick", closeOnClick);
8827 if (closeOnClick && !store.select("open")) {
8828 store.cancelPendingOpen(event.nativeEvent);
8829 }
8830 },
8831 onClick(event) {
8832 if (closeOnClick && !store.select("open")) {
8833 store.cancelPendingOpen(event.nativeEvent);
8834 }
8835 },
8836 id: thisTriggerId,
8837 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8838 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8839 }, elementProps],
8840 stateAttributesMapping: triggerOpenStateMapping
8841 });
8842 return element;
8843 });
8844 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8845
8846 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8847 var React41 = __toESM(require_react(), 1);
8848
8849 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8850 var React40 = __toESM(require_react(), 1);
8851 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8852 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8853 function useTooltipPortalContext() {
8854 const value = React40.useContext(TooltipPortalContext);
8855 if (value === void 0) {
8856 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8857 }
8858 return value;
8859 }
8860
8861 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8862 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8863 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8864 const {
8865 keepMounted = false,
8866 ...portalProps
8867 } = props;
8868 const store = useTooltipRootContext();
8869 const mounted = store.useState("mounted");
8870 const shouldRender = mounted || keepMounted;
8871 if (!shouldRender) {
8872 return null;
8873 }
8874 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8875 value: keepMounted,
8876 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8877 ref: forwardedRef,
8878 ...portalProps
8879 })
8880 });
8881 });
8882 if (true) TooltipPortal.displayName = "TooltipPortal";
8883
8884 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8885 var React43 = __toESM(require_react(), 1);
8886
8887 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8888 var React42 = __toESM(require_react(), 1);
8889 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8890 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8891 function useTooltipPositionerContext() {
8892 const context = React42.useContext(TooltipPositionerContext);
8893 if (context === void 0) {
8894 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8895 }
8896 return context;
8897 }
8898
8899 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8900 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8901 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8902 const {
8903 render: render4,
8904 className,
8905 anchor,
8906 positionMethod = "absolute",
8907 side = "top",
8908 align = "center",
8909 sideOffset = 0,
8910 alignOffset = 0,
8911 collisionBoundary = "clipping-ancestors",
8912 collisionPadding = 5,
8913 arrowPadding = 5,
8914 sticky = false,
8915 disableAnchorTracking = false,
8916 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8917 style,
8918 ...elementProps
8919 } = componentProps;
8920 const store = useTooltipRootContext();
8921 const keepMounted = useTooltipPortalContext();
8922 const open = store.useState("open");
8923 const mounted = store.useState("mounted");
8924 const trackCursorAxis = store.useState("trackCursorAxis");
8925 const disableHoverablePopup = store.useState("disableHoverablePopup");
8926 const floatingRootContext = store.useState("floatingRootContext");
8927 const instantType = store.useState("instantType");
8928 const transitionStatus = store.useState("transitionStatus");
8929 const hasViewport = store.useState("hasViewport");
8930 const positioning = useAnchorPositioning({
8931 anchor,
8932 positionMethod,
8933 floatingRootContext,
8934 mounted,
8935 side,
8936 sideOffset,
8937 align,
8938 alignOffset,
8939 collisionBoundary,
8940 collisionPadding,
8941 sticky,
8942 arrowPadding,
8943 disableAnchorTracking,
8944 keepMounted,
8945 collisionAvoidance,
8946 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8947 });
8948 const state = React43.useMemo(() => ({
8949 open,
8950 side: positioning.side,
8951 align: positioning.align,
8952 anchorHidden: positioning.anchorHidden,
8953 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8954 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8955 const element = usePositioner(componentProps, state, {
8956 styles: positioning.positionerStyles,
8957 transitionStatus,
8958 props: elementProps,
8959 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8960 hidden: !mounted,
8961 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8962 });
8963 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8964 value: positioning,
8965 children: element
8966 });
8967 });
8968 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8969
8970 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8971 var React44 = __toESM(require_react(), 1);
8972 var stateAttributesMapping = {
8973 ...popupStateMapping,
8974 ...transitionStatusMapping
8975 };
8976 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8977 const {
8978 render: render4,
8979 className,
8980 style,
8981 ...elementProps
8982 } = componentProps;
8983 const store = useTooltipRootContext();
8984 const {
8985 side,
8986 align
8987 } = useTooltipPositionerContext();
8988 const open = store.useState("open");
8989 const instantType = store.useState("instantType");
8990 const transitionStatus = store.useState("transitionStatus");
8991 const popupProps = store.useState("popupProps");
8992 const floatingContext = store.useState("floatingRootContext");
8993 const disabled2 = store.useState("disabled");
8994 const closeDelay = store.useState("closeDelay");
8995 useOpenChangeComplete({
8996 open,
8997 ref: store.context.popupRef,
8998 onComplete() {
8999 if (open) {
9000 store.context.onOpenChangeComplete?.(true);
9001 }
9002 }
9003 });
9004 useHoverFloatingInteraction(floatingContext, {
9005 enabled: !disabled2,
9006 closeDelay
9007 });
9008 const setPopupElement = store.useStateSetter("popupElement");
9009 const state = {
9010 open,
9011 side,
9012 align,
9013 instant: instantType,
9014 transitionStatus
9015 };
9016 const element = useRenderElement("div", componentProps, {
9017 state,
9018 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9019 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9020 stateAttributesMapping
9021 });
9022 return element;
9023 });
9024 if (true) TooltipPopup.displayName = "TooltipPopup";
9025
9026 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
9027 var React45 = __toESM(require_react(), 1);
9028 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9029 const {
9030 render: render4,
9031 className,
9032 style,
9033 ...elementProps
9034 } = componentProps;
9035 const store = useTooltipRootContext();
9036 const {
9037 arrowRef,
9038 side,
9039 align,
9040 arrowUncentered,
9041 arrowStyles
9042 } = useTooltipPositionerContext();
9043 const open = store.useState("open");
9044 const instantType = store.useState("instantType");
9045 const state = {
9046 open,
9047 side,
9048 align,
9049 uncentered: arrowUncentered,
9050 instant: instantType
9051 };
9052 const element = useRenderElement("div", componentProps, {
9053 state,
9054 ref: [forwardedRef, arrowRef],
9055 props: [{
9056 style: arrowStyles,
9057 "aria-hidden": true
9058 }, elementProps],
9059 stateAttributesMapping: popupStateMapping
9060 });
9061 return element;
9062 });
9063 if (true) TooltipArrow.displayName = "TooltipArrow";
9064
9065 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
9066 var React46 = __toESM(require_react(), 1);
9067 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9068 var TooltipProvider = function TooltipProvider2(props) {
9069 const {
9070 delay,
9071 closeDelay,
9072 timeout = 400
9073 } = props;
9074 const contextValue = React46.useMemo(() => ({
9075 delay,
9076 closeDelay
9077 }), [delay, closeDelay]);
9078 const delayValue = React46.useMemo(() => ({
9079 open: delay,
9080 close: closeDelay
9081 }), [delay, closeDelay]);
9082 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
9083 value: contextValue,
9084 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
9085 delay: delayValue,
9086 timeoutMs: timeout,
9087 children: props.children
9088 })
9089 });
9090 };
9091 if (true) TooltipProvider.displayName = "TooltipProvider";
9092
9093 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9094 var React47 = __toESM(require_react(), 1);
9095
9096 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
9097 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9098 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9099 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9100 return TooltipViewportCssVars2;
9101 })({});
9102
9103 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9104 var stateAttributesMapping2 = {
9105 activationDirection: (value) => value ? {
9106 "data-activation-direction": value
9107 } : null
9108 };
9109 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9110 const {
9111 render: render4,
9112 className,
9113 style,
9114 children,
9115 ...elementProps
9116 } = componentProps;
9117 const store = useTooltipRootContext();
9118 const positioner = useTooltipPositionerContext();
9119 const instantType = store.useState("instantType");
9120 const {
9121 children: childrenToRender,
9122 state: viewportState
9123 } = usePopupViewport({
9124 store,
9125 side: positioner.side,
9126 cssVars: TooltipViewportCssVars,
9127 children
9128 });
9129 const state = {
9130 activationDirection: viewportState.activationDirection,
9131 transitioning: viewportState.transitioning,
9132 instant: instantType
9133 };
9134 return useRenderElement("div", componentProps, {
9135 state,
9136 ref: forwardedRef,
9137 props: [elementProps, {
9138 children: childrenToRender
9139 }],
9140 stateAttributesMapping: stateAttributesMapping2
9141 });
9142 });
9143 if (true) TooltipViewport.displayName = "TooltipViewport";
9144
9145 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
9146 var TooltipHandle = class {
9147 /**
9148 * Internal store holding the tooltip state.
9149 * @internal
9150 */
9151 constructor() {
9152 this.store = new TooltipStore();
9153 }
9154 /**
9155 * Opens the tooltip and associates it with the trigger with the given ID.
9156 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9157 *
9158 * This method should only be called in an event handler or an effect (not during rendering).
9159 *
9160 * @param triggerId ID of the trigger to associate with the tooltip.
9161 */
9162 open(triggerId) {
9163 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9164 if (triggerId && !triggerElement) {
9165 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9166 }
9167 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9168 }
9169 /**
9170 * Closes the tooltip.
9171 */
9172 close() {
9173 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9174 }
9175 /**
9176 * Indicates whether the tooltip is currently open.
9177 */
9178 get isOpen() {
9179 return this.store.select("open");
9180 }
9181 };
9182 function createTooltipHandle() {
9183 return new TooltipHandle();
9184 }
9185
9186 // node_modules/@base-ui/react/esm/use-render/useRender.js
9187 function useRender(params) {
9188 return useRenderElement(params.defaultTagName ?? "div", params, params);
9189 }
9190
9191 // packages/ui/build-module/text/text.mjs
9192 var import_element11 = __toESM(require_element(), 1);
9193 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9194 function getRuntime() {
9195 const globalScope = globalThis;
9196 if (globalScope.__wpStyleRuntime) {
9197 return globalScope.__wpStyleRuntime;
9198 }
9199 globalScope.__wpStyleRuntime = {
9200 documents: /* @__PURE__ */ new Map(),
9201 styles: /* @__PURE__ */ new Map(),
9202 injectedStyles: /* @__PURE__ */ new WeakMap()
9203 };
9204 if (typeof document !== "undefined") {
9205 registerDocument(document);
9206 }
9207 return globalScope.__wpStyleRuntime;
9208 }
9209 function documentContainsStyleHash(targetDocument, hash) {
9210 if (!targetDocument.head) {
9211 return false;
9212 }
9213 for (const style of targetDocument.head.querySelectorAll(
9214 `style[${STYLE_HASH_ATTRIBUTE}]`
9215 )) {
9216 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9217 return true;
9218 }
9219 }
9220 return false;
9221 }
9222 function injectStyle(targetDocument, hash, css) {
9223 if (!targetDocument.head) {
9224 return;
9225 }
9226 const runtime = getRuntime();
9227 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9228 if (!injectedStyles) {
9229 injectedStyles = /* @__PURE__ */ new Set();
9230 runtime.injectedStyles.set(targetDocument, injectedStyles);
9231 }
9232 if (injectedStyles.has(hash)) {
9233 return;
9234 }
9235 if (documentContainsStyleHash(targetDocument, hash)) {
9236 injectedStyles.add(hash);
9237 return;
9238 }
9239 const style = targetDocument.createElement("style");
9240 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9241 style.appendChild(targetDocument.createTextNode(css));
9242 targetDocument.head.appendChild(style);
9243 injectedStyles.add(hash);
9244 }
9245 function registerDocument(targetDocument) {
9246 const runtime = getRuntime();
9247 runtime.documents.set(
9248 targetDocument,
9249 (runtime.documents.get(targetDocument) ?? 0) + 1
9250 );
9251 for (const [hash, css] of runtime.styles) {
9252 injectStyle(targetDocument, hash, css);
9253 }
9254 return () => {
9255 const count = runtime.documents.get(targetDocument);
9256 if (count === void 0) {
9257 return;
9258 }
9259 if (count <= 1) {
9260 runtime.documents.delete(targetDocument);
9261 return;
9262 }
9263 runtime.documents.set(targetDocument, count - 1);
9264 };
9265 }
9266 function registerStyle(hash, css) {
9267 const runtime = getRuntime();
9268 runtime.styles.set(hash, css);
9269 for (const targetDocument of runtime.documents.keys()) {
9270 injectStyle(targetDocument, hash, css);
9271 }
9272 }
9273 if (typeof process === "undefined" || true) {
9274 registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
9275 }
9276 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
9277 if (typeof process === "undefined" || true) {
9278 registerStyle("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
9279 }
9280 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
9281 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9282 const element = useRender({
9283 render: render4,
9284 defaultTagName: "span",
9285 ref,
9286 props: mergeProps(props, {
9287 className: clsx_default(
9288 style_default.text,
9289 global_css_defense_default.heading,
9290 global_css_defense_default.p,
9291 style_default[variant],
9292 className
9293 )
9294 })
9295 });
9296 return element;
9297 });
9298
9299 // packages/icons/build-module/library/arrow-down.mjs
9300 var import_primitives = __toESM(require_primitives(), 1);
9301 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9302 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
9303
9304 // packages/icons/build-module/library/arrow-left.mjs
9305 var import_primitives2 = __toESM(require_primitives(), 1);
9306 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9307 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
9308
9309 // packages/icons/build-module/library/arrow-right.mjs
9310 var import_primitives3 = __toESM(require_primitives(), 1);
9311 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9312 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
9313
9314 // packages/icons/build-module/library/arrow-up.mjs
9315 var import_primitives4 = __toESM(require_primitives(), 1);
9316 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9317 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
9318
9319 // packages/icons/build-module/library/block-table.mjs
9320 var import_primitives5 = __toESM(require_primitives(), 1);
9321 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9322 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
9323
9324 // packages/icons/build-module/library/category.mjs
9325 var import_primitives6 = __toESM(require_primitives(), 1);
9326 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9327 var category_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
9328
9329 // packages/icons/build-module/library/check.mjs
9330 var import_primitives7 = __toESM(require_primitives(), 1);
9331 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9332 var check_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
9333
9334 // packages/icons/build-module/library/close-small.mjs
9335 var import_primitives8 = __toESM(require_primitives(), 1);
9336 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9337 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
9338
9339 // packages/icons/build-module/library/cog.mjs
9340 var import_primitives9 = __toESM(require_primitives(), 1);
9341 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9342 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
9343
9344 // packages/icons/build-module/library/envelope.mjs
9345 var import_primitives10 = __toESM(require_primitives(), 1);
9346 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9347 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
9348
9349 // packages/icons/build-module/library/error.mjs
9350 var import_primitives11 = __toESM(require_primitives(), 1);
9351 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9352 var error_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
9353
9354 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9355 var import_primitives12 = __toESM(require_primitives(), 1);
9356 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9357 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
9358
9359 // packages/icons/build-module/library/format-list-bullets.mjs
9360 var import_primitives13 = __toESM(require_primitives(), 1);
9361 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9362 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
9363
9364 // packages/icons/build-module/library/funnel.mjs
9365 var import_primitives14 = __toESM(require_primitives(), 1);
9366 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9367 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9368
9369 // packages/icons/build-module/library/link.mjs
9370 var import_primitives15 = __toESM(require_primitives(), 1);
9371 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9372 var link_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
9373
9374 // packages/icons/build-module/library/mobile.mjs
9375 var import_primitives16 = __toESM(require_primitives(), 1);
9376 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9377 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
9378
9379 // packages/icons/build-module/library/more-vertical.mjs
9380 var import_primitives17 = __toESM(require_primitives(), 1);
9381 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9382 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9383
9384 // packages/icons/build-module/library/next.mjs
9385 var import_primitives18 = __toESM(require_primitives(), 1);
9386 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9387 var next_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
9388
9389 // packages/icons/build-module/library/previous.mjs
9390 var import_primitives19 = __toESM(require_primitives(), 1);
9391 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9392 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
9393
9394 // packages/icons/build-module/library/scheduled.mjs
9395 var import_primitives20 = __toESM(require_primitives(), 1);
9396 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9397 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
9398
9399 // packages/icons/build-module/library/search.mjs
9400 var import_primitives21 = __toESM(require_primitives(), 1);
9401 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9402 var search_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
9403
9404 // packages/icons/build-module/library/seen.mjs
9405 var import_primitives22 = __toESM(require_primitives(), 1);
9406 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9407 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
9408
9409 // packages/icons/build-module/library/unseen.mjs
9410 var import_primitives23 = __toESM(require_primitives(), 1);
9411 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9412 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
9413
9414 // packages/ui/build-module/utils/render-slot-with-children.mjs
9415 var import_element12 = __toESM(require_element(), 1);
9416 function renderSlotWithChildren(slot, defaultSlot, children) {
9417 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9418 }
9419
9420 // packages/ui/build-module/utils/theme-provider.mjs
9421 var theme = __toESM(require_theme(), 1);
9422
9423 // packages/ui/build-module/lock-unlock.mjs
9424 var import_private_apis2 = __toESM(require_private_apis(), 1);
9425 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9426 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9427 "@wordpress/ui"
9428 );
9429
9430 // packages/ui/build-module/utils/theme-provider.mjs
9431 function getThemeProvider() {
9432 const themePackage = theme;
9433 if (themePackage.ThemeProvider) {
9434 return themePackage.ThemeProvider;
9435 }
9436 if (!themePackage.privateApis) {
9437 throw new Error(
9438 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9439 );
9440 }
9441 return unlock2(
9442 themePackage.privateApis
9443 ).ThemeProvider;
9444 }
9445 var ThemeProvider = getThemeProvider();
9446
9447 // packages/ui/build-module/stack/stack.mjs
9448 var import_element13 = __toESM(require_element(), 1);
9449 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9450 function getRuntime2() {
9451 const globalScope = globalThis;
9452 if (globalScope.__wpStyleRuntime) {
9453 return globalScope.__wpStyleRuntime;
9454 }
9455 globalScope.__wpStyleRuntime = {
9456 documents: /* @__PURE__ */ new Map(),
9457 styles: /* @__PURE__ */ new Map(),
9458 injectedStyles: /* @__PURE__ */ new WeakMap()
9459 };
9460 if (typeof document !== "undefined") {
9461 registerDocument2(document);
9462 }
9463 return globalScope.__wpStyleRuntime;
9464 }
9465 function documentContainsStyleHash2(targetDocument, hash) {
9466 if (!targetDocument.head) {
9467 return false;
9468 }
9469 for (const style of targetDocument.head.querySelectorAll(
9470 `style[${STYLE_HASH_ATTRIBUTE2}]`
9471 )) {
9472 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9473 return true;
9474 }
9475 }
9476 return false;
9477 }
9478 function injectStyle2(targetDocument, hash, css) {
9479 if (!targetDocument.head) {
9480 return;
9481 }
9482 const runtime = getRuntime2();
9483 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9484 if (!injectedStyles) {
9485 injectedStyles = /* @__PURE__ */ new Set();
9486 runtime.injectedStyles.set(targetDocument, injectedStyles);
9487 }
9488 if (injectedStyles.has(hash)) {
9489 return;
9490 }
9491 if (documentContainsStyleHash2(targetDocument, hash)) {
9492 injectedStyles.add(hash);
9493 return;
9494 }
9495 const style = targetDocument.createElement("style");
9496 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9497 style.appendChild(targetDocument.createTextNode(css));
9498 targetDocument.head.appendChild(style);
9499 injectedStyles.add(hash);
9500 }
9501 function registerDocument2(targetDocument) {
9502 const runtime = getRuntime2();
9503 runtime.documents.set(
9504 targetDocument,
9505 (runtime.documents.get(targetDocument) ?? 0) + 1
9506 );
9507 for (const [hash, css] of runtime.styles) {
9508 injectStyle2(targetDocument, hash, css);
9509 }
9510 return () => {
9511 const count = runtime.documents.get(targetDocument);
9512 if (count === void 0) {
9513 return;
9514 }
9515 if (count <= 1) {
9516 runtime.documents.delete(targetDocument);
9517 return;
9518 }
9519 runtime.documents.set(targetDocument, count - 1);
9520 };
9521 }
9522 function registerStyle2(hash, css) {
9523 const runtime = getRuntime2();
9524 runtime.styles.set(hash, css);
9525 for (const targetDocument of runtime.documents.keys()) {
9526 injectStyle2(targetDocument, hash, css);
9527 }
9528 }
9529 if (typeof process === "undefined" || true) {
9530 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9531 }
9532 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9533 var gapTokens = {
9534 xs: "var(--wpds-dimension-gap-xs, 4px)",
9535 sm: "var(--wpds-dimension-gap-sm, 8px)",
9536 md: "var(--wpds-dimension-gap-md, 12px)",
9537 lg: "var(--wpds-dimension-gap-lg, 16px)",
9538 xl: "var(--wpds-dimension-gap-xl, 24px)",
9539 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9540 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9541 };
9542 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9543 const style = {
9544 gap: gap && gapTokens[gap],
9545 alignItems: align,
9546 justifyContent: justify,
9547 flexDirection: direction,
9548 flexWrap: wrap
9549 };
9550 const element = useRender({
9551 render: render4,
9552 ref,
9553 props: mergeProps(props, { style, className: style_default2.stack })
9554 });
9555 return element;
9556 });
9557
9558 // packages/ui/build-module/tooltip/index.mjs
9559 var tooltip_exports = {};
9560 __export(tooltip_exports, {
9561 Popup: () => Popup,
9562 Portal: () => Portal,
9563 Positioner: () => Positioner,
9564 Provider: () => Provider,
9565 Root: () => Root,
9566 Trigger: () => Trigger
9567 });
9568
9569 // packages/ui/build-module/tooltip/popup.mjs
9570 var import_element16 = __toESM(require_element(), 1);
9571
9572 // packages/ui/build-module/tooltip/portal.mjs
9573 var import_element14 = __toESM(require_element(), 1);
9574
9575 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9576 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9577 function getRuntime3() {
9578 const globalScope = globalThis;
9579 if (globalScope.__wpStyleRuntime) {
9580 return globalScope.__wpStyleRuntime;
9581 }
9582 globalScope.__wpStyleRuntime = {
9583 documents: /* @__PURE__ */ new Map(),
9584 styles: /* @__PURE__ */ new Map(),
9585 injectedStyles: /* @__PURE__ */ new WeakMap()
9586 };
9587 if (typeof document !== "undefined") {
9588 registerDocument3(document);
9589 }
9590 return globalScope.__wpStyleRuntime;
9591 }
9592 function documentContainsStyleHash3(targetDocument, hash) {
9593 if (!targetDocument.head) {
9594 return false;
9595 }
9596 for (const style of targetDocument.head.querySelectorAll(
9597 `style[${STYLE_HASH_ATTRIBUTE3}]`
9598 )) {
9599 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9600 return true;
9601 }
9602 }
9603 return false;
9604 }
9605 function injectStyle3(targetDocument, hash, css) {
9606 if (!targetDocument.head) {
9607 return;
9608 }
9609 const runtime = getRuntime3();
9610 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9611 if (!injectedStyles) {
9612 injectedStyles = /* @__PURE__ */ new Set();
9613 runtime.injectedStyles.set(targetDocument, injectedStyles);
9614 }
9615 if (injectedStyles.has(hash)) {
9616 return;
9617 }
9618 if (documentContainsStyleHash3(targetDocument, hash)) {
9619 injectedStyles.add(hash);
9620 return;
9621 }
9622 const style = targetDocument.createElement("style");
9623 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9624 style.appendChild(targetDocument.createTextNode(css));
9625 targetDocument.head.appendChild(style);
9626 injectedStyles.add(hash);
9627 }
9628 function registerDocument3(targetDocument) {
9629 const runtime = getRuntime3();
9630 runtime.documents.set(
9631 targetDocument,
9632 (runtime.documents.get(targetDocument) ?? 0) + 1
9633 );
9634 for (const [hash, css] of runtime.styles) {
9635 injectStyle3(targetDocument, hash, css);
9636 }
9637 return () => {
9638 const count = runtime.documents.get(targetDocument);
9639 if (count === void 0) {
9640 return;
9641 }
9642 if (count <= 1) {
9643 runtime.documents.delete(targetDocument);
9644 return;
9645 }
9646 runtime.documents.set(targetDocument, count - 1);
9647 };
9648 }
9649 function registerStyle3(hash, css) {
9650 const runtime = getRuntime3();
9651 runtime.styles.set(hash, css);
9652 for (const targetDocument of runtime.documents.keys()) {
9653 injectStyle3(targetDocument, hash, css);
9654 }
9655 }
9656 if (typeof process === "undefined" || true) {
9657 registerStyle3("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
9658 }
9659 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9660 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9661 function resolveOwnerDocument() {
9662 return typeof document === "undefined" ? null : document;
9663 }
9664 function isInWordPressEnvironment() {
9665 let topWp;
9666 try {
9667 topWp = window.top?.wp;
9668 } catch {
9669 }
9670 const wp = topWp ?? window.wp;
9671 return typeof wp?.components === "object" && wp.components !== null;
9672 }
9673 var cachedSlot = null;
9674 function createSlot(ownerDocument2) {
9675 const element = ownerDocument2.createElement("div");
9676 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9677 if (wp_compat_overlay_slot_default.slot) {
9678 element.classList.add(wp_compat_overlay_slot_default.slot);
9679 }
9680 ownerDocument2.body.appendChild(element);
9681 return element;
9682 }
9683 function getWpCompatOverlaySlot() {
9684 if (typeof window === "undefined") {
9685 return void 0;
9686 }
9687 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9688 return void 0;
9689 }
9690 const ownerDocument2 = resolveOwnerDocument();
9691 if (!ownerDocument2 || !ownerDocument2.body) {
9692 return void 0;
9693 }
9694 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9695 return cachedSlot;
9696 }
9697 const existing = ownerDocument2.querySelector(
9698 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9699 );
9700 if (existing instanceof HTMLDivElement) {
9701 cachedSlot = existing;
9702 return existing;
9703 }
9704 if (cachedSlot?.isConnected) {
9705 cachedSlot.remove();
9706 }
9707 cachedSlot = createSlot(ownerDocument2);
9708 return cachedSlot;
9709 }
9710
9711 // packages/ui/build-module/tooltip/portal.mjs
9712 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9713 var Portal = (0, import_element14.forwardRef)(
9714 function TooltipPortal3({ container, ...restProps }, ref) {
9715 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9716 index_parts_exports.Portal,
9717 {
9718 container: container ?? getWpCompatOverlaySlot(),
9719 ...restProps,
9720 ref
9721 }
9722 );
9723 }
9724 );
9725
9726 // packages/ui/build-module/tooltip/positioner.mjs
9727 var import_element15 = __toESM(require_element(), 1);
9728 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9729 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9730 function getRuntime4() {
9731 const globalScope = globalThis;
9732 if (globalScope.__wpStyleRuntime) {
9733 return globalScope.__wpStyleRuntime;
9734 }
9735 globalScope.__wpStyleRuntime = {
9736 documents: /* @__PURE__ */ new Map(),
9737 styles: /* @__PURE__ */ new Map(),
9738 injectedStyles: /* @__PURE__ */ new WeakMap()
9739 };
9740 if (typeof document !== "undefined") {
9741 registerDocument4(document);
9742 }
9743 return globalScope.__wpStyleRuntime;
9744 }
9745 function documentContainsStyleHash4(targetDocument, hash) {
9746 if (!targetDocument.head) {
9747 return false;
9748 }
9749 for (const style of targetDocument.head.querySelectorAll(
9750 `style[${STYLE_HASH_ATTRIBUTE4}]`
9751 )) {
9752 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9753 return true;
9754 }
9755 }
9756 return false;
9757 }
9758 function injectStyle4(targetDocument, hash, css) {
9759 if (!targetDocument.head) {
9760 return;
9761 }
9762 const runtime = getRuntime4();
9763 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9764 if (!injectedStyles) {
9765 injectedStyles = /* @__PURE__ */ new Set();
9766 runtime.injectedStyles.set(targetDocument, injectedStyles);
9767 }
9768 if (injectedStyles.has(hash)) {
9769 return;
9770 }
9771 if (documentContainsStyleHash4(targetDocument, hash)) {
9772 injectedStyles.add(hash);
9773 return;
9774 }
9775 const style = targetDocument.createElement("style");
9776 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9777 style.appendChild(targetDocument.createTextNode(css));
9778 targetDocument.head.appendChild(style);
9779 injectedStyles.add(hash);
9780 }
9781 function registerDocument4(targetDocument) {
9782 const runtime = getRuntime4();
9783 runtime.documents.set(
9784 targetDocument,
9785 (runtime.documents.get(targetDocument) ?? 0) + 1
9786 );
9787 for (const [hash, css] of runtime.styles) {
9788 injectStyle4(targetDocument, hash, css);
9789 }
9790 return () => {
9791 const count = runtime.documents.get(targetDocument);
9792 if (count === void 0) {
9793 return;
9794 }
9795 if (count <= 1) {
9796 runtime.documents.delete(targetDocument);
9797 return;
9798 }
9799 runtime.documents.set(targetDocument, count - 1);
9800 };
9801 }
9802 function registerStyle4(hash, css) {
9803 const runtime = getRuntime4();
9804 runtime.styles.set(hash, css);
9805 for (const targetDocument of runtime.documents.keys()) {
9806 injectStyle4(targetDocument, hash, css);
9807 }
9808 }
9809 if (typeof process === "undefined" || true) {
9810 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9811 }
9812 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9813 if (typeof process === "undefined" || true) {
9814 registerStyle4("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-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}}}}');
9815 }
9816 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9817 var Positioner = (0, import_element15.forwardRef)(
9818 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9819 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9820 index_parts_exports.Positioner,
9821 {
9822 ref,
9823 align,
9824 side,
9825 sideOffset,
9826 ...props,
9827 className: clsx_default(
9828 resets_default["box-sizing"],
9829 style_default3.positioner,
9830 className
9831 )
9832 }
9833 );
9834 }
9835 );
9836
9837 // packages/ui/build-module/tooltip/popup.mjs
9838 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9839 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9840 function getRuntime5() {
9841 const globalScope = globalThis;
9842 if (globalScope.__wpStyleRuntime) {
9843 return globalScope.__wpStyleRuntime;
9844 }
9845 globalScope.__wpStyleRuntime = {
9846 documents: /* @__PURE__ */ new Map(),
9847 styles: /* @__PURE__ */ new Map(),
9848 injectedStyles: /* @__PURE__ */ new WeakMap()
9849 };
9850 if (typeof document !== "undefined") {
9851 registerDocument5(document);
9852 }
9853 return globalScope.__wpStyleRuntime;
9854 }
9855 function documentContainsStyleHash5(targetDocument, hash) {
9856 if (!targetDocument.head) {
9857 return false;
9858 }
9859 for (const style of targetDocument.head.querySelectorAll(
9860 `style[${STYLE_HASH_ATTRIBUTE5}]`
9861 )) {
9862 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9863 return true;
9864 }
9865 }
9866 return false;
9867 }
9868 function injectStyle5(targetDocument, hash, css) {
9869 if (!targetDocument.head) {
9870 return;
9871 }
9872 const runtime = getRuntime5();
9873 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9874 if (!injectedStyles) {
9875 injectedStyles = /* @__PURE__ */ new Set();
9876 runtime.injectedStyles.set(targetDocument, injectedStyles);
9877 }
9878 if (injectedStyles.has(hash)) {
9879 return;
9880 }
9881 if (documentContainsStyleHash5(targetDocument, hash)) {
9882 injectedStyles.add(hash);
9883 return;
9884 }
9885 const style = targetDocument.createElement("style");
9886 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9887 style.appendChild(targetDocument.createTextNode(css));
9888 targetDocument.head.appendChild(style);
9889 injectedStyles.add(hash);
9890 }
9891 function registerDocument5(targetDocument) {
9892 const runtime = getRuntime5();
9893 runtime.documents.set(
9894 targetDocument,
9895 (runtime.documents.get(targetDocument) ?? 0) + 1
9896 );
9897 for (const [hash, css] of runtime.styles) {
9898 injectStyle5(targetDocument, hash, css);
9899 }
9900 return () => {
9901 const count = runtime.documents.get(targetDocument);
9902 if (count === void 0) {
9903 return;
9904 }
9905 if (count <= 1) {
9906 runtime.documents.delete(targetDocument);
9907 return;
9908 }
9909 runtime.documents.set(targetDocument, count - 1);
9910 };
9911 }
9912 function registerStyle5(hash, css) {
9913 const runtime = getRuntime5();
9914 runtime.styles.set(hash, css);
9915 for (const targetDocument of runtime.documents.keys()) {
9916 injectStyle5(targetDocument, hash, css);
9917 }
9918 }
9919 if (typeof process === "undefined" || true) {
9920 registerStyle5("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-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}}}}');
9921 }
9922 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9923 var POPUP_COLOR = { background: "#1e1e1e" };
9924 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9925 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9926 index_parts_exports.Popup,
9927 {
9928 ref,
9929 className: clsx_default(style_default4.popup, className),
9930 ...props,
9931 children
9932 }
9933 ) });
9934 const positionedPopup = renderSlotWithChildren(
9935 positioner,
9936 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
9937 popupContent
9938 );
9939 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
9940 });
9941
9942 // packages/ui/build-module/tooltip/trigger.mjs
9943 var import_element17 = __toESM(require_element(), 1);
9944 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9945 var Trigger = (0, import_element17.forwardRef)(
9946 function TooltipTrigger3(props, ref) {
9947 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
9948 }
9949 );
9950
9951 // packages/ui/build-module/tooltip/root.mjs
9952 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9953 function Root(props) {
9954 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
9955 }
9956
9957 // packages/ui/build-module/tooltip/provider.mjs
9958 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9959 function Provider({ ...props }) {
9960 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
9961 }
9962
9963 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9964 var import_element18 = __toESM(require_element(), 1);
9965 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9966 function getRuntime6() {
9967 const globalScope = globalThis;
9968 if (globalScope.__wpStyleRuntime) {
9969 return globalScope.__wpStyleRuntime;
9970 }
9971 globalScope.__wpStyleRuntime = {
9972 documents: /* @__PURE__ */ new Map(),
9973 styles: /* @__PURE__ */ new Map(),
9974 injectedStyles: /* @__PURE__ */ new WeakMap()
9975 };
9976 if (typeof document !== "undefined") {
9977 registerDocument6(document);
9978 }
9979 return globalScope.__wpStyleRuntime;
9980 }
9981 function documentContainsStyleHash6(targetDocument, hash) {
9982 if (!targetDocument.head) {
9983 return false;
9984 }
9985 for (const style of targetDocument.head.querySelectorAll(
9986 `style[${STYLE_HASH_ATTRIBUTE6}]`
9987 )) {
9988 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9989 return true;
9990 }
9991 }
9992 return false;
9993 }
9994 function injectStyle6(targetDocument, hash, css) {
9995 if (!targetDocument.head) {
9996 return;
9997 }
9998 const runtime = getRuntime6();
9999 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10000 if (!injectedStyles) {
10001 injectedStyles = /* @__PURE__ */ new Set();
10002 runtime.injectedStyles.set(targetDocument, injectedStyles);
10003 }
10004 if (injectedStyles.has(hash)) {
10005 return;
10006 }
10007 if (documentContainsStyleHash6(targetDocument, hash)) {
10008 injectedStyles.add(hash);
10009 return;
10010 }
10011 const style = targetDocument.createElement("style");
10012 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10013 style.appendChild(targetDocument.createTextNode(css));
10014 targetDocument.head.appendChild(style);
10015 injectedStyles.add(hash);
10016 }
10017 function registerDocument6(targetDocument) {
10018 const runtime = getRuntime6();
10019 runtime.documents.set(
10020 targetDocument,
10021 (runtime.documents.get(targetDocument) ?? 0) + 1
10022 );
10023 for (const [hash, css] of runtime.styles) {
10024 injectStyle6(targetDocument, hash, css);
10025 }
10026 return () => {
10027 const count = runtime.documents.get(targetDocument);
10028 if (count === void 0) {
10029 return;
10030 }
10031 if (count <= 1) {
10032 runtime.documents.delete(targetDocument);
10033 return;
10034 }
10035 runtime.documents.set(targetDocument, count - 1);
10036 };
10037 }
10038 function registerStyle6(hash, css) {
10039 const runtime = getRuntime6();
10040 runtime.styles.set(hash, css);
10041 for (const targetDocument of runtime.documents.keys()) {
10042 injectStyle6(targetDocument, hash, css);
10043 }
10044 }
10045 if (typeof process === "undefined" || true) {
10046 registerStyle6("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
10047 }
10048 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10049 var VisuallyHidden = (0, import_element18.forwardRef)(
10050 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10051 const element = useRender({
10052 render: render4,
10053 ref,
10054 props: mergeProps(
10055 { className: style_default5["visually-hidden"] },
10056 restProps,
10057 {
10058 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10059 "data-visually-hidden": ""
10060 }
10061 )
10062 });
10063 return element;
10064 }
10065 );
10066
10067 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10068 var import_element19 = __toESM(require_element(), 1);
10069
10070 // packages/dataviews/build-module/constants.mjs
10071 var import_i18n = __toESM(require_i18n(), 1);
10072 var OPERATOR_IS_ANY = "isAny";
10073 var OPERATOR_IS_NONE = "isNone";
10074 var OPERATOR_IS_ALL = "isAll";
10075 var OPERATOR_IS_NOT_ALL = "isNotAll";
10076 var OPERATOR_BETWEEN = "between";
10077 var OPERATOR_IN_THE_PAST = "inThePast";
10078 var OPERATOR_OVER = "over";
10079 var OPERATOR_IS = "is";
10080 var OPERATOR_IS_NOT = "isNot";
10081 var OPERATOR_LESS_THAN = "lessThan";
10082 var OPERATOR_GREATER_THAN = "greaterThan";
10083 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10084 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10085 var OPERATOR_BEFORE = "before";
10086 var OPERATOR_AFTER = "after";
10087 var OPERATOR_BEFORE_INC = "beforeInc";
10088 var OPERATOR_AFTER_INC = "afterInc";
10089 var OPERATOR_CONTAINS = "contains";
10090 var OPERATOR_NOT_CONTAINS = "notContains";
10091 var OPERATOR_STARTS_WITH = "startsWith";
10092 var OPERATOR_ON = "on";
10093 var OPERATOR_NOT_ON = "notOn";
10094 var SORTING_DIRECTIONS = ["asc", "desc"];
10095 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10096 var sortValues = { asc: "ascending", desc: "descending" };
10097 var sortLabels = {
10098 asc: (0, import_i18n.__)("Sort ascending"),
10099 desc: (0, import_i18n.__)("Sort descending")
10100 };
10101 var sortIcons = {
10102 asc: arrow_up_default,
10103 desc: arrow_down_default
10104 };
10105 var LAYOUT_TABLE = "table";
10106 var LAYOUT_GRID = "grid";
10107 var LAYOUT_LIST = "list";
10108 var LAYOUT_ACTIVITY = "activity";
10109 var LAYOUT_PICKER_GRID = "pickerGrid";
10110 var LAYOUT_PICKER_TABLE = "pickerTable";
10111 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10112
10113 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10114 var DataViewsContext = (0, import_element19.createContext)({
10115 view: { type: LAYOUT_TABLE },
10116 onChangeView: () => {
10117 },
10118 fields: [],
10119 data: [],
10120 paginationInfo: {
10121 totalItems: 0,
10122 totalPages: 0
10123 },
10124 selection: [],
10125 onChangeSelection: () => {
10126 },
10127 setOpenedFilter: () => {
10128 },
10129 openedFilter: null,
10130 getItemId: (item) => item.id,
10131 isItemClickable: () => true,
10132 renderItemLink: void 0,
10133 containerWidth: 0,
10134 containerRef: (0, import_element19.createRef)(),
10135 resizeObserverRef: () => {
10136 },
10137 defaultLayouts: { list: {}, grid: {}, table: {} },
10138 filters: [],
10139 isShowingFilter: false,
10140 setIsShowingFilter: () => {
10141 },
10142 hasInitiallyLoaded: false,
10143 config: {
10144 perPageSizes: []
10145 },
10146 intersectionObserver: null
10147 });
10148 DataViewsContext.displayName = "DataViewsContext";
10149 var dataviews_context_default = DataViewsContext;
10150
10151 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10152 var import_i18n22 = __toESM(require_i18n(), 1);
10153
10154 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10155 var import_i18n9 = __toESM(require_i18n(), 1);
10156 var import_components6 = __toESM(require_components(), 1);
10157 var import_element27 = __toESM(require_element(), 1);
10158 var import_keycodes = __toESM(require_keycodes(), 1);
10159
10160 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10161 var import_components = __toESM(require_components(), 1);
10162 var import_i18n2 = __toESM(require_i18n(), 1);
10163 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10164 function DataViewsSelectionCheckbox({
10165 selection,
10166 onChangeSelection,
10167 item,
10168 getItemId,
10169 titleField,
10170 disabled: disabled2,
10171 ...extraProps
10172 }) {
10173 const id = getItemId(item);
10174 const isInSelectionArray = selection.includes(id);
10175 const checked = !disabled2 && isInSelectionArray;
10176 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10177 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10178 import_components.CheckboxControl,
10179 {
10180 className: "dataviews-selection-checkbox",
10181 "aria-label": selectionLabel,
10182 "aria-disabled": disabled2,
10183 checked,
10184 onChange: () => {
10185 if (disabled2) {
10186 return;
10187 }
10188 onChangeSelection(
10189 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10190 );
10191 },
10192 ...extraProps
10193 }
10194 );
10195 }
10196
10197 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10198 var import_components2 = __toESM(require_components(), 1);
10199 var import_i18n3 = __toESM(require_i18n(), 1);
10200 var import_element20 = __toESM(require_element(), 1);
10201 var import_data4 = __toESM(require_data(), 1);
10202 var import_compose = __toESM(require_compose(), 1);
10203
10204 // packages/dataviews/build-module/lock-unlock.mjs
10205 var import_private_apis3 = __toESM(require_private_apis(), 1);
10206 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10207 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10208 "@wordpress/dataviews"
10209 );
10210
10211 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10212 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10213 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10214 function ButtonTrigger({
10215 action,
10216 onClick,
10217 items,
10218 variant
10219 }) {
10220 const label = typeof action.label === "string" ? action.label : action.label(items);
10221 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10222 import_components2.Button,
10223 {
10224 disabled: !!action.disabled,
10225 accessibleWhenDisabled: true,
10226 size: "compact",
10227 variant,
10228 onClick,
10229 children: label
10230 }
10231 );
10232 }
10233 function MenuItemTrigger({
10234 action,
10235 onClick,
10236 items
10237 }) {
10238 const label = typeof action.label === "string" ? action.label : action.label(items);
10239 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10240 }
10241 function ActionModal({
10242 action,
10243 items,
10244 closeModal
10245 }) {
10246 const label = typeof action.label === "string" ? action.label : action.label(items);
10247 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10248 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10249 import_components2.Modal,
10250 {
10251 title: modalHeader || label,
10252 __experimentalHideHeader: !!action.hideModalHeader,
10253 onRequestClose: closeModal,
10254 focusOnMount: action.modalFocusOnMount ?? true,
10255 size: action.modalSize || "medium",
10256 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10257 action.id
10258 )}`,
10259 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10260 }
10261 );
10262 }
10263 function ActionsMenuGroup({
10264 actions,
10265 item,
10266 registry,
10267 setActiveModalAction
10268 }) {
10269 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10270 return actions.reduce(
10271 (acc, action) => {
10272 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10273 return acc;
10274 },
10275 {
10276 primaryActions: [],
10277 regularActions: []
10278 }
10279 );
10280 }, [actions]);
10281 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10282 MenuItemTrigger,
10283 {
10284 action,
10285 onClick: () => {
10286 if ("RenderModal" in action) {
10287 setActiveModalAction(action);
10288 return;
10289 }
10290 action.callback([item], { registry });
10291 },
10292 items: [item]
10293 },
10294 action.id
10295 ));
10296 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10297 renderActionGroup(primaryActions),
10298 renderActionGroup(regularActions)
10299 ] });
10300 }
10301 function ItemActions({
10302 item,
10303 actions,
10304 isCompact
10305 }) {
10306 const registry = (0, import_data4.useRegistry)();
10307 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10308 const _eligibleActions = actions.filter(
10309 (action) => !action.isEligible || action.isEligible(item)
10310 );
10311 const _primaryActions = _eligibleActions.filter(
10312 (action) => action.isPrimary
10313 );
10314 return {
10315 primaryActions: _primaryActions,
10316 eligibleActions: _eligibleActions
10317 };
10318 }, [actions, item]);
10319 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10320 if (isCompact) {
10321 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10322 CompactItemActions,
10323 {
10324 item,
10325 actions: eligibleActions,
10326 isSmall: true,
10327 registry
10328 }
10329 );
10330 }
10331 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10332 Stack,
10333 {
10334 direction: "row",
10335 justify: "flex-end",
10336 className: "dataviews-item-actions",
10337 style: {
10338 flexShrink: 0,
10339 width: "auto"
10340 },
10341 children: [
10342 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10343 PrimaryActions,
10344 {
10345 item,
10346 actions: primaryActions,
10347 registry
10348 }
10349 ),
10350 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10351 // there if there are any actions at all.
10352 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10353 CompactItemActions,
10354 {
10355 item,
10356 actions: eligibleActions,
10357 registry
10358 }
10359 )
10360 ]
10361 }
10362 );
10363 }
10364 function CompactItemActions({
10365 item,
10366 actions,
10367 isSmall,
10368 registry
10369 }) {
10370 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
10371 null
10372 );
10373 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10374 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10375 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10376 Menu.TriggerButton,
10377 {
10378 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10379 import_components2.Button,
10380 {
10381 size: isSmall ? "small" : "compact",
10382 icon: more_vertical_default,
10383 label: (0, import_i18n3.__)("Actions"),
10384 accessibleWhenDisabled: true,
10385 disabled: !actions.length,
10386 className: "dataviews-all-actions-button"
10387 }
10388 )
10389 }
10390 ),
10391 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10392 ActionsMenuGroup,
10393 {
10394 actions,
10395 item,
10396 registry,
10397 setActiveModalAction
10398 }
10399 ) })
10400 ] }),
10401 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10402 ActionModal,
10403 {
10404 action: activeModalAction,
10405 items: [item],
10406 closeModal: () => setActiveModalAction(null)
10407 }
10408 )
10409 ] });
10410 }
10411 function PrimaryActions({
10412 item,
10413 actions,
10414 registry,
10415 buttonVariant
10416 }) {
10417 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
10418 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10419 if (isMobileViewport) {
10420 return null;
10421 }
10422 if (!Array.isArray(actions) || actions.length === 0) {
10423 return null;
10424 }
10425 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10426 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10427 ButtonTrigger,
10428 {
10429 action,
10430 onClick: () => {
10431 if ("RenderModal" in action) {
10432 setActiveModalAction(action);
10433 return;
10434 }
10435 action.callback([item], { registry });
10436 },
10437 items: [item],
10438 variant: buttonVariant
10439 },
10440 action.id
10441 )),
10442 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10443 ActionModal,
10444 {
10445 action: activeModalAction,
10446 items: [item],
10447 closeModal: () => setActiveModalAction(null)
10448 }
10449 )
10450 ] });
10451 }
10452
10453 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10454 var import_components3 = __toESM(require_components(), 1);
10455 var import_i18n5 = __toESM(require_i18n(), 1);
10456 var import_element21 = __toESM(require_element(), 1);
10457 var import_data5 = __toESM(require_data(), 1);
10458 var import_compose2 = __toESM(require_compose(), 1);
10459
10460 // packages/dataviews/build-module/utils/get-footer-message.mjs
10461 var import_i18n4 = __toESM(require_i18n(), 1);
10462 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10463 if (selectionCount > 0) {
10464 return (0, import_i18n4.sprintf)(
10465 /* translators: %d: number of items. */
10466 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10467 selectionCount
10468 );
10469 }
10470 if (onlyTotalCount || totalItems <= itemsCount) {
10471 return (0, import_i18n4.sprintf)(
10472 /* translators: %d: number of items. */
10473 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10474 totalItems
10475 );
10476 }
10477 return (0, import_i18n4.sprintf)(
10478 /* translators: %1$d: number of items. %2$d: total number of items. */
10479 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10480 itemsCount,
10481 totalItems
10482 );
10483 }
10484
10485 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10486 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10487 function ActionWithModal({
10488 action,
10489 items,
10490 ActionTriggerComponent
10491 }) {
10492 const [isModalOpen, setIsModalOpen] = (0, import_element21.useState)(false);
10493 const actionTriggerProps = {
10494 action,
10495 onClick: () => {
10496 setIsModalOpen(true);
10497 },
10498 items
10499 };
10500 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10501 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10502 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10503 ActionModal,
10504 {
10505 action,
10506 items,
10507 closeModal: () => setIsModalOpen(false)
10508 }
10509 )
10510 ] });
10511 }
10512 function useHasAPossibleBulkAction(actions, item) {
10513 return (0, import_element21.useMemo)(() => {
10514 return actions.some((action) => {
10515 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10516 });
10517 }, [actions, item]);
10518 }
10519 function useSomeItemHasAPossibleBulkAction(actions, data) {
10520 return (0, import_element21.useMemo)(() => {
10521 return data.some((item) => {
10522 return actions.some((action) => {
10523 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10524 });
10525 });
10526 }, [actions, data]);
10527 }
10528 function BulkSelectionCheckbox({
10529 selection,
10530 onChangeSelection,
10531 data,
10532 actions,
10533 getItemId,
10534 disableSelectAll = false
10535 }) {
10536 const selectableItems = (0, import_element21.useMemo)(() => {
10537 return data.filter((item) => {
10538 return actions.some(
10539 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10540 );
10541 });
10542 }, [data, actions]);
10543 const selectedItems = data.filter(
10544 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10545 );
10546 const hasSelection = selection.length > 0;
10547 const areAllSelected = selectedItems.length === selectableItems.length;
10548 if (disableSelectAll) {
10549 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10550 import_components3.CheckboxControl,
10551 {
10552 className: "dataviews-view-table-selection-checkbox",
10553 checked: hasSelection,
10554 disabled: !hasSelection,
10555 onChange: () => {
10556 onChangeSelection([]);
10557 },
10558 "aria-label": (0, import_i18n5.__)("Deselect all")
10559 }
10560 );
10561 }
10562 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10563 import_components3.CheckboxControl,
10564 {
10565 className: "dataviews-view-table-selection-checkbox",
10566 checked: areAllSelected,
10567 indeterminate: !areAllSelected && !!selectedItems.length,
10568 onChange: () => {
10569 if (areAllSelected) {
10570 onChangeSelection([]);
10571 } else {
10572 onChangeSelection(
10573 selectableItems.map((item) => getItemId(item))
10574 );
10575 }
10576 },
10577 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10578 }
10579 );
10580 }
10581 function ActionTrigger({
10582 action,
10583 onClick,
10584 isBusy,
10585 items
10586 }) {
10587 const label = typeof action.label === "string" ? action.label : action.label(items);
10588 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10589 if (isMobile) {
10590 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10591 import_components3.Button,
10592 {
10593 disabled: isBusy,
10594 accessibleWhenDisabled: true,
10595 label,
10596 icon: action.icon,
10597 size: "compact",
10598 onClick,
10599 isBusy
10600 }
10601 );
10602 }
10603 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10604 import_components3.Button,
10605 {
10606 disabled: isBusy,
10607 accessibleWhenDisabled: true,
10608 size: "compact",
10609 onClick,
10610 isBusy,
10611 children: label
10612 }
10613 );
10614 }
10615 var EMPTY_ARRAY2 = [];
10616 function ActionButton({
10617 action,
10618 selectedItems,
10619 actionInProgress,
10620 setActionInProgress
10621 }) {
10622 const registry = (0, import_data5.useRegistry)();
10623 const selectedEligibleItems = (0, import_element21.useMemo)(() => {
10624 return selectedItems.filter((item) => {
10625 return !action.isEligible || action.isEligible(item);
10626 });
10627 }, [action, selectedItems]);
10628 if ("RenderModal" in action) {
10629 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10630 ActionWithModal,
10631 {
10632 action,
10633 items: selectedEligibleItems,
10634 ActionTriggerComponent: ActionTrigger
10635 },
10636 action.id
10637 );
10638 }
10639 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10640 ActionTrigger,
10641 {
10642 action,
10643 onClick: async () => {
10644 setActionInProgress(action.id);
10645 await action.callback(selectedItems, {
10646 registry
10647 });
10648 setActionInProgress(null);
10649 },
10650 items: selectedEligibleItems,
10651 isBusy: actionInProgress === action.id
10652 },
10653 action.id
10654 );
10655 }
10656 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10657 const message2 = getFooterMessage(
10658 selection.length,
10659 data.length,
10660 paginationInfo.totalItems,
10661 isInfiniteScroll
10662 );
10663 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10664 Stack,
10665 {
10666 direction: "row",
10667 className: "dataviews-bulk-actions-footer__container",
10668 gap: "md",
10669 align: "center",
10670 children: [
10671 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10672 BulkSelectionCheckbox,
10673 {
10674 selection,
10675 onChangeSelection,
10676 data,
10677 actions,
10678 getItemId,
10679 disableSelectAll: isInfiniteScroll
10680 }
10681 ),
10682 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10683 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10684 Stack,
10685 {
10686 direction: "row",
10687 className: "dataviews-bulk-actions-footer__action-buttons",
10688 gap: "xs",
10689 children: [
10690 actionsToShow.map((action) => {
10691 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10692 ActionButton,
10693 {
10694 action,
10695 selectedItems,
10696 actionInProgress,
10697 setActionInProgress
10698 },
10699 action.id
10700 );
10701 }),
10702 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10703 import_components3.Button,
10704 {
10705 icon: close_small_default,
10706 showTooltip: true,
10707 tooltipPosition: "top",
10708 size: "compact",
10709 label: (0, import_i18n5.__)("Cancel"),
10710 disabled: !!actionInProgress,
10711 accessibleWhenDisabled: false,
10712 onClick: () => {
10713 onChangeSelection(EMPTY_ARRAY2);
10714 }
10715 }
10716 )
10717 ]
10718 }
10719 )
10720 ]
10721 }
10722 );
10723 }
10724 function FooterContent({
10725 selection,
10726 actions,
10727 onChangeSelection,
10728 data,
10729 getItemId,
10730 isInfiniteScroll,
10731 paginationInfo
10732 }) {
10733 const [actionInProgress, setActionInProgress] = (0, import_element21.useState)(
10734 null
10735 );
10736 const footerContentRef = (0, import_element21.useRef)(void 0);
10737 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10738 const bulkActions = (0, import_element21.useMemo)(
10739 () => actions.filter((action) => action.supportsBulk),
10740 [actions]
10741 );
10742 const selectableItems = (0, import_element21.useMemo)(() => {
10743 return data.filter((item) => {
10744 return bulkActions.some(
10745 (action) => !action.isEligible || action.isEligible(item)
10746 );
10747 });
10748 }, [data, bulkActions]);
10749 const selectedItems = (0, import_element21.useMemo)(() => {
10750 return data.filter(
10751 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10752 );
10753 }, [selection, data, getItemId, selectableItems]);
10754 const actionsToShow = (0, import_element21.useMemo)(
10755 () => actions.filter((action) => {
10756 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10757 (item) => !action.isEligible || action.isEligible(item)
10758 );
10759 }),
10760 [actions, selectedItems, isMobile]
10761 );
10762 if (!actionInProgress) {
10763 if (footerContentRef.current) {
10764 footerContentRef.current = void 0;
10765 }
10766 return renderFooterContent(
10767 data,
10768 actions,
10769 getItemId,
10770 isInfiniteScroll,
10771 selection,
10772 actionsToShow,
10773 selectedItems,
10774 actionInProgress,
10775 setActionInProgress,
10776 onChangeSelection,
10777 paginationInfo
10778 );
10779 } else if (!footerContentRef.current) {
10780 footerContentRef.current = renderFooterContent(
10781 data,
10782 actions,
10783 getItemId,
10784 isInfiniteScroll,
10785 selection,
10786 actionsToShow,
10787 selectedItems,
10788 actionInProgress,
10789 setActionInProgress,
10790 onChangeSelection,
10791 paginationInfo
10792 );
10793 }
10794 return footerContentRef.current;
10795 }
10796 function BulkActionsFooter() {
10797 const {
10798 data,
10799 selection,
10800 actions = EMPTY_ARRAY2,
10801 onChangeSelection,
10802 getItemId,
10803 paginationInfo,
10804 view
10805 } = (0, import_element21.useContext)(dataviews_context_default);
10806 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10807 FooterContent,
10808 {
10809 selection,
10810 onChangeSelection,
10811 data,
10812 actions,
10813 getItemId,
10814 isInfiniteScroll: !!view.infiniteScrollEnabled,
10815 paginationInfo
10816 }
10817 );
10818 }
10819
10820 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10821 var import_i18n6 = __toESM(require_i18n(), 1);
10822 var import_components4 = __toESM(require_components(), 1);
10823 var import_element22 = __toESM(require_element(), 1);
10824
10825 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10826 function getHideableFields(view, fields) {
10827 const togglableFields = [
10828 view?.titleField,
10829 view?.mediaField,
10830 view?.descriptionField
10831 ].filter(Boolean);
10832 return fields.filter(
10833 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10834 );
10835 }
10836
10837 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10838 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10839 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10840 function WithMenuSeparators({ children }) {
10841 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element22.Fragment, { children: [
10842 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10843 child
10844 ] }, i2));
10845 }
10846 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
10847 fieldId,
10848 view,
10849 fields,
10850 onChangeView,
10851 onHide,
10852 setOpenedFilter,
10853 canMove = true,
10854 canInsertLeft = true,
10855 canInsertRight = true
10856 }, ref) {
10857 const visibleFieldIds = view.fields ?? [];
10858 const index2 = visibleFieldIds?.indexOf(fieldId);
10859 const isSorted = view.sort?.field === fieldId;
10860 let isHidable = false;
10861 let isSortable = false;
10862 let canAddFilter = false;
10863 let operators = [];
10864 const field = fields.find((f2) => f2.id === fieldId);
10865 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
10866 if (!field) {
10867 return null;
10868 }
10869 isHidable = field.enableHiding !== false;
10870 isSortable = field.enableSorting !== false;
10871 const header = field.header;
10872 operators = !!field.filterBy && field.filterBy?.operators || [];
10873 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10874 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10875 return header;
10876 }
10877 const hiddenFields = getHideableFields(view, fields).filter(
10878 (f2) => !visibleFieldIds.includes(f2.id)
10879 );
10880 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10881 const isRtl = (0, import_i18n6.isRTL)();
10882 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10883 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10884 Menu2.TriggerButton,
10885 {
10886 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10887 import_components4.Button,
10888 {
10889 size: "compact",
10890 className: "dataviews-view-table-header-button",
10891 ref,
10892 variant: "tertiary"
10893 }
10894 ),
10895 children: [
10896 header,
10897 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
10898 ]
10899 }
10900 ),
10901 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
10902 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
10903 (direction) => {
10904 const isChecked = view.sort && isSorted && view.sort.direction === direction;
10905 const value = `${fieldId}-${direction}`;
10906 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10907 Menu2.RadioItem,
10908 {
10909 name: "view-table-sorting",
10910 value,
10911 checked: isChecked,
10912 onChange: () => {
10913 onChangeView({
10914 ...view,
10915 sort: {
10916 field: fieldId,
10917 direction
10918 },
10919 showLevels: false
10920 });
10921 },
10922 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
10923 },
10924 value
10925 );
10926 }
10927 ) }),
10928 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10929 Menu2.Item,
10930 {
10931 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
10932 onClick: () => {
10933 setOpenedFilter(fieldId);
10934 setIsShowingFilter(true);
10935 onChangeView({
10936 ...view,
10937 page: 1,
10938 filters: [
10939 ...view.filters || [],
10940 {
10941 field: fieldId,
10942 value: void 0,
10943 operator: operators[0]
10944 }
10945 ]
10946 });
10947 },
10948 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
10949 }
10950 ) }),
10951 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
10952 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10953 Menu2.Item,
10954 {
10955 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
10956 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
10957 onClick: () => {
10958 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
10959 const newFields = [
10960 ...visibleFieldIds
10961 ];
10962 newFields.splice(index2, 1);
10963 newFields.splice(
10964 targetIndex,
10965 0,
10966 fieldId
10967 );
10968 onChangeView({
10969 ...view,
10970 fields: newFields
10971 });
10972 },
10973 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
10974 }
10975 ),
10976 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10977 Menu2.Item,
10978 {
10979 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
10980 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
10981 onClick: () => {
10982 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
10983 const newFields = [
10984 ...visibleFieldIds
10985 ];
10986 newFields.splice(index2, 1);
10987 newFields.splice(
10988 targetIndex,
10989 0,
10990 fieldId
10991 );
10992 onChangeView({
10993 ...view,
10994 fields: newFields
10995 });
10996 },
10997 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
10998 }
10999 ),
11000 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11001 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
11002 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11003 const insertIndex = isRtl ? index2 + 1 : index2;
11004 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11005 Menu2.Item,
11006 {
11007 onClick: () => {
11008 onChangeView({
11009 ...view,
11010 fields: [
11011 ...visibleFieldIds.slice(
11012 0,
11013 insertIndex
11014 ),
11015 hiddenField.id,
11016 ...visibleFieldIds.slice(
11017 insertIndex
11018 )
11019 ]
11020 });
11021 },
11022 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11023 },
11024 hiddenField.id
11025 );
11026 }) })
11027 ] }),
11028 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11029 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
11030 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11031 const insertIndex = isRtl ? index2 : index2 + 1;
11032 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11033 Menu2.Item,
11034 {
11035 onClick: () => {
11036 onChangeView({
11037 ...view,
11038 fields: [
11039 ...visibleFieldIds.slice(
11040 0,
11041 insertIndex
11042 ),
11043 hiddenField.id,
11044 ...visibleFieldIds.slice(
11045 insertIndex
11046 )
11047 ]
11048 });
11049 },
11050 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11051 },
11052 hiddenField.id
11053 );
11054 }) })
11055 ] }),
11056 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11057 Menu2.Item,
11058 {
11059 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
11060 onClick: () => {
11061 onHide(field);
11062 onChangeView({
11063 ...view,
11064 fields: visibleFieldIds.filter(
11065 (id) => id !== fieldId
11066 )
11067 });
11068 },
11069 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
11070 }
11071 )
11072 ] })
11073 ] }) })
11074 ] });
11075 });
11076 var ColumnHeaderMenu = _HeaderMenu;
11077 var column_header_menu_default = ColumnHeaderMenu;
11078
11079 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11080 var import_element23 = __toESM(require_element(), 1);
11081 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11082 function getClickableItemProps({
11083 item,
11084 isItemClickable,
11085 onClickItem,
11086 className
11087 }) {
11088 if (!isItemClickable(item) || !onClickItem) {
11089 return { className };
11090 }
11091 return {
11092 className: className ? `${className} ${className}--clickable` : void 0,
11093 role: "button",
11094 tabIndex: 0,
11095 onClick: (event) => {
11096 event.stopPropagation();
11097 onClickItem(item);
11098 },
11099 onKeyDown: (event) => {
11100 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11101 event.stopPropagation();
11102 onClickItem(item);
11103 }
11104 }
11105 };
11106 }
11107 function ItemClickWrapper({
11108 item,
11109 isItemClickable,
11110 onClickItem,
11111 renderItemLink,
11112 className,
11113 children,
11114 ...extraProps
11115 }) {
11116 if (!isItemClickable(item)) {
11117 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
11118 }
11119 if (renderItemLink) {
11120 const renderedElement = renderItemLink({
11121 item,
11122 className: `${className} ${className}--clickable`,
11123 ...extraProps,
11124 children
11125 });
11126 return (0, import_element23.cloneElement)(renderedElement, {
11127 onClick: (event) => {
11128 event.stopPropagation();
11129 if (renderedElement.props.onClick) {
11130 renderedElement.props.onClick(event);
11131 }
11132 },
11133 onKeyDown: (event) => {
11134 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11135 event.stopPropagation();
11136 if (renderedElement.props.onKeyDown) {
11137 renderedElement.props.onKeyDown(event);
11138 }
11139 }
11140 }
11141 });
11142 }
11143 const clickProps = getClickableItemProps({
11144 item,
11145 isItemClickable,
11146 onClickItem,
11147 className
11148 });
11149 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
11150 }
11151
11152 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11153 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11154 function ColumnPrimary({
11155 item,
11156 level,
11157 titleField,
11158 mediaField,
11159 descriptionField,
11160 onClickItem,
11161 renderItemLink,
11162 isItemClickable
11163 }) {
11164 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11165 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11166 ItemClickWrapper,
11167 {
11168 item,
11169 isItemClickable,
11170 onClickItem,
11171 renderItemLink,
11172 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11173 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11174 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11175 mediaField.render,
11176 {
11177 item,
11178 field: mediaField,
11179 config: { sizes: "32px" }
11180 }
11181 )
11182 }
11183 ),
11184 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11185 Stack,
11186 {
11187 direction: "column",
11188 align: "flex-start",
11189 className: "dataviews-view-table__primary-column-content",
11190 children: [
11191 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11192 ItemClickWrapper,
11193 {
11194 item,
11195 isItemClickable,
11196 onClickItem,
11197 renderItemLink,
11198 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11199 children: [
11200 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11201 Array(level).fill("\u2014").join(" "),
11202 "\xA0"
11203 ] }),
11204 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11205 ]
11206 }
11207 ),
11208 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11209 descriptionField.render,
11210 {
11211 item,
11212 field: descriptionField
11213 }
11214 )
11215 ]
11216 }
11217 )
11218 ] });
11219 }
11220 var column_primary_default = ColumnPrimary;
11221
11222 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11223 var import_element24 = __toESM(require_element(), 1);
11224 var import_i18n7 = __toESM(require_i18n(), 1);
11225 var isScrolledToEnd = (element) => {
11226 if ((0, import_i18n7.isRTL)()) {
11227 const scrollLeft = Math.abs(element.scrollLeft);
11228 return scrollLeft <= 1;
11229 }
11230 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11231 };
11232 function useScrollState({
11233 scrollContainerRef,
11234 enabledHorizontal = false
11235 }) {
11236 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11237 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11238 const handleScroll = (0, import_element24.useCallback)(() => {
11239 const scrollContainer = scrollContainerRef.current;
11240 if (!scrollContainer) {
11241 return;
11242 }
11243 if (enabledHorizontal) {
11244 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11245 }
11246 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11247 }, [scrollContainerRef, enabledHorizontal]);
11248 (0, import_element24.useEffect)(() => {
11249 if (typeof window === "undefined" || !scrollContainerRef.current) {
11250 return () => {
11251 };
11252 }
11253 const scrollContainer = scrollContainerRef.current;
11254 handleScroll();
11255 scrollContainer.addEventListener("scroll", handleScroll);
11256 window.addEventListener("resize", handleScroll);
11257 return () => {
11258 scrollContainer.removeEventListener("scroll", handleScroll);
11259 window.removeEventListener("resize", handleScroll);
11260 };
11261 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11262 return { isHorizontalScrollEnd, isVerticallyScrolled };
11263 }
11264
11265 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11266 function getDataByGroup(data, groupByField) {
11267 return data.reduce((groups, item) => {
11268 const groupName = groupByField.getValue({ item });
11269 if (!groups.has(groupName)) {
11270 groups.set(groupName, []);
11271 }
11272 groups.get(groupName)?.push(item);
11273 return groups;
11274 }, /* @__PURE__ */ new Map());
11275 }
11276
11277 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11278 var import_components5 = __toESM(require_components(), 1);
11279 var import_i18n8 = __toESM(require_i18n(), 1);
11280 var import_element25 = __toESM(require_element(), 1);
11281 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11282 function FieldItem({
11283 field,
11284 isVisible: isVisible2,
11285 onToggleVisibility
11286 }) {
11287 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: [
11288 /* @__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 }) }),
11289 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11290 ] }) });
11291 }
11292 function isDefined(item) {
11293 return !!item;
11294 }
11295 function PropertiesSection({
11296 showLabel = true
11297 }) {
11298 const { view, fields, onChangeView } = (0, import_element25.useContext)(dataviews_context_default);
11299 const regularFields = getHideableFields(view, fields);
11300 if (!regularFields?.length) {
11301 return null;
11302 }
11303 const titleField = fields.find((f2) => f2.id === view.titleField);
11304 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11305 const descriptionField = fields.find(
11306 (f2) => f2.id === view.descriptionField
11307 );
11308 const lockedFields = [
11309 {
11310 field: titleField,
11311 isVisibleFlag: "showTitle"
11312 },
11313 {
11314 field: previewField2,
11315 isVisibleFlag: "showMedia"
11316 },
11317 {
11318 field: descriptionField,
11319 isVisibleFlag: "showDescription"
11320 }
11321 ].filter(({ field }) => isDefined(field));
11322 const visibleFieldIds = view.fields ?? [];
11323 const visibleRegularFieldsCount = regularFields.filter(
11324 (f2) => visibleFieldIds.includes(f2.id)
11325 ).length;
11326 const visibleLockedFields = lockedFields.filter(
11327 ({ isVisibleFlag }) => (
11328 // @ts-expect-error
11329 view[isVisibleFlag] ?? true
11330 )
11331 );
11332 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11333 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11334 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11335 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11336 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11337 Stack,
11338 {
11339 direction: "column",
11340 className: "dataviews-view-config__properties",
11341 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11342 lockedFields.map(({ field, isVisibleFlag }) => {
11343 const isVisible2 = view[isVisibleFlag] ?? true;
11344 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11345 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11346 FieldItem,
11347 {
11348 field: fieldToRender,
11349 isVisible: isVisible2,
11350 onToggleVisibility: () => {
11351 onChangeView({
11352 ...view,
11353 [isVisibleFlag]: !isVisible2
11354 });
11355 }
11356 },
11357 field.id
11358 );
11359 }),
11360 regularFields.map((field) => {
11361 const isVisible2 = visibleFieldIds.includes(field.id);
11362 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11363 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11364 FieldItem,
11365 {
11366 field: fieldToRender,
11367 isVisible: isVisible2,
11368 onToggleVisibility: () => {
11369 onChangeView({
11370 ...view,
11371 fields: isVisible2 ? visibleFieldIds.filter(
11372 (fieldId) => fieldId !== field.id
11373 ) : [...visibleFieldIds, field.id]
11374 });
11375 }
11376 },
11377 field.id
11378 );
11379 })
11380 ] })
11381 }
11382 )
11383 ] });
11384 }
11385
11386 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11387 var import_element26 = __toESM(require_element(), 1);
11388 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11389 const [showLoader, setShowLoader] = (0, import_element26.useState)(false);
11390 (0, import_element26.useEffect)(() => {
11391 if (!isLoading) {
11392 return;
11393 }
11394 const timeout = setTimeout(() => {
11395 setShowLoader(true);
11396 }, options.delay);
11397 return () => {
11398 clearTimeout(timeout);
11399 setShowLoader(false);
11400 };
11401 }, [isLoading, options.delay]);
11402 return showLoader;
11403 }
11404
11405 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11406 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11407 function getEffectiveAlign(explicitAlign, fieldType) {
11408 if (explicitAlign) {
11409 return explicitAlign;
11410 }
11411 if (fieldType === "integer" || fieldType === "number") {
11412 return "end";
11413 }
11414 return void 0;
11415 }
11416 function TableColumnField({
11417 item,
11418 fields,
11419 column,
11420 align
11421 }) {
11422 const field = fields.find((f2) => f2.id === column);
11423 if (!field) {
11424 return null;
11425 }
11426 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11427 "dataviews-view-table__cell-align-end": align === "end",
11428 "dataviews-view-table__cell-align-center": align === "center"
11429 });
11430 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11431 }
11432 function TableRow({
11433 hasBulkActions,
11434 item,
11435 level,
11436 actions,
11437 fields,
11438 id,
11439 view,
11440 titleField,
11441 mediaField,
11442 descriptionField,
11443 selection,
11444 getItemId,
11445 isItemClickable,
11446 onClickItem,
11447 renderItemLink,
11448 onChangeSelection,
11449 isActionsColumnSticky,
11450 posinset
11451 }) {
11452 const { paginationInfo } = (0, import_element27.useContext)(dataviews_context_default);
11453 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11454 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11455 const {
11456 showTitle = true,
11457 showMedia = true,
11458 showDescription = true,
11459 infiniteScrollEnabled
11460 } = view;
11461 const isTouchDeviceRef = (0, import_element27.useRef)(false);
11462 const columns = view.fields ?? [];
11463 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11464 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11465 "tr",
11466 {
11467 className: clsx_default("dataviews-view-table__row", {
11468 "is-selected": hasPossibleBulkAction && isSelected2,
11469 "has-bulk-actions": hasPossibleBulkAction
11470 }),
11471 onTouchStart: () => {
11472 isTouchDeviceRef.current = true;
11473 },
11474 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11475 "aria-posinset": posinset,
11476 role: infiniteScrollEnabled ? "article" : void 0,
11477 onMouseDown: (event) => {
11478 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11479 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11480 event?.preventDefault();
11481 }
11482 },
11483 onClick: (event) => {
11484 if (!hasPossibleBulkAction) {
11485 return;
11486 }
11487 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11488 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11489 onChangeSelection(
11490 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11491 );
11492 }
11493 },
11494 children: [
11495 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)(
11496 DataViewsSelectionCheckbox,
11497 {
11498 item,
11499 selection,
11500 onChangeSelection,
11501 getItemId,
11502 titleField,
11503 disabled: !hasPossibleBulkAction
11504 }
11505 ) }) }),
11506 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11507 column_primary_default,
11508 {
11509 item,
11510 level,
11511 titleField: showTitle ? titleField : void 0,
11512 mediaField: showMedia ? mediaField : void 0,
11513 descriptionField: showDescription ? descriptionField : void 0,
11514 isItemClickable,
11515 onClickItem,
11516 renderItemLink
11517 }
11518 ) }),
11519 columns.map((column) => {
11520 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11521 const field = fields.find((f2) => f2.id === column);
11522 const effectiveAlign = getEffectiveAlign(align, field?.type);
11523 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11524 "td",
11525 {
11526 style: {
11527 width,
11528 maxWidth,
11529 minWidth
11530 },
11531 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11532 TableColumnField,
11533 {
11534 fields,
11535 item,
11536 column,
11537 align: effectiveAlign
11538 }
11539 )
11540 },
11541 column
11542 );
11543 }),
11544 !!actions?.length && // Disable reason: we are not making the element interactive,
11545 // but preventing any click events from bubbling up to the
11546 // table row. This allows us to add a click handler to the row
11547 // itself (to toggle row selection) without erroneously
11548 // intercepting click events from ItemActions.
11549 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11550 "td",
11551 {
11552 className: clsx_default("dataviews-view-table__actions-column", {
11553 "dataviews-view-table__actions-column--sticky": true,
11554 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11555 }),
11556 onClick: (e2) => e2.stopPropagation(),
11557 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11558 }
11559 )
11560 ]
11561 }
11562 );
11563 }
11564 function ViewTable({
11565 actions,
11566 data,
11567 fields,
11568 getItemId,
11569 getItemLevel,
11570 isLoading = false,
11571 onChangeView,
11572 onChangeSelection,
11573 selection,
11574 setOpenedFilter,
11575 onClickItem,
11576 isItemClickable,
11577 renderItemLink,
11578 view,
11579 className,
11580 empty
11581 }) {
11582 const { containerRef } = (0, import_element27.useContext)(dataviews_context_default);
11583 const isDelayedLoading = useDelayedLoading(isLoading);
11584 const headerMenuRefs = (0, import_element27.useRef)(/* @__PURE__ */ new Map());
11585 const headerMenuToFocusRef = (0, import_element27.useRef)(void 0);
11586 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element27.useState)();
11587 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element27.useState)(null);
11588 (0, import_element27.useEffect)(() => {
11589 if (headerMenuToFocusRef.current) {
11590 headerMenuToFocusRef.current.focus();
11591 headerMenuToFocusRef.current = void 0;
11592 }
11593 });
11594 const tableNoticeId = (0, import_element27.useId)();
11595 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11596 scrollContainerRef: containerRef,
11597 enabledHorizontal: !!actions?.length
11598 });
11599 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11600 if (nextHeaderMenuToFocus) {
11601 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11602 setNextHeaderMenuToFocus(void 0);
11603 return;
11604 }
11605 const onHide = (field) => {
11606 const hidden = headerMenuRefs.current.get(field.id);
11607 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11608 setNextHeaderMenuToFocus(fallback?.node);
11609 };
11610 const handleHeaderContextMenu = (event) => {
11611 event.preventDefault();
11612 event.stopPropagation();
11613 const virtualAnchor = {
11614 getBoundingClientRect: () => ({
11615 x: event.clientX,
11616 y: event.clientY,
11617 top: event.clientY,
11618 left: event.clientX,
11619 right: event.clientX,
11620 bottom: event.clientY,
11621 width: 0,
11622 height: 0,
11623 toJSON: () => ({})
11624 })
11625 };
11626 window.requestAnimationFrame(() => {
11627 setContextMenuAnchor(virtualAnchor);
11628 });
11629 };
11630 const hasData = !!data?.length;
11631 const titleField = fields.find((field) => field.id === view.titleField);
11632 const mediaField = fields.find((field) => field.id === view.mediaField);
11633 const descriptionField = fields.find(
11634 (field) => field.id === view.descriptionField
11635 );
11636 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11637 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11638 const { showTitle = true, showMedia = true, showDescription = true } = view;
11639 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11640 const columns = view.fields ?? [];
11641 const headerMenuRef = (column, index2) => (node) => {
11642 if (node) {
11643 headerMenuRefs.current.set(column, {
11644 node,
11645 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11646 });
11647 } else {
11648 headerMenuRefs.current.delete(column);
11649 }
11650 };
11651 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11652 const isRtl = (0, import_i18n9.isRTL)();
11653 if (!hasData) {
11654 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11655 "div",
11656 {
11657 className: clsx_default("dataviews-no-results", {
11658 "is-refreshing": isDelayedLoading
11659 }),
11660 id: tableNoticeId,
11661 children: empty
11662 }
11663 );
11664 }
11665 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11666 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11667 "table",
11668 {
11669 className: clsx_default("dataviews-view-table", className, {
11670 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11671 view.layout.density
11672 ),
11673 "has-bulk-actions": hasBulkActions,
11674 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11675 }),
11676 "aria-busy": isLoading,
11677 "aria-describedby": tableNoticeId,
11678 role: isInfiniteScroll ? "feed" : void 0,
11679 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11680 children: [
11681 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11682 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11683 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11684 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11685 "col",
11686 {
11687 className: clsx_default(
11688 `dataviews-view-table__col-${column}`,
11689 {
11690 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11691 }
11692 )
11693 },
11694 `col-${column}`
11695 )),
11696 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11697 ] }),
11698 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11699 import_components6.Popover,
11700 {
11701 anchor: contextMenuAnchor,
11702 onClose: () => setContextMenuAnchor(null),
11703 placement: "bottom-start",
11704 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11705 }
11706 ),
11707 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11708 "thead",
11709 {
11710 className: clsx_default({
11711 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11712 }),
11713 onContextMenu: handleHeaderContextMenu,
11714 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11715 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11716 "th",
11717 {
11718 className: "dataviews-view-table__checkbox-column",
11719 scope: "col",
11720 onContextMenu: handleHeaderContextMenu,
11721 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11722 BulkSelectionCheckbox,
11723 {
11724 selection,
11725 onChangeSelection,
11726 data,
11727 actions,
11728 getItemId
11729 }
11730 )
11731 }
11732 ),
11733 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11734 column_header_menu_default,
11735 {
11736 ref: headerMenuRef(
11737 titleField.id,
11738 0
11739 ),
11740 fieldId: titleField.id,
11741 view,
11742 fields,
11743 onChangeView,
11744 onHide,
11745 setOpenedFilter,
11746 canMove: false,
11747 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11748 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
11749 }
11750 ) }),
11751 columns.map((column, index2) => {
11752 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11753 const field = fields.find(
11754 (f2) => f2.id === column
11755 );
11756 const effectiveAlign = getEffectiveAlign(
11757 align,
11758 field?.type
11759 );
11760 const canInsertOrMove = view.layout?.enableMoving ?? true;
11761 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11762 "th",
11763 {
11764 style: {
11765 width,
11766 maxWidth,
11767 minWidth,
11768 textAlign: effectiveAlign
11769 },
11770 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
11771 scope: "col",
11772 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11773 column_header_menu_default,
11774 {
11775 ref: headerMenuRef(column, index2),
11776 fieldId: column,
11777 view,
11778 fields,
11779 onChangeView,
11780 onHide,
11781 setOpenedFilter,
11782 canMove: canInsertOrMove,
11783 canInsertLeft: canInsertOrMove,
11784 canInsertRight: canInsertOrMove
11785 }
11786 )
11787 },
11788 column
11789 );
11790 }),
11791 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11792 "th",
11793 {
11794 className: clsx_default(
11795 "dataviews-view-table__actions-column",
11796 {
11797 "dataviews-view-table__actions-column--sticky": true,
11798 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
11799 }
11800 ),
11801 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
11802 }
11803 )
11804 ] })
11805 }
11806 ),
11807 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
11808 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
11809 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11810 "td",
11811 {
11812 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
11813 className: "dataviews-view-table__group-header-cell",
11814 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
11815 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
11816 (0, import_i18n9.__)("%1$s: %2$s"),
11817 groupField.label,
11818 groupName
11819 )
11820 }
11821 ) }),
11822 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11823 TableRow,
11824 {
11825 item,
11826 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11827 hasBulkActions,
11828 actions,
11829 fields,
11830 id: getItemId(item) || index2.toString(),
11831 view,
11832 titleField,
11833 mediaField,
11834 descriptionField,
11835 selection,
11836 getItemId,
11837 onChangeSelection,
11838 onClickItem,
11839 renderItemLink,
11840 isItemClickable,
11841 isActionsColumnSticky: !isHorizontalScrollEnd
11842 },
11843 getItemId(item)
11844 ))
11845 ] }, `group-${groupName}`)
11846 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11847 TableRow,
11848 {
11849 item,
11850 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11851 hasBulkActions,
11852 actions,
11853 fields,
11854 id: getItemId(item) || index2.toString(),
11855 view,
11856 titleField,
11857 mediaField,
11858 descriptionField,
11859 selection,
11860 getItemId,
11861 onChangeSelection,
11862 onClickItem,
11863 renderItemLink,
11864 isItemClickable,
11865 isActionsColumnSticky: !isHorizontalScrollEnd,
11866 posinset: isInfiniteScroll ? index2 + 1 : void 0
11867 },
11868 getItemId(item)
11869 )) })
11870 ]
11871 }
11872 ),
11873 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, {}) }) })
11874 ] });
11875 }
11876 var table_default = ViewTable;
11877
11878 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
11879 var import_components9 = __toESM(require_components(), 1);
11880 var import_i18n12 = __toESM(require_i18n(), 1);
11881
11882 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11883 var import_components8 = __toESM(require_components(), 1);
11884 var import_i18n11 = __toESM(require_i18n(), 1);
11885 var import_compose3 = __toESM(require_compose(), 1);
11886 var import_keycodes2 = __toESM(require_keycodes(), 1);
11887 var import_element31 = __toESM(require_element(), 1);
11888
11889 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
11890 var import_components7 = __toESM(require_components(), 1);
11891 var import_i18n10 = __toESM(require_i18n(), 1);
11892 var import_element28 = __toESM(require_element(), 1);
11893 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11894 var imageSizes = [
11895 {
11896 value: 120,
11897 breakpoint: 1
11898 },
11899 {
11900 value: 170,
11901 breakpoint: 1
11902 },
11903 {
11904 value: 230,
11905 breakpoint: 1
11906 },
11907 {
11908 value: 290,
11909 breakpoint: 1112
11910 // at minimum image width, 4 images display at this container size
11911 },
11912 {
11913 value: 350,
11914 breakpoint: 1636
11915 // at minimum image width, 6 images display at this container size
11916 },
11917 {
11918 value: 430,
11919 breakpoint: 588
11920 // at minimum image width, 2 images display at this container size
11921 }
11922 ];
11923 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
11924 function useGridColumns() {
11925 const context = (0, import_element28.useContext)(dataviews_context_default);
11926 const view = context.view;
11927 return (0, import_element28.useMemo)(() => {
11928 const containerWidth = context.containerWidth;
11929 const gap = 32;
11930 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
11931 const columns = Math.floor(
11932 (containerWidth + gap) / (previewSize + gap)
11933 );
11934 return Math.max(1, columns);
11935 }, [context.containerWidth, view.layout?.previewSize]);
11936 }
11937
11938 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
11939 var import_element29 = __toESM(require_element(), 1);
11940 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11941 var GridItems = (0, import_element29.forwardRef)(({ className, previewSize, ...props }, ref) => {
11942 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11943 "div",
11944 {
11945 ref,
11946 className: clsx_default("dataviews-view-grid-items", className),
11947 style: {
11948 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
11949 },
11950 ...props
11951 }
11952 );
11953 });
11954
11955 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
11956 var import_element30 = __toESM(require_element(), 1);
11957 function useIntersectionObserver(elementRef, posinset) {
11958 const { intersectionObserver } = (0, import_element30.useContext)(dataviews_context_default);
11959 (0, import_element30.useEffect)(() => {
11960 const element = elementRef.current;
11961 if (!element || posinset === void 0 || !intersectionObserver) {
11962 return;
11963 }
11964 intersectionObserver.observe(element);
11965 return () => {
11966 intersectionObserver.unobserve(element);
11967 };
11968 }, [elementRef, intersectionObserver, posinset]);
11969 }
11970 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
11971 const hasData = !!data?.length;
11972 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
11973 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
11974 }
11975
11976 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11977 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11978 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
11979 function chunk(array, size4) {
11980 const chunks = [];
11981 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
11982 chunks.push(array.slice(i2, i2 + size4));
11983 }
11984 return chunks;
11985 }
11986 var GridItem = (0, import_element31.forwardRef)(
11987 function GridItem2({
11988 view,
11989 selection,
11990 onChangeSelection,
11991 onClickItem,
11992 isItemClickable,
11993 renderItemLink,
11994 getItemId,
11995 item,
11996 actions,
11997 mediaField,
11998 titleField,
11999 descriptionField,
12000 regularFields,
12001 badgeFields,
12002 hasBulkActions,
12003 config,
12004 posinset,
12005 setsize,
12006 ...props
12007 }, forwardedRef) {
12008 const {
12009 showTitle = true,
12010 showMedia = true,
12011 showDescription = true
12012 } = view;
12013 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12014 const id = getItemId(item);
12015 const elementRef = (0, import_element31.useRef)(null);
12016 const setRefs = (0, import_element31.useCallback)(
12017 (node) => {
12018 elementRef.current = node;
12019 if (typeof forwardedRef === "function") {
12020 forwardedRef(node);
12021 } else if (forwardedRef) {
12022 forwardedRef.current = node;
12023 }
12024 },
12025 [forwardedRef]
12026 );
12027 useIntersectionObserver(elementRef, posinset);
12028 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12029 const isSelected2 = selection.includes(id);
12030 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12031 const rendersMediaField = showMedia && mediaField?.render;
12032 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12033 mediaField.render,
12034 {
12035 item,
12036 field: mediaField,
12037 config
12038 }
12039 ) : mediaPlaceholder;
12040 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
12041 let mediaA11yProps;
12042 let titleA11yProps;
12043 if (isItemClickable(item) && onClickItem) {
12044 if (renderedTitleField) {
12045 mediaA11yProps = {
12046 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12047 };
12048 titleA11yProps = {
12049 id: `dataviews-view-grid__title-field-${instanceId}`
12050 };
12051 } else {
12052 mediaA11yProps = {
12053 "aria-label": (0, import_i18n11.__)("Navigate to item")
12054 };
12055 }
12056 }
12057 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12058 Stack,
12059 {
12060 direction: "column",
12061 ...props,
12062 ref: setRefs,
12063 "aria-setsize": setsize,
12064 "aria-posinset": posinset,
12065 className: clsx_default(
12066 props.className,
12067 "dataviews-view-grid__row__gridcell",
12068 "dataviews-view-grid__card",
12069 {
12070 "is-selected": hasBulkAction && isSelected2
12071 }
12072 ),
12073 onClickCapture: (event) => {
12074 props.onClickCapture?.(event);
12075 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12076 event.stopPropagation();
12077 event.preventDefault();
12078 if (!hasBulkAction) {
12079 return;
12080 }
12081 onChangeSelection(
12082 isSelected2 ? selection.filter(
12083 (itemId) => id !== itemId
12084 ) : [...selection, id]
12085 );
12086 }
12087 },
12088 children: [
12089 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12090 ItemClickWrapper,
12091 {
12092 item,
12093 isItemClickable,
12094 onClickItem,
12095 renderItemLink,
12096 className: clsx_default("dataviews-view-grid__media", {
12097 "dataviews-view-grid__media--placeholder": !rendersMediaField
12098 }),
12099 ...mediaA11yProps,
12100 children: renderedMediaField
12101 }
12102 ),
12103 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12104 DataViewsSelectionCheckbox,
12105 {
12106 item,
12107 selection,
12108 onChangeSelection,
12109 getItemId,
12110 titleField,
12111 disabled: !hasBulkAction
12112 }
12113 ),
12114 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12115 ItemActions,
12116 {
12117 item,
12118 actions,
12119 isCompact: true
12120 }
12121 ) }),
12122 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12123 ItemClickWrapper,
12124 {
12125 item,
12126 isItemClickable,
12127 onClickItem,
12128 renderItemLink,
12129 className: "dataviews-view-grid__title-field dataviews-title-field",
12130 ...titleA11yProps,
12131 title: titleField?.getValueFormatted({
12132 item,
12133 field: titleField
12134 }) || void 0,
12135 children: renderedTitleField
12136 }
12137 ) }),
12138 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12139 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12140 descriptionField.render,
12141 {
12142 item,
12143 field: descriptionField
12144 }
12145 ),
12146 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12147 Stack,
12148 {
12149 direction: "row",
12150 className: "dataviews-view-grid__badge-fields",
12151 gap: "sm",
12152 wrap: "wrap",
12153 align: "top",
12154 justify: "flex-start",
12155 children: badgeFields.map((field) => {
12156 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12157 WCBadge,
12158 {
12159 className: "dataviews-view-grid__field-value",
12160 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12161 field.render,
12162 {
12163 item,
12164 field
12165 }
12166 )
12167 },
12168 field.id
12169 );
12170 })
12171 }
12172 ),
12173 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12174 Stack,
12175 {
12176 direction: "column",
12177 className: "dataviews-view-grid__fields",
12178 gap: "xs",
12179 children: regularFields.map((field) => {
12180 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12181 import_components8.Flex,
12182 {
12183 className: "dataviews-view-grid__field",
12184 gap: 1,
12185 justify: "flex-start",
12186 expanded: true,
12187 style: { height: "auto" },
12188 direction: "row",
12189 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12190 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12191 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12192 tooltip_exports.Trigger,
12193 {
12194 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12195 }
12196 ),
12197 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12198 ] }),
12199 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12200 import_components8.FlexItem,
12201 {
12202 className: "dataviews-view-grid__field-value",
12203 style: { maxHeight: "none" },
12204 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12205 field.render,
12206 {
12207 item,
12208 field
12209 }
12210 )
12211 }
12212 )
12213 ] })
12214 },
12215 field.id
12216 );
12217 })
12218 }
12219 )
12220 ] })
12221 ]
12222 }
12223 );
12224 }
12225 );
12226 function CompositeGrid({
12227 data,
12228 isInfiniteScroll,
12229 className,
12230 inert,
12231 isLoading,
12232 view,
12233 fields,
12234 selection,
12235 onChangeSelection,
12236 onClickItem,
12237 isItemClickable,
12238 renderItemLink,
12239 getItemId,
12240 actions
12241 }) {
12242 const { paginationInfo, resizeObserverRef } = (0, import_element31.useContext)(dataviews_context_default);
12243 const gridColumns = useGridColumns();
12244 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12245 const titleField = fields.find(
12246 (field) => field.id === view?.titleField
12247 );
12248 const mediaField = fields.find(
12249 (field) => field.id === view?.mediaField
12250 );
12251 const descriptionField = fields.find(
12252 (field) => field.id === view?.descriptionField
12253 );
12254 const otherFields = view.fields ?? [];
12255 const { regularFields, badgeFields } = otherFields.reduce(
12256 (accumulator, fieldId) => {
12257 const field = fields.find((f2) => f2.id === fieldId);
12258 if (!field) {
12259 return accumulator;
12260 }
12261 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12262 accumulator[key].push(field);
12263 return accumulator;
12264 },
12265 { regularFields: [], badgeFields: [] }
12266 );
12267 const size4 = "900px";
12268 const totalRows = Math.ceil(data.length / gridColumns);
12269 const placeholdersNeeded = usePlaceholdersNeeded(
12270 data,
12271 isInfiniteScroll,
12272 gridColumns
12273 );
12274 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12275 // Render infinite scroll layout (no rows, feed semantics)
12276 children: [
12277 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12278 import_components8.Composite,
12279 {
12280 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12281 GridItems,
12282 {
12283 className: clsx_default(
12284 "dataviews-view-grid-infinite-scroll",
12285 className,
12286 {
12287 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12288 "compact",
12289 "comfortable"
12290 ].includes(view.layout.density)
12291 }
12292 ),
12293 previewSize: view.layout?.previewSize,
12294 "aria-busy": isLoading,
12295 ref: resizeObserverRef
12296 }
12297 ),
12298 role: "feed",
12299 focusWrap: true,
12300 inert,
12301 children: [
12302 Array.from({ length: placeholdersNeeded }).map(
12303 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12304 import_components8.Composite.Item,
12305 {
12306 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12307 Stack,
12308 {
12309 ...props,
12310 direction: "column",
12311 role: "article",
12312 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12313 }
12314 ),
12315 "aria-hidden": true,
12316 tabIndex: -1
12317 },
12318 `placeholder-${index2}`
12319 )
12320 ),
12321 data.map((item) => {
12322 const itemId = getItemId(item);
12323 const stablePosition = item.position;
12324 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12325 import_components8.Composite.Item,
12326 {
12327 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12328 GridItem,
12329 {
12330 ...props,
12331 id: itemId,
12332 role: "article",
12333 view,
12334 selection,
12335 onChangeSelection,
12336 onClickItem,
12337 isItemClickable,
12338 renderItemLink,
12339 getItemId,
12340 item,
12341 actions,
12342 mediaField,
12343 titleField,
12344 descriptionField,
12345 regularFields,
12346 badgeFields,
12347 hasBulkActions,
12348 posinset: stablePosition,
12349 setsize: paginationInfo.totalItems,
12350 config: {
12351 sizes: size4
12352 }
12353 }
12354 )
12355 },
12356 itemId
12357 );
12358 })
12359 ]
12360 }
12361 ),
12362 // Render standard grid layout (with rows, grid semantics)
12363 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12364 import_components8.Composite,
12365 {
12366 role: "grid",
12367 className: clsx_default("dataviews-view-grid", className, {
12368 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12369 view.layout.density
12370 )
12371 }),
12372 focusWrap: true,
12373 "aria-busy": isLoading,
12374 "aria-rowcount": totalRows,
12375 ref: resizeObserverRef,
12376 inert,
12377 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12378 import_components8.Composite.Row,
12379 {
12380 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12381 "div",
12382 {
12383 role: "row",
12384 "aria-rowindex": i2 + 1,
12385 "aria-label": (0, import_i18n11.sprintf)(
12386 /* translators: %d: The row number in the grid */
12387 (0, import_i18n11.__)("Row %d"),
12388 i2 + 1
12389 ),
12390 className: "dataviews-view-grid__row",
12391 style: {
12392 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12393 }
12394 }
12395 ),
12396 children: row.map((item) => {
12397 const itemId = getItemId(item);
12398 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12399 import_components8.Composite.Item,
12400 {
12401 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12402 GridItem,
12403 {
12404 ...props,
12405 id: itemId,
12406 role: "gridcell",
12407 view,
12408 selection,
12409 onChangeSelection,
12410 onClickItem,
12411 isItemClickable,
12412 renderItemLink,
12413 getItemId,
12414 item,
12415 actions,
12416 mediaField,
12417 titleField,
12418 descriptionField,
12419 regularFields,
12420 badgeFields,
12421 hasBulkActions,
12422 config: {
12423 sizes: size4
12424 }
12425 }
12426 )
12427 },
12428 itemId
12429 );
12430 })
12431 },
12432 i2
12433 ))
12434 }
12435 )
12436 ]
12437 });
12438 }
12439
12440 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12441 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12442 function ViewGrid({
12443 actions,
12444 data,
12445 fields,
12446 getItemId,
12447 isLoading,
12448 onChangeSelection,
12449 onClickItem,
12450 isItemClickable,
12451 renderItemLink,
12452 selection,
12453 view,
12454 className,
12455 empty
12456 }) {
12457 const isDelayedLoading = useDelayedLoading(!!isLoading);
12458 const hasData = !!data?.length;
12459 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12460 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12461 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12462 if (!hasData) {
12463 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12464 "div",
12465 {
12466 className: clsx_default("dataviews-no-results", {
12467 "is-refreshing": isDelayedLoading
12468 }),
12469 children: empty
12470 }
12471 );
12472 }
12473 const gridProps = {
12474 className: clsx_default(className, {
12475 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12476 }),
12477 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12478 isLoading,
12479 view,
12480 fields,
12481 selection,
12482 onChangeSelection,
12483 onClickItem,
12484 isItemClickable,
12485 renderItemLink,
12486 getItemId,
12487 actions
12488 };
12489 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12490 // Render multiple groups.
12491 children: [
12492 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12493 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12494 Stack,
12495 {
12496 direction: "column",
12497 gap: "sm",
12498 children: [
12499 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12500 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12501 (0, import_i18n12.__)("%1$s: %2$s"),
12502 groupField.label,
12503 groupName
12504 ) }),
12505 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12506 CompositeGrid,
12507 {
12508 ...gridProps,
12509 data: groupItems,
12510 isInfiniteScroll: false
12511 }
12512 )
12513 ]
12514 },
12515 groupName
12516 )
12517 ) }),
12518 // Render a single grid with all data.
12519 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12520 CompositeGrid,
12521 {
12522 ...gridProps,
12523 data,
12524 isInfiniteScroll: !!isInfiniteScroll
12525 }
12526 ),
12527 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12528 ]
12529 });
12530 }
12531 var grid_default = ViewGrid;
12532
12533 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12534 var import_compose4 = __toESM(require_compose(), 1);
12535 var import_components10 = __toESM(require_components(), 1);
12536 var import_element32 = __toESM(require_element(), 1);
12537 var import_i18n13 = __toESM(require_i18n(), 1);
12538 var import_data6 = __toESM(require_data(), 1);
12539 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12540 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12541 function generateItemWrapperCompositeId(idPrefix) {
12542 return `${idPrefix}-item-wrapper`;
12543 }
12544 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12545 return `${idPrefix}-primary-action-${primaryActionId}`;
12546 }
12547 function generateDropdownTriggerCompositeId(idPrefix) {
12548 return `${idPrefix}-dropdown`;
12549 }
12550 function PrimaryActionGridCell({
12551 idPrefix,
12552 primaryAction,
12553 item
12554 }) {
12555 const registry = (0, import_data6.useRegistry)();
12556 const [isModalOpen, setIsModalOpen] = (0, import_element32.useState)(false);
12557 const compositeItemId = generatePrimaryActionCompositeId(
12558 idPrefix,
12559 primaryAction.id
12560 );
12561 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12562 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12563 import_components10.Composite.Item,
12564 {
12565 id: compositeItemId,
12566 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12567 import_components10.Button,
12568 {
12569 disabled: !!primaryAction.disabled,
12570 accessibleWhenDisabled: true,
12571 text: label,
12572 size: "small",
12573 onClick: () => setIsModalOpen(true)
12574 }
12575 ),
12576 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12577 ActionModal,
12578 {
12579 action: primaryAction,
12580 items: [item],
12581 closeModal: () => setIsModalOpen(false)
12582 }
12583 )
12584 }
12585 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12586 import_components10.Composite.Item,
12587 {
12588 id: compositeItemId,
12589 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12590 import_components10.Button,
12591 {
12592 disabled: !!primaryAction.disabled,
12593 accessibleWhenDisabled: true,
12594 size: "small",
12595 onClick: () => {
12596 primaryAction.callback([item], { registry });
12597 },
12598 children: label
12599 }
12600 )
12601 }
12602 ) }, primaryAction.id);
12603 }
12604 function ListItem({
12605 view,
12606 actions,
12607 idPrefix,
12608 isSelected: isSelected2,
12609 item,
12610 titleField,
12611 mediaField,
12612 descriptionField,
12613 onSelect,
12614 otherFields,
12615 onDropdownTriggerKeyDown,
12616 posinset
12617 }) {
12618 const {
12619 showTitle = true,
12620 showMedia = true,
12621 showDescription = true,
12622 infiniteScrollEnabled
12623 } = view;
12624 const itemRef = (0, import_element32.useRef)(null);
12625 const labelId = `${idPrefix}-label`;
12626 const descriptionId = `${idPrefix}-description`;
12627 const registry = (0, import_data6.useRegistry)();
12628 const [isHovered, setIsHovered] = (0, import_element32.useState)(false);
12629 const [activeModalAction, setActiveModalAction] = (0, import_element32.useState)(
12630 null
12631 );
12632 const handleHover = ({ type }) => {
12633 const isHover = type === "mouseenter";
12634 setIsHovered(isHover);
12635 };
12636 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
12637 (0, import_element32.useEffect)(() => {
12638 if (isSelected2) {
12639 itemRef.current?.scrollIntoView({
12640 behavior: "auto",
12641 block: "nearest",
12642 inline: "nearest"
12643 });
12644 }
12645 }, [isSelected2]);
12646 const { primaryAction, eligibleActions } = (0, import_element32.useMemo)(() => {
12647 const _eligibleActions = actions.filter(
12648 (action) => !action.isEligible || action.isEligible(item)
12649 );
12650 const _primaryActions = _eligibleActions.filter(
12651 (action) => action.isPrimary
12652 );
12653 return {
12654 primaryAction: _primaryActions[0],
12655 eligibleActions: _eligibleActions
12656 };
12657 }, [actions, item]);
12658 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12659 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)(
12660 mediaField.render,
12661 {
12662 item,
12663 field: mediaField,
12664 config: { sizes: "52px" }
12665 }
12666 ) }) : null;
12667 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12668 const renderDescription = showDescription && descriptionField?.render;
12669 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12670 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12671 Stack,
12672 {
12673 direction: "row",
12674 gap: "md",
12675 className: "dataviews-view-list__item-actions",
12676 children: [
12677 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12678 PrimaryActionGridCell,
12679 {
12680 idPrefix,
12681 primaryAction,
12682 item
12683 }
12684 ),
12685 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12686 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12687 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12688 Menu3.TriggerButton,
12689 {
12690 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12691 import_components10.Composite.Item,
12692 {
12693 id: generateDropdownTriggerCompositeId(
12694 idPrefix
12695 ),
12696 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12697 import_components10.Button,
12698 {
12699 size: "small",
12700 icon: more_vertical_default,
12701 label: (0, import_i18n13.__)("Actions"),
12702 accessibleWhenDisabled: true,
12703 disabled: !actions.length,
12704 onKeyDown: onDropdownTriggerKeyDown
12705 }
12706 )
12707 }
12708 )
12709 }
12710 ),
12711 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12712 ActionsMenuGroup,
12713 {
12714 actions: eligibleActions,
12715 item,
12716 registry,
12717 setActiveModalAction
12718 }
12719 ) })
12720 ] }),
12721 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12722 ActionModal,
12723 {
12724 action: activeModalAction,
12725 items: [item],
12726 closeModal: () => setActiveModalAction(null)
12727 }
12728 )
12729 ] })
12730 ]
12731 }
12732 );
12733 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12734 import_components10.Composite.Row,
12735 {
12736 ref: itemRef,
12737 render: (
12738 /* aria-posinset breaks Composite.Row if passed to it directly. */
12739 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12740 "div",
12741 {
12742 "aria-posinset": posinset,
12743 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
12744 }
12745 )
12746 ),
12747 role: infiniteScrollEnabled ? "article" : "row",
12748 className: clsx_default({
12749 "is-selected": isSelected2,
12750 "is-hovered": isHovered
12751 }),
12752 onMouseEnter: handleHover,
12753 onMouseLeave: handleHover,
12754 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12755 Stack,
12756 {
12757 direction: "row",
12758 className: "dataviews-view-list__item-wrapper",
12759 children: [
12760 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12761 import_components10.Composite.Item,
12762 {
12763 id: generateItemWrapperCompositeId(idPrefix),
12764 "aria-pressed": isSelected2,
12765 "aria-labelledby": labelId,
12766 "aria-describedby": descriptionId,
12767 className: "dataviews-view-list__item",
12768 onClick: () => onSelect(item)
12769 }
12770 ) }),
12771 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12772 Stack,
12773 {
12774 direction: "row",
12775 gap: "md",
12776 justify: "start",
12777 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
12778 style: { flex: 1, minWidth: 0 },
12779 children: [
12780 renderedMediaField,
12781 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12782 Stack,
12783 {
12784 direction: "column",
12785 gap: "xs",
12786 className: "dataviews-view-list__field-wrapper",
12787 children: [
12788 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
12789 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12790 "div",
12791 {
12792 className: "dataviews-title-field dataviews-view-list__title-field",
12793 id: labelId,
12794 children: renderedTitleField
12795 }
12796 ),
12797 usedActions
12798 ] }),
12799 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12800 descriptionField.render,
12801 {
12802 item,
12803 field: descriptionField
12804 }
12805 ) }),
12806 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12807 "div",
12808 {
12809 className: "dataviews-view-list__fields",
12810 id: descriptionId,
12811 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12812 "div",
12813 {
12814 className: "dataviews-view-list__field",
12815 children: [
12816 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12817 VisuallyHidden,
12818 {
12819 className: "dataviews-view-list__field-label",
12820 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
12821 children: field.label
12822 }
12823 ),
12824 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12825 field.render,
12826 {
12827 item,
12828 field
12829 }
12830 ) })
12831 ]
12832 },
12833 field.id
12834 ))
12835 }
12836 )
12837 ]
12838 }
12839 )
12840 ]
12841 }
12842 )
12843 ]
12844 }
12845 )
12846 }
12847 );
12848 }
12849 function isDefined2(item) {
12850 return !!item;
12851 }
12852 function ViewList(props) {
12853 const {
12854 actions,
12855 data,
12856 fields,
12857 getItemId,
12858 isLoading,
12859 onChangeSelection,
12860 selection,
12861 view,
12862 className,
12863 empty
12864 } = props;
12865 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
12866 const isDelayedLoading = useDelayedLoading(!!isLoading);
12867 const selectedItem = data?.findLast(
12868 (item) => selection.includes(getItemId(item))
12869 );
12870 const titleField = fields.find((field) => field.id === view.titleField);
12871 const mediaField = fields.find((field) => field.id === view.mediaField);
12872 const descriptionField = fields.find(
12873 (field) => field.id === view.descriptionField
12874 );
12875 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
12876 const onSelect = (item) => onChangeSelection([getItemId(item)]);
12877 const generateCompositeItemIdPrefix = (0, import_element32.useCallback)(
12878 (item) => `${baseId}-${getItemId(item)}`,
12879 [baseId, getItemId]
12880 );
12881 const isActiveCompositeItem = (0, import_element32.useCallback)(
12882 (item, idToCheck) => {
12883 return idToCheck.startsWith(
12884 generateCompositeItemIdPrefix(item)
12885 );
12886 },
12887 [generateCompositeItemIdPrefix]
12888 );
12889 const [activeCompositeId, setActiveCompositeId] = (0, import_element32.useState)(void 0);
12890 const compositeRef = (0, import_element32.useRef)(null);
12891 (0, import_element32.useEffect)(() => {
12892 if (selectedItem) {
12893 setActiveCompositeId(
12894 generateItemWrapperCompositeId(
12895 generateCompositeItemIdPrefix(selectedItem)
12896 )
12897 );
12898 }
12899 }, [selectedItem, generateCompositeItemIdPrefix]);
12900 const activeItemIndex = data.findIndex(
12901 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
12902 );
12903 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
12904 const isActiveIdInList = activeItemIndex !== -1;
12905 const selectCompositeItem = (0, import_element32.useCallback)(
12906 (targetIndex, generateCompositeId) => {
12907 const clampedIndex = Math.min(
12908 data.length - 1,
12909 Math.max(0, targetIndex)
12910 );
12911 if (!data[clampedIndex]) {
12912 return;
12913 }
12914 const itemIdPrefix = generateCompositeItemIdPrefix(
12915 data[clampedIndex]
12916 );
12917 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
12918 setActiveCompositeId(targetCompositeItemId);
12919 if (compositeRef.current?.contains(
12920 compositeRef.current.ownerDocument.activeElement
12921 )) {
12922 document.getElementById(targetCompositeItemId)?.focus();
12923 }
12924 },
12925 [data, generateCompositeItemIdPrefix]
12926 );
12927 (0, import_element32.useEffect)(() => {
12928 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
12929 if (!isActiveIdInList && wasActiveIdInList) {
12930 selectCompositeItem(
12931 previousActiveItemIndex,
12932 generateItemWrapperCompositeId
12933 );
12934 }
12935 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
12936 const onDropdownTriggerKeyDown = (0, import_element32.useCallback)(
12937 (event) => {
12938 if (event.key === "ArrowDown") {
12939 event.preventDefault();
12940 selectCompositeItem(
12941 activeItemIndex + 1,
12942 generateDropdownTriggerCompositeId
12943 );
12944 }
12945 if (event.key === "ArrowUp") {
12946 event.preventDefault();
12947 selectCompositeItem(
12948 activeItemIndex - 1,
12949 generateDropdownTriggerCompositeId
12950 );
12951 }
12952 },
12953 [selectCompositeItem, activeItemIndex]
12954 );
12955 const hasData = !!data?.length;
12956 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
12957 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
12958 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12959 if (!hasData) {
12960 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12961 "div",
12962 {
12963 className: clsx_default("dataviews-no-results", {
12964 "is-refreshing": isDelayedLoading
12965 }),
12966 children: empty
12967 }
12968 );
12969 }
12970 if (hasData && groupField && dataByGroup) {
12971 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12972 import_components10.Composite,
12973 {
12974 ref: compositeRef,
12975 id: `${baseId}`,
12976 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12977 className: "dataviews-view-list__group",
12978 role: "grid",
12979 activeId: activeCompositeId,
12980 setActiveId: setActiveCompositeId,
12981 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12982 Stack,
12983 {
12984 direction: "column",
12985 gap: "lg",
12986 className: clsx_default("dataviews-view-list", className),
12987 children: Array.from(dataByGroup.entries()).map(
12988 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12989 Stack,
12990 {
12991 direction: "column",
12992 gap: "sm",
12993 children: [
12994 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12995 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12996 (0, import_i18n13.__)("%1$s: %2$s"),
12997 groupField.label,
12998 groupName
12999 ) }),
13000 groupItems.map((item) => {
13001 const id = generateCompositeItemIdPrefix(item);
13002 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13003 ListItem,
13004 {
13005 view,
13006 idPrefix: id,
13007 actions,
13008 item,
13009 isSelected: item === selectedItem,
13010 onSelect,
13011 mediaField,
13012 titleField,
13013 descriptionField,
13014 otherFields,
13015 onDropdownTriggerKeyDown
13016 },
13017 id
13018 );
13019 })
13020 ]
13021 },
13022 groupName
13023 )
13024 )
13025 }
13026 )
13027 }
13028 );
13029 }
13030 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
13031 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13032 import_components10.Composite,
13033 {
13034 ref: compositeRef,
13035 id: baseId,
13036 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
13037 className: clsx_default("dataviews-view-list", className, {
13038 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13039 view.layout.density
13040 ),
13041 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13042 }),
13043 role: view.infiniteScrollEnabled ? "feed" : "grid",
13044 activeId: activeCompositeId,
13045 setActiveId: setActiveCompositeId,
13046 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13047 children: data.map((item, index2) => {
13048 const id = generateCompositeItemIdPrefix(item);
13049 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13050 ListItem,
13051 {
13052 view,
13053 idPrefix: id,
13054 actions,
13055 item,
13056 isSelected: item === selectedItem,
13057 onSelect,
13058 mediaField,
13059 titleField,
13060 descriptionField,
13061 otherFields,
13062 onDropdownTriggerKeyDown,
13063 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13064 },
13065 id
13066 );
13067 })
13068 }
13069 ),
13070 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {}) })
13071 ] });
13072 }
13073
13074 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13075 var import_components11 = __toESM(require_components(), 1);
13076
13077 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13078 var import_i18n14 = __toESM(require_i18n(), 1);
13079 var import_element33 = __toESM(require_element(), 1);
13080 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13081 function ActivityGroup({
13082 groupName,
13083 groupData,
13084 groupField,
13085 showLabel = true,
13086 children
13087 }) {
13088 const groupHeader = showLabel ? (0, import_element33.createInterpolateElement)(
13089 // translators: %s: The label of the field e.g. "Status".
13090 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
13091 {
13092 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
13093 groupField.render,
13094 {
13095 item: groupData[0],
13096 field: groupField
13097 }
13098 )
13099 }
13100 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
13101 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
13102 Stack,
13103 {
13104 direction: "column",
13105 className: "dataviews-view-activity__group",
13106 children: [
13107 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13108 children
13109 ]
13110 },
13111 groupName
13112 );
13113 }
13114
13115 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13116 var import_element34 = __toESM(require_element(), 1);
13117 var import_data7 = __toESM(require_data(), 1);
13118 var import_compose5 = __toESM(require_compose(), 1);
13119 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13120 function ActivityItem(props) {
13121 const {
13122 view,
13123 actions,
13124 item,
13125 titleField,
13126 mediaField,
13127 descriptionField,
13128 otherFields,
13129 posinset,
13130 onClickItem,
13131 renderItemLink,
13132 isItemClickable
13133 } = props;
13134 const {
13135 showTitle = true,
13136 showMedia = true,
13137 showDescription = true,
13138 infiniteScrollEnabled
13139 } = view;
13140 const itemRef = (0, import_element34.useRef)(null);
13141 const registry = (0, import_data7.useRegistry)();
13142 const { paginationInfo } = (0, import_element34.useContext)(dataviews_context_default);
13143 const { primaryActions, eligibleActions } = (0, import_element34.useMemo)(() => {
13144 const _eligibleActions = actions.filter(
13145 (action) => !action.isEligible || action.isEligible(item)
13146 );
13147 const _primaryActions = _eligibleActions.filter(
13148 (action) => action.isPrimary
13149 );
13150 return {
13151 primaryActions: _primaryActions,
13152 eligibleActions: _eligibleActions
13153 };
13154 }, [actions, item]);
13155 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13156 const density = view.layout?.density ?? "balanced";
13157 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13158 mediaField.render,
13159 {
13160 item,
13161 field: mediaField,
13162 config: {
13163 sizes: density === "comfortable" ? "32px" : "24px"
13164 }
13165 }
13166 ) : null;
13167 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13168 "span",
13169 {
13170 className: "dataviews-view-activity__item-bullet",
13171 "aria-hidden": "true"
13172 }
13173 ) });
13174 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13175 const verticalGap = (0, import_element34.useMemo)(() => {
13176 switch (density) {
13177 case "comfortable":
13178 return "md";
13179 default:
13180 return "sm";
13181 }
13182 }, [density]);
13183 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13184 "div",
13185 {
13186 ref: itemRef,
13187 role: infiniteScrollEnabled ? "article" : void 0,
13188 "aria-posinset": posinset,
13189 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13190 className: clsx_default(
13191 "dataviews-view-activity__item",
13192 density === "compact" && "is-compact",
13193 density === "balanced" && "is-balanced",
13194 density === "comfortable" && "is-comfortable"
13195 ),
13196 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13197 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13198 Stack,
13199 {
13200 direction: "column",
13201 gap: "xs",
13202 align: "center",
13203 className: "dataviews-view-activity__item-type",
13204 children: renderedMediaField
13205 }
13206 ),
13207 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13208 Stack,
13209 {
13210 direction: "column",
13211 gap: verticalGap,
13212 align: "flex-start",
13213 className: "dataviews-view-activity__item-content",
13214 children: [
13215 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13216 ItemClickWrapper,
13217 {
13218 item,
13219 isItemClickable,
13220 onClickItem,
13221 renderItemLink,
13222 className: "dataviews-view-activity__item-title",
13223 children: renderedTitleField
13224 }
13225 ),
13226 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13227 descriptionField.render,
13228 {
13229 item,
13230 field: descriptionField
13231 }
13232 ) }),
13233 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13234 "div",
13235 {
13236 className: "dataviews-view-activity__item-field",
13237 children: [
13238 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13239 VisuallyHidden,
13240 {
13241 className: "dataviews-view-activity__item-field-label",
13242 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13243 children: field.label
13244 }
13245 ),
13246 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13247 field.render,
13248 {
13249 item,
13250 field
13251 }
13252 ) })
13253 ]
13254 },
13255 field.id
13256 )) }),
13257 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13258 PrimaryActions,
13259 {
13260 item,
13261 actions: primaryActions,
13262 registry,
13263 buttonVariant: "secondary"
13264 }
13265 )
13266 ]
13267 }
13268 ),
13269 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13270 // there if there are any actions at all.
13271 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13272 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13273 ItemActions,
13274 {
13275 item,
13276 actions: eligibleActions,
13277 isCompact: true
13278 }
13279 ) })
13280 ] })
13281 }
13282 );
13283 }
13284 var activity_item_default = ActivityItem;
13285
13286 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13287 var import_react6 = __toESM(require_react(), 1);
13288 function isDefined3(item) {
13289 return !!item;
13290 }
13291 function ActivityItems(props) {
13292 const { data, fields, getItemId, view } = props;
13293 const titleField = fields.find((field) => field.id === view.titleField);
13294 const mediaField = fields.find((field) => field.id === view.mediaField);
13295 const descriptionField = fields.find(
13296 (field) => field.id === view.descriptionField
13297 );
13298 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13299 return data.map((item, index2) => {
13300 return /* @__PURE__ */ (0, import_react6.createElement)(
13301 activity_item_default,
13302 {
13303 ...props,
13304 key: getItemId(item),
13305 item,
13306 mediaField,
13307 titleField,
13308 descriptionField,
13309 otherFields,
13310 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13311 }
13312 );
13313 });
13314 }
13315
13316 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13317 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13318 function ViewActivity(props) {
13319 const { empty, data, fields, isLoading, view, className } = props;
13320 const isDelayedLoading = useDelayedLoading(!!isLoading);
13321 const hasData = !!data?.length;
13322 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13323 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13324 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13325 if (!hasData) {
13326 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13327 "div",
13328 {
13329 className: clsx_default("dataviews-no-results", {
13330 "is-refreshing": isDelayedLoading
13331 }),
13332 children: empty
13333 }
13334 );
13335 }
13336 const isInert = !isInfiniteScroll && !!isLoading;
13337 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13338 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13339 });
13340 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13341 if (hasData && groupField && dataByGroup) {
13342 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13343 Stack,
13344 {
13345 direction: "column",
13346 gap: "sm",
13347 className: wrapperClassName,
13348 inert: isInert ? "true" : void 0,
13349 children: groupedEntries.map(
13350 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13351 ActivityGroup,
13352 {
13353 groupName,
13354 groupData,
13355 groupField,
13356 showLabel: view.groupBy?.showLabel !== false,
13357 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13358 ActivityItems,
13359 {
13360 ...props,
13361 data: groupData
13362 }
13363 )
13364 },
13365 groupName
13366 )
13367 )
13368 }
13369 );
13370 }
13371 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13372 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13373 "div",
13374 {
13375 className: wrapperClassName,
13376 role: view.infiniteScrollEnabled ? "feed" : void 0,
13377 inert: isInert ? "true" : void 0,
13378 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13379 }
13380 ),
13381 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13382 ] });
13383 }
13384
13385 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13386 var import_components14 = __toESM(require_components(), 1);
13387 var import_i18n17 = __toESM(require_i18n(), 1);
13388 var import_compose6 = __toESM(require_compose(), 1);
13389 var import_element37 = __toESM(require_element(), 1);
13390
13391 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13392 var import_components13 = __toESM(require_components(), 1);
13393 var import_data8 = __toESM(require_data(), 1);
13394 var import_element36 = __toESM(require_element(), 1);
13395 var import_i18n16 = __toESM(require_i18n(), 1);
13396
13397 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13398 var import_components12 = __toESM(require_components(), 1);
13399 var import_element35 = __toESM(require_element(), 1);
13400 var import_i18n15 = __toESM(require_i18n(), 1);
13401 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13402 function DataViewsPagination() {
13403 const {
13404 view,
13405 onChangeView,
13406 paginationInfo: { totalItems = 0, totalPages }
13407 } = (0, import_element35.useContext)(dataviews_context_default);
13408 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13409 return null;
13410 }
13411 const currentPage = view.page ?? 1;
13412 const pageSelectOptions = Array.from(Array(totalPages)).map(
13413 (_, i2) => {
13414 const page = i2 + 1;
13415 return {
13416 value: page.toString(),
13417 label: page.toString(),
13418 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13419 // translators: 1: current page number. 2: total number of pages.
13420 (0, import_i18n15.__)("Page %1$d of %2$d"),
13421 currentPage,
13422 totalPages
13423 ) : page.toString()
13424 };
13425 }
13426 );
13427 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13428 Stack,
13429 {
13430 direction: "row",
13431 className: "dataviews-pagination",
13432 justify: "end",
13433 align: "center",
13434 gap: "xl",
13435 children: [
13436 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13437 Stack,
13438 {
13439 direction: "row",
13440 justify: "flex-start",
13441 align: "center",
13442 gap: "xs",
13443 className: "dataviews-pagination__page-select",
13444 children: (0, import_element35.createInterpolateElement)(
13445 (0, import_i18n15.sprintf)(
13446 // translators: 1: Current page number, 2: Total number of pages.
13447 (0, import_i18n15._x)(
13448 "<div>Page</div>%1$s<div>of %2$d</div>",
13449 "paging"
13450 ),
13451 "<CurrentPage />",
13452 totalPages
13453 ),
13454 {
13455 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13456 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13457 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13458 import_components12.SelectControl,
13459 {
13460 "aria-label": (0, import_i18n15.__)("Current page"),
13461 value: currentPage.toString(),
13462 options: pageSelectOptions,
13463 onChange: (newValue) => {
13464 onChangeView({
13465 ...view,
13466 page: +newValue
13467 });
13468 },
13469 size: "small",
13470 variant: "minimal"
13471 }
13472 )
13473 }
13474 )
13475 }
13476 ),
13477 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13478 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13479 import_components12.Button,
13480 {
13481 onClick: () => onChangeView({
13482 ...view,
13483 page: currentPage - 1
13484 }),
13485 disabled: currentPage === 1,
13486 accessibleWhenDisabled: true,
13487 label: (0, import_i18n15.__)("Previous page"),
13488 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13489 showTooltip: true,
13490 size: "compact",
13491 tooltipPosition: "top"
13492 }
13493 ),
13494 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13495 import_components12.Button,
13496 {
13497 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13498 disabled: currentPage >= totalPages,
13499 accessibleWhenDisabled: true,
13500 label: (0, import_i18n15.__)("Next page"),
13501 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13502 showTooltip: true,
13503 size: "compact",
13504 tooltipPosition: "top"
13505 }
13506 )
13507 ] })
13508 ]
13509 }
13510 );
13511 }
13512 var dataviews_pagination_default = (0, import_element35.memo)(DataViewsPagination);
13513
13514 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13515 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13516 function useIsMultiselectPicker(actions) {
13517 return (0, import_element36.useMemo)(() => {
13518 return !!actions?.length && actions?.every((action) => action.supportsBulk);
13519 }, [actions]);
13520 }
13521
13522 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13523 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13524 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13525 function GridItem3({
13526 view,
13527 multiselect,
13528 selection,
13529 onChangeSelection,
13530 getItemId,
13531 item,
13532 mediaField,
13533 titleField,
13534 descriptionField,
13535 regularFields,
13536 badgeFields,
13537 config,
13538 posinset,
13539 setsize
13540 }) {
13541 const { showTitle = true, showMedia = true, showDescription = true } = view;
13542 const id = getItemId(item);
13543 const elementRef = (0, import_element37.useRef)(null);
13544 const isSelected2 = selection.includes(id);
13545 useIntersectionObserver(elementRef, posinset);
13546 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13547 mediaField.render,
13548 {
13549 item,
13550 field: mediaField,
13551 config
13552 }
13553 ) : null;
13554 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13555 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13556 import_components14.Composite.Item,
13557 {
13558 ref: elementRef,
13559 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13560 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13561 role: "option",
13562 "aria-posinset": posinset,
13563 "aria-setsize": setsize,
13564 className: clsx_default("dataviews-view-picker-grid__card", {
13565 "is-selected": isSelected2
13566 }),
13567 "aria-selected": isSelected2,
13568 onClick: () => {
13569 if (isSelected2) {
13570 onChangeSelection(
13571 selection.filter((itemId) => id !== itemId)
13572 );
13573 } else {
13574 const newSelection = multiselect ? [...selection, id] : [id];
13575 onChangeSelection(newSelection);
13576 }
13577 },
13578 children: [
13579 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13580 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13581 DataViewsSelectionCheckbox,
13582 {
13583 item,
13584 selection,
13585 onChangeSelection,
13586 getItemId,
13587 titleField,
13588 disabled: false,
13589 "aria-hidden": true,
13590 tabIndex: -1
13591 }
13592 ),
13593 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13594 Stack,
13595 {
13596 direction: "row",
13597 justify: "space-between",
13598 className: "dataviews-view-picker-grid__title-actions",
13599 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13600 }
13601 ),
13602 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13603 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13604 descriptionField.render,
13605 {
13606 item,
13607 field: descriptionField
13608 }
13609 ),
13610 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13611 Stack,
13612 {
13613 direction: "row",
13614 className: "dataviews-view-picker-grid__badge-fields",
13615 gap: "sm",
13616 wrap: "wrap",
13617 align: "top",
13618 justify: "flex-start",
13619 children: badgeFields.map((field) => {
13620 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13621 WCBadge2,
13622 {
13623 className: "dataviews-view-picker-grid__field-value",
13624 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13625 field.render,
13626 {
13627 item,
13628 field
13629 }
13630 )
13631 },
13632 field.id
13633 );
13634 })
13635 }
13636 ),
13637 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13638 Stack,
13639 {
13640 direction: "column",
13641 className: "dataviews-view-picker-grid__fields",
13642 gap: "xs",
13643 children: regularFields.map((field) => {
13644 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13645 import_components14.Flex,
13646 {
13647 className: "dataviews-view-picker-grid__field",
13648 gap: 1,
13649 justify: "flex-start",
13650 expanded: true,
13651 style: { height: "auto" },
13652 direction: "row",
13653 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13654 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13655 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13656 import_components14.FlexItem,
13657 {
13658 className: "dataviews-view-picker-grid__field-value",
13659 style: { maxHeight: "none" },
13660 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13661 field.render,
13662 {
13663 item,
13664 field
13665 }
13666 )
13667 }
13668 )
13669 ] })
13670 },
13671 field.id
13672 );
13673 })
13674 }
13675 )
13676 ] })
13677 ]
13678 },
13679 id
13680 );
13681 }
13682 function GridGroup({
13683 groupName,
13684 groupField,
13685 showLabel = true,
13686 children
13687 }) {
13688 const headerId = (0, import_compose6.useInstanceId)(
13689 GridGroup,
13690 "dataviews-view-picker-grid-group__header"
13691 );
13692 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13693 Stack,
13694 {
13695 direction: "column",
13696 gap: "sm",
13697 role: "group",
13698 "aria-labelledby": headerId,
13699 children: [
13700 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13701 "h3",
13702 {
13703 className: "dataviews-view-picker-grid-group__header",
13704 id: headerId,
13705 children: showLabel ? (0, import_i18n17.sprintf)(
13706 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13707 (0, import_i18n17.__)("%1$s: %2$s"),
13708 groupField.label,
13709 groupName
13710 ) : groupName
13711 }
13712 ),
13713 children
13714 ]
13715 },
13716 groupName
13717 );
13718 }
13719 function ViewPickerGrid({
13720 actions,
13721 data,
13722 fields,
13723 getItemId,
13724 isLoading,
13725 onChangeSelection,
13726 selection,
13727 view,
13728 className,
13729 empty
13730 }) {
13731 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element37.useContext)(dataviews_context_default);
13732 const titleField = fields.find(
13733 (field) => field.id === view?.titleField
13734 );
13735 const mediaField = fields.find(
13736 (field) => field.id === view?.mediaField
13737 );
13738 const descriptionField = fields.find(
13739 (field) => field.id === view?.descriptionField
13740 );
13741 const otherFields = view.fields ?? [];
13742 const { regularFields, badgeFields } = otherFields.reduce(
13743 (accumulator, fieldId) => {
13744 const field = fields.find((f2) => f2.id === fieldId);
13745 if (!field) {
13746 return accumulator;
13747 }
13748 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
13749 accumulator[key].push(field);
13750 return accumulator;
13751 },
13752 { regularFields: [], badgeFields: [] }
13753 );
13754 const hasData = !!data?.length;
13755 const usedPreviewSize = view.layout?.previewSize;
13756 const isMultiselect = useIsMultiselectPicker(actions);
13757 const size4 = "900px";
13758 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13759 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13760 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
13761 const currentPage = view?.page ?? 1;
13762 const perPage = view?.perPage ?? 0;
13763 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
13764 const gridColumns = useGridColumns();
13765 const placeholdersNeeded = usePlaceholdersNeeded(
13766 data,
13767 isInfiniteScroll,
13768 gridColumns
13769 );
13770 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
13771 // Render multiple groups.
13772 children: [
13773 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13774 import_components14.Composite,
13775 {
13776 virtualFocus: true,
13777 orientation: "horizontal",
13778 role: "listbox",
13779 "aria-multiselectable": isMultiselect,
13780 className: clsx_default(
13781 "dataviews-view-picker-grid",
13782 className,
13783 {
13784 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13785 view.layout.density
13786 )
13787 }
13788 ),
13789 "aria-label": itemListLabel,
13790 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13791 Stack,
13792 {
13793 direction: "column",
13794 gap: "lg",
13795 children,
13796 ...props
13797 }
13798 ),
13799 children: Array.from(dataByGroup.entries()).map(
13800 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13801 GridGroup,
13802 {
13803 groupName,
13804 groupField,
13805 showLabel: view.groupBy?.showLabel !== false,
13806 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13807 GridItems,
13808 {
13809 previewSize: usedPreviewSize,
13810 style: {
13811 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
13812 },
13813 "aria-busy": isLoading,
13814 ref: resizeObserverRef,
13815 children: groupItems.map((item) => {
13816 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
13817 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13818 GridItem3,
13819 {
13820 view,
13821 multiselect: isMultiselect,
13822 selection,
13823 onChangeSelection,
13824 getItemId,
13825 item,
13826 mediaField,
13827 titleField,
13828 descriptionField,
13829 regularFields,
13830 badgeFields,
13831 config: {
13832 sizes: size4
13833 },
13834 posinset: posInSet,
13835 setsize: setSize
13836 },
13837 getItemId(item)
13838 );
13839 })
13840 }
13841 )
13842 },
13843 groupName
13844 )
13845 )
13846 }
13847 ),
13848 // Render a single grid with all data.
13849 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13850 import_components14.Composite,
13851 {
13852 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13853 GridItems,
13854 {
13855 className: clsx_default(
13856 "dataviews-view-picker-grid",
13857 className,
13858 {
13859 [`has-${view.layout?.density}-density`]: view.layout?.density && [
13860 "compact",
13861 "comfortable"
13862 ].includes(view.layout.density)
13863 }
13864 ),
13865 previewSize: usedPreviewSize,
13866 "aria-busy": isLoading,
13867 ref: resizeObserverRef
13868 }
13869 ),
13870 virtualFocus: true,
13871 orientation: "horizontal",
13872 role: "listbox",
13873 "aria-multiselectable": isMultiselect,
13874 "aria-label": itemListLabel,
13875 children: [
13876 Array.from({ length: placeholdersNeeded }).map(
13877 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13878 import_components14.Composite.Item,
13879 {
13880 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13881 Stack,
13882 {
13883 direction: "column",
13884 children,
13885 ...props
13886 }
13887 ),
13888 role: "option",
13889 "aria-hidden": true,
13890 tabIndex: -1,
13891 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
13892 },
13893 `placeholder-${index2}`
13894 )
13895 ),
13896 data.map((item) => {
13897 const posinset = item.position;
13898 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13899 GridItem3,
13900 {
13901 view,
13902 multiselect: isMultiselect,
13903 selection,
13904 onChangeSelection,
13905 getItemId,
13906 item,
13907 mediaField,
13908 titleField,
13909 descriptionField,
13910 regularFields,
13911 badgeFields,
13912 config: {
13913 sizes: size4
13914 },
13915 posinset,
13916 setsize: setSize
13917 },
13918 getItemId(item)
13919 );
13920 })
13921 ]
13922 }
13923 ),
13924 // Render empty state.
13925 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13926 "div",
13927 {
13928 className: clsx_default({
13929 "dataviews-loading": isLoading,
13930 "dataviews-no-results": !isLoading
13931 }),
13932 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
13933 }
13934 ),
13935 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
13936 ]
13937 });
13938 }
13939 var picker_grid_default = ViewPickerGrid;
13940
13941 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
13942 var import_i18n18 = __toESM(require_i18n(), 1);
13943 var import_components15 = __toESM(require_components(), 1);
13944 var import_element38 = __toESM(require_element(), 1);
13945 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13946 function TableColumnField2({
13947 item,
13948 fields,
13949 column,
13950 align
13951 }) {
13952 const field = fields.find((f2) => f2.id === column);
13953 if (!field) {
13954 return null;
13955 }
13956 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
13957 "dataviews-view-table__cell-align-end": align === "end",
13958 "dataviews-view-table__cell-align-center": align === "center"
13959 });
13960 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
13961 }
13962 function TableRow2({
13963 item,
13964 fields,
13965 id,
13966 view,
13967 titleField,
13968 mediaField,
13969 descriptionField,
13970 selection,
13971 getItemId,
13972 onChangeSelection,
13973 multiselect,
13974 posinset
13975 }) {
13976 const { paginationInfo } = (0, import_element38.useContext)(dataviews_context_default);
13977 const isSelected2 = selection.includes(id);
13978 const [isHovered, setIsHovered] = (0, import_element38.useState)(false);
13979 const elementRef = (0, import_element38.useRef)(null);
13980 useIntersectionObserver(elementRef, posinset);
13981 const {
13982 showTitle = true,
13983 showMedia = true,
13984 showDescription = true,
13985 infiniteScrollEnabled
13986 } = view;
13987 const handleMouseEnter = () => {
13988 setIsHovered(true);
13989 };
13990 const handleMouseLeave = () => {
13991 setIsHovered(false);
13992 };
13993 const columns = view.fields ?? [];
13994 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13995 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13996 import_components15.Composite.Item,
13997 {
13998 ref: elementRef,
13999 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14000 "tr",
14001 {
14002 className: clsx_default("dataviews-view-table__row", {
14003 "is-selected": isSelected2,
14004 "is-hovered": isHovered
14005 }),
14006 onMouseEnter: handleMouseEnter,
14007 onMouseLeave: handleMouseLeave,
14008 children,
14009 ...props
14010 }
14011 ),
14012 "aria-selected": isSelected2,
14013 "aria-setsize": paginationInfo.totalItems || void 0,
14014 "aria-posinset": posinset,
14015 role: infiniteScrollEnabled ? "article" : "option",
14016 onMouseDown: (event) => {
14017 if (event.button !== 0) {
14018 return;
14019 }
14020 event.currentTarget.parentElement?.focus({
14021 preventScroll: true
14022 });
14023 },
14024 onClick: () => {
14025 if (isSelected2) {
14026 onChangeSelection(
14027 selection.filter((itemId) => id !== itemId)
14028 );
14029 } else {
14030 const newSelection = multiselect ? [...selection, id] : [id];
14031 onChangeSelection(newSelection);
14032 }
14033 },
14034 children: [
14035 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14036 "td",
14037 {
14038 className: "dataviews-view-table__checkbox-column",
14039 role: "presentation",
14040 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14041 DataViewsSelectionCheckbox,
14042 {
14043 item,
14044 selection,
14045 onChangeSelection,
14046 getItemId,
14047 titleField,
14048 disabled: false,
14049 "aria-hidden": true,
14050 tabIndex: -1
14051 }
14052 ) })
14053 }
14054 ),
14055 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14056 "td",
14057 {
14058 role: "presentation",
14059 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14060 column_primary_default,
14061 {
14062 item,
14063 titleField: showTitle ? titleField : void 0,
14064 mediaField: showMedia ? mediaField : void 0,
14065 descriptionField: showDescription ? descriptionField : void 0,
14066 isItemClickable: () => false
14067 }
14068 )
14069 }
14070 ),
14071 columns.map((column) => {
14072 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14073 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14074 "td",
14075 {
14076 style: {
14077 width,
14078 maxWidth,
14079 minWidth
14080 },
14081 role: "presentation",
14082 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14083 TableColumnField2,
14084 {
14085 fields,
14086 item,
14087 column,
14088 align
14089 }
14090 )
14091 },
14092 column
14093 );
14094 })
14095 ]
14096 },
14097 id
14098 );
14099 }
14100 function ViewPickerTable({
14101 actions,
14102 data,
14103 fields,
14104 getItemId,
14105 isLoading = false,
14106 onChangeView,
14107 onChangeSelection,
14108 selection,
14109 setOpenedFilter,
14110 view,
14111 className,
14112 empty
14113 }) {
14114 const headerMenuRefs = (0, import_element38.useRef)(/* @__PURE__ */ new Map());
14115 const headerMenuToFocusRef = (0, import_element38.useRef)(void 0);
14116 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element38.useState)();
14117 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14118 (0, import_element38.useEffect)(() => {
14119 if (headerMenuToFocusRef.current) {
14120 headerMenuToFocusRef.current.focus();
14121 headerMenuToFocusRef.current = void 0;
14122 }
14123 });
14124 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14125 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14126 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14127 const tableNoticeId = (0, import_element38.useId)();
14128 if (nextHeaderMenuToFocus) {
14129 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14130 setNextHeaderMenuToFocus(void 0);
14131 return;
14132 }
14133 const onHide = (field) => {
14134 const hidden = headerMenuRefs.current.get(field.id);
14135 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14136 setNextHeaderMenuToFocus(fallback?.node);
14137 };
14138 const hasData = !!data?.length;
14139 const titleField = fields.find((field) => field.id === view.titleField);
14140 const mediaField = fields.find((field) => field.id === view.mediaField);
14141 const descriptionField = fields.find(
14142 (field) => field.id === view.descriptionField
14143 );
14144 const { showTitle = true, showMedia = true, showDescription = true } = view;
14145 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14146 const columns = view.fields ?? [];
14147 const headerMenuRef = (column, index2) => (node) => {
14148 if (node) {
14149 headerMenuRefs.current.set(column, {
14150 node,
14151 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14152 });
14153 } else {
14154 headerMenuRefs.current.delete(column);
14155 }
14156 };
14157 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
14158 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14159 "table",
14160 {
14161 className: clsx_default(
14162 "dataviews-view-table",
14163 "dataviews-view-picker-table",
14164 className,
14165 {
14166 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14167 view.layout.density
14168 )
14169 }
14170 ),
14171 "aria-busy": isLoading,
14172 "aria-describedby": tableNoticeId,
14173 role: isInfiniteScroll ? "feed" : "listbox",
14174 children: [
14175 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14176 "tr",
14177 {
14178 className: "dataviews-view-table__row",
14179 role: "presentation",
14180 children: [
14181 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14182 BulkSelectionCheckbox,
14183 {
14184 selection,
14185 onChangeSelection,
14186 data,
14187 actions,
14188 getItemId,
14189 disableSelectAll: isInfiniteScroll
14190 }
14191 ) }),
14192 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14193 column_header_menu_default,
14194 {
14195 ref: headerMenuRef(
14196 titleField.id,
14197 0
14198 ),
14199 fieldId: titleField.id,
14200 view,
14201 fields,
14202 onChangeView,
14203 onHide,
14204 setOpenedFilter,
14205 canMove: false
14206 }
14207 ) }),
14208 columns.map((column, index2) => {
14209 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14210 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14211 "th",
14212 {
14213 style: {
14214 width,
14215 maxWidth,
14216 minWidth,
14217 textAlign: align
14218 },
14219 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14220 scope: "col",
14221 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14222 column_header_menu_default,
14223 {
14224 ref: headerMenuRef(column, index2),
14225 fieldId: column,
14226 view,
14227 fields,
14228 onChangeView,
14229 onHide,
14230 setOpenedFilter,
14231 canMove: view.layout?.enableMoving ?? true
14232 }
14233 )
14234 },
14235 column
14236 );
14237 })
14238 ]
14239 }
14240 ) }),
14241 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14242 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14243 import_components15.Composite,
14244 {
14245 virtualFocus: true,
14246 orientation: "vertical",
14247 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14248 children: [
14249 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14250 "tr",
14251 {
14252 className: "dataviews-view-table__group-header-row",
14253 role: "presentation",
14254 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14255 "td",
14256 {
14257 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14258 className: "dataviews-view-table__group-header-cell",
14259 role: "presentation",
14260 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14261 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14262 (0, import_i18n18.__)("%1$s: %2$s"),
14263 groupField.label,
14264 groupName
14265 )
14266 }
14267 )
14268 }
14269 ),
14270 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14271 TableRow2,
14272 {
14273 item,
14274 fields,
14275 id: getItemId(item) || index2.toString(),
14276 view,
14277 titleField,
14278 mediaField,
14279 descriptionField,
14280 selection,
14281 getItemId,
14282 onChangeSelection,
14283 multiselect: isMultiselect
14284 },
14285 getItemId(item)
14286 ))
14287 ]
14288 },
14289 `group-${groupName}`
14290 )
14291 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14292 import_components15.Composite,
14293 {
14294 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14295 virtualFocus: true,
14296 orientation: "vertical",
14297 children: hasData && data.map((item, index2) => {
14298 const itemId = getItemId(item);
14299 const posinset = item.position;
14300 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14301 TableRow2,
14302 {
14303 item,
14304 fields,
14305 id: itemId || index2.toString(),
14306 view,
14307 titleField,
14308 mediaField,
14309 descriptionField,
14310 selection,
14311 getItemId,
14312 onChangeSelection,
14313 multiselect: isMultiselect,
14314 posinset
14315 },
14316 itemId
14317 );
14318 })
14319 }
14320 )
14321 ]
14322 }
14323 ),
14324 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14325 "div",
14326 {
14327 className: clsx_default({
14328 "dataviews-loading": isLoading,
14329 "dataviews-no-results": !hasData && !isLoading
14330 }),
14331 id: tableNoticeId,
14332 children: [
14333 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14334 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14335 ]
14336 }
14337 )
14338 ] });
14339 }
14340 var picker_table_default = ViewPickerTable;
14341
14342 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14343 var import_components16 = __toESM(require_components(), 1);
14344 var import_element39 = __toESM(require_element(), 1);
14345 var import_compose7 = __toESM(require_compose(), 1);
14346 var import_i18n19 = __toESM(require_i18n(), 1);
14347 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14348 function isDefined4(item) {
14349 return !!item;
14350 }
14351 function PickerActivityItem({
14352 view,
14353 multiselect,
14354 selection,
14355 onChangeSelection,
14356 getItemId,
14357 item,
14358 titleField,
14359 mediaField,
14360 descriptionField,
14361 otherFields,
14362 posinset,
14363 setsize
14364 }) {
14365 const elementRef = (0, import_element39.useRef)(null);
14366 useIntersectionObserver(elementRef, posinset);
14367 const { showTitle = true, showMedia = true, showDescription = true } = view;
14368 const id = getItemId(item);
14369 const isSelected2 = selection.includes(id);
14370 const density = view.layout?.density ?? "balanced";
14371 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14372 mediaField.render,
14373 {
14374 item,
14375 field: mediaField,
14376 config: {
14377 sizes: density === "comfortable" ? "32px" : "24px"
14378 }
14379 }
14380 ) : null;
14381 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14382 "span",
14383 {
14384 className: "dataviews-view-picker-activity__item-bullet",
14385 "aria-hidden": "true"
14386 }
14387 ) });
14388 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
14389 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14390 const verticalGap = (0, import_element39.useMemo)(() => {
14391 switch (density) {
14392 case "comfortable":
14393 return "md";
14394 default:
14395 return "sm";
14396 }
14397 }, [density]);
14398 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14399 import_components16.Composite.Item,
14400 {
14401 ref: elementRef,
14402 role: "option",
14403 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14404 "aria-posinset": posinset,
14405 "aria-setsize": setsize,
14406 "aria-selected": isSelected2,
14407 className: clsx_default(
14408 "dataviews-view-picker-activity__item",
14409 density === "compact" && "is-compact",
14410 density === "balanced" && "is-balanced",
14411 density === "comfortable" && "is-comfortable",
14412 isSelected2 && "is-selected"
14413 ),
14414 onClick: () => {
14415 if (isSelected2) {
14416 onChangeSelection(
14417 selection.filter((itemId) => id !== itemId)
14418 );
14419 } else {
14420 const newSelection = multiselect ? [...selection, id] : [id];
14421 onChangeSelection(newSelection);
14422 }
14423 },
14424 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
14425 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14426 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14427 Stack,
14428 {
14429 direction: "column",
14430 gap: "xs",
14431 align: "center",
14432 className: "dataviews-view-picker-activity__item-type",
14433 children: renderedMediaField
14434 }
14435 ),
14436 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14437 Stack,
14438 {
14439 direction: "column",
14440 gap: verticalGap,
14441 align: "flex-start",
14442 className: "dataviews-view-picker-activity__item-content",
14443 children: [
14444 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14445 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14446 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14447 "div",
14448 {
14449 className: "dataviews-view-picker-activity__item-field",
14450 children: [
14451 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14452 VisuallyHidden,
14453 {
14454 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
14455 className: "dataviews-view-picker-activity__item-field-label",
14456 children: field.label
14457 }
14458 ),
14459 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14460 field.render,
14461 {
14462 item,
14463 field
14464 }
14465 ) })
14466 ]
14467 },
14468 field.id
14469 )) })
14470 ]
14471 }
14472 )
14473 ] })
14474 }
14475 );
14476 }
14477 function PickerActivityGroup({
14478 groupName,
14479 groupField,
14480 showLabel = true,
14481 children
14482 }) {
14483 const headerId = (0, import_compose7.useInstanceId)(
14484 PickerActivityGroup,
14485 "dataviews-view-picker-activity-group__header"
14486 );
14487 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14488 Stack,
14489 {
14490 direction: "column",
14491 role: "group",
14492 "aria-labelledby": headerId,
14493 className: "dataviews-view-picker-activity-group",
14494 children: [
14495 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14496 "h3",
14497 {
14498 className: "dataviews-view-picker-activity-group__header",
14499 id: headerId,
14500 children: showLabel ? (0, import_i18n19.sprintf)(
14501 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14502 (0, import_i18n19.__)("%1$s: %2$s"),
14503 groupField.label,
14504 groupName
14505 ) : groupName
14506 }
14507 ),
14508 children
14509 ]
14510 }
14511 );
14512 }
14513 function ViewPickerActivity({
14514 data,
14515 fields,
14516 getItemId,
14517 isLoading,
14518 onChangeSelection,
14519 selection,
14520 view,
14521 actions,
14522 className,
14523 empty
14524 }) {
14525 const { itemListLabel, paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14526 const isMultiselect = useIsMultiselectPicker(actions);
14527 const titleField = fields.find(
14528 (field) => field.id === view?.titleField
14529 );
14530 const mediaField = fields.find(
14531 (field) => field.id === view?.mediaField
14532 );
14533 const descriptionField = fields.find(
14534 (field) => field.id === view?.descriptionField
14535 );
14536 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14537 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14538 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14539 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14540 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14541 const hasData = !!data?.length;
14542 const isGrouped = !!(groupField && dataByGroup);
14543 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14544 PickerActivityItem,
14545 {
14546 view,
14547 multiselect: isMultiselect,
14548 selection,
14549 onChangeSelection,
14550 getItemId,
14551 item,
14552 titleField,
14553 mediaField,
14554 descriptionField,
14555 otherFields,
14556 posinset: item.position,
14557 setsize
14558 },
14559 getItemId(item)
14560 );
14561 if (!hasData) {
14562 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14563 "div",
14564 {
14565 className: clsx_default({
14566 "dataviews-loading": isLoading,
14567 "dataviews-no-results": !isLoading
14568 }),
14569 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) }) : empty
14570 }
14571 );
14572 }
14573 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
14574 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14575 import_components16.Composite,
14576 {
14577 virtualFocus: true,
14578 orientation: "vertical",
14579 role: "listbox",
14580 "aria-multiselectable": isMultiselect,
14581 "aria-label": itemListLabel,
14582 "aria-busy": isLoading,
14583 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
14584 className: clsx_default(
14585 "dataviews-view-picker-activity",
14586 className
14587 ),
14588 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
14589 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14590 PickerActivityGroup,
14591 {
14592 groupName,
14593 groupField,
14594 showLabel: view.groupBy?.showLabel !== false,
14595 children: groupItems.map(renderItem)
14596 },
14597 groupName
14598 )
14599 ) : data.map(renderItem)
14600 }
14601 ),
14602 isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) })
14603 ] });
14604 }
14605
14606 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14607 var import_components17 = __toESM(require_components(), 1);
14608 var import_i18n20 = __toESM(require_i18n(), 1);
14609 var import_element40 = __toESM(require_element(), 1);
14610 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14611 function DensityPicker() {
14612 const context = (0, import_element40.useContext)(dataviews_context_default);
14613 const view = context.view;
14614 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
14615 import_components17.__experimentalToggleGroupControl,
14616 {
14617 size: "__unstable-large",
14618 label: (0, import_i18n20.__)("Density"),
14619 value: view.layout?.density || "balanced",
14620 onChange: (value) => {
14621 context.onChangeView({
14622 ...view,
14623 layout: {
14624 ...view.layout,
14625 density: value
14626 }
14627 });
14628 },
14629 isBlock: true,
14630 children: [
14631 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14632 import_components17.__experimentalToggleGroupControlOption,
14633 {
14634 value: "comfortable",
14635 label: (0, import_i18n20._x)(
14636 "Comfortable",
14637 "Density option for DataView layout"
14638 )
14639 },
14640 "comfortable"
14641 ),
14642 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14643 import_components17.__experimentalToggleGroupControlOption,
14644 {
14645 value: "balanced",
14646 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14647 },
14648 "balanced"
14649 ),
14650 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14651 import_components17.__experimentalToggleGroupControlOption,
14652 {
14653 value: "compact",
14654 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14655 },
14656 "compact"
14657 )
14658 ]
14659 }
14660 );
14661 }
14662
14663 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14664 var import_components18 = __toESM(require_components(), 1);
14665 var import_i18n21 = __toESM(require_i18n(), 1);
14666 var import_element41 = __toESM(require_element(), 1);
14667 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14668 var imageSizes2 = [
14669 {
14670 value: 120,
14671 breakpoint: 1
14672 },
14673 {
14674 value: 170,
14675 breakpoint: 1
14676 },
14677 {
14678 value: 230,
14679 breakpoint: 1
14680 },
14681 {
14682 value: 290,
14683 breakpoint: 1112
14684 // at minimum image width, 4 images display at this container size
14685 },
14686 {
14687 value: 350,
14688 breakpoint: 1636
14689 // at minimum image width, 6 images display at this container size
14690 },
14691 {
14692 value: 430,
14693 breakpoint: 588
14694 // at minimum image width, 2 images display at this container size
14695 }
14696 ];
14697 function PreviewSizePicker() {
14698 const context = (0, import_element41.useContext)(dataviews_context_default);
14699 const view = context.view;
14700 const breakValues = imageSizes2.filter((size4) => {
14701 return context.containerWidth >= size4.breakpoint;
14702 });
14703 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14704 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14705 const marks = breakValues.map((size4, index2) => {
14706 return {
14707 value: index2
14708 };
14709 });
14710 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
14711 import_components18.RangeControl,
14712 {
14713 __next40pxDefaultSize: true,
14714 showTooltip: false,
14715 label: (0, import_i18n21.__)("Preview size"),
14716 value: previewSizeToUse,
14717 min: 0,
14718 max: breakValues.length - 1,
14719 withInputField: false,
14720 onChange: (value = 0) => {
14721 context.onChangeView({
14722 ...view,
14723 layout: {
14724 ...view.layout,
14725 previewSize: breakValues[value].value
14726 }
14727 });
14728 },
14729 step: 1,
14730 marks
14731 }
14732 );
14733 }
14734
14735 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14736 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14737 function GridConfigOptions() {
14738 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
14739 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DensityPicker, {}),
14740 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(PreviewSizePicker, {})
14741 ] });
14742 }
14743
14744 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14745 var VIEW_LAYOUTS = [
14746 {
14747 type: LAYOUT_TABLE,
14748 label: (0, import_i18n22.__)("Table"),
14749 component: table_default,
14750 icon: block_table_default,
14751 viewConfigOptions: DensityPicker
14752 },
14753 {
14754 type: LAYOUT_GRID,
14755 label: (0, import_i18n22.__)("Grid"),
14756 component: grid_default,
14757 icon: category_default,
14758 viewConfigOptions: GridConfigOptions
14759 },
14760 {
14761 type: LAYOUT_LIST,
14762 label: (0, import_i18n22.__)("List"),
14763 component: ViewList,
14764 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14765 viewConfigOptions: DensityPicker
14766 },
14767 {
14768 type: LAYOUT_ACTIVITY,
14769 label: (0, import_i18n22.__)("Activity"),
14770 component: ViewActivity,
14771 icon: scheduled_default,
14772 viewConfigOptions: DensityPicker
14773 },
14774 {
14775 type: LAYOUT_PICKER_GRID,
14776 label: (0, import_i18n22.__)("Grid"),
14777 component: picker_grid_default,
14778 icon: category_default,
14779 viewConfigOptions: GridConfigOptions,
14780 isPicker: true
14781 },
14782 {
14783 type: LAYOUT_PICKER_TABLE,
14784 label: (0, import_i18n22.__)("Table"),
14785 component: picker_table_default,
14786 icon: block_table_default,
14787 viewConfigOptions: DensityPicker,
14788 isPicker: true
14789 },
14790 {
14791 type: LAYOUT_PICKER_ACTIVITY,
14792 label: (0, import_i18n22.__)("Activity"),
14793 component: ViewPickerActivity,
14794 icon: scheduled_default,
14795 viewConfigOptions: DensityPicker,
14796 isPicker: true
14797 }
14798 ];
14799
14800 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14801 var import_element49 = __toESM(require_element(), 1);
14802
14803 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14804 var import_components21 = __toESM(require_components(), 1);
14805 var import_i18n25 = __toESM(require_i18n(), 1);
14806 var import_element46 = __toESM(require_element(), 1);
14807
14808 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
14809 var import_react7 = __toESM(require_react(), 1);
14810 var FocusableContext = (0, import_react7.createContext)(true);
14811
14812 // node_modules/@ariakit/utils/dist/index.js
14813 function toArray(arg) {
14814 if (Array.isArray(arg)) return arg;
14815 return typeof arg !== "undefined" ? [arg] : [];
14816 }
14817 function flatten2DArray(array) {
14818 const flattened = [];
14819 for (const row of array) flattened.push(...row);
14820 return flattened;
14821 }
14822 function reverseArray(array) {
14823 return array.slice().reverse();
14824 }
14825 var canUseDOM = checkIsBrowser();
14826 function checkIsBrowser() {
14827 return typeof window !== "undefined" && !!window.document?.createElement;
14828 }
14829 function getDocument(node) {
14830 if (!node) return document;
14831 if ("self" in node) return node.document;
14832 return node.ownerDocument || document;
14833 }
14834 function getActiveElement(node, activeDescendant = false) {
14835 const { activeElement: activeElement2 } = getDocument(node);
14836 if (!activeElement2?.nodeName) return null;
14837 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
14838 if (activeDescendant) {
14839 const id = activeElement2.getAttribute("aria-activedescendant");
14840 if (id) {
14841 const element = getDocument(activeElement2).getElementById(id);
14842 if (element) return element;
14843 }
14844 }
14845 return activeElement2;
14846 }
14847 function contains2(parent, child) {
14848 return parent === child || parent.contains(child);
14849 }
14850 function isElement2(target) {
14851 return target?.nodeType === 1;
14852 }
14853 function isNode2(target) {
14854 return typeof target?.nodeType === "number";
14855 }
14856 function isFrame(element) {
14857 return element.tagName === "IFRAME";
14858 }
14859 function isButton(element) {
14860 const tagName = element.tagName.toLowerCase();
14861 if (tagName === "button") return true;
14862 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
14863 return false;
14864 }
14865 var buttonInputTypes = [
14866 "button",
14867 "color",
14868 "file",
14869 "image",
14870 "reset",
14871 "submit"
14872 ];
14873 function isVisible(element) {
14874 if (typeof element.checkVisibility === "function") return element.checkVisibility();
14875 const htmlElement = element;
14876 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
14877 }
14878 function isTextField(element) {
14879 try {
14880 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
14881 const isTextArea = element.tagName === "TEXTAREA";
14882 return isTextInput || isTextArea || false;
14883 } catch (_error) {
14884 return false;
14885 }
14886 }
14887 function isTextbox(element) {
14888 return element.isContentEditable || isTextField(element);
14889 }
14890 function getTextboxValue(element) {
14891 if (isTextField(element)) return element.value;
14892 if (element.isContentEditable) {
14893 const range = getDocument(element).createRange();
14894 range.selectNodeContents(element);
14895 return range.toString();
14896 }
14897 return "";
14898 }
14899 function getTextboxSelection(element) {
14900 let start = 0;
14901 let end = 0;
14902 if (isTextField(element)) {
14903 start = element.selectionStart || 0;
14904 end = element.selectionEnd || 0;
14905 } else if (element.isContentEditable) {
14906 const selection = getDocument(element).getSelection();
14907 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
14908 const range = selection.getRangeAt(0);
14909 const nextRange = range.cloneRange();
14910 nextRange.selectNodeContents(element);
14911 nextRange.setEnd(range.startContainer, range.startOffset);
14912 start = nextRange.toString().length;
14913 nextRange.setEnd(range.endContainer, range.endOffset);
14914 end = nextRange.toString().length;
14915 }
14916 }
14917 return {
14918 start,
14919 end
14920 };
14921 }
14922 function getPopupRole(element, fallback) {
14923 const allowedPopupRoles = [
14924 "dialog",
14925 "menu",
14926 "listbox",
14927 "tree",
14928 "grid"
14929 ];
14930 const role = element?.getAttribute("role");
14931 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
14932 return fallback;
14933 }
14934 function getScrollingElement(element) {
14935 if (!element) return null;
14936 const isScrollableOverflow = (overflow) => {
14937 if (overflow === "auto") return true;
14938 if (overflow === "scroll") return true;
14939 return false;
14940 };
14941 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
14942 const { overflowY } = getComputedStyle(element);
14943 if (isScrollableOverflow(overflowY)) return element;
14944 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
14945 const { overflowX } = getComputedStyle(element);
14946 if (isScrollableOverflow(overflowX)) return element;
14947 }
14948 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
14949 }
14950 function setSelectionRange(element, ...args) {
14951 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
14952 }
14953 function sortBasedOnDOMPosition(items, getElement) {
14954 const pairs = items.map((item, index2) => [index2, item]);
14955 let isOrderDifferent = false;
14956 pairs.sort(([indexA, a2], [indexB, b2]) => {
14957 const elementA = getElement(a2);
14958 const elementB = getElement(b2);
14959 if (elementA === elementB) return 0;
14960 if (!elementA || !elementB) return 0;
14961 if (isElementPreceding(elementA, elementB)) {
14962 if (indexA > indexB) isOrderDifferent = true;
14963 return -1;
14964 }
14965 if (indexA < indexB) isOrderDifferent = true;
14966 return 1;
14967 });
14968 if (isOrderDifferent) return pairs.map(([_, item]) => item);
14969 return items;
14970 }
14971 function isElementPreceding(a2, b2) {
14972 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
14973 }
14974 function isTouchDevice() {
14975 return canUseDOM && !!navigator.maxTouchPoints;
14976 }
14977 function isApple() {
14978 if (!canUseDOM) return false;
14979 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
14980 }
14981 function isSafari2() {
14982 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
14983 }
14984 function isFirefox2() {
14985 return canUseDOM && /firefox\//i.test(navigator.userAgent);
14986 }
14987 function isPortalEvent(event) {
14988 const { currentTarget, target } = event;
14989 if (!currentTarget) return false;
14990 if (!isNode2(target)) return true;
14991 return !contains2(currentTarget, target);
14992 }
14993 function isSelfTarget(event) {
14994 return event.target === event.currentTarget;
14995 }
14996 function isOpeningInNewTab(event) {
14997 const element = event.currentTarget;
14998 if (!element) return false;
14999 const isAppleDevice = isApple();
15000 if (isAppleDevice && !event.metaKey) return false;
15001 if (!isAppleDevice && !event.ctrlKey) return false;
15002 const tagName = element.tagName.toLowerCase();
15003 if (tagName === "a") return true;
15004 if (tagName === "button" && element.type === "submit") return true;
15005 if (tagName === "input" && element.type === "submit") return true;
15006 return false;
15007 }
15008 function isDownloading(event) {
15009 const element = event.currentTarget;
15010 if (!element) return false;
15011 const tagName = element.tagName.toLowerCase();
15012 if (!event.altKey) return false;
15013 if (tagName === "a") return true;
15014 if (tagName === "button" && element.type === "submit") return true;
15015 if (tagName === "input" && element.type === "submit") return true;
15016 return false;
15017 }
15018 function fireBlurEvent(element, eventInit) {
15019 const event = new FocusEvent("blur", eventInit);
15020 const defaultAllowed = element.dispatchEvent(event);
15021 const bubbleInit = {
15022 ...eventInit,
15023 bubbles: true
15024 };
15025 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15026 return defaultAllowed;
15027 }
15028 function fireKeyboardEvent(element, type, eventInit) {
15029 const event = new KeyboardEvent(type, eventInit);
15030 return element.dispatchEvent(event);
15031 }
15032 function fireClickEvent(element, eventInit) {
15033 const event = new MouseEvent("click", eventInit);
15034 return element.dispatchEvent(event);
15035 }
15036 function isFocusEventOutside(event, container) {
15037 const containerElement = container || event.currentTarget;
15038 const relatedTarget = event.relatedTarget;
15039 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15040 }
15041 function queueBeforeEvent(element, type, callback, timeout) {
15042 const createTimer = (callback2) => {
15043 if (timeout) {
15044 const timerId2 = setTimeout(callback2, timeout);
15045 return () => clearTimeout(timerId2);
15046 }
15047 const timerId = requestAnimationFrame(callback2);
15048 return () => cancelAnimationFrame(timerId);
15049 };
15050 const cancelTimer = createTimer(() => {
15051 element.removeEventListener(type, callSync, true);
15052 callback();
15053 });
15054 const callSync = () => {
15055 cancelTimer();
15056 callback();
15057 };
15058 element.addEventListener(type, callSync, {
15059 once: true,
15060 capture: true
15061 });
15062 return cancelTimer;
15063 }
15064 function addGlobalEventListener(type, listener, options, scope = window) {
15065 const children = [];
15066 try {
15067 scope.document.addEventListener(type, listener, options);
15068 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15069 } catch {
15070 }
15071 const removeEventListener = () => {
15072 try {
15073 scope.document.removeEventListener(type, listener, options);
15074 } catch {
15075 }
15076 for (const remove of children) remove();
15077 };
15078 return removeEventListener;
15079 }
15080 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'])";
15081 function isFocusable(element) {
15082 if (!element.matches(selector)) return false;
15083 if (!isVisible(element)) return false;
15084 if (element.closest("[inert]")) return false;
15085 return true;
15086 }
15087 function hasFocus(element) {
15088 const activeElement2 = getActiveElement(element);
15089 if (!activeElement2) return false;
15090 if (activeElement2 === element) return true;
15091 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15092 if (!activeDescendant) return false;
15093 return activeDescendant === element.id;
15094 }
15095 function hasFocusWithin(element) {
15096 const activeElement2 = getActiveElement(element);
15097 if (!activeElement2) return false;
15098 if (contains2(element, activeElement2)) return true;
15099 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15100 if (!activeDescendant) return false;
15101 if (!("id" in element)) return false;
15102 if (activeDescendant === element.id) return true;
15103 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15104 }
15105 function focusIntoView(element, options) {
15106 if (!("scrollIntoView" in element)) element.focus();
15107 else {
15108 element.focus({ preventScroll: true });
15109 element.scrollIntoView({
15110 block: "nearest",
15111 inline: "nearest",
15112 ...options
15113 });
15114 }
15115 }
15116 function noop4(..._) {
15117 }
15118 function hasOwnProperty(object, prop) {
15119 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15120 return Object.prototype.hasOwnProperty.call(object, prop);
15121 }
15122 function chain(...fns) {
15123 return (...args) => {
15124 for (const fn of fns) if (typeof fn === "function") fn(...args);
15125 };
15126 }
15127 function normalizeString(str) {
15128 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15129 }
15130 function omit2(object, keys) {
15131 const result = { ...object };
15132 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15133 return result;
15134 }
15135 function pick(object, paths) {
15136 const result = {};
15137 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15138 return result;
15139 }
15140 function identity(value) {
15141 return value;
15142 }
15143 function invariant(condition, message2) {
15144 if (condition) return;
15145 if (typeof message2 !== "string") throw new Error("Invariant failed");
15146 throw new Error(message2);
15147 }
15148 function getKeys(obj) {
15149 return Object.keys(obj);
15150 }
15151 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15152 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15153 if (result == null) return false;
15154 return !result;
15155 }
15156 function disabledFromProps(props) {
15157 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15158 }
15159 function removeUndefinedValues(obj) {
15160 const result = {};
15161 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15162 return result;
15163 }
15164 function defaultValue(...values) {
15165 for (const value of values) if (value !== void 0) return value;
15166 }
15167 function createUndoCallback(callback) {
15168 return async () => {
15169 const redo = await callback?.();
15170 return createUndoCallback(async () => {
15171 await redo?.();
15172 return callback;
15173 });
15174 };
15175 }
15176 var UndoManager = createUndoManager();
15177 function createUndoManager({ limit = 100 } = {}) {
15178 const undoStack = [];
15179 let redoStack = [];
15180 let currentGroup = null;
15181 const canUndo = () => undoStack.length > 0;
15182 const canRedo = () => redoStack.length > 0;
15183 const undo = async () => {
15184 if (!canUndo()) return;
15185 currentGroup = null;
15186 redoStack.push(await undoStack.pop()?.());
15187 };
15188 const redo = async () => {
15189 if (!canRedo()) return;
15190 currentGroup = null;
15191 undoStack.push(await redoStack.pop()?.());
15192 };
15193 const execute = async (callback, group) => {
15194 if (!callback) return;
15195 while (undoStack.length > limit) undoStack.shift();
15196 const sameGroup = group === currentGroup;
15197 currentGroup = group ?? null;
15198 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15199 const undoCallback = await callback();
15200 if (!undoCallback) return;
15201 redoStack = [];
15202 const currentUndo = undoStack[nextIndex];
15203 undoStack[nextIndex] = createUndoCallback(async () => {
15204 await undoCallback?.();
15205 const currentRedo = await currentUndo?.();
15206 return async () => {
15207 await currentRedo?.();
15208 await callback?.();
15209 };
15210 });
15211 };
15212 return {
15213 canUndo,
15214 canRedo,
15215 undo,
15216 redo,
15217 execute
15218 };
15219 }
15220
15221 // node_modules/@ariakit/react-utils/dist/index.js
15222 var React48 = __toESM(require_react(), 1);
15223 var import_react8 = __toESM(require_react(), 1);
15224 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15225 function setRef(ref, value) {
15226 if (typeof ref === "function") ref(value);
15227 else if (ref) ref.current = value;
15228 }
15229 function isValidElementWithRef(element) {
15230 if (!element) return false;
15231 if (!(0, import_react8.isValidElement)(element)) return false;
15232 if ("ref" in element.props) return true;
15233 if ("ref" in element) return true;
15234 return false;
15235 }
15236 function getRefProperty(element) {
15237 if (!isValidElementWithRef(element)) return null;
15238 return { ...element.props }.ref || element.ref;
15239 }
15240 function mergeProps2(base, overrides) {
15241 const props = { ...base };
15242 for (const key in overrides) {
15243 if (!hasOwnProperty(overrides, key)) continue;
15244 if (key === "className") {
15245 const prop = "className";
15246 const baseClass = base[prop];
15247 const overrideClass = overrides[prop];
15248 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15249 else props[prop] = overrideClass || baseClass;
15250 continue;
15251 }
15252 if (key === "style") {
15253 const prop = "style";
15254 props[prop] = base[prop] ? {
15255 ...base[prop],
15256 ...overrides[prop]
15257 } : overrides[prop];
15258 continue;
15259 }
15260 const overrideValue = overrides[key];
15261 if (key.startsWith("on")) {
15262 if (typeof overrideValue !== "function") continue;
15263 const baseValue = base[key];
15264 if (typeof baseValue === "function") {
15265 props[key] = (...args) => {
15266 overrideValue(...args);
15267 baseValue(...args);
15268 };
15269 continue;
15270 }
15271 }
15272 props[key] = overrideValue;
15273 }
15274 return props;
15275 }
15276 var _React = { ...React48 };
15277 var useReactId = _React.useId;
15278 var useReactDeferredValue = _React.useDeferredValue;
15279 var useReactInsertionEffect = _React.useInsertionEffect;
15280 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
15281 function useInitialValue(value) {
15282 const [initialValue] = (0, import_react8.useState)(value);
15283 return initialValue;
15284 }
15285 function useLiveRef(value) {
15286 const ref = (0, import_react8.useRef)(value);
15287 useSafeLayoutEffect(() => {
15288 ref.current = value;
15289 });
15290 return ref;
15291 }
15292 function useEvent(callback) {
15293 const ref = (0, import_react8.useRef)(() => {
15294 throw new Error("Cannot call an event handler while rendering.");
15295 });
15296 if (useReactInsertionEffect) useReactInsertionEffect(() => {
15297 ref.current = callback;
15298 });
15299 else ref.current = callback;
15300 return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
15301 }
15302 function useTransactionState(callback) {
15303 const [state, setState] = (0, import_react8.useState)(null);
15304 useSafeLayoutEffect(() => {
15305 if (state == null) return;
15306 if (!callback) return;
15307 let prevState = null;
15308 callback((prev) => {
15309 prevState = prev;
15310 return state;
15311 });
15312 return () => {
15313 callback(prevState);
15314 };
15315 }, [state, callback]);
15316 return [state, setState];
15317 }
15318 function useMergeRefs(...refs) {
15319 return (0, import_react8.useMemo)(() => {
15320 if (!refs.some(Boolean)) return;
15321 return (value) => {
15322 for (const ref of refs) setRef(ref, value);
15323 };
15324 }, refs);
15325 }
15326 function useId4(defaultId) {
15327 if (useReactId) {
15328 const reactId = useReactId();
15329 if (defaultId) return defaultId;
15330 return reactId;
15331 }
15332 const [id, setId] = (0, import_react8.useState)(defaultId);
15333 useSafeLayoutEffect(() => {
15334 if (defaultId || id) return;
15335 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
15336 }, [defaultId, id]);
15337 return defaultId || id;
15338 }
15339 function useTagName(refOrElement, type) {
15340 const stringOrUndefined = (type2) => {
15341 if (typeof type2 !== "string") return;
15342 return type2;
15343 };
15344 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
15345 useSafeLayoutEffect(() => {
15346 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
15347 }, [refOrElement, type]);
15348 return tagName;
15349 }
15350 function useAttribute(refOrElement, attributeName, defaultValue2) {
15351 const initialValue = useInitialValue(defaultValue2);
15352 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
15353 (0, import_react8.useEffect)(() => {
15354 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15355 if (!element) return;
15356 const callback = () => {
15357 const value = element.getAttribute(attributeName);
15358 setAttribute(value == null ? initialValue : value);
15359 };
15360 const observer = new MutationObserver(callback);
15361 observer.observe(element, { attributeFilter: [attributeName] });
15362 callback();
15363 return () => observer.disconnect();
15364 }, [
15365 refOrElement,
15366 attributeName,
15367 initialValue
15368 ]);
15369 return attribute;
15370 }
15371 function useUpdateEffect(effect, deps) {
15372 const mounted = (0, import_react8.useRef)(false);
15373 (0, import_react8.useEffect)(() => {
15374 if (mounted.current) return effect();
15375 mounted.current = true;
15376 }, deps);
15377 (0, import_react8.useEffect)(() => () => {
15378 mounted.current = false;
15379 }, []);
15380 }
15381 function useUpdateLayoutEffect(effect, deps) {
15382 const mounted = (0, import_react8.useRef)(false);
15383 useSafeLayoutEffect(() => {
15384 if (mounted.current) return effect();
15385 mounted.current = true;
15386 }, deps);
15387 useSafeLayoutEffect(() => () => {
15388 mounted.current = false;
15389 }, []);
15390 }
15391 function useForceUpdate() {
15392 return (0, import_react8.useReducer)(() => [], []);
15393 }
15394 function useBooleanEvent(booleanOrCallback) {
15395 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
15396 }
15397 function useWrapElement(props, callback, deps = []) {
15398 const wrapElement = (0, import_react8.useCallback)((element) => {
15399 if (props.wrapElement) element = props.wrapElement(element);
15400 return callback(element);
15401 }, [...deps, props.wrapElement]);
15402 return {
15403 ...props,
15404 wrapElement
15405 };
15406 }
15407 function useMetadataProps(props, key, value) {
15408 const parent = props.onLoadedMetadataCapture;
15409 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
15410 return Object.assign(() => {
15411 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
15412 }, [
15413 parent,
15414 key,
15415 value
15416 ]);
15417 return [parent?.[key], { onLoadedMetadataCapture }];
15418 }
15419 var hasInstalledGlobalEventListeners = false;
15420 function useIsMouseMoving() {
15421 (0, import_react8.useEffect)(() => {
15422 if (hasInstalledGlobalEventListeners) return;
15423 addGlobalEventListener("mousemove", setMouseMoving, true);
15424 addGlobalEventListener("mousedown", resetMouseMoving, true);
15425 addGlobalEventListener("mouseup", resetMouseMoving, true);
15426 addGlobalEventListener("keydown", resetMouseMoving, true);
15427 addGlobalEventListener("scroll", resetMouseMoving, true);
15428 hasInstalledGlobalEventListeners = true;
15429 }, []);
15430 return useEvent(() => mouseMoving);
15431 }
15432 var mouseMoving = false;
15433 var previousScreenX = 0;
15434 var previousScreenY = 0;
15435 function hasMouseMovement(event) {
15436 const movementX = event.movementX || event.screenX - previousScreenX;
15437 const movementY = event.movementY || event.screenY - previousScreenY;
15438 previousScreenX = event.screenX;
15439 previousScreenY = event.screenY;
15440 return movementX || movementY || false;
15441 }
15442 function setMouseMoving(event) {
15443 if (!hasMouseMovement(event)) return;
15444 mouseMoving = true;
15445 }
15446 function resetMouseMoving() {
15447 mouseMoving = false;
15448 }
15449 function forwardRef21(render4) {
15450 const Role = React48.forwardRef((props, ref) => render4({
15451 ...props,
15452 ref
15453 }));
15454 Role.displayName = render4.displayName || render4.name;
15455 return Role;
15456 }
15457 function memo3(Component, propsAreEqual) {
15458 return React48.memo(Component, propsAreEqual);
15459 }
15460 function createElement3(Type, props) {
15461 const { wrapElement, render: render4, ...rest } = props;
15462 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15463 let element;
15464 if (React48.isValidElement(render4)) {
15465 const renderProps = {
15466 ...render4.props,
15467 ref: mergedRef
15468 };
15469 element = React48.cloneElement(render4, mergeProps2(rest, renderProps));
15470 } else if (render4) element = render4(rest);
15471 else element = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Type, { ...rest });
15472 if (wrapElement) return wrapElement(element);
15473 return element;
15474 }
15475 function createHook(useProps) {
15476 const useRole = (props = {}) => {
15477 return useProps(props);
15478 };
15479 useRole.displayName = useProps.name;
15480 return useRole;
15481 }
15482 function createStoreContext(providers = [], scopedProviders = []) {
15483 const context = React48.createContext(void 0);
15484 const scopedContext = React48.createContext(void 0);
15485 const useContext38 = () => React48.useContext(context);
15486 const useScopedContext = (onlyScoped = false) => {
15487 const scoped = React48.useContext(scopedContext);
15488 const store = useContext38();
15489 if (onlyScoped) return scoped;
15490 return scoped || store;
15491 };
15492 const useProviderContext = () => {
15493 const scoped = React48.useContext(scopedContext);
15494 const store = useContext38();
15495 if (scoped && scoped === store) return;
15496 return store;
15497 };
15498 const ContextProvider = (props) => {
15499 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15500 ...props,
15501 children
15502 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(context.Provider, { ...props }));
15503 };
15504 const ScopedContextProvider = (props) => {
15505 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ContextProvider, {
15506 ...props,
15507 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15508 ...props,
15509 children
15510 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(scopedContext.Provider, { ...props }))
15511 });
15512 };
15513 return {
15514 context,
15515 scopedContext,
15516 useContext: useContext38,
15517 useScopedContext,
15518 useProviderContext,
15519 ContextProvider,
15520 ScopedContextProvider
15521 };
15522 }
15523
15524 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
15525 var import_react9 = __toESM(require_react(), 1);
15526 var TagName = "div";
15527 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
15528 var isSafariBrowser = isSafari2();
15529 var alwaysFocusVisibleInputTypes = [
15530 "text",
15531 "search",
15532 "url",
15533 "tel",
15534 "email",
15535 "password",
15536 "number",
15537 "date",
15538 "month",
15539 "week",
15540 "time",
15541 "datetime",
15542 "datetime-local"
15543 ];
15544 function isAlwaysFocusVisible(element) {
15545 const { tagName, readOnly, type } = element;
15546 if (tagName === "TEXTAREA" && !readOnly) return true;
15547 if (tagName === "SELECT" && !readOnly) return true;
15548 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
15549 if (element.isContentEditable) return true;
15550 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
15551 return false;
15552 }
15553 function isNativeTabbable(tagName) {
15554 if (!tagName) return true;
15555 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15556 }
15557 function supportsDisabledAttribute(tagName) {
15558 if (!tagName) return true;
15559 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15560 }
15561 var buttonInputTypes2 = [
15562 "button",
15563 "color",
15564 "file",
15565 "image",
15566 "reset",
15567 "submit"
15568 ];
15569 function needsSafariTabIndex(tagName, inputType) {
15570 if (tagName === "button") return true;
15571 if (tagName === "input" && inputType) {
15572 if (inputType === "checkbox" || inputType === "radio") return true;
15573 return buttonInputTypes2.includes(inputType);
15574 }
15575 return false;
15576 }
15577 function isNativeSubmitControl(element) {
15578 if (element.tagName === "BUTTON") {
15579 const { type } = element;
15580 return type === "submit";
15581 }
15582 if (element.tagName === "INPUT") {
15583 const { type } = element;
15584 return type === "submit" || type === "image";
15585 }
15586 return false;
15587 }
15588 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
15589 if (!focusable2) return tabIndexProp;
15590 if (trulyDisabled) {
15591 if (nativeTabbable && !supportsDisabled) return -1;
15592 return;
15593 }
15594 if (nativeTabbable) {
15595 if (safariTabIndex && tabIndexProp == null) return 0;
15596 return tabIndexProp;
15597 }
15598 return tabIndexProp ?? 0;
15599 }
15600 function useDisableEvent(onEvent, disabled2) {
15601 return useEvent((event) => {
15602 onEvent?.(event);
15603 if (event.defaultPrevented) return;
15604 if (disabled2) {
15605 event.stopPropagation();
15606 event.preventDefault();
15607 }
15608 });
15609 }
15610 var hasInstalledGlobalEventListeners2 = false;
15611 var isKeyboardModality = true;
15612 function onGlobalMouseDown(event) {
15613 const target = event.target;
15614 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
15615 }
15616 function onGlobalKeyDown(event) {
15617 if (event.metaKey) return;
15618 if (event.ctrlKey) return;
15619 if (event.altKey) return;
15620 isKeyboardModality = true;
15621 }
15622 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
15623 const ref = (0, import_react9.useRef)(null);
15624 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
15625 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
15626 (0, import_react9.useEffect)(() => {
15627 if (!focusable2) return;
15628 if (hasInstalledGlobalEventListeners2) return;
15629 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15630 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15631 hasInstalledGlobalEventListeners2 = true;
15632 }, [focusable2]);
15633 const disabled2 = focusable2 && disabledFromProps(props);
15634 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
15635 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
15636 const focusVisibleRef = (0, import_react9.useRef)(false);
15637 const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
15638 const cleanupFocusVisible = useEvent((element) => {
15639 nativeSubmitObserverCleanupRef.current?.();
15640 nativeSubmitObserverCleanupRef.current = null;
15641 focusVisibleRef.current = false;
15642 element?.removeAttribute("data-focus-visible");
15643 });
15644 (0, import_react9.useEffect)(() => {
15645 if (!focusable2) return;
15646 if (!trulyDisabled) return;
15647 cleanupFocusVisible(ref.current);
15648 if (focusVisible) setFocusVisible(false);
15649 }, [
15650 focusable2,
15651 trulyDisabled,
15652 focusVisible,
15653 cleanupFocusVisible
15654 ]);
15655 (0, import_react9.useEffect)(() => {
15656 if (!focusable2) return;
15657 if (!focusVisible) return;
15658 const element = ref.current;
15659 if (!element) return;
15660 if (typeof IntersectionObserver === "undefined") return;
15661 const observer = new IntersectionObserver(() => {
15662 if (!isFocusable(element)) {
15663 focusVisibleRef.current = false;
15664 setFocusVisible(false);
15665 }
15666 });
15667 observer.observe(element);
15668 return () => observer.disconnect();
15669 }, [focusable2, focusVisible]);
15670 (0, import_react9.useEffect)(() => {
15671 return () => nativeSubmitObserverCleanupRef.current?.();
15672 }, []);
15673 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
15674 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
15675 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15676 const handleFocusVisible = (event, currentTarget) => {
15677 if (currentTarget) event.currentTarget = currentTarget;
15678 if (!focusable2) return;
15679 const element = event.currentTarget;
15680 if (!element) return;
15681 if (!hasFocus(element)) return;
15682 onFocusVisible?.(event);
15683 if (event.defaultPrevented) return;
15684 element.dataset.focusVisible = "true";
15685 focusVisibleRef.current = true;
15686 if (isNativeSubmitControl(element)) {
15687 nativeSubmitObserverCleanupRef.current?.();
15688 nativeSubmitObserverCleanupRef.current = null;
15689 if (typeof IntersectionObserver !== "undefined") {
15690 const observer = new IntersectionObserver(() => {
15691 if (isFocusable(element)) return;
15692 cleanupFocusVisible(element);
15693 });
15694 observer.observe(element);
15695 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
15696 }
15697 return;
15698 }
15699 setFocusVisible(true);
15700 };
15701 const onKeyDownCaptureProp = props.onKeyDownCapture;
15702 const onKeyDownCapture = useEvent((event) => {
15703 onKeyDownCaptureProp?.(event);
15704 if (event.defaultPrevented) return;
15705 if (!focusable2) return;
15706 if (focusVisible) return;
15707 if (focusVisibleRef.current) return;
15708 if (event.metaKey) return;
15709 if (event.altKey) return;
15710 if (event.ctrlKey) return;
15711 if (!isSelfTarget(event)) return;
15712 const element = event.currentTarget;
15713 const applyFocusVisible = () => handleFocusVisible(event, element);
15714 queueBeforeEvent(element, "focusout", applyFocusVisible);
15715 });
15716 const onFocusCaptureProp = props.onFocusCapture;
15717 const onFocusCapture = useEvent((event) => {
15718 onFocusCaptureProp?.(event);
15719 if (event.defaultPrevented) return;
15720 if (!focusable2) return;
15721 if (!isSelfTarget(event)) {
15722 setFocusVisible(false);
15723 return;
15724 }
15725 const element = event.currentTarget;
15726 const applyFocusVisible = () => handleFocusVisible(event, element);
15727 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15728 else setFocusVisible(false);
15729 });
15730 const onBlurProp = props.onBlur;
15731 const onBlur = useEvent((event) => {
15732 onBlurProp?.(event);
15733 if (!focusable2) return;
15734 if (!isFocusEventOutside(event)) return;
15735 cleanupFocusVisible(event.currentTarget);
15736 setFocusVisible(false);
15737 });
15738 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
15739 const autoFocusRef = useEvent((element) => {
15740 if (!focusable2) return;
15741 if (!autoFocus) return;
15742 if (!element) return;
15743 if (!autoFocusOnShow) return;
15744 queueMicrotask(() => {
15745 if (hasFocus(element)) return;
15746 if (!isFocusable(element)) return;
15747 element.focus();
15748 });
15749 });
15750 const tagName = useTagName(ref);
15751 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15752 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15753 const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
15754 if (isSafariBrowser) (0, import_react9.useEffect)(() => {
15755 if (!focusable2) return;
15756 const element = ref.current;
15757 if (!element) return;
15758 const tag = element.tagName.toLowerCase();
15759 const type = element.type;
15760 setSafariTabIndex(needsSafariTabIndex(tag, type));
15761 }, [focusable2]);
15762 const styleProp = props.style;
15763 const style = (0, import_react9.useMemo)(() => {
15764 if (trulyDisabled) return {
15765 pointerEvents: "none",
15766 ...styleProp
15767 };
15768 return styleProp;
15769 }, [trulyDisabled, styleProp]);
15770 props = {
15771 "data-focus-visible": focusable2 && focusVisible || void 0,
15772 "data-autofocus": autoFocus || void 0,
15773 "aria-disabled": disabled2 || void 0,
15774 ...props,
15775 ...metadataProps,
15776 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15777 style,
15778 tabIndex: getTabIndex2({
15779 focusable: focusable2,
15780 trulyDisabled,
15781 nativeTabbable,
15782 supportsDisabled,
15783 safariTabIndex,
15784 tabIndexProp: props.tabIndex
15785 }),
15786 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15787 contentEditable: disabled2 ? void 0 : props.contentEditable,
15788 onKeyPressCapture,
15789 onClickCapture,
15790 onMouseDownCapture,
15791 onKeyDownCapture,
15792 onFocusCapture,
15793 onBlur
15794 };
15795 return removeUndefinedValues(props);
15796 });
15797 var Focusable = forwardRef21(function Focusable2(props) {
15798 return createElement3(TagName, useFocusable(props));
15799 });
15800
15801 // node_modules/@ariakit/react-components/dist/command/command.js
15802 var import_react10 = __toESM(require_react(), 1);
15803 var TagName2 = "button";
15804 function isNativeClick(event) {
15805 if (!event.isTrusted) return false;
15806 const element = event.currentTarget;
15807 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15808 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15809 return false;
15810 }
15811 var symbol = /* @__PURE__ */ Symbol("command");
15812 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15813 const ref = (0, import_react10.useRef)(null);
15814 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
15815 (0, import_react10.useEffect)(() => {
15816 if (!ref.current) return;
15817 setIsNativeButton(isButton(ref.current));
15818 }, []);
15819 const [active, setActive] = (0, import_react10.useState)(false);
15820 const activeRef = (0, import_react10.useRef)(false);
15821 const disabled2 = disabledFromProps(props);
15822 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15823 const onKeyDownProp = props.onKeyDown;
15824 const onKeyDown = useEvent((event) => {
15825 onKeyDownProp?.(event);
15826 const element = event.currentTarget;
15827 if (event.defaultPrevented) return;
15828 if (isDuplicate) return;
15829 if (disabled2) return;
15830 if (!isSelfTarget(event)) return;
15831 if (isTextField(element)) return;
15832 if (element.isContentEditable) return;
15833 const isEnter = clickOnEnter && event.key === "Enter";
15834 const isSpace = clickOnSpace && event.key === " ";
15835 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
15836 const shouldPreventSpace = event.key === " " && !clickOnSpace;
15837 if (shouldPreventEnter || shouldPreventSpace) {
15838 event.preventDefault();
15839 return;
15840 }
15841 if (isEnter || isSpace) {
15842 const nativeClick = isNativeClick(event);
15843 if (isEnter) {
15844 if (!nativeClick) {
15845 event.preventDefault();
15846 const { view, ...eventInit } = event;
15847 const click = () => fireClickEvent(element, eventInit);
15848 if (isFirefox2()) queueBeforeEvent(element, "keyup", click);
15849 else queueMicrotask(click);
15850 }
15851 } else if (isSpace) {
15852 activeRef.current = true;
15853 if (!nativeClick) {
15854 event.preventDefault();
15855 setActive(true);
15856 }
15857 }
15858 }
15859 });
15860 const onKeyUpProp = props.onKeyUp;
15861 const onKeyUp = useEvent((event) => {
15862 onKeyUpProp?.(event);
15863 if (event.defaultPrevented) return;
15864 if (isDuplicate) return;
15865 if (disabled2) return;
15866 if (event.metaKey) return;
15867 const isSpace = clickOnSpace && event.key === " ";
15868 if (activeRef.current && isSpace) {
15869 activeRef.current = false;
15870 if (!isNativeClick(event)) {
15871 event.preventDefault();
15872 setActive(false);
15873 const element = event.currentTarget;
15874 const { view, ...eventInit } = event;
15875 queueMicrotask(() => fireClickEvent(element, eventInit));
15876 }
15877 }
15878 });
15879 props = {
15880 "data-active": active || void 0,
15881 type: isNativeButton ? "button" : void 0,
15882 ...metadataProps,
15883 ...props,
15884 ref: useMergeRefs(ref, props.ref),
15885 onKeyDown,
15886 onKeyUp
15887 };
15888 props = useFocusable(props);
15889 return props;
15890 });
15891 var Command = forwardRef21(function Command2(props) {
15892 return createElement3(TagName2, useCommand(props));
15893 });
15894
15895 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
15896 var ctx = createStoreContext();
15897 var useCollectionContext = ctx.useContext;
15898 var useCollectionScopedContext = ctx.useScopedContext;
15899 var useCollectionProviderContext = ctx.useProviderContext;
15900 var CollectionContextProvider = ctx.ContextProvider;
15901 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15902
15903 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
15904 var import_react11 = __toESM(require_react(), 1);
15905 var TagName3 = "div";
15906 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
15907 const context = useCollectionContext();
15908 store = store || context;
15909 const id = useId4(props.id);
15910 const ref = (0, import_react11.useRef)(element);
15911 (0, import_react11.useEffect)(() => {
15912 const element2 = ref.current;
15913 if (!id) return;
15914 if (!element2) return;
15915 if (!shouldRegisterItem) return;
15916 const item = getItem({
15917 id,
15918 element: element2
15919 });
15920 return store?.renderItem(item);
15921 }, [
15922 id,
15923 shouldRegisterItem,
15924 getItem,
15925 store
15926 ]);
15927 props = {
15928 ...props,
15929 ref: useMergeRefs(ref, props.ref)
15930 };
15931 return removeUndefinedValues(props);
15932 });
15933 var CollectionItem = forwardRef21(function CollectionItem2(props) {
15934 return createElement3(TagName3, useCollectionItem(props));
15935 });
15936
15937 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
15938 var import_react12 = __toESM(require_react(), 1);
15939 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
15940 var useCompositeContext = ctx2.useContext;
15941 var useCompositeScopedContext = ctx2.useScopedContext;
15942 var useCompositeProviderContext = ctx2.useProviderContext;
15943 var CompositeContextProvider = ctx2.ContextProvider;
15944 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15945 var CompositeItemContext = (0, import_react12.createContext)(void 0);
15946 var CompositeRowContext = (0, import_react12.createContext)(void 0);
15947
15948 // node_modules/@ariakit/react-components/dist/composite/utils.js
15949 function findFirstEnabledItem(items, excludeId) {
15950 return items.find((item) => {
15951 if (excludeId) return !item.disabled && item.id !== excludeId;
15952 return !item.disabled;
15953 });
15954 }
15955 function getEnabledItem(store, id) {
15956 if (!id) return null;
15957 return store.item(id) || null;
15958 }
15959 function groupItemsByRows(items) {
15960 const rows = [];
15961 for (const item of items) {
15962 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
15963 if (row) row.push(item);
15964 else rows.push([item]);
15965 }
15966 return rows;
15967 }
15968 function selectTextField(element, collapseToEnd = false) {
15969 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
15970 else if (element.isContentEditable) {
15971 const selection = getDocument(element).getSelection();
15972 selection?.selectAllChildren(element);
15973 if (collapseToEnd) selection?.collapseToEnd();
15974 }
15975 }
15976 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15977 function focusSilently(element) {
15978 element[FOCUS_SILENTLY] = true;
15979 element.focus({ preventScroll: true });
15980 }
15981 function silentlyFocused(element) {
15982 const isSilentlyFocused = element[FOCUS_SILENTLY];
15983 delete element[FOCUS_SILENTLY];
15984 return isSilentlyFocused;
15985 }
15986 function isItem(store, element, exclude) {
15987 if (!element) return false;
15988 if (element === exclude) return false;
15989 const item = store.item(element.id);
15990 if (!item) return false;
15991 if (exclude && item.element === exclude) return false;
15992 return true;
15993 }
15994
15995 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
15996 var import_react13 = __toESM(require_react(), 1);
15997 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
15998
15999 // node_modules/@ariakit/store/dist/index.js
16000 function getInternal(store, key) {
16001 const internals = store.__unstableInternals;
16002 invariant(internals, "Invalid store");
16003 return internals[key];
16004 }
16005 function hasUpdatedKey(keys, updatedKey) {
16006 if (!keys) return true;
16007 for (const currentKey of keys) if (updatedKey instanceof Set) {
16008 if (updatedKey.has(currentKey)) return true;
16009 } else if (currentKey === updatedKey) return true;
16010 return false;
16011 }
16012 function addKeyedListener(map, keys, listener) {
16013 if (!keys) return;
16014 for (const key of keys) {
16015 let listeners = map.get(key);
16016 if (!listeners) {
16017 listeners = /* @__PURE__ */ new Set();
16018 map.set(key, listeners);
16019 }
16020 listeners.add(listener);
16021 }
16022 }
16023 function deleteKeyedListener(map, keys, listener) {
16024 if (!map) return;
16025 if (!keys) return;
16026 for (const key of keys) {
16027 const listeners = map.get(key);
16028 if (!listeners) continue;
16029 listeners.delete(listener);
16030 if (!listeners.size) map.delete(key);
16031 }
16032 }
16033 function createStore(initialState, ...stores) {
16034 let state = initialState;
16035 let prevStateBatch = state;
16036 let destroy = noop4;
16037 let batchPending = false;
16038 let inDispatch = false;
16039 let updatedKeys = /* @__PURE__ */ new Set();
16040 const instances = /* @__PURE__ */ new Set();
16041 const setups = /* @__PURE__ */ new Set();
16042 const syncListenerGroup = {
16043 listeners: /* @__PURE__ */ new Set(),
16044 disposables: /* @__PURE__ */ new Map(),
16045 listenerKeys: /* @__PURE__ */ new WeakMap()
16046 };
16047 const batchListenerGroup = {
16048 listeners: /* @__PURE__ */ new Set(),
16049 disposables: /* @__PURE__ */ new Map(),
16050 listenerKeys: /* @__PURE__ */ new WeakMap()
16051 };
16052 const storeSetup = (callback) => {
16053 setups.add(callback);
16054 return () => setups.delete(callback);
16055 };
16056 const storeInit = () => {
16057 const initializedInstances = instances.size;
16058 const instance = /* @__PURE__ */ Symbol();
16059 instances.add(instance);
16060 const maybeDestroy = () => {
16061 instances.delete(instance);
16062 if (instances.size) return;
16063 destroy();
16064 };
16065 if (initializedInstances) return maybeDestroy;
16066 const stateKeys = getKeys(state);
16067 const desyncs = [];
16068 for (const store of stores) {
16069 const storeState = store?.getState?.();
16070 if (!storeState) continue;
16071 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16072 if (!keys.length) continue;
16073 if (stores.length === 1 || keys.length === stateKeys.length) {
16074 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16075 setState(key, state2[key], true);
16076 }));
16077 continue;
16078 }
16079 let didSyncInitialState = false;
16080 desyncs.push(sync(store, keys, (state2, prevState) => {
16081 for (const key of keys) {
16082 if (didSyncInitialState && state2[key] === prevState[key]) continue;
16083 setState(key, state2[key], true);
16084 }
16085 didSyncInitialState = true;
16086 }));
16087 }
16088 const teardowns = [];
16089 for (const setup2 of setups) teardowns.push(setup2());
16090 const cleanups = stores.map(init);
16091 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16092 return maybeDestroy;
16093 };
16094 const deleteListenerIndexes = (group, listener, keys) => {
16095 if (keys === void 0) return;
16096 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16097 else group.allKeysListeners?.delete(listener);
16098 };
16099 const registerListener = (keys, listener, group = syncListenerGroup) => {
16100 const listenerKeysValue = keys ? [...keys] : null;
16101 if (group.listeners.has(listener)) deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16102 group.listeners.add(listener);
16103 if (listenerKeysValue) {
16104 group.listenersByKey ??= /* @__PURE__ */ new Map();
16105 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16106 } else {
16107 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16108 group.allKeysListeners.add(listener);
16109 }
16110 group.listenerKeys.set(listener, listenerKeysValue);
16111 return () => {
16112 group.disposables.get(listener)?.();
16113 group.disposables.delete(listener);
16114 const currentKeys = group.listenerKeys.get(listener);
16115 deleteListenerIndexes(group, listener, listenerKeysValue);
16116 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16117 group.listenerKeys.delete(listener);
16118 group.listeners.delete(listener);
16119 };
16120 };
16121 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16122 const reconcileInitialCleanup = (group, listener, cleanup) => {
16123 if (cleanup) group.disposables.set(listener, cleanup);
16124 else group.disposables.delete(listener);
16125 };
16126 const storeSync = (keys, listener) => {
16127 reconcileInitialCleanup(syncListenerGroup, listener, listener(state, state));
16128 return registerListener(keys, listener);
16129 };
16130 const storeBatch = (keys, listener) => {
16131 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
16132 reconcileInitialCleanup(batchListenerGroup, listener, listener(state, prevStateBatch));
16133 return registerListener(keys, listener, batchListenerGroup);
16134 };
16135 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16136 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
16137 const getState = () => state;
16138 const runListeners = (group, prevState, updatedKey) => {
16139 const { disposables } = group;
16140 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
16141 const keyedListeners = group.listenersByKey?.get(updatedKey);
16142 if (!keyedListeners) return;
16143 for (const listener of keyedListeners) {
16144 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16145 if (cleanup) cleanup();
16146 const result = listener(state, prevState);
16147 if (result) disposables.set(listener, result);
16148 else if (cleanup) disposables.delete(listener);
16149 }
16150 return;
16151 }
16152 const allKeysListeners = group.allKeysListeners;
16153 for (const listener of group.listeners) {
16154 if (!allKeysListeners?.has(listener)) {
16155 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16156 }
16157 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16158 if (cleanup) cleanup();
16159 const result = listener(state, prevState);
16160 if (result) disposables.set(listener, result);
16161 else if (cleanup) disposables.delete(listener);
16162 }
16163 };
16164 const setState = (key, value, fromStores = false) => {
16165 if (!hasOwnProperty(state, key)) return;
16166 const currentValue = state[key];
16167 const nextValue = typeof value === "function" ? value(currentValue) : value;
16168 if (nextValue === currentValue) return;
16169 if (!fromStores && stores.length) for (const store of stores) store?.setState?.(key, nextValue);
16170 const prevState = state;
16171 state = {
16172 ...state,
16173 [key]: nextValue
16174 };
16175 const wasInDispatch = inDispatch;
16176 inDispatch = true;
16177 try {
16178 runListeners(syncListenerGroup, prevState, key);
16179 } finally {
16180 inDispatch = wasInDispatch;
16181 }
16182 if (!batchListenerGroup.listeners.size) {
16183 if (!inDispatch) prevStateBatch = state;
16184 return;
16185 }
16186 updatedKeys.add(key);
16187 if (batchPending) return;
16188 batchPending = true;
16189 queueMicrotask(() => {
16190 batchPending = false;
16191 const snapshot = state;
16192 const updatedKeysSnapshot = updatedKeys;
16193 updatedKeys = /* @__PURE__ */ new Set();
16194 const prevStateBatchBefore = prevStateBatch;
16195 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
16196 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
16197 });
16198 };
16199 const finalStore = {
16200 getState,
16201 setState,
16202 __unstableInternals: {
16203 setup: storeSetup,
16204 init: storeInit,
16205 subscribe: storeSubscribe,
16206 sync: storeSync,
16207 batch: storeBatch,
16208 pick: storePick,
16209 omit: storeOmit
16210 }
16211 };
16212 return finalStore;
16213 }
16214 function setup(store, ...args) {
16215 if (!store) return;
16216 return getInternal(store, "setup")(...args);
16217 }
16218 function init(store, ...args) {
16219 if (!store) return;
16220 return getInternal(store, "init")(...args);
16221 }
16222 function subscribe(store, ...args) {
16223 if (!store) return;
16224 return getInternal(store, "subscribe")(...args);
16225 }
16226 function sync(store, ...args) {
16227 if (!store) return;
16228 return getInternal(store, "sync")(...args);
16229 }
16230 function batch(store, ...args) {
16231 if (!store) return;
16232 return getInternal(store, "batch")(...args);
16233 }
16234 function omit3(store, ...args) {
16235 if (!store) return;
16236 return getInternal(store, "omit")(...args);
16237 }
16238 function pick2(store, ...args) {
16239 if (!store) return;
16240 return getInternal(store, "pick")(...args);
16241 }
16242 function mergeStore(...stores) {
16243 const initialState = {};
16244 for (const store2 of stores) {
16245 const nextState = store2?.getState?.();
16246 if (nextState) Object.assign(initialState, nextState);
16247 }
16248 const store = createStore(initialState, ...stores);
16249 return Object.assign({}, ...stores, store);
16250 }
16251 function throwOnConflictingProps(props, store) {
16252 if (false) return;
16253 if (!store) return;
16254 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16255 const stateKey = key.replace("default", "");
16256 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
16257 });
16258 if (!defaultKeys.length) return;
16259 const storeState = store.getState();
16260 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
16261 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
16262
16263 const store = useSelectStore();
16264 <SelectProvider store={store} defaultValue="Apple" />
16265 ^ ^
16266
16267 Instead, pass the default state to the topmost store:
16268
16269 const store = useSelectStore({ defaultValue: "Apple" });
16270 <SelectProvider store={store} />
16271
16272 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16273
16274 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16275 `);
16276 }
16277
16278 // node_modules/@ariakit/react-store/dist/index.js
16279 var React49 = __toESM(require_react(), 1);
16280 var import_shim2 = __toESM(require_shim(), 1);
16281 var noopSubscribe = () => () => {
16282 };
16283 function useStoreState(store, keyOrSelector = identity) {
16284 const storeSubscribe = React49.useCallback((callback) => {
16285 if (!store) return noopSubscribe();
16286 return subscribe(store, null, callback);
16287 }, [store]);
16288 const getSnapshot = () => {
16289 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16290 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16291 const state = store?.getState();
16292 if (selector2) return selector2(state);
16293 if (!state) return;
16294 if (!key) return;
16295 if (!hasOwnProperty(state, key)) return;
16296 return state[key];
16297 };
16298 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16299 }
16300 function useStoreStateObject(store, object) {
16301 const objRef = React49.useRef({});
16302 const storeSubscribe = React49.useCallback((callback) => {
16303 if (!store) return noopSubscribe();
16304 return subscribe(store, null, callback);
16305 }, [store]);
16306 const getSnapshot = () => {
16307 const state = store?.getState();
16308 let updated = false;
16309 const obj = objRef.current;
16310 for (const prop in object) {
16311 const keyOrSelector = object[prop];
16312 if (typeof keyOrSelector === "function") {
16313 const value = keyOrSelector(state);
16314 if (value !== obj[prop]) {
16315 obj[prop] = value;
16316 updated = true;
16317 }
16318 }
16319 if (typeof keyOrSelector === "string") {
16320 if (!state) continue;
16321 if (!hasOwnProperty(state, keyOrSelector)) continue;
16322 const value = state[keyOrSelector];
16323 if (value !== obj[prop]) {
16324 obj[prop] = value;
16325 updated = true;
16326 }
16327 }
16328 }
16329 if (updated) objRef.current = { ...obj };
16330 return objRef.current;
16331 };
16332 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16333 }
16334 function useStoreProps(store, props, key, setKey) {
16335 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16336 const propsRef = useLiveRef({
16337 value,
16338 setValue: setKey ? props[setKey] : void 0
16339 });
16340 useSafeLayoutEffect(() => {
16341 return sync(store, [key], (state, prev) => {
16342 const { value: value2, setValue } = propsRef.current;
16343 if (!setValue) return;
16344 if (state[key] === prev[key]) return;
16345 if (state[key] === value2) return;
16346 setValue(state[key]);
16347 });
16348 }, [store, key]);
16349 useSafeLayoutEffect(() => {
16350 if (value === void 0) return;
16351 store.setState(key, value);
16352 return batch(store, [key], () => {
16353 if (value === void 0) return;
16354 store.setState(key, value);
16355 });
16356 });
16357 }
16358 function useStore2(createStore2, props) {
16359 const [store, setStore] = React49.useState(() => createStore2(props));
16360 useSafeLayoutEffect(() => init(store), [store]);
16361 const useState36 = React49.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
16362 return [React49.useMemo(() => ({
16363 ...store,
16364 useState: useState36
16365 }), [store, useState36]), useEvent(() => {
16366 setStore((store2) => createStore2({
16367 ...props,
16368 ...store2.getState()
16369 }));
16370 })];
16371 }
16372
16373 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
16374 var TagName4 = "button";
16375 function isEditableElement(element) {
16376 if (isTextbox(element)) return true;
16377 return element.tagName === "INPUT" && !isButton(element);
16378 }
16379 function getNextPageOffset(scrollingElement, pageUp = false) {
16380 const height = scrollingElement.clientHeight;
16381 const { top } = scrollingElement.getBoundingClientRect();
16382 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16383 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16384 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
16385 return pageOffset;
16386 }
16387 function getItemOffset(itemElement, pageUp = false) {
16388 const { top } = itemElement.getBoundingClientRect();
16389 if (pageUp) return top + itemElement.clientHeight;
16390 return top;
16391 }
16392 function findNextPageItemId(element, store, next, pageUp = false) {
16393 if (!store) return;
16394 if (!next) return;
16395 const { renderedItems } = store.getState();
16396 const scrollingElement = getScrollingElement(element);
16397 if (!scrollingElement) return;
16398 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16399 let id;
16400 let prevDifference;
16401 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16402 const previousId = id;
16403 id = next(i2);
16404 if (!id) break;
16405 if (id === previousId) continue;
16406 const itemElement = getEnabledItem(store, id)?.element;
16407 if (!itemElement) continue;
16408 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
16409 const absDifference = Math.abs(difference);
16410 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16411 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
16412 break;
16413 }
16414 prevDifference = absDifference;
16415 }
16416 return id;
16417 }
16418 function targetIsAnotherItem(event, store) {
16419 if (isSelfTarget(event)) return false;
16420 return isItem(store, event.target);
16421 }
16422 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
16423 const context = useCompositeScopedContext();
16424 store = store || context;
16425 const id = useId4(props.id);
16426 const ref = (0, import_react13.useRef)(null);
16427 const row = (0, import_react13.useContext)(CompositeRowContext);
16428 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
16429 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
16430 rowId(state) {
16431 if (rowIdProp) return rowIdProp;
16432 if (!state) return;
16433 if (!row?.baseElement) return;
16434 if (row.baseElement !== state.baseElement) return;
16435 return row.id;
16436 },
16437 baseElement(state) {
16438 return state?.baseElement || void 0;
16439 },
16440 isActiveItem(state) {
16441 return !!state && state.activeId === id;
16442 },
16443 ariaSetSize(state) {
16444 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16445 if (!state) return;
16446 if (!row?.ariaSetSize) return;
16447 if (row.baseElement !== state.baseElement) return;
16448 return row.ariaSetSize;
16449 },
16450 ariaPosInSet(state) {
16451 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16452 if (!state) return;
16453 if (!row?.ariaPosInSet) return;
16454 if (row.baseElement !== state.baseElement) return;
16455 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId);
16456 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16457 },
16458 isTabbable(state) {
16459 if (!state?.renderedItems.length) return true;
16460 if (state.virtualFocus) return false;
16461 if (tabbable2) return true;
16462 if (state.activeId === null) return false;
16463 const item = store?.item(state.activeId);
16464 if (item?.disabled) return true;
16465 if (!item?.element) return true;
16466 return state.activeId === id;
16467 }
16468 });
16469 const getItem = (0, import_react13.useCallback)((item) => {
16470 const nextItem = {
16471 ...item,
16472 id: id || item.id,
16473 rowId,
16474 disabled: trulyDisabled,
16475 children: item.element?.textContent
16476 };
16477 if (getItemProp) return getItemProp(nextItem);
16478 return nextItem;
16479 }, [
16480 id,
16481 rowId,
16482 trulyDisabled,
16483 getItemProp
16484 ]);
16485 const onFocusProp = props.onFocus;
16486 const hasFocusedComposite = (0, import_react13.useRef)(false);
16487 const onFocus = useEvent((event) => {
16488 onFocusProp?.(event);
16489 if (event.defaultPrevented) return;
16490 if (isPortalEvent(event)) return;
16491 if (!id) return;
16492 if (!store) return;
16493 if (targetIsAnotherItem(event, store)) return;
16494 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16495 store.setActiveId(id);
16496 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
16497 if (!virtualFocus) return;
16498 if (!isSelfTarget(event)) return;
16499 if (isEditableElement(event.currentTarget)) return;
16500 if (!baseElement2?.isConnected) return;
16501 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) event.currentTarget.scrollIntoView({
16502 block: "nearest",
16503 inline: "nearest"
16504 });
16505 hasFocusedComposite.current = true;
16506 if (event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget)) focusSilently(baseElement2);
16507 else baseElement2.focus();
16508 });
16509 const onBlurCaptureProp = props.onBlurCapture;
16510 const onBlurCapture = useEvent((event) => {
16511 onBlurCaptureProp?.(event);
16512 if (event.defaultPrevented) return;
16513 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
16514 hasFocusedComposite.current = false;
16515 event.preventDefault();
16516 event.stopPropagation();
16517 }
16518 });
16519 const onKeyDownProp = props.onKeyDown;
16520 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16521 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16522 const onKeyDown = useEvent((event) => {
16523 onKeyDownProp?.(event);
16524 if (event.defaultPrevented) return;
16525 if (!isSelfTarget(event)) return;
16526 if (!store) return;
16527 const { currentTarget } = event;
16528 const state = store.getState();
16529 const isGrid2 = !!store.item(id)?.rowId;
16530 const isVertical = state.orientation !== "horizontal";
16531 const isHorizontal = state.orientation !== "vertical";
16532 const canHomeEnd = () => {
16533 if (isGrid2) return true;
16534 if (isHorizontal) return true;
16535 if (!state.baseElement) return true;
16536 if (!isTextField(state.baseElement)) return true;
16537 return false;
16538 };
16539 const action = {
16540 ArrowUp: (isGrid2 || isVertical) && store.up,
16541 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16542 ArrowDown: (isGrid2 || isVertical) && store.down,
16543 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16544 Home: () => {
16545 if (!canHomeEnd()) return;
16546 if (!isGrid2 || event.ctrlKey) return store?.first();
16547 return store?.previous(-1);
16548 },
16549 End: () => {
16550 if (!canHomeEnd()) return;
16551 if (!isGrid2 || event.ctrlKey) return store?.last();
16552 return store?.next(-1);
16553 },
16554 PageUp: () => {
16555 return findNextPageItemId(currentTarget, store, store?.up, true);
16556 },
16557 PageDown: () => {
16558 return findNextPageItemId(currentTarget, store, store?.down);
16559 }
16560 }[event.key];
16561 if (action) {
16562 if (isTextbox(currentTarget)) {
16563 const selection = getTextboxSelection(currentTarget);
16564 const isLeft = isHorizontal && event.key === "ArrowLeft";
16565 const isRight = isHorizontal && event.key === "ArrowRight";
16566 const isUp = isVertical && event.key === "ArrowUp";
16567 const isDown = isVertical && event.key === "ArrowDown";
16568 if (isRight || isDown) {
16569 const { length: valueLength } = getTextboxValue(currentTarget);
16570 if (selection.end !== valueLength) return;
16571 } else if ((isLeft || isUp) && selection.start !== 0) return;
16572 }
16573 const nextId = action();
16574 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16575 if (!moveOnKeyPressProp(event)) return;
16576 event.preventDefault();
16577 store.move(nextId);
16578 }
16579 }
16580 });
16581 const providerValue = (0, import_react13.useMemo)(() => ({
16582 id,
16583 baseElement
16584 }), [id, baseElement]);
16585 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeItemContext.Provider, {
16586 value: providerValue,
16587 children: element
16588 }), [providerValue]);
16589 props = {
16590 "data-active-item": isActiveItem || void 0,
16591 ...props,
16592 id,
16593 ref: useMergeRefs(ref, props.ref),
16594 tabIndex: isTabbable ? props.tabIndex : -1,
16595 onFocus,
16596 onBlurCapture,
16597 onKeyDown
16598 };
16599 props = useCommand(props);
16600 props = useCollectionItem({
16601 store,
16602 ...props,
16603 getItem,
16604 shouldRegisterItem: id ? props.shouldRegisterItem : false
16605 });
16606 return removeUndefinedValues({
16607 ...props,
16608 "aria-setsize": ariaSetSize,
16609 "aria-posinset": ariaPosInSet
16610 });
16611 });
16612 var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
16613 return createElement3(TagName4, useCompositeItem(props));
16614 }));
16615
16616 // node_modules/@ariakit/react-components/dist/composite/composite.js
16617 var import_react14 = __toESM(require_react(), 1);
16618 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
16619 var TagName5 = "div";
16620 function isGrid(items) {
16621 return items.some((item) => !!item.rowId);
16622 }
16623 function isPrintableKey(event) {
16624 const target = event.target;
16625 if (target && !isTextField(target)) return false;
16626 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16627 }
16628 function isModifierKey(event) {
16629 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16630 }
16631 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16632 return useEvent((event) => {
16633 onKeyboardEvent?.(event);
16634 if (event.defaultPrevented) return;
16635 if (event.isPropagationStopped()) return;
16636 if (!isSelfTarget(event)) return;
16637 if (isModifierKey(event)) return;
16638 if (isPrintableKey(event)) return;
16639 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
16640 if (!activeElement2) return;
16641 const { view, ...eventInit } = event;
16642 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
16643 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
16644 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
16645 });
16646 }
16647 function findFirstEnabledItemInTheLastRow(items) {
16648 return findFirstEnabledItem(flatten2DArray(reverseArray(groupItemsByRows(items))));
16649 }
16650 function withBaseScrollPreserved(store, callback) {
16651 const { virtualFocus, baseElement } = store.getState();
16652 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
16653 callback();
16654 return;
16655 }
16656 const savedScrollLeft = baseElement.scrollLeft;
16657 const savedScrollTop = baseElement.scrollTop;
16658 callback();
16659 baseElement.scrollLeft = savedScrollLeft;
16660 baseElement.scrollTop = savedScrollTop;
16661 }
16662 function useScheduleFocus(store) {
16663 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
16664 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
16665 const activeItem = useStoreState(store, (state) => getEnabledItem(store, state.activeId));
16666 (0, import_react14.useEffect)(() => {
16667 const activeElement2 = activeItem?.element;
16668 if (!scheduled) return;
16669 if (!activeElement2) return;
16670 setScheduled(false);
16671 withBaseScrollPreserved(store, () => {
16672 activeElement2.focus({ preventScroll: true });
16673 });
16674 }, [
16675 store,
16676 activeItem,
16677 scheduled
16678 ]);
16679 return schedule;
16680 }
16681 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
16682 const context = useCompositeProviderContext();
16683 store = store || context;
16684 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
16685 const ref = (0, import_react14.useRef)(null);
16686 const previousElementRef = (0, import_react14.useRef)(null);
16687 const scheduleFocus = useScheduleFocus(store);
16688 const moves = useStoreState(store, "moves");
16689 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
16690 (0, import_react14.useEffect)(() => {
16691 if (!store) return;
16692 if (!moves) return;
16693 if (!composite) return;
16694 if (!focusOnMove) return;
16695 const { activeId: activeId2 } = store.getState();
16696 const itemElement = getEnabledItem(store, activeId2)?.element;
16697 if (!itemElement) return;
16698 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
16699 }, [
16700 store,
16701 moves,
16702 composite,
16703 focusOnMove
16704 ]);
16705 useSafeLayoutEffect(() => {
16706 if (!store) return;
16707 if (!moves) return;
16708 if (!composite) return;
16709 const { baseElement, activeId: activeId2 } = store.getState();
16710 if (!(activeId2 === null)) return;
16711 if (!baseElement) return;
16712 const previousElement = previousElementRef.current;
16713 previousElementRef.current = null;
16714 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
16715 if (!hasFocus(baseElement)) baseElement.focus();
16716 }, [
16717 store,
16718 moves,
16719 composite
16720 ]);
16721 const activeId = useStoreState(store, "activeId");
16722 const virtualFocus = useStoreState(store, "virtualFocus");
16723 useSafeLayoutEffect(() => {
16724 if (!store) return;
16725 if (!composite) return;
16726 if (!virtualFocus) return;
16727 const previousElement = previousElementRef.current;
16728 previousElementRef.current = null;
16729 if (!previousElement) return;
16730 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
16731 if (relatedTarget === previousElement) return;
16732 fireBlurEvent(previousElement, { relatedTarget });
16733 }, [
16734 store,
16735 activeId,
16736 virtualFocus,
16737 composite
16738 ]);
16739 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
16740 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
16741 const onFocusCaptureProp = props.onFocusCapture;
16742 const onFocusCapture = useEvent((event) => {
16743 onFocusCaptureProp?.(event);
16744 if (event.defaultPrevented) return;
16745 if (!store) return;
16746 const { virtualFocus: virtualFocus2 } = store.getState();
16747 if (!virtualFocus2) return;
16748 const previousActiveElement = event.relatedTarget;
16749 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16750 if (isSelfTarget(event) && isSilentlyFocused) {
16751 event.stopPropagation();
16752 previousElementRef.current = previousActiveElement;
16753 }
16754 });
16755 const onFocusProp = props.onFocus;
16756 const onFocus = useEvent((event) => {
16757 onFocusProp?.(event);
16758 if (event.defaultPrevented) return;
16759 if (!composite) return;
16760 if (!store) return;
16761 const { relatedTarget } = event;
16762 const { virtualFocus: virtualFocus2 } = store.getState();
16763 if (virtualFocus2) {
16764 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
16765 } else if (isSelfTarget(event)) store.setActiveId(null);
16766 });
16767 const onBlurCaptureProp = props.onBlurCapture;
16768 const onBlurCapture = useEvent((event) => {
16769 onBlurCaptureProp?.(event);
16770 if (event.defaultPrevented) return;
16771 if (!store) return;
16772 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16773 if (!virtualFocus2) return;
16774 const activeElement2 = getEnabledItem(store, activeId2)?.element;
16775 const nextActiveElement = event.relatedTarget;
16776 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16777 const previousElement = previousElementRef.current;
16778 previousElementRef.current = null;
16779 if (isSelfTarget(event) && nextActiveElementIsItem) {
16780 if (nextActiveElement === activeElement2) {
16781 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
16782 } else if (activeElement2) fireBlurEvent(activeElement2, event);
16783 else if (previousElement) fireBlurEvent(previousElement, event);
16784 event.stopPropagation();
16785 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
16786 });
16787 const onKeyDownProp = props.onKeyDown;
16788 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16789 const onKeyDown = useEvent((event) => {
16790 onKeyDownProp?.(event);
16791 if (event.nativeEvent.isComposing) return;
16792 if (event.defaultPrevented) return;
16793 if (!store) return;
16794 if (!isSelfTarget(event)) return;
16795 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16796 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
16797 const isVertical = orientation !== "horizontal";
16798 const isHorizontal = orientation !== "vertical";
16799 const grid = isGrid(renderedItems);
16800 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
16801 const up = () => {
16802 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
16803 return store?.last();
16804 };
16805 const action = {
16806 ArrowUp: (grid || isVertical) && up,
16807 ArrowRight: (grid || isHorizontal) && store.first,
16808 ArrowDown: (grid || isVertical) && store.first,
16809 ArrowLeft: (grid || isHorizontal) && store.last,
16810 Home: store.first,
16811 End: store.last,
16812 PageUp: store.first,
16813 PageDown: store.last
16814 }[event.key];
16815 if (action) {
16816 const id = action();
16817 if (id !== void 0) {
16818 if (!moveOnKeyPressProp(event)) return;
16819 event.preventDefault();
16820 store.move(id);
16821 }
16822 }
16823 });
16824 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(CompositeScopedContextProvider, {
16825 value: store,
16826 children: element
16827 }), [store]);
16828 props = {
16829 "aria-activedescendant": useStoreState(store, (state) => {
16830 if (!store) return;
16831 if (!composite) return;
16832 if (!state.virtualFocus) return;
16833 return getEnabledItem(store, state.activeId)?.id;
16834 }),
16835 ...props,
16836 ref: useMergeRefs(ref, setBaseElement, props.ref),
16837 onKeyDownCapture,
16838 onKeyUpCapture,
16839 onFocusCapture,
16840 onFocus,
16841 onBlurCapture,
16842 onKeyDown
16843 };
16844 props = useFocusable({
16845 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
16846 ...props
16847 });
16848 return props;
16849 });
16850 var Composite6 = forwardRef21(function Composite7(props) {
16851 return createElement3(TagName5, useComposite(props));
16852 });
16853
16854 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
16855 var ctx3 = createStoreContext();
16856 var useDisclosureContext = ctx3.useContext;
16857 var useDisclosureScopedContext = ctx3.useScopedContext;
16858 var useDisclosureProviderContext = ctx3.useProviderContext;
16859 var DisclosureContextProvider = ctx3.ContextProvider;
16860 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16861
16862 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
16863 var import_react15 = __toESM(require_react(), 1);
16864 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
16865 var useDialogContext = ctx4.useContext;
16866 var useDialogScopedContext = ctx4.useScopedContext;
16867 var useDialogProviderContext = ctx4.useProviderContext;
16868 var DialogContextProvider = ctx4.ContextProvider;
16869 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16870 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
16871 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
16872
16873 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
16874 var import_react16 = __toESM(require_react(), 1);
16875 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
16876 var import_react_dom4 = __toESM(require_react_dom(), 1);
16877 var TagName6 = "div";
16878 function afterTimeout(timeoutMs, cb) {
16879 const timeoutId = setTimeout(cb, timeoutMs);
16880 return () => clearTimeout(timeoutId);
16881 }
16882 function afterPaint(cb) {
16883 let raf = requestAnimationFrame(() => {
16884 raf = requestAnimationFrame(cb);
16885 });
16886 return () => cancelAnimationFrame(raf);
16887 }
16888 function parseCSSTime(...times) {
16889 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
16890 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
16891 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
16892 if (currentTime > longestTime) return currentTime;
16893 return longestTime;
16894 }, 0);
16895 }
16896 function isHidden(mounted, hidden, alwaysVisible) {
16897 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
16898 }
16899 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
16900 const context = useDisclosureProviderContext();
16901 store = store || context;
16902 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
16903 const ref = (0, import_react16.useRef)(null);
16904 const id = useId4(props.id);
16905 const [transition, setTransition] = (0, import_react16.useState)(null);
16906 const open = useStoreState(store, "open");
16907 const mounted = useStoreState(store, "mounted");
16908 const animated = useStoreState(store, "animated");
16909 const contentElement = useStoreState(store, "contentElement");
16910 const otherElement = useStoreState(store.disclosure, "contentElement");
16911 const hasClosedRef = (0, import_react16.useRef)(false);
16912 useSafeLayoutEffect(() => {
16913 if (!ref.current) return;
16914 store?.setContentElement(ref.current);
16915 }, [store]);
16916 useSafeLayoutEffect(() => {
16917 let previousAnimated;
16918 store?.setState("animated", (animated2) => {
16919 previousAnimated = animated2;
16920 return true;
16921 });
16922 return () => {
16923 if (previousAnimated === void 0) return;
16924 store?.setState("animated", previousAnimated);
16925 };
16926 }, [store]);
16927 useSafeLayoutEffect(() => {
16928 if (!animated) {
16929 if (!open) {
16930 hasClosedRef.current = true;
16931 setTransition(null);
16932 } else if (hasClosedRef.current) {
16933 hasClosedRef.current = false;
16934 setTransition("enter");
16935 }
16936 return;
16937 }
16938 if (!contentElement?.isConnected) {
16939 setTransition(null);
16940 return;
16941 }
16942 return afterPaint(() => {
16943 setTransition(open ? "enter" : mounted ? "leave" : null);
16944 });
16945 }, [
16946 animated,
16947 contentElement,
16948 open,
16949 mounted
16950 ]);
16951 useSafeLayoutEffect(() => {
16952 if (!store) return;
16953 if (!animated) return;
16954 if (!transition) return;
16955 if (!contentElement) return;
16956 const stopAnimation = () => store?.setState("animating", false);
16957 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
16958 if (transition === "leave" && open) return;
16959 if (transition === "enter" && !open) return;
16960 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
16961 const { transitionDuration, animationDuration, transitionDelay, animationDelay } = getComputedStyle(contentElement);
16962 const { transitionDuration: transitionDuration2 = "0", animationDuration: animationDuration2 = "0", transitionDelay: transitionDelay2 = "0", animationDelay: animationDelay2 = "0" } = otherElement ? getComputedStyle(otherElement) : {};
16963 const timeout = parseCSSTime(transitionDelay, animationDelay, transitionDelay2, animationDelay2) + parseCSSTime(transitionDuration, animationDuration, transitionDuration2, animationDuration2);
16964 if (!timeout) {
16965 if (transition === "enter") store.setState("animated", false);
16966 stopAnimation();
16967 return;
16968 }
16969 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
16970 }, [
16971 store,
16972 animated,
16973 contentElement,
16974 otherElement,
16975 open,
16976 transition
16977 ]);
16978 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DialogScopedContextProvider, {
16979 value: store,
16980 children: element
16981 }), [store]);
16982 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
16983 const styleProp = props.style;
16984 const style = (0, import_react16.useMemo)(() => {
16985 if (hidden) return {
16986 ...styleProp,
16987 display: "none"
16988 };
16989 return styleProp;
16990 }, [hidden, styleProp]);
16991 props = {
16992 "data-open": open || void 0,
16993 "data-enter": transition === "enter" || void 0,
16994 "data-leave": transition === "leave" || void 0,
16995 hidden,
16996 ...props,
16997 id,
16998 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
16999 style
17000 };
17001 return removeUndefinedValues(props);
17002 });
17003 var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
17004 return createElement3(TagName6, useDisclosureContent(props));
17005 });
17006 var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
17007 const context = useDisclosureProviderContext();
17008 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
17009 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DisclosureContentImpl, { ...props });
17010 });
17011
17012 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
17013 function createDisclosureStore(props = {}) {
17014 const store = mergeStore(props.store, omit3(props.disclosure, ["contentElement", "disclosureElement"]));
17015 throwOnConflictingProps(props, store);
17016 const syncState = store?.getState();
17017 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
17018 const animated = defaultValue(props.animated, syncState?.animated, false);
17019 const disclosure = createStore({
17020 open,
17021 animated,
17022 animating: !!animated && open,
17023 mounted: open,
17024 contentElement: defaultValue(syncState?.contentElement, null),
17025 disclosureElement: defaultValue(syncState?.disclosureElement, null)
17026 }, store);
17027 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
17028 if (state.animated) return;
17029 disclosure.setState("animating", false);
17030 }));
17031 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
17032 if (!disclosure.getState().animated) return;
17033 disclosure.setState("animating", true);
17034 }));
17035 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
17036 disclosure.setState("mounted", state.open || state.animating);
17037 }));
17038 return {
17039 ...disclosure,
17040 disclosure: props.disclosure,
17041 setOpen: (value) => disclosure.setState("open", value),
17042 show: () => disclosure.setState("open", true),
17043 hide: () => disclosure.setState("open", false),
17044 toggle: () => disclosure.setState("open", (open2) => !open2),
17045 stopAnimation: () => disclosure.setState("animating", false),
17046 setContentElement: (value) => disclosure.setState("contentElement", value),
17047 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17048 };
17049 }
17050
17051 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
17052 function useDisclosureStoreProps(store, update2, props) {
17053 useUpdateEffect(update2, [props.store, props.disclosure]);
17054 useStoreProps(store, props, "open", "setOpen");
17055 useStoreProps(store, props, "mounted", "setMounted");
17056 useStoreProps(store, props, "animated");
17057 return Object.assign(store, { disclosure: props.disclosure });
17058 }
17059
17060 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
17061 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
17062 var usePopoverContext = ctx5.useContext;
17063 var usePopoverScopedContext = ctx5.useScopedContext;
17064 var usePopoverProviderContext = ctx5.useProviderContext;
17065 var PopoverContextProvider = ctx5.ContextProvider;
17066 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17067
17068 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
17069 var import_react17 = __toESM(require_react(), 1);
17070 var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
17071 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
17072 var useComboboxContext = ctx6.useContext;
17073 var useComboboxScopedContext = ctx6.useScopedContext;
17074 var useComboboxProviderContext = ctx6.useProviderContext;
17075 var ComboboxContextProvider = ctx6.ContextProvider;
17076 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17077 var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
17078 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
17079
17080 // node_modules/@ariakit/components/dist/collection/collection-store.js
17081 function getCommonParent(items) {
17082 const firstItem = items.find((item) => !!item.element);
17083 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17084 let parentElement = firstItem?.element?.parentElement;
17085 if (!lastElement) return getDocument(parentElement).body;
17086 while (parentElement) {
17087 if (parentElement.contains(lastElement)) return parentElement;
17088 parentElement = parentElement.parentElement;
17089 }
17090 return getDocument(parentElement).body;
17091 }
17092 function getPrivateStore(store) {
17093 return store?.__unstablePrivateStore;
17094 }
17095 function createCollectionStore(props = {}) {
17096 throwOnConflictingProps(props, props.store);
17097 const syncState = props.store?.getState();
17098 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17099 const itemsMap = new Map(items.map((item) => [item.id, item]));
17100 const initialState = {
17101 items,
17102 renderedItems: defaultValue(syncState?.renderedItems, [])
17103 };
17104 const syncPrivateStore = getPrivateStore(props.store);
17105 const privateStore = createStore({
17106 items,
17107 renderedItems: initialState.renderedItems
17108 }, syncPrivateStore);
17109 const collection = createStore(initialState, props.store);
17110 const sortItems = (renderedItems) => {
17111 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17112 privateStore.setState("renderedItems", sortedItems);
17113 collection.setState("renderedItems", sortedItems);
17114 };
17115 setup(collection, () => init(privateStore));
17116 setup(privateStore, () => {
17117 return batch(privateStore, ["items"], (state) => {
17118 collection.setState("items", state.items);
17119 });
17120 });
17121 setup(privateStore, () => {
17122 return batch(privateStore, ["renderedItems"], (state) => {
17123 let firstRun = true;
17124 let raf = requestAnimationFrame(() => {
17125 const { renderedItems } = collection.getState();
17126 if (state.renderedItems === renderedItems) return;
17127 sortItems(state.renderedItems);
17128 });
17129 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17130 const ioCallback = () => {
17131 if (firstRun) {
17132 firstRun = false;
17133 return;
17134 }
17135 cancelAnimationFrame(raf);
17136 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17137 };
17138 const root = getCommonParent(state.renderedItems);
17139 const observer = new IntersectionObserver(ioCallback, { root });
17140 for (const item of state.renderedItems) {
17141 if (!item.element) continue;
17142 observer.observe(item.element);
17143 }
17144 return () => {
17145 cancelAnimationFrame(raf);
17146 observer.disconnect();
17147 };
17148 });
17149 });
17150 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17151 let prevItem;
17152 setItems((items2) => {
17153 const index2 = items2.findIndex(({ id }) => id === item.id);
17154 const nextItems = items2.slice();
17155 if (index2 !== -1) {
17156 prevItem = items2[index2];
17157 const nextItem = {
17158 ...prevItem,
17159 ...item
17160 };
17161 nextItems[index2] = nextItem;
17162 itemsMap.set(item.id, nextItem);
17163 } else {
17164 nextItems.push(item);
17165 itemsMap.set(item.id, item);
17166 }
17167 return nextItems;
17168 });
17169 const unmergeItem = () => {
17170 setItems((items2) => {
17171 if (!prevItem) {
17172 if (canDeleteFromMap) itemsMap.delete(item.id);
17173 return items2.filter(({ id }) => id !== item.id);
17174 }
17175 const index2 = items2.findIndex(({ id }) => id === item.id);
17176 if (index2 === -1) return items2;
17177 const nextItems = items2.slice();
17178 nextItems[index2] = prevItem;
17179 itemsMap.set(item.id, prevItem);
17180 return nextItems;
17181 });
17182 };
17183 return unmergeItem;
17184 };
17185 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17186 return {
17187 ...collection,
17188 registerItem,
17189 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17190 item: (id) => {
17191 if (!id) return null;
17192 let item = itemsMap.get(id);
17193 if (!item) {
17194 const { items: items2 } = privateStore.getState();
17195 item = items2.find((item2) => item2.id === id);
17196 if (item) itemsMap.set(id, item);
17197 }
17198 return item || null;
17199 },
17200 __unstablePrivateStore: privateStore
17201 };
17202 }
17203
17204 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
17205 function useCollectionStoreProps(store, update2, props) {
17206 useUpdateEffect(update2, [props.store]);
17207 useStoreProps(store, props, "items", "setItems");
17208 return store;
17209 }
17210
17211 // node_modules/@ariakit/components/dist/composite/composite-store.js
17212 var NULL_ITEM = { id: null };
17213 function findFirstEnabledItem2(items, excludeId) {
17214 return items.find((item) => {
17215 if (excludeId) return !item.disabled && item.id !== excludeId;
17216 return !item.disabled;
17217 });
17218 }
17219 function getEnabledItems(items, excludeId) {
17220 return items.filter((item) => {
17221 if (excludeId) return !item.disabled && item.id !== excludeId;
17222 return !item.disabled;
17223 });
17224 }
17225 function getItemsInRow(items, rowId) {
17226 return items.filter((item) => item.rowId === rowId);
17227 }
17228 function flipItems(items, activeId, shouldInsertNullItem = false) {
17229 const index2 = items.findIndex((item) => item.id === activeId);
17230 return [
17231 ...items.slice(index2 + 1),
17232 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17233 ...items.slice(0, index2)
17234 ];
17235 }
17236 function groupItemsByRows2(items) {
17237 const rows = [];
17238 for (const item of items) {
17239 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17240 if (row) row.push(item);
17241 else rows.push([item]);
17242 }
17243 return rows;
17244 }
17245 function getMaxRowLength(array) {
17246 let maxLength = 0;
17247 for (const { length } of array) if (length > maxLength) maxLength = length;
17248 return maxLength;
17249 }
17250 function createEmptyItem(rowId) {
17251 return {
17252 id: "__EMPTY_ITEM__",
17253 disabled: true,
17254 rowId
17255 };
17256 }
17257 function normalizeRows(rows, activeId, focusShift) {
17258 const maxLength = getMaxRowLength(rows);
17259 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17260 const item = row[i2];
17261 if (!item || focusShift && item.disabled) {
17262 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17263 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17264 }
17265 }
17266 return rows;
17267 }
17268 function verticalizeItems(items) {
17269 const rows = groupItemsByRows2(items);
17270 const maxLength = getMaxRowLength(rows);
17271 const verticalized = [];
17272 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17273 const item = row[i2];
17274 if (item) verticalized.push({
17275 ...item,
17276 rowId: item.rowId ? `${i2}` : void 0
17277 });
17278 }
17279 return verticalized;
17280 }
17281 function createCompositeStore(props = {}) {
17282 const syncState = props.store?.getState();
17283 const collection = createCollectionStore(props);
17284 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17285 const composite = createStore({
17286 ...collection.getState(),
17287 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17288 activeId,
17289 baseElement: defaultValue(syncState?.baseElement, null),
17290 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17291 moves: defaultValue(syncState?.moves, 0),
17292 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17293 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17294 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17295 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17296 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17297 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17298 }, collection, props.store);
17299 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17300 composite.setState("activeId", (activeId2) => {
17301 if (activeId2 !== void 0) return activeId2;
17302 return findFirstEnabledItem2(state.renderedItems)?.id;
17303 });
17304 }));
17305 const getNextId = (direction = "next", options = {}) => {
17306 const defaultState = composite.getState();
17307 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
17308 const isVerticalDirection = direction === "up" || direction === "down";
17309 const isNextDirection = direction === "next" || direction === "down";
17310 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17311 const canShift = focusShift && !skip;
17312 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift));
17313 items = canReverse ? reverseArray(items) : items;
17314 items = isVerticalDirection ? verticalizeItems(items) : items;
17315 if (activeId2 == null) return findFirstEnabledItem2(items)?.id;
17316 const activeItem = items.find((item) => item.id === activeId2);
17317 if (!activeItem) return findFirstEnabledItem2(items)?.id;
17318 const isGrid2 = items.some((item) => item.rowId);
17319 const activeIndex = items.indexOf(activeItem);
17320 const nextItems = items.slice(activeIndex + 1);
17321 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17322 if (skip) {
17323 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17324 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17325 }
17326 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17327 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17328 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17329 if (canLoop) return findFirstEnabledItem2(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17330 if (canWrap) {
17331 const nextItem2 = findFirstEnabledItem2(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17332 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17333 }
17334 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17335 if (!nextItem && hasNullItem) return null;
17336 return nextItem?.id;
17337 };
17338 return {
17339 ...collection,
17340 ...composite,
17341 setBaseElement: (element) => composite.setState("baseElement", element),
17342 setActiveId: (id) => composite.setState("activeId", id),
17343 move: (id) => {
17344 if (id === void 0) return;
17345 composite.setState("activeId", id);
17346 composite.setState("moves", (moves) => moves + 1);
17347 },
17348 first: () => findFirstEnabledItem2(composite.getState().renderedItems)?.id,
17349 last: () => findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))?.id,
17350 next: (options) => {
17351 if (options !== void 0 && typeof options === "number") options = { skip: options };
17352 return getNextId("next", options);
17353 },
17354 previous: (options) => {
17355 if (options !== void 0 && typeof options === "number") options = { skip: options };
17356 return getNextId("previous", options);
17357 },
17358 down: (options) => {
17359 if (options !== void 0 && typeof options === "number") options = { skip: options };
17360 return getNextId("down", options);
17361 },
17362 up: (options) => {
17363 if (options !== void 0 && typeof options === "number") options = { skip: options };
17364 return getNextId("up", options);
17365 }
17366 };
17367 }
17368
17369 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
17370 function useCompositeStoreOptions(props) {
17371 return {
17372 id: useId4(props.id),
17373 ...props
17374 };
17375 }
17376 function useCompositeStoreProps(store, update2, props) {
17377 store = useCollectionStoreProps(store, update2, props);
17378 useStoreProps(store, props, "activeId", "setActiveId");
17379 useStoreProps(store, props, "includesBaseElement");
17380 useStoreProps(store, props, "virtualFocus");
17381 useStoreProps(store, props, "orientation");
17382 useStoreProps(store, props, "rtl");
17383 useStoreProps(store, props, "focusLoop");
17384 useStoreProps(store, props, "focusWrap");
17385 useStoreProps(store, props, "focusShift");
17386 return store;
17387 }
17388
17389 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
17390 function createDialogStore(props = {}) {
17391 return createDisclosureStore(props);
17392 }
17393
17394 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
17395 function useDialogStoreProps(store, update2, props) {
17396 return useDisclosureStoreProps(store, update2, props);
17397 }
17398
17399 // node_modules/@ariakit/components/dist/popover/popover-store.js
17400 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
17401 const store = mergeStore(props.store, omit3(otherPopover, [
17402 "arrowElement",
17403 "anchorElement",
17404 "contentElement",
17405 "popoverElement",
17406 "disclosureElement"
17407 ]));
17408 throwOnConflictingProps(props, store);
17409 const syncState = store?.getState();
17410 const dialog = createDialogStore({
17411 ...props,
17412 store
17413 });
17414 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
17415 const popover = createStore({
17416 ...dialog.getState(),
17417 placement,
17418 currentPlacement: placement,
17419 anchorElement: defaultValue(syncState?.anchorElement, null),
17420 popoverElement: defaultValue(syncState?.popoverElement, null),
17421 arrowElement: defaultValue(syncState?.arrowElement, null),
17422 rendered: /* @__PURE__ */ Symbol("rendered")
17423 }, dialog, store);
17424 return {
17425 ...dialog,
17426 ...popover,
17427 setAnchorElement: (element) => popover.setState("anchorElement", element),
17428 setPopoverElement: (element) => popover.setState("popoverElement", element),
17429 setArrowElement: (element) => popover.setState("arrowElement", element),
17430 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17431 };
17432 }
17433
17434 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
17435 function usePopoverStoreProps(store, update2, props) {
17436 useUpdateEffect(update2, [props.popover]);
17437 useStoreProps(store, props, "placement");
17438 return useDialogStoreProps(store, update2, props);
17439 }
17440
17441 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
17442 var TagName7 = "div";
17443 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
17444 const context = usePopoverProviderContext();
17445 store = store || context;
17446 props = {
17447 ...props,
17448 ref: useMergeRefs(store?.setAnchorElement, props.ref)
17449 };
17450 return props;
17451 });
17452 var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
17453 return createElement3(TagName7, usePopoverAnchor(props));
17454 });
17455
17456 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
17457 var import_react18 = __toESM(require_react(), 1);
17458 var TagName8 = "div";
17459 function hoveringInside(event) {
17460 const nextElement = event.relatedTarget;
17461 if (!isElement2(nextElement)) return false;
17462 return contains2(event.currentTarget, nextElement);
17463 }
17464 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17465 function movingToAnotherItem(event) {
17466 const { relatedTarget } = event;
17467 if (!isElement2(relatedTarget)) return false;
17468 let dest = relatedTarget;
17469 do {
17470 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17471 dest = dest.parentElement;
17472 } while (dest);
17473 return false;
17474 }
17475 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
17476 const context = useCompositeScopedContext();
17477 store = store || context;
17478 invariant(store, "CompositeHover must be wrapped in a Composite component.");
17479 const isMouseMoving = useIsMouseMoving();
17480 const onMouseMoveProp = props.onMouseMove;
17481 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17482 const onMouseMove = useEvent((event) => {
17483 onMouseMoveProp?.(event);
17484 if (event.defaultPrevented) return;
17485 if (!isMouseMoving()) return;
17486 if (!focusOnHoverProp(event)) return;
17487 if (!hasFocusWithin(event.currentTarget)) {
17488 const baseElement = store?.getState().baseElement;
17489 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
17490 }
17491 store?.setActiveId(event.currentTarget.id);
17492 });
17493 const onMouseLeaveProp = props.onMouseLeave;
17494 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17495 const onMouseLeave = useEvent((event) => {
17496 onMouseLeaveProp?.(event);
17497 if (event.defaultPrevented) return;
17498 if (!isMouseMoving()) return;
17499 if (hoveringInside(event)) return;
17500 if (movingToAnotherItem(event)) return;
17501 if (!focusOnHoverProp(event)) return;
17502 if (!blurOnHoverEndProp(event)) return;
17503 store?.setActiveId(null);
17504 store?.getState().baseElement?.focus();
17505 });
17506 const ref = (0, import_react18.useCallback)((element) => {
17507 if (!element) return;
17508 element[symbol2] = true;
17509 }, []);
17510 props = {
17511 ...props,
17512 ref: useMergeRefs(ref, props.ref),
17513 onMouseMove,
17514 onMouseLeave
17515 };
17516 return removeUndefinedValues(props);
17517 });
17518 var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
17519 return createElement3(TagName8, useCompositeHover(props));
17520 }));
17521
17522 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
17523 var import_react19 = __toESM(require_react(), 1);
17524 var TagName9 = "input";
17525 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17526 if (!autoSelect) return false;
17527 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
17528 }
17529 function hasCompletionString(value, activeValue) {
17530 if (!activeValue) return false;
17531 if (value == null) return false;
17532 value = normalizeString(value);
17533 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17534 }
17535 function isInputEvent(event) {
17536 return event.type === "input";
17537 }
17538 function isAriaAutoCompleteValue(value) {
17539 return value === "inline" || value === "list" || value === "both" || value === "none";
17540 }
17541 function getDefaultAutoSelectId(items) {
17542 return items.find((item) => {
17543 if (item.disabled) return false;
17544 return item.element?.getAttribute("role") !== "tab";
17545 })?.id;
17546 }
17547 var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) {
17548 const context = useComboboxProviderContext();
17549 store = store || context;
17550 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
17551 const ref = (0, import_react19.useRef)(null);
17552 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17553 const canAutoSelectRef = (0, import_react19.useRef)(false);
17554 const composingRef = (0, import_react19.useRef)(false);
17555 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
17556 const inline4 = autoComplete === "inline" || autoComplete === "both";
17557 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
17558 useUpdateLayoutEffect(() => {
17559 if (!inline4) return;
17560 setCanInline(true);
17561 }, [inline4]);
17562 const storeValue = useStoreState(store, "value");
17563 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
17564 (0, import_react19.useEffect)(() => {
17565 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17566 prevSelectedValueRef.current = prev.selectedValue;
17567 });
17568 }, [store]);
17569 const inlineActiveValue = useStoreState(store, (state) => {
17570 if (!inline4) return;
17571 if (!canInline) return;
17572 if (state.activeValue && Array.isArray(state.selectedValue)) {
17573 if (state.selectedValue.includes(state.activeValue)) return;
17574 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
17575 }
17576 return state.activeValue;
17577 });
17578 const items = useStoreState(store, "renderedItems");
17579 const open = useStoreState(store, "open");
17580 const contentElement = useStoreState(store, "contentElement");
17581 const value = (0, import_react19.useMemo)(() => {
17582 if (!inline4) return storeValue;
17583 if (!canInline) return storeValue;
17584 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
17585 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
17586 return storeValue;
17587 }
17588 return inlineActiveValue || storeValue;
17589 }, [
17590 inline4,
17591 canInline,
17592 items,
17593 inlineActiveValue,
17594 autoSelect,
17595 storeValue
17596 ]);
17597 (0, import_react19.useEffect)(() => {
17598 const element = ref.current;
17599 if (!element) return;
17600 const onCompositeItemMove = () => setCanInline(true);
17601 element.addEventListener("combobox-item-move", onCompositeItemMove);
17602 return () => {
17603 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17604 };
17605 }, []);
17606 (0, import_react19.useEffect)(() => {
17607 if (!inline4) return;
17608 if (!canInline) return;
17609 if (!inlineActiveValue) return;
17610 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
17611 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17612 let cleanup = noop4;
17613 queueMicrotask(() => {
17614 const element = ref.current;
17615 if (!element) return;
17616 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17617 const nextStart = storeValue.length;
17618 const nextEnd = inlineActiveValue.length;
17619 setSelectionRange(element, nextStart, nextEnd);
17620 cleanup = () => {
17621 if (!hasFocus(element)) return;
17622 const { start, end } = getTextboxSelection(element);
17623 if (start !== nextStart) return;
17624 if (end !== nextEnd) return;
17625 setSelectionRange(element, prevStart, prevEnd);
17626 };
17627 });
17628 return () => cleanup();
17629 }, [
17630 valueUpdated,
17631 inline4,
17632 canInline,
17633 inlineActiveValue,
17634 items,
17635 autoSelect,
17636 storeValue
17637 ]);
17638 const scrollingElementRef = (0, import_react19.useRef)(null);
17639 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17640 const autoSelectIdRef = (0, import_react19.useRef)(null);
17641 const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
17642 const userScrolledRef = (0, import_react19.useRef)(false);
17643 const isAutoScrollingRef = (0, import_react19.useRef)(false);
17644 (0, import_react19.useEffect)(() => {
17645 if (!open) return;
17646 if (!contentElement) return;
17647 const scrollingElement = getScrollingElement(contentElement);
17648 if (!scrollingElement) return;
17649 scrollingElementRef.current = scrollingElement;
17650 const onUserScroll = () => {
17651 canAutoSelectRef.current = false;
17652 userScrolledRef.current = true;
17653 };
17654 const onScroll = () => {
17655 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
17656 if (!store) return;
17657 if (!canAutoSelectRef.current) return;
17658 const { activeId } = store.getState();
17659 if (activeId === null) return;
17660 if (activeId === autoSelectIdRef.current) return;
17661 canAutoSelectRef.current = false;
17662 };
17663 const options = {
17664 passive: true,
17665 capture: true
17666 };
17667 scrollingElement.addEventListener("wheel", onUserScroll, options);
17668 scrollingElement.addEventListener("touchmove", onUserScroll, options);
17669 scrollingElement.addEventListener("scroll", onScroll, options);
17670 return () => {
17671 scrollingElement.removeEventListener("wheel", onUserScroll, true);
17672 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
17673 scrollingElement.removeEventListener("scroll", onScroll, true);
17674 };
17675 }, [
17676 open,
17677 contentElement,
17678 store
17679 ]);
17680 useSafeLayoutEffect(() => {
17681 userScrolledRef.current = false;
17682 if (!storeValue) return;
17683 if (composingRef.current) return;
17684 canAutoSelectRef.current = true;
17685 }, [storeValue]);
17686 useSafeLayoutEffect(() => {
17687 if (autoSelect !== "always" && open) return;
17688 canAutoSelectRef.current = open;
17689 }, [autoSelect, open]);
17690 useSafeLayoutEffect(() => {
17691 if (open) return;
17692 autoSelectMovedRef.current = void 0;
17693 }, [open]);
17694 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
17695 useUpdateEffect(() => {
17696 const canAutoSelect = canAutoSelectRef.current;
17697 if (!store) return;
17698 if (!open) return;
17699 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
17700 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
17701 if (baseElement && !hasFocus(baseElement)) return;
17702 if (contentElement2?.hasAttribute("data-placing")) {
17703 const observer = new MutationObserver(forceValueUpdate);
17704 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
17705 return () => observer.disconnect();
17706 }
17707 if (autoSelect && canAutoSelect) {
17708 const userAutoSelectId = getAutoSelectIdProp(items);
17709 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
17710 autoSelectIdRef.current = autoSelectId;
17711 const nextActiveId = autoSelectId ?? null;
17712 const nextActiveValue = store.item(nextActiveId)?.value;
17713 const moved = autoSelectMovedRef.current;
17714 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
17715 autoSelectMovedRef.current = {
17716 id: nextActiveId,
17717 value: nextActiveValue
17718 };
17719 store.move(nextActiveId);
17720 } else store.setState("activeValue", nextActiveValue);
17721 } else {
17722 const element = store.item(activeId || store.first())?.element;
17723 if (element && "scrollIntoView" in element) {
17724 isAutoScrollingRef.current = true;
17725 element.scrollIntoView({
17726 block: "nearest",
17727 inline: "nearest"
17728 });
17729 requestAnimationFrame(() => {
17730 isAutoScrollingRef.current = false;
17731 });
17732 }
17733 }
17734 }, [
17735 store,
17736 open,
17737 valueUpdated,
17738 storeValue,
17739 autoSelect,
17740 resetValueOnSelect,
17741 getAutoSelectIdProp,
17742 items
17743 ]);
17744 (0, import_react19.useEffect)(() => {
17745 if (!inline4) return;
17746 const combobox = ref.current;
17747 if (!combobox) return;
17748 const elements = [combobox, contentElement].filter((value2) => !!value2);
17749 const onBlur2 = (event) => {
17750 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
17751 };
17752 for (const element of elements) element.addEventListener("focusout", onBlur2);
17753 return () => {
17754 for (const element of elements) element.removeEventListener("focusout", onBlur2);
17755 };
17756 }, [
17757 inline4,
17758 contentElement,
17759 store,
17760 value
17761 ]);
17762 const canShow = (event) => {
17763 return event.currentTarget.value.length >= showMinLength;
17764 };
17765 const onChangeProp = props.onChange;
17766 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
17767 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
17768 const onChange = useEvent((event) => {
17769 onChangeProp?.(event);
17770 if (event.defaultPrevented) return;
17771 if (!store) return;
17772 const currentTarget = event.currentTarget;
17773 const { value: value2, selectionStart, selectionEnd } = currentTarget;
17774 const nativeEvent = event.nativeEvent;
17775 canAutoSelectRef.current = true;
17776 if (isInputEvent(nativeEvent)) {
17777 if (nativeEvent.isComposing) {
17778 canAutoSelectRef.current = false;
17779 composingRef.current = true;
17780 }
17781 if (inline4) {
17782 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
17783 const caretAtEnd = selectionStart === value2.length;
17784 setCanInline(textInserted && caretAtEnd);
17785 }
17786 }
17787 if (setValueOnChangeProp(event)) {
17788 const isSameValue = value2 === store.getState().value;
17789 store.setValue(value2);
17790 queueMicrotask(() => {
17791 setSelectionRange(currentTarget, selectionStart, selectionEnd);
17792 });
17793 if (inline4 && autoSelect && isSameValue) forceValueUpdate();
17794 }
17795 if (showOnChangeProp(event)) store.show();
17796 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
17797 });
17798 const onCompositionEndProp = props.onCompositionEnd;
17799 const onCompositionEnd = useEvent((event) => {
17800 canAutoSelectRef.current = true;
17801 composingRef.current = false;
17802 onCompositionEndProp?.(event);
17803 if (event.defaultPrevented) return;
17804 if (!autoSelect) return;
17805 forceValueUpdate();
17806 });
17807 const onMouseDownProp = props.onMouseDown;
17808 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
17809 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17810 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
17811 const onMouseDown = useEvent((event) => {
17812 onMouseDownProp?.(event);
17813 if (event.defaultPrevented) return;
17814 if (event.button) return;
17815 if (event.ctrlKey) return;
17816 if (!store) return;
17817 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
17818 if (setValueOnClickProp(event)) store.setValue(value);
17819 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
17820 });
17821 const onKeyDownProp = props.onKeyDown;
17822 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
17823 const onKeyDown = useEvent((event) => {
17824 onKeyDownProp?.(event);
17825 if (!event.repeat) canAutoSelectRef.current = false;
17826 if (event.defaultPrevented) return;
17827 if (!store) return;
17828 const { open: open2 } = store.getState();
17829 if (open2 && event.key === "Enter") {
17830 event.preventDefault();
17831 return;
17832 }
17833 if (event.ctrlKey) return;
17834 if (event.altKey) return;
17835 if (event.shiftKey) return;
17836 if (event.metaKey) return;
17837 if (open2) return;
17838 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
17839 if (showOnKeyPressProp(event)) {
17840 event.preventDefault();
17841 store.show();
17842 }
17843 }
17844 });
17845 const onBlurProp = props.onBlur;
17846 const onBlur = useEvent((event) => {
17847 canAutoSelectRef.current = false;
17848 onBlurProp?.(event);
17849 if (event.defaultPrevented) return;
17850 });
17851 const id = useId4(props.id);
17852 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
17853 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
17854 props = {
17855 role: "combobox",
17856 "aria-autocomplete": ariaAutoComplete,
17857 "aria-haspopup": getPopupRole(contentElement, "listbox"),
17858 "aria-expanded": open,
17859 "aria-controls": contentElement?.id,
17860 "data-active-item": isActiveItem || void 0,
17861 value,
17862 ...props,
17863 id,
17864 ref: useMergeRefs(ref, props.ref),
17865 onChange,
17866 onCompositionEnd,
17867 onMouseDown,
17868 onKeyDown,
17869 onBlur
17870 };
17871 props = useComposite({
17872 store,
17873 focusable: focusable2,
17874 ...props,
17875 moveOnKeyPress: (event) => {
17876 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
17877 if (inline4) setCanInline(true);
17878 return true;
17879 }
17880 });
17881 props = usePopoverAnchor({
17882 store,
17883 ...props
17884 });
17885 return {
17886 autoComplete: "off",
17887 ...props
17888 };
17889 });
17890 var Combobox = forwardRef21(function Combobox2(props) {
17891 return createElement3(TagName9, useCombobox(props));
17892 });
17893
17894 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
17895 var import_react20 = __toESM(require_react(), 1);
17896 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
17897 var TagName10 = "div";
17898 function isSelected(storeValue, itemValue) {
17899 if (itemValue == null) return;
17900 if (storeValue == null) return false;
17901 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
17902 return storeValue === itemValue;
17903 }
17904 function getItemRole(popupRole) {
17905 return {
17906 menu: "menuitem",
17907 listbox: "option",
17908 tree: "treeitem"
17909 }[popupRole] ?? "option";
17910 }
17911 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
17912 const context = useComboboxScopedContext();
17913 store = store || context;
17914 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
17915 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
17916 resetValueOnSelectState: "resetValueOnSelect",
17917 multiSelectable(state) {
17918 return Array.isArray(state.selectedValue);
17919 },
17920 selected(state) {
17921 return isSelected(state.selectedValue, value);
17922 }
17923 });
17924 const getItem = (0, import_react20.useCallback)((item) => {
17925 const nextItem = {
17926 ...item,
17927 value
17928 };
17929 if (getItemProp) return getItemProp(nextItem);
17930 return nextItem;
17931 }, [value, getItemProp]);
17932 setValueOnClick = setValueOnClick ?? !multiSelectable;
17933 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
17934 const onClickProp = props.onClick;
17935 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17936 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
17937 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
17938 const hideOnClickProp = useBooleanEvent(hideOnClick);
17939 const onClick = useEvent((event) => {
17940 onClickProp?.(event);
17941 if (event.defaultPrevented) return;
17942 if (isDownloading(event)) return;
17943 if (isOpeningInNewTab(event)) return;
17944 if (value != null) {
17945 if (selectValueOnClickProp(event)) {
17946 if (resetValueOnSelectProp(event)) store?.resetValue();
17947 store?.setSelectedValue((prevValue) => {
17948 if (!Array.isArray(prevValue)) return value;
17949 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
17950 return [...prevValue, value];
17951 });
17952 }
17953 if (setValueOnClickProp(event)) store?.setValue(value);
17954 }
17955 if (hideOnClickProp(event)) store?.hide();
17956 });
17957 const onKeyDownProp = props.onKeyDown;
17958 const onKeyDown = useEvent((event) => {
17959 onKeyDownProp?.(event);
17960 if (event.defaultPrevented) return;
17961 const baseElement = store?.getState().baseElement;
17962 if (!baseElement) return;
17963 if (hasFocus(baseElement)) return;
17964 if (event.key.length === 1 || event.key === "Backspace" || event.key === "Delete") {
17965 queueMicrotask(() => baseElement.focus());
17966 if (isTextField(baseElement)) store?.setValue(baseElement.value);
17967 }
17968 });
17969 if (multiSelectable && selected != null) props = {
17970 "aria-selected": selected,
17971 ...props
17972 };
17973 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemValueContext.Provider, {
17974 value,
17975 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemCheckedContext.Provider, {
17976 value: selected ?? false,
17977 children: element
17978 })
17979 }), [value, selected]);
17980 props = {
17981 role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
17982 children: value,
17983 ...props,
17984 onClick,
17985 onKeyDown
17986 };
17987 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17988 props = useCompositeItem({
17989 store,
17990 ...props,
17991 getItem,
17992 moveOnKeyPress: (event) => {
17993 if (!moveOnKeyPressProp(event)) return false;
17994 const moveEvent = new Event("combobox-item-move");
17995 store?.getState().baseElement?.dispatchEvent(moveEvent);
17996 return true;
17997 }
17998 });
17999 props = useCompositeHover({
18000 store,
18001 focusOnHover,
18002 ...props
18003 });
18004 return props;
18005 });
18006 var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
18007 return createElement3(TagName10, useComboboxItem(props));
18008 }));
18009
18010 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
18011 var import_react21 = __toESM(require_react(), 1);
18012 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18013 var TagName11 = "span";
18014 function normalizeValue(value) {
18015 return normalizeString(value).toLowerCase();
18016 }
18017 function getOffsets(string, values) {
18018 const offsets = [];
18019 for (const value of values) {
18020 let pos = 0;
18021 const length = value.length;
18022 while (string.indexOf(value, pos) !== -1) {
18023 const index2 = string.indexOf(value, pos);
18024 if (index2 !== -1) offsets.push([index2, length]);
18025 pos = index2 + 1;
18026 }
18027 }
18028 return offsets;
18029 }
18030 function filterOverlappingOffsets(offsets) {
18031 return offsets.filter(([offset4, length], i2, arr) => {
18032 return !arr.some(([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length);
18033 });
18034 }
18035 function sortOffsets(offsets) {
18036 return offsets.sort(([a2], [b2]) => a2 - b2);
18037 }
18038 function splitValue(itemValue, userValue) {
18039 if (!itemValue) return itemValue;
18040 if (!userValue) return itemValue;
18041 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18042 const parts = [];
18043 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", {
18044 "data-autocomplete-value": autocomplete ? "" : void 0,
18045 "data-user-value": autocomplete ? void 0 : "",
18046 children: value
18047 }, parts.length);
18048 const offsets = sortOffsets(filterOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
18049 const firstEntry = offsets[0];
18050 if (!firstEntry) {
18051 parts.push(span(itemValue, true));
18052 return parts;
18053 }
18054 const [firstOffset] = firstEntry;
18055 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
18056 const value = itemValue.slice(offset4, offset4 + length);
18057 const nextOffset = offsets[i2 + 1]?.[0];
18058 return [value, itemValue.slice(offset4 + length, nextOffset)];
18059 })].forEach((value, i2) => {
18060 if (!value) return;
18061 parts.push(span(value, i2 % 2 === 0));
18062 });
18063 return parts;
18064 }
18065 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18066 const context = useComboboxScopedContext();
18067 store = store || context;
18068 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
18069 const itemValue = value ?? itemContext;
18070 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
18071 props = {
18072 children: (0, import_react21.useMemo)(() => {
18073 if (!itemValue) return;
18074 if (!inputValue) return itemValue;
18075 return splitValue(itemValue, inputValue);
18076 }, [itemValue, inputValue]),
18077 ...props
18078 };
18079 return removeUndefinedValues(props);
18080 });
18081 var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
18082 return createElement3(TagName11, useComboboxItemValue(props));
18083 });
18084
18085 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
18086 var TagName12 = "label";
18087 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
18088 const context = useComboboxProviderContext();
18089 store = store || context;
18090 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18091 props = {
18092 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
18093 ...props
18094 };
18095 return removeUndefinedValues(props);
18096 });
18097 var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
18098 return createElement3(TagName12, useComboboxLabel(props));
18099 }));
18100
18101 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
18102 var import_react22 = __toESM(require_react(), 1);
18103 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18104 var TagName13 = "div";
18105 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
18106 const scopedContext = useComboboxScopedContext(true);
18107 const context = useComboboxContext();
18108 store = store || context;
18109 const scopedContextSameStore = !!store && store === scopedContext;
18110 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18111 const ref = (0, import_react22.useRef)(null);
18112 const id = useId4(props.id);
18113 const mounted = useStoreState(store, "mounted");
18114 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18115 const style = hidden ? {
18116 ...props.style,
18117 display: "none"
18118 } : props.style;
18119 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
18120 const role = useAttribute(ref, "role", props.role);
18121 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
18122 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
18123 const contentElement = useStoreState(store, "contentElement");
18124 useSafeLayoutEffect(() => {
18125 if (!mounted) return;
18126 const element = ref.current;
18127 if (!element) return;
18128 if (contentElement !== element) return;
18129 const callback = () => {
18130 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18131 };
18132 const observer = new MutationObserver(callback);
18133 observer.observe(element, {
18134 subtree: true,
18135 childList: true,
18136 attributeFilter: ["role"]
18137 });
18138 callback();
18139 return () => observer.disconnect();
18140 }, [mounted, contentElement]);
18141 if (!hasListboxInside) props = {
18142 role: "listbox",
18143 "aria-multiselectable": ariaMultiSelectable,
18144 ...props
18145 };
18146 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxScopedContextProvider, {
18147 value: store,
18148 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxListRoleContext.Provider, {
18149 value: role,
18150 children: element
18151 })
18152 }), [store, role]);
18153 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18154 props = {
18155 hidden,
18156 ...props,
18157 id,
18158 ref: useMergeRefs(setContentElement, ref, props.ref),
18159 style
18160 };
18161 return removeUndefinedValues(props);
18162 });
18163 var ComboboxList = forwardRef21(function ComboboxList2(props) {
18164 return createElement3(TagName13, useComboboxList(props));
18165 });
18166
18167 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
18168 var import_react23 = __toESM(require_react(), 1);
18169 var TagValueContext = (0, import_react23.createContext)(null);
18170 var TagRemoveIdContext = (0, import_react23.createContext)(null);
18171 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
18172 var useTagContext = ctx7.useContext;
18173 var useTagScopedContext = ctx7.useScopedContext;
18174 var useTagProviderContext = ctx7.useProviderContext;
18175 var TagContextProvider = ctx7.ContextProvider;
18176 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18177
18178 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
18179 var isTouchSafari = isSafari2() && isTouchDevice();
18180 function createComboboxStore({ tag, ...props } = {}) {
18181 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18182 throwOnConflictingProps(props, store);
18183 const tagState = tag?.getState();
18184 const syncState = store?.getState();
18185 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
18186 const composite = createCompositeStore({
18187 ...props,
18188 activeId,
18189 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
18190 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
18191 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
18192 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
18193 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
18194 });
18195 const popover = createPopoverStore({
18196 ...props,
18197 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
18198 });
18199 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
18200 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
18201 const multiSelectable = Array.isArray(selectedValue);
18202 const initialState = {
18203 ...composite.getState(),
18204 ...popover.getState(),
18205 value,
18206 selectedValue,
18207 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
18208 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
18209 activeValue: syncState?.activeValue
18210 };
18211 const combobox = createStore(initialState, composite, popover, store);
18212 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
18213 combobox.setState("virtualFocus", false);
18214 }));
18215 setup(combobox, () => {
18216 if (!tag) return;
18217 return chain(sync(combobox, ["selectedValue"], (state) => {
18218 if (!Array.isArray(state.selectedValue)) return;
18219 tag.setValues(state.selectedValue);
18220 }), sync(tag, ["values"], (state) => {
18221 combobox.setState("selectedValue", state.values);
18222 }));
18223 });
18224 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18225 if (!state.resetValueOnHide) return;
18226 if (state.mounted) return;
18227 combobox.setState("value", value);
18228 }));
18229 setup(combobox, () => sync(combobox, ["open"], (state) => {
18230 if (state.open) return;
18231 combobox.setState("activeId", activeId);
18232 combobox.setState("moves", 0);
18233 }));
18234 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18235 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
18236 }));
18237 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18238 if (state.moves === prev.moves) return;
18239 const { activeId: activeId2 } = combobox.getState();
18240 const activeItem = composite.item(activeId2);
18241 combobox.setState("activeValue", activeItem?.value);
18242 }));
18243 return {
18244 ...popover,
18245 ...composite,
18246 ...combobox,
18247 tag,
18248 setValue: (value2) => combobox.setState("value", value2),
18249 resetValue: () => combobox.setState("value", initialState.value),
18250 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18251 };
18252 }
18253
18254 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
18255 function useComboboxStoreOptions(props) {
18256 const tag = useTagContext();
18257 props = {
18258 ...props,
18259 tag: props.tag !== void 0 ? props.tag : tag
18260 };
18261 return useCompositeStoreOptions(props);
18262 }
18263 function useComboboxStoreProps(store, update2, props) {
18264 useUpdateEffect(update2, [props.tag]);
18265 useStoreProps(store, props, "value", "setValue");
18266 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18267 useStoreProps(store, props, "resetValueOnHide");
18268 useStoreProps(store, props, "resetValueOnSelect");
18269 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
18270 }
18271 function useComboboxStore(props = {}) {
18272 props = useComboboxStoreOptions(props);
18273 const [store, update2] = useStore2(createComboboxStore, props);
18274 return useComboboxStoreProps(store, update2, props);
18275 }
18276
18277 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
18278 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18279 function ComboboxProvider(props = {}) {
18280 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxContextProvider, {
18281 value: useComboboxStore(props),
18282 children: props.children
18283 });
18284 }
18285
18286 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18287 var import_remove_accents = __toESM(require_remove_accents(), 1);
18288 var import_compose8 = __toESM(require_compose(), 1);
18289 var import_i18n23 = __toESM(require_i18n(), 1);
18290 var import_element43 = __toESM(require_element(), 1);
18291 var import_components19 = __toESM(require_components(), 1);
18292
18293 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18294 var EMPTY_ARRAY3 = [];
18295 var getCurrentValue = (filterDefinition, currentFilter) => {
18296 if (filterDefinition.singleSelection) {
18297 return currentFilter?.value;
18298 }
18299 if (Array.isArray(currentFilter?.value)) {
18300 return currentFilter.value;
18301 }
18302 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18303 return [currentFilter.value];
18304 }
18305 return EMPTY_ARRAY3;
18306 };
18307
18308 // packages/dataviews/build-module/hooks/use-elements.mjs
18309 var import_element42 = __toESM(require_element(), 1);
18310 var EMPTY_ARRAY4 = [];
18311 function useElements({
18312 elements,
18313 getElements
18314 }) {
18315 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18316 const [records, setRecords] = (0, import_element42.useState)(staticElements);
18317 const [isLoading, setIsLoading] = (0, import_element42.useState)(false);
18318 (0, import_element42.useEffect)(() => {
18319 if (!getElements) {
18320 setRecords(staticElements);
18321 return;
18322 }
18323 let cancelled = false;
18324 setIsLoading(true);
18325 getElements().then((fetchedElements) => {
18326 if (!cancelled) {
18327 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18328 setRecords(dynamicElements);
18329 }
18330 }).catch(() => {
18331 if (!cancelled) {
18332 setRecords(staticElements);
18333 }
18334 }).finally(() => {
18335 if (!cancelled) {
18336 setIsLoading(false);
18337 }
18338 });
18339 return () => {
18340 cancelled = true;
18341 };
18342 }, [getElements, staticElements]);
18343 return {
18344 elements: records,
18345 isLoading
18346 };
18347 }
18348
18349 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18350 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
18351 function normalizeSearchInput(input = "") {
18352 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18353 }
18354 var getNewValue = (filterDefinition, currentFilter, value) => {
18355 if (filterDefinition.singleSelection) {
18356 return value;
18357 }
18358 if (Array.isArray(currentFilter?.value)) {
18359 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18360 }
18361 return [value];
18362 };
18363 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18364 return `${prefix}-${filterElementValue}`;
18365 }
18366 var MultiSelectionOption = ({ selected }) => {
18367 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18368 "span",
18369 {
18370 className: clsx_default(
18371 "dataviews-filters__search-widget-listitem-multi-selection",
18372 { "is-selected": selected }
18373 ),
18374 children: selected && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: check_default })
18375 }
18376 );
18377 };
18378 var SingleSelectionOption = ({ selected }) => {
18379 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18380 "span",
18381 {
18382 className: clsx_default(
18383 "dataviews-filters__search-widget-listitem-single-selection",
18384 { "is-selected": selected }
18385 )
18386 }
18387 );
18388 };
18389 function ListBox({ view, filter, onChangeView }) {
18390 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
18391 const [activeCompositeId, setActiveCompositeId] = (0, import_element43.useState)(
18392 // When there are one or less operators, the first item is set as active
18393 // (by setting the initial `activeId` to `undefined`).
18394 // With 2 or more operators, the focus is moved on the operators control
18395 // (by setting the initial `activeId` to `null`), meaning that there won't
18396 // be an active item initially. Focus is then managed via the
18397 // `onFocusVisible` callback.
18398 filter.operators?.length === 1 ? void 0 : null
18399 );
18400 const currentFilter = view.filters?.find(
18401 (f2) => f2.field === filter.field
18402 );
18403 const currentValue = getCurrentValue(filter, currentFilter);
18404 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18405 import_components19.Composite,
18406 {
18407 virtualFocus: true,
18408 focusLoop: true,
18409 activeId: activeCompositeId,
18410 setActiveId: setActiveCompositeId,
18411 role: "listbox",
18412 className: "dataviews-filters__search-widget-listbox",
18413 "aria-label": (0, import_i18n23.sprintf)(
18414 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18415 (0, import_i18n23.__)("List of: %1$s"),
18416 filter.name
18417 ),
18418 onFocusVisible: () => {
18419 if (!activeCompositeId && filter.elements.length) {
18420 setActiveCompositeId(
18421 generateFilterElementCompositeItemId(
18422 baseId,
18423 filter.elements[0].value
18424 )
18425 );
18426 }
18427 },
18428 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Composite.Typeahead, {}),
18429 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18430 import_components19.Composite.Hover,
18431 {
18432 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18433 import_components19.Composite.Item,
18434 {
18435 id: generateFilterElementCompositeItemId(
18436 baseId,
18437 element.value
18438 ),
18439 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18440 "div",
18441 {
18442 "aria-label": element.label,
18443 role: "option",
18444 className: "dataviews-filters__search-widget-listitem"
18445 }
18446 ),
18447 onClick: () => {
18448 const newFilters = currentFilter ? [
18449 ...(view.filters ?? []).map(
18450 (_filter) => {
18451 if (_filter.field === filter.field) {
18452 return {
18453 ..._filter,
18454 operator: currentFilter.operator || filter.operators[0],
18455 value: getNewValue(
18456 filter,
18457 currentFilter,
18458 element.value
18459 )
18460 };
18461 }
18462 return _filter;
18463 }
18464 )
18465 ] : [
18466 ...view.filters ?? [],
18467 {
18468 field: filter.field,
18469 operator: filter.operators[0],
18470 value: getNewValue(
18471 filter,
18472 currentFilter,
18473 element.value
18474 )
18475 }
18476 ];
18477 onChangeView({
18478 ...view,
18479 page: 1,
18480 filters: newFilters
18481 });
18482 }
18483 }
18484 ),
18485 children: [
18486 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18487 SingleSelectionOption,
18488 {
18489 selected: currentValue === element.value
18490 }
18491 ),
18492 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18493 MultiSelectionOption,
18494 {
18495 selected: currentValue.includes(element.value)
18496 }
18497 ),
18498 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18499 "span",
18500 {
18501 className: "dataviews-filters__search-widget-listitem-value",
18502 title: element.label,
18503 children: element.label
18504 }
18505 )
18506 ]
18507 },
18508 element.value
18509 ))
18510 }
18511 );
18512 }
18513 function ComboboxList22({ view, filter, onChangeView }) {
18514 const [searchValue, setSearchValue] = (0, import_element43.useState)("");
18515 const deferredSearchValue = (0, import_element43.useDeferredValue)(searchValue);
18516 const currentFilter = view.filters?.find(
18517 (_filter) => _filter.field === filter.field
18518 );
18519 const currentValue = getCurrentValue(filter, currentFilter);
18520 const matches = (0, import_element43.useMemo)(() => {
18521 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18522 return filter.elements.filter(
18523 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18524 );
18525 }, [filter.elements, deferredSearchValue]);
18526 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18527 ComboboxProvider,
18528 {
18529 selectedValue: currentValue,
18530 setSelectedValue: (value) => {
18531 const newFilters = currentFilter ? [
18532 ...(view.filters ?? []).map((_filter) => {
18533 if (_filter.field === filter.field) {
18534 return {
18535 ..._filter,
18536 operator: currentFilter.operator || filter.operators[0],
18537 value
18538 };
18539 }
18540 return _filter;
18541 })
18542 ] : [
18543 ...view.filters ?? [],
18544 {
18545 field: filter.field,
18546 operator: filter.operators[0],
18547 value
18548 }
18549 ];
18550 onChangeView({
18551 ...view,
18552 page: 1,
18553 filters: newFilters
18554 });
18555 },
18556 setValue: setSearchValue,
18557 children: [
18558 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
18559 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
18560 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18561 Combobox,
18562 {
18563 autoSelect: "always",
18564 placeholder: (0, import_i18n23.__)("Search"),
18565 className: "dataviews-filters__search-widget-filter-combobox__input"
18566 }
18567 ),
18568 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: search_default }) })
18569 ] }),
18570 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18571 ComboboxList,
18572 {
18573 className: "dataviews-filters__search-widget-filter-combobox-list",
18574 alwaysVisible: true,
18575 children: [
18576 matches.map((element) => {
18577 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18578 ComboboxItem,
18579 {
18580 resetValueOnSelect: false,
18581 value: element.value,
18582 className: "dataviews-filters__search-widget-listitem",
18583 hideOnClick: false,
18584 setValueOnClick: false,
18585 focusOnHover: true,
18586 children: [
18587 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18588 SingleSelectionOption,
18589 {
18590 selected: currentValue === element.value
18591 }
18592 ),
18593 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18594 MultiSelectionOption,
18595 {
18596 selected: currentValue.includes(
18597 element.value
18598 )
18599 }
18600 ),
18601 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18602 "span",
18603 {
18604 className: "dataviews-filters__search-widget-listitem-value",
18605 title: element.label,
18606 children: [
18607 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18608 ComboboxItemValue,
18609 {
18610 className: "dataviews-filters__search-widget-filter-combobox-item-value",
18611 value: element.label
18612 }
18613 ),
18614 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
18615 ]
18616 }
18617 )
18618 ]
18619 },
18620 element.value
18621 );
18622 }),
18623 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
18624 ]
18625 }
18626 )
18627 ]
18628 }
18629 );
18630 }
18631 function SearchWidget(props) {
18632 const { elements, isLoading } = useElements({
18633 elements: props.filter.elements,
18634 getElements: props.filter.getElements
18635 });
18636 if (isLoading) {
18637 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Spinner, {}) });
18638 }
18639 if (elements.length === 0) {
18640 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
18641 }
18642 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
18643 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
18644 }
18645
18646 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
18647 var import_es6 = __toESM(require_es6(), 1);
18648 var import_compose9 = __toESM(require_compose(), 1);
18649 var import_element44 = __toESM(require_element(), 1);
18650 var import_components20 = __toESM(require_components(), 1);
18651 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
18652 function InputWidget({
18653 filter,
18654 view,
18655 onChangeView,
18656 fields
18657 }) {
18658 const currentFilter = view.filters?.find(
18659 (f2) => f2.field === filter.field
18660 );
18661 const currentValue = getCurrentValue(filter, currentFilter);
18662 const field = (0, import_element44.useMemo)(() => {
18663 const currentField = fields.find((f2) => f2.id === filter.field);
18664 if (currentField) {
18665 return {
18666 ...currentField,
18667 // Deactivate validation for filters.
18668 isValid: {},
18669 // Filter controls are always enabled.
18670 isDisabled: () => false,
18671 // Filter controls are always visible.
18672 isVisible: () => true,
18673 // Configure getValue/setValue as if Item was a plain object.
18674 getValue: ({ item }) => item[currentField.id],
18675 setValue: ({ value }) => ({
18676 [currentField.id]: value
18677 })
18678 };
18679 }
18680 return currentField;
18681 }, [fields, filter.field]);
18682 const data = (0, import_element44.useMemo)(() => {
18683 return (view.filters ?? []).reduce(
18684 (acc, activeFilter) => {
18685 acc[activeFilter.field] = activeFilter.value;
18686 return acc;
18687 },
18688 {}
18689 );
18690 }, [view.filters]);
18691 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
18692 if (!field || !currentFilter) {
18693 return;
18694 }
18695 const nextValue = field.getValue({ item: updatedData });
18696 if ((0, import_es6.default)(nextValue, currentValue)) {
18697 return;
18698 }
18699 onChangeView({
18700 ...view,
18701 filters: (view.filters ?? []).map(
18702 (_filter) => _filter.field === filter.field ? {
18703 ..._filter,
18704 operator: currentFilter.operator || filter.operators[0],
18705 // Consider empty strings as undefined:
18706 //
18707 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
18708 // - empty string as value means "search empty string": returns only the records that have an empty string as value
18709 //
18710 // In practice, this means the filter will not be able to find an empty string as the value.
18711 value: nextValue === "" ? void 0 : nextValue
18712 } : _filter
18713 )
18714 });
18715 });
18716 if (!field || !field.Edit || !currentFilter) {
18717 return null;
18718 }
18719 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
18720 import_components20.Flex,
18721 {
18722 className: "dataviews-filters__user-input-widget",
18723 gap: 2.5,
18724 direction: "column",
18725 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
18726 field.Edit,
18727 {
18728 hideLabelFromVision: true,
18729 data,
18730 field,
18731 operator: currentFilter.operator,
18732 onChange: handleChange
18733 }
18734 )
18735 }
18736 );
18737 }
18738
18739 // node_modules/date-fns/constants.js
18740 var daysInYear = 365.2425;
18741 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
18742 var minTime = -maxTime;
18743 var millisecondsInWeek = 6048e5;
18744 var millisecondsInDay = 864e5;
18745 var secondsInHour = 3600;
18746 var secondsInDay = secondsInHour * 24;
18747 var secondsInWeek = secondsInDay * 7;
18748 var secondsInYear = secondsInDay * daysInYear;
18749 var secondsInMonth = secondsInYear / 12;
18750 var secondsInQuarter = secondsInMonth * 3;
18751 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
18752
18753 // node_modules/date-fns/constructFrom.js
18754 function constructFrom(date, value) {
18755 if (typeof date === "function") return date(value);
18756 if (date && typeof date === "object" && constructFromSymbol in date)
18757 return date[constructFromSymbol](value);
18758 if (date instanceof Date) return new date.constructor(value);
18759 return new Date(value);
18760 }
18761
18762 // node_modules/date-fns/toDate.js
18763 function toDate(argument, context) {
18764 return constructFrom(context || argument, argument);
18765 }
18766
18767 // node_modules/date-fns/addDays.js
18768 function addDays(date, amount, options) {
18769 const _date = toDate(date, options?.in);
18770 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18771 if (!amount) return _date;
18772 _date.setDate(_date.getDate() + amount);
18773 return _date;
18774 }
18775
18776 // node_modules/date-fns/addMonths.js
18777 function addMonths(date, amount, options) {
18778 const _date = toDate(date, options?.in);
18779 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18780 if (!amount) {
18781 return _date;
18782 }
18783 const dayOfMonth = _date.getDate();
18784 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
18785 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
18786 const daysInMonth = endOfDesiredMonth.getDate();
18787 if (dayOfMonth >= daysInMonth) {
18788 return endOfDesiredMonth;
18789 } else {
18790 _date.setFullYear(
18791 endOfDesiredMonth.getFullYear(),
18792 endOfDesiredMonth.getMonth(),
18793 dayOfMonth
18794 );
18795 return _date;
18796 }
18797 }
18798
18799 // node_modules/date-fns/_lib/defaultOptions.js
18800 var defaultOptions = {};
18801 function getDefaultOptions() {
18802 return defaultOptions;
18803 }
18804
18805 // node_modules/date-fns/startOfWeek.js
18806 function startOfWeek(date, options) {
18807 const defaultOptions2 = getDefaultOptions();
18808 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
18809 const _date = toDate(date, options?.in);
18810 const day = _date.getDay();
18811 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
18812 _date.setDate(_date.getDate() - diff);
18813 _date.setHours(0, 0, 0, 0);
18814 return _date;
18815 }
18816
18817 // node_modules/date-fns/startOfISOWeek.js
18818 function startOfISOWeek(date, options) {
18819 return startOfWeek(date, { ...options, weekStartsOn: 1 });
18820 }
18821
18822 // node_modules/date-fns/getISOWeekYear.js
18823 function getISOWeekYear(date, options) {
18824 const _date = toDate(date, options?.in);
18825 const year = _date.getFullYear();
18826 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
18827 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
18828 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
18829 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
18830 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
18831 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
18832 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
18833 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
18834 if (_date.getTime() >= startOfNextYear.getTime()) {
18835 return year + 1;
18836 } else if (_date.getTime() >= startOfThisYear.getTime()) {
18837 return year;
18838 } else {
18839 return year - 1;
18840 }
18841 }
18842
18843 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
18844 function getTimezoneOffsetInMilliseconds(date) {
18845 const _date = toDate(date);
18846 const utcDate = new Date(
18847 Date.UTC(
18848 _date.getFullYear(),
18849 _date.getMonth(),
18850 _date.getDate(),
18851 _date.getHours(),
18852 _date.getMinutes(),
18853 _date.getSeconds(),
18854 _date.getMilliseconds()
18855 )
18856 );
18857 utcDate.setUTCFullYear(_date.getFullYear());
18858 return +date - +utcDate;
18859 }
18860
18861 // node_modules/date-fns/_lib/normalizeDates.js
18862 function normalizeDates(context, ...dates) {
18863 const normalize = constructFrom.bind(
18864 null,
18865 context || dates.find((date) => typeof date === "object")
18866 );
18867 return dates.map(normalize);
18868 }
18869
18870 // node_modules/date-fns/startOfDay.js
18871 function startOfDay(date, options) {
18872 const _date = toDate(date, options?.in);
18873 _date.setHours(0, 0, 0, 0);
18874 return _date;
18875 }
18876
18877 // node_modules/date-fns/differenceInCalendarDays.js
18878 function differenceInCalendarDays(laterDate, earlierDate, options) {
18879 const [laterDate_, earlierDate_] = normalizeDates(
18880 options?.in,
18881 laterDate,
18882 earlierDate
18883 );
18884 const laterStartOfDay = startOfDay(laterDate_);
18885 const earlierStartOfDay = startOfDay(earlierDate_);
18886 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
18887 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
18888 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
18889 }
18890
18891 // node_modules/date-fns/startOfISOWeekYear.js
18892 function startOfISOWeekYear(date, options) {
18893 const year = getISOWeekYear(date, options);
18894 const fourthOfJanuary = constructFrom(options?.in || date, 0);
18895 fourthOfJanuary.setFullYear(year, 0, 4);
18896 fourthOfJanuary.setHours(0, 0, 0, 0);
18897 return startOfISOWeek(fourthOfJanuary);
18898 }
18899
18900 // node_modules/date-fns/addWeeks.js
18901 function addWeeks(date, amount, options) {
18902 return addDays(date, amount * 7, options);
18903 }
18904
18905 // node_modules/date-fns/addYears.js
18906 function addYears(date, amount, options) {
18907 return addMonths(date, amount * 12, options);
18908 }
18909
18910 // node_modules/date-fns/isDate.js
18911 function isDate(value) {
18912 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
18913 }
18914
18915 // node_modules/date-fns/isValid.js
18916 function isValid(date) {
18917 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
18918 }
18919
18920 // node_modules/date-fns/startOfMonth.js
18921 function startOfMonth(date, options) {
18922 const _date = toDate(date, options?.in);
18923 _date.setDate(1);
18924 _date.setHours(0, 0, 0, 0);
18925 return _date;
18926 }
18927
18928 // node_modules/date-fns/startOfYear.js
18929 function startOfYear(date, options) {
18930 const date_ = toDate(date, options?.in);
18931 date_.setFullYear(date_.getFullYear(), 0, 1);
18932 date_.setHours(0, 0, 0, 0);
18933 return date_;
18934 }
18935
18936 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
18937 var formatDistanceLocale = {
18938 lessThanXSeconds: {
18939 one: "less than a second",
18940 other: "less than {{count}} seconds"
18941 },
18942 xSeconds: {
18943 one: "1 second",
18944 other: "{{count}} seconds"
18945 },
18946 halfAMinute: "half a minute",
18947 lessThanXMinutes: {
18948 one: "less than a minute",
18949 other: "less than {{count}} minutes"
18950 },
18951 xMinutes: {
18952 one: "1 minute",
18953 other: "{{count}} minutes"
18954 },
18955 aboutXHours: {
18956 one: "about 1 hour",
18957 other: "about {{count}} hours"
18958 },
18959 xHours: {
18960 one: "1 hour",
18961 other: "{{count}} hours"
18962 },
18963 xDays: {
18964 one: "1 day",
18965 other: "{{count}} days"
18966 },
18967 aboutXWeeks: {
18968 one: "about 1 week",
18969 other: "about {{count}} weeks"
18970 },
18971 xWeeks: {
18972 one: "1 week",
18973 other: "{{count}} weeks"
18974 },
18975 aboutXMonths: {
18976 one: "about 1 month",
18977 other: "about {{count}} months"
18978 },
18979 xMonths: {
18980 one: "1 month",
18981 other: "{{count}} months"
18982 },
18983 aboutXYears: {
18984 one: "about 1 year",
18985 other: "about {{count}} years"
18986 },
18987 xYears: {
18988 one: "1 year",
18989 other: "{{count}} years"
18990 },
18991 overXYears: {
18992 one: "over 1 year",
18993 other: "over {{count}} years"
18994 },
18995 almostXYears: {
18996 one: "almost 1 year",
18997 other: "almost {{count}} years"
18998 }
18999 };
19000 var formatDistance = (token, count, options) => {
19001 let result;
19002 const tokenValue = formatDistanceLocale[token];
19003 if (typeof tokenValue === "string") {
19004 result = tokenValue;
19005 } else if (count === 1) {
19006 result = tokenValue.one;
19007 } else {
19008 result = tokenValue.other.replace("{{count}}", count.toString());
19009 }
19010 if (options?.addSuffix) {
19011 if (options.comparison && options.comparison > 0) {
19012 return "in " + result;
19013 } else {
19014 return result + " ago";
19015 }
19016 }
19017 return result;
19018 };
19019
19020 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19021 function buildFormatLongFn(args) {
19022 return (options = {}) => {
19023 const width = options.width ? String(options.width) : args.defaultWidth;
19024 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19025 return format6;
19026 };
19027 }
19028
19029 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19030 var dateFormats = {
19031 full: "EEEE, MMMM do, y",
19032 long: "MMMM do, y",
19033 medium: "MMM d, y",
19034 short: "MM/dd/yyyy"
19035 };
19036 var timeFormats = {
19037 full: "h:mm:ss a zzzz",
19038 long: "h:mm:ss a z",
19039 medium: "h:mm:ss a",
19040 short: "h:mm a"
19041 };
19042 var dateTimeFormats = {
19043 full: "{{date}} 'at' {{time}}",
19044 long: "{{date}} 'at' {{time}}",
19045 medium: "{{date}}, {{time}}",
19046 short: "{{date}}, {{time}}"
19047 };
19048 var formatLong = {
19049 date: buildFormatLongFn({
19050 formats: dateFormats,
19051 defaultWidth: "full"
19052 }),
19053 time: buildFormatLongFn({
19054 formats: timeFormats,
19055 defaultWidth: "full"
19056 }),
19057 dateTime: buildFormatLongFn({
19058 formats: dateTimeFormats,
19059 defaultWidth: "full"
19060 })
19061 };
19062
19063 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19064 var formatRelativeLocale = {
19065 lastWeek: "'last' eeee 'at' p",
19066 yesterday: "'yesterday at' p",
19067 today: "'today at' p",
19068 tomorrow: "'tomorrow at' p",
19069 nextWeek: "eeee 'at' p",
19070 other: "P"
19071 };
19072 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19073
19074 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19075 function buildLocalizeFn(args) {
19076 return (value, options) => {
19077 const context = options?.context ? String(options.context) : "standalone";
19078 let valuesArray;
19079 if (context === "formatting" && args.formattingValues) {
19080 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19081 const width = options?.width ? String(options.width) : defaultWidth;
19082 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19083 } else {
19084 const defaultWidth = args.defaultWidth;
19085 const width = options?.width ? String(options.width) : args.defaultWidth;
19086 valuesArray = args.values[width] || args.values[defaultWidth];
19087 }
19088 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19089 return valuesArray[index2];
19090 };
19091 }
19092
19093 // node_modules/date-fns/locale/en-US/_lib/localize.js
19094 var eraValues = {
19095 narrow: ["B", "A"],
19096 abbreviated: ["BC", "AD"],
19097 wide: ["Before Christ", "Anno Domini"]
19098 };
19099 var quarterValues = {
19100 narrow: ["1", "2", "3", "4"],
19101 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19102 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19103 };
19104 var monthValues = {
19105 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19106 abbreviated: [
19107 "Jan",
19108 "Feb",
19109 "Mar",
19110 "Apr",
19111 "May",
19112 "Jun",
19113 "Jul",
19114 "Aug",
19115 "Sep",
19116 "Oct",
19117 "Nov",
19118 "Dec"
19119 ],
19120 wide: [
19121 "January",
19122 "February",
19123 "March",
19124 "April",
19125 "May",
19126 "June",
19127 "July",
19128 "August",
19129 "September",
19130 "October",
19131 "November",
19132 "December"
19133 ]
19134 };
19135 var dayValues = {
19136 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19137 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19138 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19139 wide: [
19140 "Sunday",
19141 "Monday",
19142 "Tuesday",
19143 "Wednesday",
19144 "Thursday",
19145 "Friday",
19146 "Saturday"
19147 ]
19148 };
19149 var dayPeriodValues = {
19150 narrow: {
19151 am: "a",
19152 pm: "p",
19153 midnight: "mi",
19154 noon: "n",
19155 morning: "morning",
19156 afternoon: "afternoon",
19157 evening: "evening",
19158 night: "night"
19159 },
19160 abbreviated: {
19161 am: "AM",
19162 pm: "PM",
19163 midnight: "midnight",
19164 noon: "noon",
19165 morning: "morning",
19166 afternoon: "afternoon",
19167 evening: "evening",
19168 night: "night"
19169 },
19170 wide: {
19171 am: "a.m.",
19172 pm: "p.m.",
19173 midnight: "midnight",
19174 noon: "noon",
19175 morning: "morning",
19176 afternoon: "afternoon",
19177 evening: "evening",
19178 night: "night"
19179 }
19180 };
19181 var formattingDayPeriodValues = {
19182 narrow: {
19183 am: "a",
19184 pm: "p",
19185 midnight: "mi",
19186 noon: "n",
19187 morning: "in the morning",
19188 afternoon: "in the afternoon",
19189 evening: "in the evening",
19190 night: "at night"
19191 },
19192 abbreviated: {
19193 am: "AM",
19194 pm: "PM",
19195 midnight: "midnight",
19196 noon: "noon",
19197 morning: "in the morning",
19198 afternoon: "in the afternoon",
19199 evening: "in the evening",
19200 night: "at night"
19201 },
19202 wide: {
19203 am: "a.m.",
19204 pm: "p.m.",
19205 midnight: "midnight",
19206 noon: "noon",
19207 morning: "in the morning",
19208 afternoon: "in the afternoon",
19209 evening: "in the evening",
19210 night: "at night"
19211 }
19212 };
19213 var ordinalNumber = (dirtyNumber, _options) => {
19214 const number = Number(dirtyNumber);
19215 const rem100 = number % 100;
19216 if (rem100 > 20 || rem100 < 10) {
19217 switch (rem100 % 10) {
19218 case 1:
19219 return number + "st";
19220 case 2:
19221 return number + "nd";
19222 case 3:
19223 return number + "rd";
19224 }
19225 }
19226 return number + "th";
19227 };
19228 var localize = {
19229 ordinalNumber,
19230 era: buildLocalizeFn({
19231 values: eraValues,
19232 defaultWidth: "wide"
19233 }),
19234 quarter: buildLocalizeFn({
19235 values: quarterValues,
19236 defaultWidth: "wide",
19237 argumentCallback: (quarter) => quarter - 1
19238 }),
19239 month: buildLocalizeFn({
19240 values: monthValues,
19241 defaultWidth: "wide"
19242 }),
19243 day: buildLocalizeFn({
19244 values: dayValues,
19245 defaultWidth: "wide"
19246 }),
19247 dayPeriod: buildLocalizeFn({
19248 values: dayPeriodValues,
19249 defaultWidth: "wide",
19250 formattingValues: formattingDayPeriodValues,
19251 defaultFormattingWidth: "wide"
19252 })
19253 };
19254
19255 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19256 function buildMatchFn(args) {
19257 return (string, options = {}) => {
19258 const width = options.width;
19259 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19260 const matchResult = string.match(matchPattern);
19261 if (!matchResult) {
19262 return null;
19263 }
19264 const matchedString = matchResult[0];
19265 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19266 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19267 // [TODO] -- I challenge you to fix the type
19268 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19269 );
19270 let value;
19271 value = args.valueCallback ? args.valueCallback(key) : key;
19272 value = options.valueCallback ? (
19273 // [TODO] -- I challenge you to fix the type
19274 options.valueCallback(value)
19275 ) : value;
19276 const rest = string.slice(matchedString.length);
19277 return { value, rest };
19278 };
19279 }
19280 function findKey(object, predicate) {
19281 for (const key in object) {
19282 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19283 return key;
19284 }
19285 }
19286 return void 0;
19287 }
19288 function findIndex(array, predicate) {
19289 for (let key = 0; key < array.length; key++) {
19290 if (predicate(array[key])) {
19291 return key;
19292 }
19293 }
19294 return void 0;
19295 }
19296
19297 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19298 function buildMatchPatternFn(args) {
19299 return (string, options = {}) => {
19300 const matchResult = string.match(args.matchPattern);
19301 if (!matchResult) return null;
19302 const matchedString = matchResult[0];
19303 const parseResult = string.match(args.parsePattern);
19304 if (!parseResult) return null;
19305 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19306 value = options.valueCallback ? options.valueCallback(value) : value;
19307 const rest = string.slice(matchedString.length);
19308 return { value, rest };
19309 };
19310 }
19311
19312 // node_modules/date-fns/locale/en-US/_lib/match.js
19313 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19314 var parseOrdinalNumberPattern = /\d+/i;
19315 var matchEraPatterns = {
19316 narrow: /^(b|a)/i,
19317 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19318 wide: /^(before christ|before common era|anno domini|common era)/i
19319 };
19320 var parseEraPatterns = {
19321 any: [/^b/i, /^(a|c)/i]
19322 };
19323 var matchQuarterPatterns = {
19324 narrow: /^[1234]/i,
19325 abbreviated: /^q[1234]/i,
19326 wide: /^[1234](th|st|nd|rd)? quarter/i
19327 };
19328 var parseQuarterPatterns = {
19329 any: [/1/i, /2/i, /3/i, /4/i]
19330 };
19331 var matchMonthPatterns = {
19332 narrow: /^[jfmasond]/i,
19333 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19334 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19335 };
19336 var parseMonthPatterns = {
19337 narrow: [
19338 /^j/i,
19339 /^f/i,
19340 /^m/i,
19341 /^a/i,
19342 /^m/i,
19343 /^j/i,
19344 /^j/i,
19345 /^a/i,
19346 /^s/i,
19347 /^o/i,
19348 /^n/i,
19349 /^d/i
19350 ],
19351 any: [
19352 /^ja/i,
19353 /^f/i,
19354 /^mar/i,
19355 /^ap/i,
19356 /^may/i,
19357 /^jun/i,
19358 /^jul/i,
19359 /^au/i,
19360 /^s/i,
19361 /^o/i,
19362 /^n/i,
19363 /^d/i
19364 ]
19365 };
19366 var matchDayPatterns = {
19367 narrow: /^[smtwf]/i,
19368 short: /^(su|mo|tu|we|th|fr|sa)/i,
19369 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19370 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19371 };
19372 var parseDayPatterns = {
19373 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19374 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19375 };
19376 var matchDayPeriodPatterns = {
19377 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19378 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19379 };
19380 var parseDayPeriodPatterns = {
19381 any: {
19382 am: /^a/i,
19383 pm: /^p/i,
19384 midnight: /^mi/i,
19385 noon: /^no/i,
19386 morning: /morning/i,
19387 afternoon: /afternoon/i,
19388 evening: /evening/i,
19389 night: /night/i
19390 }
19391 };
19392 var match = {
19393 ordinalNumber: buildMatchPatternFn({
19394 matchPattern: matchOrdinalNumberPattern,
19395 parsePattern: parseOrdinalNumberPattern,
19396 valueCallback: (value) => parseInt(value, 10)
19397 }),
19398 era: buildMatchFn({
19399 matchPatterns: matchEraPatterns,
19400 defaultMatchWidth: "wide",
19401 parsePatterns: parseEraPatterns,
19402 defaultParseWidth: "any"
19403 }),
19404 quarter: buildMatchFn({
19405 matchPatterns: matchQuarterPatterns,
19406 defaultMatchWidth: "wide",
19407 parsePatterns: parseQuarterPatterns,
19408 defaultParseWidth: "any",
19409 valueCallback: (index2) => index2 + 1
19410 }),
19411 month: buildMatchFn({
19412 matchPatterns: matchMonthPatterns,
19413 defaultMatchWidth: "wide",
19414 parsePatterns: parseMonthPatterns,
19415 defaultParseWidth: "any"
19416 }),
19417 day: buildMatchFn({
19418 matchPatterns: matchDayPatterns,
19419 defaultMatchWidth: "wide",
19420 parsePatterns: parseDayPatterns,
19421 defaultParseWidth: "any"
19422 }),
19423 dayPeriod: buildMatchFn({
19424 matchPatterns: matchDayPeriodPatterns,
19425 defaultMatchWidth: "any",
19426 parsePatterns: parseDayPeriodPatterns,
19427 defaultParseWidth: "any"
19428 })
19429 };
19430
19431 // node_modules/date-fns/locale/en-US.js
19432 var enUS = {
19433 code: "en-US",
19434 formatDistance,
19435 formatLong,
19436 formatRelative,
19437 localize,
19438 match,
19439 options: {
19440 weekStartsOn: 0,
19441 firstWeekContainsDate: 1
19442 }
19443 };
19444
19445 // node_modules/date-fns/getDayOfYear.js
19446 function getDayOfYear(date, options) {
19447 const _date = toDate(date, options?.in);
19448 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19449 const dayOfYear = diff + 1;
19450 return dayOfYear;
19451 }
19452
19453 // node_modules/date-fns/getISOWeek.js
19454 function getISOWeek(date, options) {
19455 const _date = toDate(date, options?.in);
19456 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19457 return Math.round(diff / millisecondsInWeek) + 1;
19458 }
19459
19460 // node_modules/date-fns/getWeekYear.js
19461 function getWeekYear(date, options) {
19462 const _date = toDate(date, options?.in);
19463 const year = _date.getFullYear();
19464 const defaultOptions2 = getDefaultOptions();
19465 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19466 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19467 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19468 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19469 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19470 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19471 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19472 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19473 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19474 if (+_date >= +startOfNextYear) {
19475 return year + 1;
19476 } else if (+_date >= +startOfThisYear) {
19477 return year;
19478 } else {
19479 return year - 1;
19480 }
19481 }
19482
19483 // node_modules/date-fns/startOfWeekYear.js
19484 function startOfWeekYear(date, options) {
19485 const defaultOptions2 = getDefaultOptions();
19486 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19487 const year = getWeekYear(date, options);
19488 const firstWeek = constructFrom(options?.in || date, 0);
19489 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19490 firstWeek.setHours(0, 0, 0, 0);
19491 const _date = startOfWeek(firstWeek, options);
19492 return _date;
19493 }
19494
19495 // node_modules/date-fns/getWeek.js
19496 function getWeek(date, options) {
19497 const _date = toDate(date, options?.in);
19498 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19499 return Math.round(diff / millisecondsInWeek) + 1;
19500 }
19501
19502 // node_modules/date-fns/_lib/addLeadingZeros.js
19503 function addLeadingZeros(number, targetLength) {
19504 const sign = number < 0 ? "-" : "";
19505 const output = Math.abs(number).toString().padStart(targetLength, "0");
19506 return sign + output;
19507 }
19508
19509 // node_modules/date-fns/_lib/format/lightFormatters.js
19510 var lightFormatters = {
19511 // Year
19512 y(date, token) {
19513 const signedYear = date.getFullYear();
19514 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19515 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19516 },
19517 // Month
19518 M(date, token) {
19519 const month = date.getMonth();
19520 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19521 },
19522 // Day of the month
19523 d(date, token) {
19524 return addLeadingZeros(date.getDate(), token.length);
19525 },
19526 // AM or PM
19527 a(date, token) {
19528 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19529 switch (token) {
19530 case "a":
19531 case "aa":
19532 return dayPeriodEnumValue.toUpperCase();
19533 case "aaa":
19534 return dayPeriodEnumValue;
19535 case "aaaaa":
19536 return dayPeriodEnumValue[0];
19537 case "aaaa":
19538 default:
19539 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
19540 }
19541 },
19542 // Hour [1-12]
19543 h(date, token) {
19544 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
19545 },
19546 // Hour [0-23]
19547 H(date, token) {
19548 return addLeadingZeros(date.getHours(), token.length);
19549 },
19550 // Minute
19551 m(date, token) {
19552 return addLeadingZeros(date.getMinutes(), token.length);
19553 },
19554 // Second
19555 s(date, token) {
19556 return addLeadingZeros(date.getSeconds(), token.length);
19557 },
19558 // Fraction of second
19559 S(date, token) {
19560 const numberOfDigits = token.length;
19561 const milliseconds = date.getMilliseconds();
19562 const fractionalSeconds = Math.trunc(
19563 milliseconds * Math.pow(10, numberOfDigits - 3)
19564 );
19565 return addLeadingZeros(fractionalSeconds, token.length);
19566 }
19567 };
19568
19569 // node_modules/date-fns/_lib/format/formatters.js
19570 var dayPeriodEnum = {
19571 am: "am",
19572 pm: "pm",
19573 midnight: "midnight",
19574 noon: "noon",
19575 morning: "morning",
19576 afternoon: "afternoon",
19577 evening: "evening",
19578 night: "night"
19579 };
19580 var formatters = {
19581 // Era
19582 G: function(date, token, localize2) {
19583 const era = date.getFullYear() > 0 ? 1 : 0;
19584 switch (token) {
19585 // AD, BC
19586 case "G":
19587 case "GG":
19588 case "GGG":
19589 return localize2.era(era, { width: "abbreviated" });
19590 // A, B
19591 case "GGGGG":
19592 return localize2.era(era, { width: "narrow" });
19593 // Anno Domini, Before Christ
19594 case "GGGG":
19595 default:
19596 return localize2.era(era, { width: "wide" });
19597 }
19598 },
19599 // Year
19600 y: function(date, token, localize2) {
19601 if (token === "yo") {
19602 const signedYear = date.getFullYear();
19603 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19604 return localize2.ordinalNumber(year, { unit: "year" });
19605 }
19606 return lightFormatters.y(date, token);
19607 },
19608 // Local week-numbering year
19609 Y: function(date, token, localize2, options) {
19610 const signedWeekYear = getWeekYear(date, options);
19611 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
19612 if (token === "YY") {
19613 const twoDigitYear = weekYear % 100;
19614 return addLeadingZeros(twoDigitYear, 2);
19615 }
19616 if (token === "Yo") {
19617 return localize2.ordinalNumber(weekYear, { unit: "year" });
19618 }
19619 return addLeadingZeros(weekYear, token.length);
19620 },
19621 // ISO week-numbering year
19622 R: function(date, token) {
19623 const isoWeekYear = getISOWeekYear(date);
19624 return addLeadingZeros(isoWeekYear, token.length);
19625 },
19626 // Extended year. This is a single number designating the year of this calendar system.
19627 // The main difference between `y` and `u` localizers are B.C. years:
19628 // | Year | `y` | `u` |
19629 // |------|-----|-----|
19630 // | AC 1 | 1 | 1 |
19631 // | BC 1 | 1 | 0 |
19632 // | BC 2 | 2 | -1 |
19633 // Also `yy` always returns the last two digits of a year,
19634 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
19635 u: function(date, token) {
19636 const year = date.getFullYear();
19637 return addLeadingZeros(year, token.length);
19638 },
19639 // Quarter
19640 Q: function(date, token, localize2) {
19641 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19642 switch (token) {
19643 // 1, 2, 3, 4
19644 case "Q":
19645 return String(quarter);
19646 // 01, 02, 03, 04
19647 case "QQ":
19648 return addLeadingZeros(quarter, 2);
19649 // 1st, 2nd, 3rd, 4th
19650 case "Qo":
19651 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19652 // Q1, Q2, Q3, Q4
19653 case "QQQ":
19654 return localize2.quarter(quarter, {
19655 width: "abbreviated",
19656 context: "formatting"
19657 });
19658 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19659 case "QQQQQ":
19660 return localize2.quarter(quarter, {
19661 width: "narrow",
19662 context: "formatting"
19663 });
19664 // 1st quarter, 2nd quarter, ...
19665 case "QQQQ":
19666 default:
19667 return localize2.quarter(quarter, {
19668 width: "wide",
19669 context: "formatting"
19670 });
19671 }
19672 },
19673 // Stand-alone quarter
19674 q: function(date, token, localize2) {
19675 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19676 switch (token) {
19677 // 1, 2, 3, 4
19678 case "q":
19679 return String(quarter);
19680 // 01, 02, 03, 04
19681 case "qq":
19682 return addLeadingZeros(quarter, 2);
19683 // 1st, 2nd, 3rd, 4th
19684 case "qo":
19685 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19686 // Q1, Q2, Q3, Q4
19687 case "qqq":
19688 return localize2.quarter(quarter, {
19689 width: "abbreviated",
19690 context: "standalone"
19691 });
19692 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19693 case "qqqqq":
19694 return localize2.quarter(quarter, {
19695 width: "narrow",
19696 context: "standalone"
19697 });
19698 // 1st quarter, 2nd quarter, ...
19699 case "qqqq":
19700 default:
19701 return localize2.quarter(quarter, {
19702 width: "wide",
19703 context: "standalone"
19704 });
19705 }
19706 },
19707 // Month
19708 M: function(date, token, localize2) {
19709 const month = date.getMonth();
19710 switch (token) {
19711 case "M":
19712 case "MM":
19713 return lightFormatters.M(date, token);
19714 // 1st, 2nd, ..., 12th
19715 case "Mo":
19716 return localize2.ordinalNumber(month + 1, { unit: "month" });
19717 // Jan, Feb, ..., Dec
19718 case "MMM":
19719 return localize2.month(month, {
19720 width: "abbreviated",
19721 context: "formatting"
19722 });
19723 // J, F, ..., D
19724 case "MMMMM":
19725 return localize2.month(month, {
19726 width: "narrow",
19727 context: "formatting"
19728 });
19729 // January, February, ..., December
19730 case "MMMM":
19731 default:
19732 return localize2.month(month, { width: "wide", context: "formatting" });
19733 }
19734 },
19735 // Stand-alone month
19736 L: function(date, token, localize2) {
19737 const month = date.getMonth();
19738 switch (token) {
19739 // 1, 2, ..., 12
19740 case "L":
19741 return String(month + 1);
19742 // 01, 02, ..., 12
19743 case "LL":
19744 return addLeadingZeros(month + 1, 2);
19745 // 1st, 2nd, ..., 12th
19746 case "Lo":
19747 return localize2.ordinalNumber(month + 1, { unit: "month" });
19748 // Jan, Feb, ..., Dec
19749 case "LLL":
19750 return localize2.month(month, {
19751 width: "abbreviated",
19752 context: "standalone"
19753 });
19754 // J, F, ..., D
19755 case "LLLLL":
19756 return localize2.month(month, {
19757 width: "narrow",
19758 context: "standalone"
19759 });
19760 // January, February, ..., December
19761 case "LLLL":
19762 default:
19763 return localize2.month(month, { width: "wide", context: "standalone" });
19764 }
19765 },
19766 // Local week of year
19767 w: function(date, token, localize2, options) {
19768 const week = getWeek(date, options);
19769 if (token === "wo") {
19770 return localize2.ordinalNumber(week, { unit: "week" });
19771 }
19772 return addLeadingZeros(week, token.length);
19773 },
19774 // ISO week of year
19775 I: function(date, token, localize2) {
19776 const isoWeek = getISOWeek(date);
19777 if (token === "Io") {
19778 return localize2.ordinalNumber(isoWeek, { unit: "week" });
19779 }
19780 return addLeadingZeros(isoWeek, token.length);
19781 },
19782 // Day of the month
19783 d: function(date, token, localize2) {
19784 if (token === "do") {
19785 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
19786 }
19787 return lightFormatters.d(date, token);
19788 },
19789 // Day of year
19790 D: function(date, token, localize2) {
19791 const dayOfYear = getDayOfYear(date);
19792 if (token === "Do") {
19793 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
19794 }
19795 return addLeadingZeros(dayOfYear, token.length);
19796 },
19797 // Day of week
19798 E: function(date, token, localize2) {
19799 const dayOfWeek = date.getDay();
19800 switch (token) {
19801 // Tue
19802 case "E":
19803 case "EE":
19804 case "EEE":
19805 return localize2.day(dayOfWeek, {
19806 width: "abbreviated",
19807 context: "formatting"
19808 });
19809 // T
19810 case "EEEEE":
19811 return localize2.day(dayOfWeek, {
19812 width: "narrow",
19813 context: "formatting"
19814 });
19815 // Tu
19816 case "EEEEEE":
19817 return localize2.day(dayOfWeek, {
19818 width: "short",
19819 context: "formatting"
19820 });
19821 // Tuesday
19822 case "EEEE":
19823 default:
19824 return localize2.day(dayOfWeek, {
19825 width: "wide",
19826 context: "formatting"
19827 });
19828 }
19829 },
19830 // Local day of week
19831 e: function(date, token, localize2, options) {
19832 const dayOfWeek = date.getDay();
19833 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19834 switch (token) {
19835 // Numerical value (Nth day of week with current locale or weekStartsOn)
19836 case "e":
19837 return String(localDayOfWeek);
19838 // Padded numerical value
19839 case "ee":
19840 return addLeadingZeros(localDayOfWeek, 2);
19841 // 1st, 2nd, ..., 7th
19842 case "eo":
19843 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19844 case "eee":
19845 return localize2.day(dayOfWeek, {
19846 width: "abbreviated",
19847 context: "formatting"
19848 });
19849 // T
19850 case "eeeee":
19851 return localize2.day(dayOfWeek, {
19852 width: "narrow",
19853 context: "formatting"
19854 });
19855 // Tu
19856 case "eeeeee":
19857 return localize2.day(dayOfWeek, {
19858 width: "short",
19859 context: "formatting"
19860 });
19861 // Tuesday
19862 case "eeee":
19863 default:
19864 return localize2.day(dayOfWeek, {
19865 width: "wide",
19866 context: "formatting"
19867 });
19868 }
19869 },
19870 // Stand-alone local day of week
19871 c: function(date, token, localize2, options) {
19872 const dayOfWeek = date.getDay();
19873 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19874 switch (token) {
19875 // Numerical value (same as in `e`)
19876 case "c":
19877 return String(localDayOfWeek);
19878 // Padded numerical value
19879 case "cc":
19880 return addLeadingZeros(localDayOfWeek, token.length);
19881 // 1st, 2nd, ..., 7th
19882 case "co":
19883 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19884 case "ccc":
19885 return localize2.day(dayOfWeek, {
19886 width: "abbreviated",
19887 context: "standalone"
19888 });
19889 // T
19890 case "ccccc":
19891 return localize2.day(dayOfWeek, {
19892 width: "narrow",
19893 context: "standalone"
19894 });
19895 // Tu
19896 case "cccccc":
19897 return localize2.day(dayOfWeek, {
19898 width: "short",
19899 context: "standalone"
19900 });
19901 // Tuesday
19902 case "cccc":
19903 default:
19904 return localize2.day(dayOfWeek, {
19905 width: "wide",
19906 context: "standalone"
19907 });
19908 }
19909 },
19910 // ISO day of week
19911 i: function(date, token, localize2) {
19912 const dayOfWeek = date.getDay();
19913 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
19914 switch (token) {
19915 // 2
19916 case "i":
19917 return String(isoDayOfWeek);
19918 // 02
19919 case "ii":
19920 return addLeadingZeros(isoDayOfWeek, token.length);
19921 // 2nd
19922 case "io":
19923 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
19924 // Tue
19925 case "iii":
19926 return localize2.day(dayOfWeek, {
19927 width: "abbreviated",
19928 context: "formatting"
19929 });
19930 // T
19931 case "iiiii":
19932 return localize2.day(dayOfWeek, {
19933 width: "narrow",
19934 context: "formatting"
19935 });
19936 // Tu
19937 case "iiiiii":
19938 return localize2.day(dayOfWeek, {
19939 width: "short",
19940 context: "formatting"
19941 });
19942 // Tuesday
19943 case "iiii":
19944 default:
19945 return localize2.day(dayOfWeek, {
19946 width: "wide",
19947 context: "formatting"
19948 });
19949 }
19950 },
19951 // AM or PM
19952 a: function(date, token, localize2) {
19953 const hours = date.getHours();
19954 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
19955 switch (token) {
19956 case "a":
19957 case "aa":
19958 return localize2.dayPeriod(dayPeriodEnumValue, {
19959 width: "abbreviated",
19960 context: "formatting"
19961 });
19962 case "aaa":
19963 return localize2.dayPeriod(dayPeriodEnumValue, {
19964 width: "abbreviated",
19965 context: "formatting"
19966 }).toLowerCase();
19967 case "aaaaa":
19968 return localize2.dayPeriod(dayPeriodEnumValue, {
19969 width: "narrow",
19970 context: "formatting"
19971 });
19972 case "aaaa":
19973 default:
19974 return localize2.dayPeriod(dayPeriodEnumValue, {
19975 width: "wide",
19976 context: "formatting"
19977 });
19978 }
19979 },
19980 // AM, PM, midnight, noon
19981 b: function(date, token, localize2) {
19982 const hours = date.getHours();
19983 let dayPeriodEnumValue;
19984 if (hours === 12) {
19985 dayPeriodEnumValue = dayPeriodEnum.noon;
19986 } else if (hours === 0) {
19987 dayPeriodEnumValue = dayPeriodEnum.midnight;
19988 } else {
19989 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
19990 }
19991 switch (token) {
19992 case "b":
19993 case "bb":
19994 return localize2.dayPeriod(dayPeriodEnumValue, {
19995 width: "abbreviated",
19996 context: "formatting"
19997 });
19998 case "bbb":
19999 return localize2.dayPeriod(dayPeriodEnumValue, {
20000 width: "abbreviated",
20001 context: "formatting"
20002 }).toLowerCase();
20003 case "bbbbb":
20004 return localize2.dayPeriod(dayPeriodEnumValue, {
20005 width: "narrow",
20006 context: "formatting"
20007 });
20008 case "bbbb":
20009 default:
20010 return localize2.dayPeriod(dayPeriodEnumValue, {
20011 width: "wide",
20012 context: "formatting"
20013 });
20014 }
20015 },
20016 // in the morning, in the afternoon, in the evening, at night
20017 B: function(date, token, localize2) {
20018 const hours = date.getHours();
20019 let dayPeriodEnumValue;
20020 if (hours >= 17) {
20021 dayPeriodEnumValue = dayPeriodEnum.evening;
20022 } else if (hours >= 12) {
20023 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20024 } else if (hours >= 4) {
20025 dayPeriodEnumValue = dayPeriodEnum.morning;
20026 } else {
20027 dayPeriodEnumValue = dayPeriodEnum.night;
20028 }
20029 switch (token) {
20030 case "B":
20031 case "BB":
20032 case "BBB":
20033 return localize2.dayPeriod(dayPeriodEnumValue, {
20034 width: "abbreviated",
20035 context: "formatting"
20036 });
20037 case "BBBBB":
20038 return localize2.dayPeriod(dayPeriodEnumValue, {
20039 width: "narrow",
20040 context: "formatting"
20041 });
20042 case "BBBB":
20043 default:
20044 return localize2.dayPeriod(dayPeriodEnumValue, {
20045 width: "wide",
20046 context: "formatting"
20047 });
20048 }
20049 },
20050 // Hour [1-12]
20051 h: function(date, token, localize2) {
20052 if (token === "ho") {
20053 let hours = date.getHours() % 12;
20054 if (hours === 0) hours = 12;
20055 return localize2.ordinalNumber(hours, { unit: "hour" });
20056 }
20057 return lightFormatters.h(date, token);
20058 },
20059 // Hour [0-23]
20060 H: function(date, token, localize2) {
20061 if (token === "Ho") {
20062 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20063 }
20064 return lightFormatters.H(date, token);
20065 },
20066 // Hour [0-11]
20067 K: function(date, token, localize2) {
20068 const hours = date.getHours() % 12;
20069 if (token === "Ko") {
20070 return localize2.ordinalNumber(hours, { unit: "hour" });
20071 }
20072 return addLeadingZeros(hours, token.length);
20073 },
20074 // Hour [1-24]
20075 k: function(date, token, localize2) {
20076 let hours = date.getHours();
20077 if (hours === 0) hours = 24;
20078 if (token === "ko") {
20079 return localize2.ordinalNumber(hours, { unit: "hour" });
20080 }
20081 return addLeadingZeros(hours, token.length);
20082 },
20083 // Minute
20084 m: function(date, token, localize2) {
20085 if (token === "mo") {
20086 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20087 }
20088 return lightFormatters.m(date, token);
20089 },
20090 // Second
20091 s: function(date, token, localize2) {
20092 if (token === "so") {
20093 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20094 }
20095 return lightFormatters.s(date, token);
20096 },
20097 // Fraction of second
20098 S: function(date, token) {
20099 return lightFormatters.S(date, token);
20100 },
20101 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20102 X: function(date, token, _localize) {
20103 const timezoneOffset = date.getTimezoneOffset();
20104 if (timezoneOffset === 0) {
20105 return "Z";
20106 }
20107 switch (token) {
20108 // Hours and optional minutes
20109 case "X":
20110 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20111 // Hours, minutes and optional seconds without `:` delimiter
20112 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20113 // so this token always has the same output as `XX`
20114 case "XXXX":
20115 case "XX":
20116 return formatTimezone(timezoneOffset);
20117 // Hours, minutes and optional seconds with `:` delimiter
20118 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20119 // so this token always has the same output as `XXX`
20120 case "XXXXX":
20121 case "XXX":
20122 // Hours and minutes with `:` delimiter
20123 default:
20124 return formatTimezone(timezoneOffset, ":");
20125 }
20126 },
20127 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20128 x: function(date, token, _localize) {
20129 const timezoneOffset = date.getTimezoneOffset();
20130 switch (token) {
20131 // Hours and optional minutes
20132 case "x":
20133 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20134 // Hours, minutes and optional seconds without `:` delimiter
20135 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20136 // so this token always has the same output as `xx`
20137 case "xxxx":
20138 case "xx":
20139 return formatTimezone(timezoneOffset);
20140 // Hours, minutes and optional seconds with `:` delimiter
20141 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20142 // so this token always has the same output as `xxx`
20143 case "xxxxx":
20144 case "xxx":
20145 // Hours and minutes with `:` delimiter
20146 default:
20147 return formatTimezone(timezoneOffset, ":");
20148 }
20149 },
20150 // Timezone (GMT)
20151 O: function(date, token, _localize) {
20152 const timezoneOffset = date.getTimezoneOffset();
20153 switch (token) {
20154 // Short
20155 case "O":
20156 case "OO":
20157 case "OOO":
20158 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20159 // Long
20160 case "OOOO":
20161 default:
20162 return "GMT" + formatTimezone(timezoneOffset, ":");
20163 }
20164 },
20165 // Timezone (specific non-location)
20166 z: function(date, token, _localize) {
20167 const timezoneOffset = date.getTimezoneOffset();
20168 switch (token) {
20169 // Short
20170 case "z":
20171 case "zz":
20172 case "zzz":
20173 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20174 // Long
20175 case "zzzz":
20176 default:
20177 return "GMT" + formatTimezone(timezoneOffset, ":");
20178 }
20179 },
20180 // Seconds timestamp
20181 t: function(date, token, _localize) {
20182 const timestamp = Math.trunc(+date / 1e3);
20183 return addLeadingZeros(timestamp, token.length);
20184 },
20185 // Milliseconds timestamp
20186 T: function(date, token, _localize) {
20187 return addLeadingZeros(+date, token.length);
20188 }
20189 };
20190 function formatTimezoneShort(offset4, delimiter = "") {
20191 const sign = offset4 > 0 ? "-" : "+";
20192 const absOffset = Math.abs(offset4);
20193 const hours = Math.trunc(absOffset / 60);
20194 const minutes = absOffset % 60;
20195 if (minutes === 0) {
20196 return sign + String(hours);
20197 }
20198 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20199 }
20200 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20201 if (offset4 % 60 === 0) {
20202 const sign = offset4 > 0 ? "-" : "+";
20203 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20204 }
20205 return formatTimezone(offset4, delimiter);
20206 }
20207 function formatTimezone(offset4, delimiter = "") {
20208 const sign = offset4 > 0 ? "-" : "+";
20209 const absOffset = Math.abs(offset4);
20210 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20211 const minutes = addLeadingZeros(absOffset % 60, 2);
20212 return sign + hours + delimiter + minutes;
20213 }
20214
20215 // node_modules/date-fns/_lib/format/longFormatters.js
20216 var dateLongFormatter = (pattern, formatLong2) => {
20217 switch (pattern) {
20218 case "P":
20219 return formatLong2.date({ width: "short" });
20220 case "PP":
20221 return formatLong2.date({ width: "medium" });
20222 case "PPP":
20223 return formatLong2.date({ width: "long" });
20224 case "PPPP":
20225 default:
20226 return formatLong2.date({ width: "full" });
20227 }
20228 };
20229 var timeLongFormatter = (pattern, formatLong2) => {
20230 switch (pattern) {
20231 case "p":
20232 return formatLong2.time({ width: "short" });
20233 case "pp":
20234 return formatLong2.time({ width: "medium" });
20235 case "ppp":
20236 return formatLong2.time({ width: "long" });
20237 case "pppp":
20238 default:
20239 return formatLong2.time({ width: "full" });
20240 }
20241 };
20242 var dateTimeLongFormatter = (pattern, formatLong2) => {
20243 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20244 const datePattern = matchResult[1];
20245 const timePattern = matchResult[2];
20246 if (!timePattern) {
20247 return dateLongFormatter(pattern, formatLong2);
20248 }
20249 let dateTimeFormat;
20250 switch (datePattern) {
20251 case "P":
20252 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20253 break;
20254 case "PP":
20255 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20256 break;
20257 case "PPP":
20258 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20259 break;
20260 case "PPPP":
20261 default:
20262 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20263 break;
20264 }
20265 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20266 };
20267 var longFormatters = {
20268 p: timeLongFormatter,
20269 P: dateTimeLongFormatter
20270 };
20271
20272 // node_modules/date-fns/_lib/protectedTokens.js
20273 var dayOfYearTokenRE = /^D+$/;
20274 var weekYearTokenRE = /^Y+$/;
20275 var throwTokens = ["D", "DD", "YY", "YYYY"];
20276 function isProtectedDayOfYearToken(token) {
20277 return dayOfYearTokenRE.test(token);
20278 }
20279 function isProtectedWeekYearToken(token) {
20280 return weekYearTokenRE.test(token);
20281 }
20282 function warnOrThrowProtectedError(token, format6, input) {
20283 const _message = message(token, format6, input);
20284 console.warn(_message);
20285 if (throwTokens.includes(token)) throw new RangeError(_message);
20286 }
20287 function message(token, format6, input) {
20288 const subject = token[0] === "Y" ? "years" : "days of the month";
20289 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`;
20290 }
20291
20292 // node_modules/date-fns/format.js
20293 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20294 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20295 var escapedStringRegExp = /^'([^]*?)'?$/;
20296 var doubleQuoteRegExp = /''/g;
20297 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20298 function format(date, formatStr, options) {
20299 const defaultOptions2 = getDefaultOptions();
20300 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20301 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20302 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20303 const originalDate = toDate(date, options?.in);
20304 if (!isValid(originalDate)) {
20305 throw new RangeError("Invalid time value");
20306 }
20307 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20308 const firstCharacter = substring[0];
20309 if (firstCharacter === "p" || firstCharacter === "P") {
20310 const longFormatter = longFormatters[firstCharacter];
20311 return longFormatter(substring, locale.formatLong);
20312 }
20313 return substring;
20314 }).join("").match(formattingTokensRegExp).map((substring) => {
20315 if (substring === "''") {
20316 return { isToken: false, value: "'" };
20317 }
20318 const firstCharacter = substring[0];
20319 if (firstCharacter === "'") {
20320 return { isToken: false, value: cleanEscapedString(substring) };
20321 }
20322 if (formatters[firstCharacter]) {
20323 return { isToken: true, value: substring };
20324 }
20325 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20326 throw new RangeError(
20327 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20328 );
20329 }
20330 return { isToken: false, value: substring };
20331 });
20332 if (locale.localize.preprocessor) {
20333 parts = locale.localize.preprocessor(originalDate, parts);
20334 }
20335 const formatterOptions = {
20336 firstWeekContainsDate,
20337 weekStartsOn,
20338 locale
20339 };
20340 return parts.map((part) => {
20341 if (!part.isToken) return part.value;
20342 const token = part.value;
20343 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20344 warnOrThrowProtectedError(token, formatStr, String(date));
20345 }
20346 const formatter = formatters[token[0]];
20347 return formatter(originalDate, token, locale.localize, formatterOptions);
20348 }).join("");
20349 }
20350 function cleanEscapedString(input) {
20351 const matched = input.match(escapedStringRegExp);
20352 if (!matched) {
20353 return input;
20354 }
20355 return matched[1].replace(doubleQuoteRegExp, "'");
20356 }
20357
20358 // node_modules/date-fns/subDays.js
20359 function subDays(date, amount, options) {
20360 return addDays(date, -amount, options);
20361 }
20362
20363 // node_modules/date-fns/subMonths.js
20364 function subMonths(date, amount, options) {
20365 return addMonths(date, -amount, options);
20366 }
20367
20368 // node_modules/date-fns/subWeeks.js
20369 function subWeeks(date, amount, options) {
20370 return addWeeks(date, -amount, options);
20371 }
20372
20373 // node_modules/date-fns/subYears.js
20374 function subYears(date, amount, options) {
20375 return addYears(date, -amount, options);
20376 }
20377
20378 // packages/dataviews/build-module/utils/operators.mjs
20379 var import_i18n24 = __toESM(require_i18n(), 1);
20380 var import_element45 = __toESM(require_element(), 1);
20381 var import_date = __toESM(require_date(), 1);
20382 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
20383 var filterTextWrappers = {
20384 Name: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20385 Value: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20386 };
20387 function getRelativeDate(value, unit) {
20388 switch (unit) {
20389 case "days":
20390 return subDays(/* @__PURE__ */ new Date(), value);
20391 case "weeks":
20392 return subWeeks(/* @__PURE__ */ new Date(), value);
20393 case "months":
20394 return subMonths(/* @__PURE__ */ new Date(), value);
20395 case "years":
20396 return subYears(/* @__PURE__ */ new Date(), value);
20397 default:
20398 return /* @__PURE__ */ new Date();
20399 }
20400 }
20401 var isNoneOperatorDefinition = {
20402 /* translators: DataViews operator name */
20403 label: (0, import_i18n24.__)("Is none of"),
20404 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20405 (0, import_i18n24.sprintf)(
20406 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20407 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20408 filter.name,
20409 activeElements.map((element) => element.label).join(", ")
20410 ),
20411 filterTextWrappers
20412 ),
20413 filter: ((item, field, filterValue) => {
20414 if (!filterValue?.length) {
20415 return true;
20416 }
20417 const fieldValue = field.getValue({ item });
20418 if (Array.isArray(fieldValue)) {
20419 return !filterValue.some(
20420 (fv) => fieldValue.includes(fv)
20421 );
20422 } else if (typeof fieldValue === "string") {
20423 return !filterValue.includes(fieldValue);
20424 }
20425 return false;
20426 }),
20427 selection: "multi"
20428 };
20429 var OPERATORS = [
20430 {
20431 name: OPERATOR_IS_ANY,
20432 /* translators: DataViews operator name */
20433 label: (0, import_i18n24.__)("Includes"),
20434 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20435 (0, import_i18n24.sprintf)(
20436 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20437 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20438 filter.name,
20439 activeElements.map((element) => element.label).join(", ")
20440 ),
20441 filterTextWrappers
20442 ),
20443 filter(item, field, filterValue) {
20444 if (!filterValue?.length) {
20445 return true;
20446 }
20447 const fieldValue = field.getValue({ item });
20448 if (Array.isArray(fieldValue)) {
20449 return filterValue.some(
20450 (fv) => fieldValue.includes(fv)
20451 );
20452 } else if (typeof fieldValue === "string") {
20453 return filterValue.includes(fieldValue);
20454 }
20455 return false;
20456 },
20457 selection: "multi"
20458 },
20459 {
20460 name: OPERATOR_IS_NONE,
20461 ...isNoneOperatorDefinition
20462 },
20463 {
20464 name: OPERATOR_IS_ALL,
20465 /* translators: DataViews operator name */
20466 label: (0, import_i18n24.__)("Includes all"),
20467 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20468 (0, import_i18n24.sprintf)(
20469 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20470 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20471 filter.name,
20472 activeElements.map((element) => element.label).join(", ")
20473 ),
20474 filterTextWrappers
20475 ),
20476 filter(item, field, filterValue) {
20477 if (!filterValue?.length) {
20478 return true;
20479 }
20480 return filterValue.every((value) => {
20481 return field.getValue({ item })?.includes(value);
20482 });
20483 },
20484 selection: "multi"
20485 },
20486 {
20487 name: OPERATOR_IS_NOT_ALL,
20488 ...isNoneOperatorDefinition
20489 },
20490 {
20491 name: OPERATOR_BETWEEN,
20492 /* translators: DataViews operator name */
20493 label: (0, import_i18n24.__)("Between (inc)"),
20494 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20495 (0, import_i18n24.sprintf)(
20496 /* 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". */
20497 (0, import_i18n24.__)(
20498 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20499 ),
20500 filter.name,
20501 activeElements[0].label[0],
20502 activeElements[0].label[1]
20503 ),
20504 filterTextWrappers
20505 ),
20506 filter(item, field, filterValue) {
20507 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20508 return true;
20509 }
20510 const fieldValue = field.getValue({ item });
20511 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20512 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20513 }
20514 return false;
20515 },
20516 selection: "custom"
20517 },
20518 {
20519 name: OPERATOR_IN_THE_PAST,
20520 /* translators: DataViews operator name */
20521 label: (0, import_i18n24.__)("In the past"),
20522 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20523 (0, import_i18n24.sprintf)(
20524 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20525 (0, import_i18n24.__)(
20526 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20527 ),
20528 filter.name,
20529 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20530 ),
20531 filterTextWrappers
20532 ),
20533 filter(item, field, filterValue) {
20534 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20535 return true;
20536 }
20537 const targetDate = getRelativeDate(
20538 filterValue.value,
20539 filterValue.unit
20540 );
20541 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20542 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
20543 },
20544 selection: "custom"
20545 },
20546 {
20547 name: OPERATOR_OVER,
20548 /* translators: DataViews operator name */
20549 label: (0, import_i18n24.__)("Over"),
20550 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20551 (0, import_i18n24.sprintf)(
20552 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
20553 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
20554 filter.name,
20555 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20556 ),
20557 filterTextWrappers
20558 ),
20559 filter(item, field, filterValue) {
20560 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20561 return true;
20562 }
20563 const targetDate = getRelativeDate(
20564 filterValue.value,
20565 filterValue.unit
20566 );
20567 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20568 return fieldValue < targetDate;
20569 },
20570 selection: "custom"
20571 },
20572 {
20573 name: OPERATOR_IS,
20574 /* translators: DataViews operator name */
20575 label: (0, import_i18n24.__)("Is"),
20576 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20577 (0, import_i18n24.sprintf)(
20578 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
20579 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20580 filter.name,
20581 activeElements[0].label
20582 ),
20583 filterTextWrappers
20584 ),
20585 filter(item, field, filterValue) {
20586 return filterValue === field.getValue({ item }) || filterValue === void 0;
20587 },
20588 selection: "single"
20589 },
20590 {
20591 name: OPERATOR_IS_NOT,
20592 /* translators: DataViews operator name */
20593 label: (0, import_i18n24.__)("Is not"),
20594 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20595 (0, import_i18n24.sprintf)(
20596 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
20597 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20598 filter.name,
20599 activeElements[0].label
20600 ),
20601 filterTextWrappers
20602 ),
20603 filter(item, field, filterValue) {
20604 return filterValue !== field.getValue({ item });
20605 },
20606 selection: "single"
20607 },
20608 {
20609 name: OPERATOR_LESS_THAN,
20610 /* translators: DataViews operator name */
20611 label: (0, import_i18n24.__)("Less than"),
20612 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20613 (0, import_i18n24.sprintf)(
20614 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
20615 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
20616 filter.name,
20617 activeElements[0].label
20618 ),
20619 filterTextWrappers
20620 ),
20621 filter(item, field, filterValue) {
20622 if (filterValue === void 0) {
20623 return true;
20624 }
20625 const fieldValue = field.getValue({ item });
20626 return fieldValue < filterValue;
20627 },
20628 selection: "single"
20629 },
20630 {
20631 name: OPERATOR_GREATER_THAN,
20632 /* translators: DataViews operator name */
20633 label: (0, import_i18n24.__)("Greater than"),
20634 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20635 (0, import_i18n24.sprintf)(
20636 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
20637 (0, import_i18n24.__)(
20638 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
20639 ),
20640 filter.name,
20641 activeElements[0].label
20642 ),
20643 filterTextWrappers
20644 ),
20645 filter(item, field, filterValue) {
20646 if (filterValue === void 0) {
20647 return true;
20648 }
20649 const fieldValue = field.getValue({ item });
20650 return fieldValue > filterValue;
20651 },
20652 selection: "single"
20653 },
20654 {
20655 name: OPERATOR_LESS_THAN_OR_EQUAL,
20656 /* translators: DataViews operator name */
20657 label: (0, import_i18n24.__)("Less than or equal"),
20658 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20659 (0, import_i18n24.sprintf)(
20660 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
20661 (0, import_i18n24.__)(
20662 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
20663 ),
20664 filter.name,
20665 activeElements[0].label
20666 ),
20667 filterTextWrappers
20668 ),
20669 filter(item, field, filterValue) {
20670 if (filterValue === void 0) {
20671 return true;
20672 }
20673 const fieldValue = field.getValue({ item });
20674 return fieldValue <= filterValue;
20675 },
20676 selection: "single"
20677 },
20678 {
20679 name: OPERATOR_GREATER_THAN_OR_EQUAL,
20680 /* translators: DataViews operator name */
20681 label: (0, import_i18n24.__)("Greater than or equal"),
20682 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20683 (0, import_i18n24.sprintf)(
20684 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
20685 (0, import_i18n24.__)(
20686 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
20687 ),
20688 filter.name,
20689 activeElements[0].label
20690 ),
20691 filterTextWrappers
20692 ),
20693 filter(item, field, filterValue) {
20694 if (filterValue === void 0) {
20695 return true;
20696 }
20697 const fieldValue = field.getValue({ item });
20698 return fieldValue >= filterValue;
20699 },
20700 selection: "single"
20701 },
20702 {
20703 name: OPERATOR_BEFORE,
20704 /* translators: DataViews operator name */
20705 label: (0, import_i18n24.__)("Before"),
20706 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20707 (0, import_i18n24.sprintf)(
20708 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
20709 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
20710 filter.name,
20711 activeElements[0].label
20712 ),
20713 filterTextWrappers
20714 ),
20715 filter(item, field, filterValue) {
20716 if (filterValue === void 0) {
20717 return true;
20718 }
20719 const filterDate = (0, import_date.getDate)(filterValue);
20720 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20721 return fieldDate < filterDate;
20722 },
20723 selection: "single"
20724 },
20725 {
20726 name: OPERATOR_AFTER,
20727 /* translators: DataViews operator name */
20728 label: (0, import_i18n24.__)("After"),
20729 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20730 (0, import_i18n24.sprintf)(
20731 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
20732 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
20733 filter.name,
20734 activeElements[0].label
20735 ),
20736 filterTextWrappers
20737 ),
20738 filter(item, field, filterValue) {
20739 if (filterValue === void 0) {
20740 return true;
20741 }
20742 const filterDate = (0, import_date.getDate)(filterValue);
20743 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20744 return fieldDate > filterDate;
20745 },
20746 selection: "single"
20747 },
20748 {
20749 name: OPERATOR_BEFORE_INC,
20750 /* translators: DataViews operator name */
20751 label: (0, import_i18n24.__)("Before (inc)"),
20752 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20753 (0, import_i18n24.sprintf)(
20754 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
20755 (0, import_i18n24.__)(
20756 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
20757 ),
20758 filter.name,
20759 activeElements[0].label
20760 ),
20761 filterTextWrappers
20762 ),
20763 filter(item, field, filterValue) {
20764 if (filterValue === void 0) {
20765 return true;
20766 }
20767 const filterDate = (0, import_date.getDate)(filterValue);
20768 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20769 return fieldDate <= filterDate;
20770 },
20771 selection: "single"
20772 },
20773 {
20774 name: OPERATOR_AFTER_INC,
20775 /* translators: DataViews operator name */
20776 label: (0, import_i18n24.__)("After (inc)"),
20777 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20778 (0, import_i18n24.sprintf)(
20779 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
20780 (0, import_i18n24.__)(
20781 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
20782 ),
20783 filter.name,
20784 activeElements[0].label
20785 ),
20786 filterTextWrappers
20787 ),
20788 filter(item, field, filterValue) {
20789 if (filterValue === void 0) {
20790 return true;
20791 }
20792 const filterDate = (0, import_date.getDate)(filterValue);
20793 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20794 return fieldDate >= filterDate;
20795 },
20796 selection: "single"
20797 },
20798 {
20799 name: OPERATOR_CONTAINS,
20800 /* translators: DataViews operator name */
20801 label: (0, import_i18n24.__)("Contains"),
20802 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20803 (0, import_i18n24.sprintf)(
20804 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
20805 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
20806 filter.name,
20807 activeElements[0].label
20808 ),
20809 filterTextWrappers
20810 ),
20811 filter(item, field, filterValue) {
20812 if (filterValue === void 0) {
20813 return true;
20814 }
20815 const fieldValue = field.getValue({ item });
20816 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20817 },
20818 selection: "single"
20819 },
20820 {
20821 name: OPERATOR_NOT_CONTAINS,
20822 /* translators: DataViews operator name */
20823 label: (0, import_i18n24.__)("Doesn't contain"),
20824 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20825 (0, import_i18n24.sprintf)(
20826 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
20827 (0, import_i18n24.__)(
20828 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
20829 ),
20830 filter.name,
20831 activeElements[0].label
20832 ),
20833 filterTextWrappers
20834 ),
20835 filter(item, field, filterValue) {
20836 if (filterValue === void 0) {
20837 return true;
20838 }
20839 const fieldValue = field.getValue({ item });
20840 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20841 },
20842 selection: "single"
20843 },
20844 {
20845 name: OPERATOR_STARTS_WITH,
20846 /* translators: DataViews operator name */
20847 label: (0, import_i18n24.__)("Starts with"),
20848 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20849 (0, import_i18n24.sprintf)(
20850 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
20851 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
20852 filter.name,
20853 activeElements[0].label
20854 ),
20855 filterTextWrappers
20856 ),
20857 filter(item, field, filterValue) {
20858 if (filterValue === void 0) {
20859 return true;
20860 }
20861 const fieldValue = field.getValue({ item });
20862 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
20863 },
20864 selection: "single"
20865 },
20866 {
20867 name: OPERATOR_ON,
20868 /* translators: DataViews operator name */
20869 label: (0, import_i18n24.__)("On"),
20870 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20871 (0, import_i18n24.sprintf)(
20872 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
20873 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20874 filter.name,
20875 activeElements[0].label
20876 ),
20877 filterTextWrappers
20878 ),
20879 filter(item, field, filterValue) {
20880 if (filterValue === void 0) {
20881 return true;
20882 }
20883 const filterDate = (0, import_date.getDate)(filterValue);
20884 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20885 return filterDate.getTime() === fieldDate.getTime();
20886 },
20887 selection: "single"
20888 },
20889 {
20890 name: OPERATOR_NOT_ON,
20891 /* translators: DataViews operator name */
20892 label: (0, import_i18n24.__)("Not on"),
20893 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20894 (0, import_i18n24.sprintf)(
20895 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
20896 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20897 filter.name,
20898 activeElements[0].label
20899 ),
20900 filterTextWrappers
20901 ),
20902 filter(item, field, filterValue) {
20903 if (filterValue === void 0) {
20904 return true;
20905 }
20906 const filterDate = (0, import_date.getDate)(filterValue);
20907 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20908 return filterDate.getTime() !== fieldDate.getTime();
20909 },
20910 selection: "single"
20911 }
20912 ];
20913 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
20914 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
20915 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
20916 (op) => op.name === name
20917 );
20918 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
20919
20920 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
20921 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
20922 var ENTER = "Enter";
20923 var SPACE = " ";
20924 var FilterText = ({
20925 activeElements,
20926 filterInView,
20927 filter
20928 }) => {
20929 if (activeElements === void 0 || activeElements.length === 0) {
20930 return filter.name;
20931 }
20932 const operator = getOperatorByName(filterInView?.operator);
20933 if (operator !== void 0) {
20934 return operator.filterText(filter, activeElements);
20935 }
20936 return (0, import_i18n25.sprintf)(
20937 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
20938 (0, import_i18n25.__)("Unknown status for %1$s"),
20939 filter.name
20940 );
20941 };
20942 function OperatorSelector({
20943 filter,
20944 view,
20945 onChangeView
20946 }) {
20947 const operatorOptions = filter.operators?.map((operator) => ({
20948 value: operator,
20949 label: getOperatorByName(operator)?.label || operator
20950 }));
20951 const currentFilter = view.filters?.find(
20952 (_filter) => _filter.field === filter.field
20953 );
20954 const value = currentFilter?.operator || filter.operators[0];
20955 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
20956 Stack,
20957 {
20958 direction: "row",
20959 gap: "sm",
20960 justify: "flex-start",
20961 className: "dataviews-filters__summary-operators-container",
20962 align: "center",
20963 children: [
20964 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
20965 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
20966 import_components21.SelectControl,
20967 {
20968 className: "dataviews-filters__summary-operators-filter-select",
20969 label: (0, import_i18n25.__)("Conditions"),
20970 value,
20971 options: operatorOptions,
20972 onChange: (newValue) => {
20973 const newOperator = newValue;
20974 const currentOperator = currentFilter?.operator;
20975 const newFilters = currentFilter ? [
20976 ...(view.filters ?? []).map(
20977 (_filter) => {
20978 if (_filter.field === filter.field) {
20979 const currentOpSelectionModel = getOperatorByName(
20980 currentOperator
20981 )?.selection;
20982 const newOpSelectionModel = getOperatorByName(
20983 newOperator
20984 )?.selection;
20985 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
20986 currentOpSelectionModel,
20987 newOpSelectionModel
20988 ].includes("custom");
20989 return {
20990 ..._filter,
20991 value: shouldResetValue ? void 0 : _filter.value,
20992 operator: newOperator
20993 };
20994 }
20995 return _filter;
20996 }
20997 )
20998 ] : [
20999 ...view.filters ?? [],
21000 {
21001 field: filter.field,
21002 operator: newOperator,
21003 value: void 0
21004 }
21005 ];
21006 onChangeView({
21007 ...view,
21008 page: 1,
21009 filters: newFilters
21010 });
21011 },
21012 size: "small",
21013 variant: "minimal",
21014 hideLabelFromVision: true
21015 }
21016 )
21017 ]
21018 }
21019 );
21020 }
21021 function Filter({
21022 addFilterRef,
21023 openedFilter,
21024 fields,
21025 ...commonProps
21026 }) {
21027 const toggleRef = (0, import_element46.useRef)(null);
21028 const { filter, view, onChangeView } = commonProps;
21029 const filterInView = view.filters?.find(
21030 (f2) => f2.field === filter.field
21031 );
21032 let activeElements = [];
21033 const field = (0, import_element46.useMemo)(() => {
21034 const currentField = fields.find((f2) => f2.id === filter.field);
21035 if (currentField) {
21036 return {
21037 ...currentField,
21038 // Configure getValue as if Item was a plain object.
21039 // See related input-widget.tsx
21040 getValue: ({ item }) => item[currentField.id]
21041 };
21042 }
21043 return currentField;
21044 }, [fields, filter.field]);
21045 const { elements } = useElements({
21046 elements: filter.elements,
21047 getElements: filter.getElements
21048 });
21049 if (elements.length > 0) {
21050 activeElements = elements.filter((element) => {
21051 if (filter.singleSelection) {
21052 return element.value === filterInView?.value;
21053 }
21054 return filterInView?.value?.includes(element.value);
21055 });
21056 } else if (Array.isArray(filterInView?.value)) {
21057 const label = filterInView.value.map((v2) => {
21058 const formattedValue = field?.getValueFormatted({
21059 item: { [field.id]: v2 },
21060 field
21061 });
21062 return formattedValue || String(v2);
21063 });
21064 activeElements = [
21065 {
21066 value: filterInView.value,
21067 // @ts-ignore
21068 label
21069 }
21070 ];
21071 } else if (typeof filterInView?.value === "object") {
21072 activeElements = [
21073 { value: filterInView.value, label: filterInView.value }
21074 ];
21075 } else if (filterInView?.value !== void 0) {
21076 const label = field !== void 0 ? field.getValueFormatted({
21077 item: { [field.id]: filterInView.value },
21078 field
21079 }) : String(filterInView.value);
21080 activeElements = [
21081 {
21082 value: filterInView.value,
21083 label
21084 }
21085 ];
21086 }
21087 const isPrimary = filter.isPrimary;
21088 const isLocked = filterInView?.isLocked;
21089 const hasValues = !isLocked && filterInView?.value !== void 0;
21090 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21091 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21092 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21093 import_components21.Dropdown,
21094 {
21095 defaultOpen: openedFilter === filter.field,
21096 contentClassName: "dataviews-filters__summary-popover",
21097 popoverProps: { placement: "bottom-start", role: "dialog" },
21098 onClose: () => {
21099 toggleRef.current?.focus();
21100 },
21101 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21102 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21103 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21104 tooltip_exports.Trigger,
21105 {
21106 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21107 "div",
21108 {
21109 className: clsx_default(
21110 "dataviews-filters__summary-chip",
21111 {
21112 "has-reset": canResetOrRemove,
21113 "has-values": hasValues,
21114 "is-not-clickable": isLocked
21115 }
21116 ),
21117 role: "button",
21118 tabIndex: isLocked ? -1 : 0,
21119 onClick: () => {
21120 if (!isLocked) {
21121 onToggle();
21122 }
21123 },
21124 onKeyDown: (event) => {
21125 if (!isLocked && [ENTER, SPACE].includes(
21126 event.key
21127 )) {
21128 onToggle();
21129 event.preventDefault();
21130 }
21131 },
21132 "aria-disabled": isLocked,
21133 "aria-pressed": isOpen,
21134 "aria-expanded": isOpen,
21135 ref: toggleRef,
21136 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21137 FilterText,
21138 {
21139 activeElements,
21140 filterInView,
21141 filter
21142 }
21143 )
21144 }
21145 )
21146 }
21147 ),
21148 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21149 /* translators: 1: Filter name. */
21150 (0, import_i18n25.__)("Filter by: %1$s"),
21151 filter.name.toLowerCase()
21152 ) })
21153 ] }),
21154 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21155 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21156 tooltip_exports.Trigger,
21157 {
21158 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21159 "button",
21160 {
21161 className: clsx_default(
21162 "dataviews-filters__summary-chip-remove",
21163 { "has-values": hasValues }
21164 ),
21165 "aria-label": resetOrRemoveLabel,
21166 onClick: () => {
21167 onChangeView({
21168 ...view,
21169 page: 1,
21170 filters: view.filters?.filter(
21171 (_filter) => _filter.field !== filter.field
21172 )
21173 });
21174 if (!isPrimary) {
21175 addFilterRef.current?.focus();
21176 } else {
21177 toggleRef.current?.focus();
21178 }
21179 },
21180 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.Icon, { icon: close_small_default })
21181 }
21182 )
21183 }
21184 ),
21185 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21186 ] })
21187 ] }),
21188 renderContent: () => {
21189 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21190 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(OperatorSelector, { ...commonProps }),
21191 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21192 SearchWidget,
21193 {
21194 ...commonProps,
21195 filter: {
21196 ...commonProps.filter,
21197 elements
21198 }
21199 }
21200 ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(InputWidget, { ...commonProps, fields })
21201 ] });
21202 }
21203 }
21204 );
21205 }
21206
21207 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21208 var import_components22 = __toESM(require_components(), 1);
21209 var import_i18n26 = __toESM(require_i18n(), 1);
21210 var import_element47 = __toESM(require_element(), 1);
21211 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21212 var { Menu: Menu4 } = unlock3(import_components22.privateApis);
21213 function AddFilterMenu({
21214 filters,
21215 view,
21216 onChangeView,
21217 setOpenedFilter,
21218 triggerProps
21219 }) {
21220 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21221 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Menu4, { children: [
21222 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21223 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21224 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21225 Menu4.Item,
21226 {
21227 onClick: () => {
21228 setOpenedFilter(filter.field);
21229 onChangeView({
21230 ...view,
21231 page: 1,
21232 filters: [
21233 ...view.filters || [],
21234 {
21235 field: filter.field,
21236 value: void 0,
21237 operator: filter.operators[0]
21238 }
21239 ]
21240 });
21241 },
21242 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.ItemLabel, { children: filter.name })
21243 },
21244 filter.field
21245 );
21246 }) })
21247 ] });
21248 }
21249 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21250 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21251 return null;
21252 }
21253 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21254 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21255 AddFilterMenu,
21256 {
21257 triggerProps: {
21258 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21259 import_components22.Button,
21260 {
21261 accessibleWhenDisabled: true,
21262 size: "compact",
21263 className: "dataviews-filters-button",
21264 variant: "tertiary",
21265 disabled: !inactiveFilters.length,
21266 ref
21267 }
21268 ),
21269 children: (0, import_i18n26.__)("Add filter")
21270 },
21271 ...{ filters, view, onChangeView, setOpenedFilter }
21272 }
21273 );
21274 }
21275 var add_filter_default = (0, import_element47.forwardRef)(AddFilter);
21276
21277 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21278 var import_components23 = __toESM(require_components(), 1);
21279 var import_i18n27 = __toESM(require_i18n(), 1);
21280 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21281 function ResetFilter({
21282 filters,
21283 view,
21284 onChangeView
21285 }) {
21286 const isPrimary = (field) => filters.some(
21287 (_filter) => _filter.field === field && _filter.isPrimary
21288 );
21289 const isDisabled = !view.search && !view.filters?.some(
21290 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21291 );
21292 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21293 import_components23.Button,
21294 {
21295 disabled: isDisabled,
21296 accessibleWhenDisabled: true,
21297 size: "compact",
21298 variant: "tertiary",
21299 className: "dataviews-filters__reset-button",
21300 onClick: () => {
21301 onChangeView({
21302 ...view,
21303 page: 1,
21304 search: "",
21305 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21306 });
21307 },
21308 children: (0, import_i18n27.__)("Reset")
21309 }
21310 );
21311 }
21312
21313 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21314 var import_element48 = __toESM(require_element(), 1);
21315 function useFilters(fields, view) {
21316 return (0, import_element48.useMemo)(() => {
21317 const filters = [];
21318 fields.forEach((field) => {
21319 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21320 return;
21321 }
21322 const operators = field.filterBy.operators;
21323 const isPrimary = !!field.filterBy?.isPrimary;
21324 const isLocked = view.filters?.some(
21325 (f2) => f2.field === field.id && !!f2.isLocked
21326 ) ?? false;
21327 filters.push({
21328 field: field.id,
21329 name: field.label,
21330 elements: field.elements,
21331 getElements: field.getElements,
21332 hasElements: field.hasElements,
21333 singleSelection: operators.some(
21334 (op) => isSingleSelectionOperator(op)
21335 ),
21336 operators,
21337 isVisible: isLocked || isPrimary || !!view.filters?.some(
21338 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21339 ),
21340 isPrimary,
21341 isLocked
21342 });
21343 });
21344 filters.sort((a2, b2) => {
21345 if (a2.isLocked && !b2.isLocked) {
21346 return -1;
21347 }
21348 if (!a2.isLocked && b2.isLocked) {
21349 return 1;
21350 }
21351 if (a2.isPrimary && !b2.isPrimary) {
21352 return -1;
21353 }
21354 if (!a2.isPrimary && b2.isPrimary) {
21355 return 1;
21356 }
21357 return a2.name.localeCompare(b2.name);
21358 });
21359 return filters;
21360 }, [fields, view]);
21361 }
21362 var use_filters_default = useFilters;
21363
21364 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21365 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
21366 function Filters({ className }) {
21367 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element49.useContext)(dataviews_context_default);
21368 const addFilterRef = (0, import_element49.useRef)(null);
21369 const filters = use_filters_default(fields, view);
21370 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21371 add_filter_default,
21372 {
21373 filters,
21374 view,
21375 onChangeView,
21376 ref: addFilterRef,
21377 setOpenedFilter
21378 },
21379 "add-filter"
21380 );
21381 const visibleFilters = filters.filter((filter) => filter.isVisible);
21382 if (visibleFilters.length === 0) {
21383 return null;
21384 }
21385 const filterComponents = [
21386 ...visibleFilters.map((filter) => {
21387 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21388 Filter,
21389 {
21390 filter,
21391 view,
21392 fields,
21393 onChangeView,
21394 addFilterRef,
21395 openedFilter
21396 },
21397 filter.field
21398 );
21399 }),
21400 addFilter
21401 ];
21402 filterComponents.push(
21403 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21404 ResetFilter,
21405 {
21406 filters,
21407 view,
21408 onChangeView
21409 },
21410 "reset-filters"
21411 )
21412 );
21413 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21414 Stack,
21415 {
21416 direction: "row",
21417 justify: "flex-start",
21418 gap: "sm",
21419 style: { width: "fit-content" },
21420 wrap: "wrap",
21421 className,
21422 children: filterComponents
21423 }
21424 );
21425 }
21426 var filters_default = (0, import_element49.memo)(Filters);
21427
21428 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21429 var import_element50 = __toESM(require_element(), 1);
21430 var import_components24 = __toESM(require_components(), 1);
21431 var import_i18n28 = __toESM(require_i18n(), 1);
21432 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
21433 function FiltersToggle() {
21434 const {
21435 filters,
21436 view,
21437 onChangeView,
21438 setOpenedFilter,
21439 isShowingFilter,
21440 setIsShowingFilter
21441 } = (0, import_element50.useContext)(dataviews_context_default);
21442 const buttonRef = (0, import_element50.useRef)(null);
21443 const onChangeViewWithFilterVisibility = (0, import_element50.useCallback)(
21444 (_view) => {
21445 onChangeView(_view);
21446 setIsShowingFilter(true);
21447 },
21448 [onChangeView, setIsShowingFilter]
21449 );
21450 if (filters.length === 0) {
21451 return null;
21452 }
21453 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21454 const addFilterButtonProps = {
21455 label: (0, import_i18n28.__)("Add filter"),
21456 "aria-expanded": false,
21457 isPressed: false
21458 };
21459 const toggleFiltersButtonProps = {
21460 label: (0, import_i18n28._x)("Filter", "verb"),
21461 "aria-expanded": isShowingFilter,
21462 isPressed: isShowingFilter,
21463 onClick: () => {
21464 if (!isShowingFilter) {
21465 setOpenedFilter(null);
21466 }
21467 setIsShowingFilter(!isShowingFilter);
21468 }
21469 };
21470 const hasPrimaryOrLockedFilters = filters.some(
21471 (filter) => filter.isPrimary || filter.isLocked
21472 );
21473 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21474 import_components24.Button,
21475 {
21476 ref: buttonRef,
21477 className: "dataviews-filters__visibility-toggle",
21478 size: "compact",
21479 icon: funnel_default,
21480 disabled: hasPrimaryOrLockedFilters,
21481 accessibleWhenDisabled: true,
21482 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21483 }
21484 );
21485 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21486 AddFilterMenu,
21487 {
21488 filters,
21489 view,
21490 onChangeView: onChangeViewWithFilterVisibility,
21491 setOpenedFilter,
21492 triggerProps: { render: buttonComponent }
21493 }
21494 ) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21495 FilterVisibilityToggle,
21496 {
21497 buttonRef,
21498 filtersCount: view.filters?.length,
21499 children: buttonComponent
21500 }
21501 ) });
21502 }
21503 function FilterVisibilityToggle({
21504 buttonRef,
21505 filtersCount,
21506 children
21507 }) {
21508 (0, import_element50.useEffect)(
21509 () => () => {
21510 buttonRef.current?.focus();
21511 },
21512 [buttonRef]
21513 );
21514 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
21515 children,
21516 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21517 ] });
21518 }
21519 var toggle_default = FiltersToggle;
21520
21521 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21522 var import_element51 = __toESM(require_element(), 1);
21523 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
21524 function FiltersToggled(props) {
21525 const { isShowingFilter } = (0, import_element51.useContext)(dataviews_context_default);
21526 if (!isShowingFilter) {
21527 return null;
21528 }
21529 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(filters_default, { ...props });
21530 }
21531 var filters_toggled_default = FiltersToggled;
21532
21533 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
21534 var import_element52 = __toESM(require_element(), 1);
21535 var import_components25 = __toESM(require_components(), 1);
21536 var import_i18n29 = __toESM(require_i18n(), 1);
21537 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21538 function DataViewsLayout({ className }) {
21539 const {
21540 actions = [],
21541 data,
21542 fields,
21543 getItemId,
21544 getItemLevel,
21545 hasInitiallyLoaded,
21546 isLoading,
21547 view,
21548 onChangeView,
21549 selection,
21550 onChangeSelection,
21551 setOpenedFilter,
21552 onClickItem,
21553 isItemClickable,
21554 renderItemLink,
21555 defaultLayouts,
21556 containerRef,
21557 empty = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: (0, import_i18n29.__)("No results") })
21558 } = (0, import_element52.useContext)(dataviews_context_default);
21559 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
21560 delay: 200
21561 });
21562 if (!hasInitiallyLoaded) {
21563 if (!isDelayedInitialLoading) {
21564 return null;
21565 }
21566 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components25.Spinner, {}) }) });
21567 }
21568 const ViewComponent = VIEW_LAYOUTS.find(
21569 (v2) => v2.type === view.type && defaultLayouts[v2.type]
21570 )?.component;
21571 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21572 ViewComponent,
21573 {
21574 className,
21575 actions,
21576 data,
21577 fields,
21578 getItemId,
21579 getItemLevel,
21580 isLoading,
21581 onChangeView,
21582 onChangeSelection,
21583 selection,
21584 setOpenedFilter,
21585 onClickItem,
21586 renderItemLink,
21587 isItemClickable,
21588 view,
21589 empty
21590 }
21591 ) });
21592 }
21593
21594 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
21595 var import_element53 = __toESM(require_element(), 1);
21596 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21597 var EMPTY_ARRAY5 = [];
21598 function DataViewsFooter() {
21599 const {
21600 view,
21601 paginationInfo: { totalItems = 0, totalPages },
21602 data,
21603 actions = EMPTY_ARRAY5,
21604 isLoading,
21605 hasInitiallyLoaded
21606 } = (0, import_element53.useContext)(dataviews_context_default);
21607 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
21608 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
21609 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
21610 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
21611 return null;
21612 }
21613 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21614 "div",
21615 {
21616 className: "dataviews-footer",
21617 inert: isRefreshing ? "true" : void 0,
21618 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
21619 Stack,
21620 {
21621 direction: "row",
21622 justify: "end",
21623 align: "center",
21624 className: clsx_default("dataviews-footer__content", {
21625 "is-refreshing": isDelayedRefreshing
21626 }),
21627 gap: "sm",
21628 children: [
21629 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(BulkActionsFooter, {}),
21630 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(dataviews_pagination_default, {})
21631 ]
21632 }
21633 )
21634 }
21635 );
21636 }
21637
21638 // packages/dataviews/build-module/components/dataviews-search/index.mjs
21639 var import_i18n30 = __toESM(require_i18n(), 1);
21640 var import_element54 = __toESM(require_element(), 1);
21641 var import_components26 = __toESM(require_components(), 1);
21642 var import_compose10 = __toESM(require_compose(), 1);
21643 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21644 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
21645 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
21646 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
21647 view.search
21648 );
21649 (0, import_element54.useEffect)(() => {
21650 if (view.search !== debouncedSearch) {
21651 setSearch(view.search ?? "");
21652 }
21653 }, [view.search, setSearch]);
21654 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
21655 const viewRef = (0, import_element54.useRef)(view);
21656 (0, import_element54.useEffect)(() => {
21657 onChangeViewRef.current = onChangeView;
21658 viewRef.current = view;
21659 }, [onChangeView, view]);
21660 (0, import_element54.useEffect)(() => {
21661 if (debouncedSearch !== viewRef.current?.search) {
21662 onChangeViewRef.current({
21663 ...viewRef.current,
21664 page: view.page ? 1 : void 0,
21665 startPosition: view.startPosition ? 1 : void 0,
21666 search: debouncedSearch
21667 });
21668 }
21669 }, [debouncedSearch]);
21670 const searchLabel = label || (0, import_i18n30.__)("Search");
21671 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21672 import_components26.SearchControl,
21673 {
21674 className: "dataviews-search",
21675 onChange: setSearch,
21676 value: search,
21677 label: searchLabel,
21678 placeholder: searchLabel,
21679 size: "compact"
21680 }
21681 );
21682 });
21683 var dataviews_search_default = DataViewsSearch;
21684
21685 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
21686 var import_components27 = __toESM(require_components(), 1);
21687 var import_i18n31 = __toESM(require_i18n(), 1);
21688 var import_element55 = __toESM(require_element(), 1);
21689 var import_warning = __toESM(require_warning(), 1);
21690 var import_compose11 = __toESM(require_compose(), 1);
21691 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21692 var { Menu: Menu5 } = unlock3(import_components27.privateApis);
21693 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
21694 className: "dataviews-config__popover",
21695 placement: "bottom-end",
21696 offset: 9
21697 };
21698 function ViewTypeMenu() {
21699 const { view, onChangeView, defaultLayouts } = (0, import_element55.useContext)(dataviews_context_default);
21700 const availableLayouts = Object.keys(defaultLayouts);
21701 if (availableLayouts.length <= 1) {
21702 return null;
21703 }
21704 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
21705 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu5, { children: [
21706 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21707 Menu5.TriggerButton,
21708 {
21709 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21710 import_components27.Button,
21711 {
21712 size: "compact",
21713 icon: activeView?.icon,
21714 label: (0, import_i18n31.__)("Layout")
21715 }
21716 )
21717 }
21718 ),
21719 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
21720 const config = VIEW_LAYOUTS.find(
21721 (v2) => v2.type === layout
21722 );
21723 if (!config) {
21724 return null;
21725 }
21726 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21727 Menu5.RadioItem,
21728 {
21729 value: layout,
21730 name: "view-actions-available-view",
21731 checked: layout === view.type,
21732 hideOnClick: true,
21733 onChange: (e2) => {
21734 switch (e2.target.value) {
21735 case "list":
21736 case "grid":
21737 case "table":
21738 case "pickerGrid":
21739 case "pickerTable":
21740 case "pickerActivity":
21741 case "activity":
21742 const viewWithoutLayout = { ...view };
21743 if ("layout" in viewWithoutLayout) {
21744 delete viewWithoutLayout.layout;
21745 }
21746 return onChangeView({
21747 ...viewWithoutLayout,
21748 type: e2.target.value,
21749 ...defaultLayouts[e2.target.value]
21750 });
21751 }
21752 (0, import_warning.default)("Invalid dataview");
21753 },
21754 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.ItemLabel, { children: config.label })
21755 },
21756 layout
21757 );
21758 }) })
21759 ] });
21760 }
21761 function SortFieldControl() {
21762 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
21763 const orderOptions = (0, import_element55.useMemo)(() => {
21764 const sortableFields = fields.filter(
21765 (field) => field.enableSorting !== false
21766 );
21767 return sortableFields.map((field) => {
21768 return {
21769 label: field.label,
21770 value: field.id
21771 };
21772 });
21773 }, [fields]);
21774 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21775 import_components27.SelectControl,
21776 {
21777 __next40pxDefaultSize: true,
21778 label: (0, import_i18n31.__)("Sort by"),
21779 value: view.sort?.field,
21780 options: orderOptions,
21781 onChange: (value) => {
21782 onChangeView({
21783 ...view,
21784 sort: {
21785 direction: view?.sort?.direction || "desc",
21786 field: value
21787 },
21788 showLevels: false
21789 });
21790 }
21791 }
21792 );
21793 }
21794 function SortDirectionControl() {
21795 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
21796 const sortableFields = fields.filter(
21797 (field) => field.enableSorting !== false
21798 );
21799 if (sortableFields.length === 0) {
21800 return null;
21801 }
21802 let value = view.sort?.direction;
21803 if (!value && view.sort?.field) {
21804 value = "desc";
21805 }
21806 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21807 import_components27.__experimentalToggleGroupControl,
21808 {
21809 className: "dataviews-view-config__sort-direction",
21810 __next40pxDefaultSize: true,
21811 isBlock: true,
21812 label: (0, import_i18n31.__)("Order"),
21813 value,
21814 onChange: (newDirection) => {
21815 if (newDirection === "asc" || newDirection === "desc") {
21816 onChangeView({
21817 ...view,
21818 sort: {
21819 direction: newDirection,
21820 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
21821 fields.find(
21822 (field) => field.enableSorting !== false
21823 )?.id || ""
21824 },
21825 showLevels: false
21826 });
21827 return;
21828 }
21829 (0, import_warning.default)("Invalid direction");
21830 },
21831 children: SORTING_DIRECTIONS.map((direction) => {
21832 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21833 import_components27.__experimentalToggleGroupControlOptionIcon,
21834 {
21835 value: direction,
21836 icon: sortIcons[direction],
21837 label: sortLabels[direction]
21838 },
21839 direction
21840 );
21841 })
21842 }
21843 );
21844 }
21845 function ItemsPerPageControl() {
21846 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
21847 const { infiniteScrollEnabled } = view;
21848 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
21849 return null;
21850 }
21851 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21852 import_components27.__experimentalToggleGroupControl,
21853 {
21854 __next40pxDefaultSize: true,
21855 isBlock: true,
21856 label: (0, import_i18n31.__)("Items per page"),
21857 value: view.perPage || 10,
21858 disabled: !view?.sort?.field,
21859 onChange: (newItemsPerPage) => {
21860 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
21861 onChangeView({
21862 ...view,
21863 perPage: newItemsPerPageNumber,
21864 page: 1
21865 });
21866 },
21867 children: config.perPageSizes.map((value) => {
21868 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21869 import_components27.__experimentalToggleGroupControlOption,
21870 {
21871 value,
21872 label: value.toString()
21873 },
21874 value
21875 );
21876 })
21877 }
21878 );
21879 }
21880 function ResetViewButton() {
21881 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
21882 if (onReset === void 0) {
21883 return null;
21884 }
21885 const isDisabled = onReset === false;
21886 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21887 import_components27.Button,
21888 {
21889 variant: "tertiary",
21890 size: "compact",
21891 disabled: isDisabled,
21892 accessibleWhenDisabled: true,
21893 className: "dataviews-view-config__reset-button",
21894 onClick: () => {
21895 if (typeof onReset === "function") {
21896 onReset();
21897 }
21898 },
21899 children: (0, import_i18n31.__)("Reset view")
21900 }
21901 );
21902 }
21903 function DataviewsViewConfigDropdown() {
21904 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
21905 const popoverId = (0, import_compose11.useInstanceId)(
21906 _DataViewsViewConfig,
21907 "dataviews-view-config-dropdown"
21908 );
21909 const activeLayout = VIEW_LAYOUTS.find(
21910 (layout) => layout.type === view.type
21911 );
21912 const isModified = typeof onReset === "function";
21913 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21914 import_components27.Dropdown,
21915 {
21916 expandOnMobile: true,
21917 popoverProps: {
21918 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
21919 id: popoverId
21920 },
21921 renderToggle: ({ onToggle, isOpen }) => {
21922 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
21923 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21924 import_components27.Button,
21925 {
21926 size: "compact",
21927 icon: cog_default,
21928 label: (0, import_i18n31._x)(
21929 "View options",
21930 "View is used as a noun"
21931 ),
21932 onClick: onToggle,
21933 "aria-expanded": isOpen ? "true" : "false",
21934 "aria-controls": popoverId
21935 }
21936 ),
21937 isModified && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
21938 ] });
21939 },
21940 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21941 import_components27.__experimentalDropdownContentWrapper,
21942 {
21943 paddingSize: "medium",
21944 className: "dataviews-config__popover-content-wrapper",
21945 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
21946 Stack,
21947 {
21948 direction: "column",
21949 className: "dataviews-view-config",
21950 gap: "xl",
21951 children: [
21952 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
21953 Stack,
21954 {
21955 direction: "row",
21956 justify: "space-between",
21957 align: "center",
21958 className: "dataviews-view-config__header",
21959 children: [
21960 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21961 import_components27.__experimentalHeading,
21962 {
21963 level: 2,
21964 className: "dataviews-settings-section__title",
21965 children: (0, import_i18n31.__)("Appearance")
21966 }
21967 ),
21968 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ResetViewButton, {})
21969 ]
21970 }
21971 ),
21972 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Stack, { direction: "column", gap: "lg", children: [
21973 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
21974 Stack,
21975 {
21976 direction: "row",
21977 gap: "sm",
21978 className: "dataviews-view-config__sort-controls",
21979 children: [
21980 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortFieldControl, {}),
21981 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortDirectionControl, {})
21982 ]
21983 }
21984 ),
21985 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(activeLayout.viewConfigOptions, {}),
21986 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ItemsPerPageControl, {}),
21987 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(PropertiesSection, {})
21988 ] })
21989 ]
21990 }
21991 )
21992 }
21993 )
21994 }
21995 );
21996 }
21997 function _DataViewsViewConfig() {
21998 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
21999 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ViewTypeMenu, {}),
22000 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DataviewsViewConfigDropdown, {})
22001 ] });
22002 }
22003 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
22004 var dataviews_view_config_default = DataViewsViewConfig;
22005
22006 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22007 var import_components28 = __toESM(require_components(), 1);
22008 var import_element56 = __toESM(require_element(), 1);
22009
22010 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22011 function getCustomValidity(isValid2, validity) {
22012 let customValidity;
22013 if (isValid2?.required && validity?.required) {
22014 customValidity = validity?.required?.message ? validity.required : void 0;
22015 } else if (isValid2?.pattern && validity?.pattern) {
22016 customValidity = validity.pattern;
22017 } else if (isValid2?.min && validity?.min) {
22018 customValidity = validity.min;
22019 } else if (isValid2?.max && validity?.max) {
22020 customValidity = validity.max;
22021 } else if (isValid2?.minLength && validity?.minLength) {
22022 customValidity = validity.minLength;
22023 } else if (isValid2?.maxLength && validity?.maxLength) {
22024 customValidity = validity.maxLength;
22025 } else if (isValid2?.elements && validity?.elements) {
22026 customValidity = validity.elements;
22027 } else if (validity?.custom) {
22028 customValidity = validity.custom;
22029 }
22030 return customValidity;
22031 }
22032
22033 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22034 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22035 var { ValidatedCheckboxControl } = unlock3(import_components28.privateApis);
22036 function Checkbox({
22037 field,
22038 onChange,
22039 data,
22040 hideLabelFromVision,
22041 markWhenOptional,
22042 validity
22043 }) {
22044 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22045 const disabled2 = field.isDisabled({ item: data, field });
22046 const onChangeControl = (0, import_element56.useCallback)(() => {
22047 onChange(
22048 setValue({ item: data, value: !getValue({ item: data }) })
22049 );
22050 }, [data, getValue, onChange, setValue]);
22051 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22052 ValidatedCheckboxControl,
22053 {
22054 required: !!field.isValid?.required,
22055 markWhenOptional,
22056 customValidity: getCustomValidity(isValid2, validity),
22057 hidden: hideLabelFromVision,
22058 label,
22059 help: description,
22060 checked: getValue({ item: data }),
22061 onChange: onChangeControl,
22062 disabled: disabled2
22063 }
22064 );
22065 }
22066
22067 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22068 var import_components29 = __toESM(require_components(), 1);
22069 var import_element57 = __toESM(require_element(), 1);
22070 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22071 var { ValidatedComboboxControl } = unlock3(import_components29.privateApis);
22072 function Combobox3({
22073 data,
22074 field,
22075 onChange,
22076 hideLabelFromVision,
22077 validity
22078 }) {
22079 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22080 const value = getValue({ item: data }) ?? "";
22081 const onChangeControl = (0, import_element57.useCallback)(
22082 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22083 [data, onChange, setValue]
22084 );
22085 const { elements, isLoading } = useElements({
22086 elements: field.elements,
22087 getElements: field.getElements
22088 });
22089 if (isLoading) {
22090 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components29.Spinner, {});
22091 }
22092 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22093 ValidatedComboboxControl,
22094 {
22095 required: !!field.isValid?.required,
22096 customValidity: getCustomValidity(isValid2, validity),
22097 label,
22098 value,
22099 help: description,
22100 placeholder,
22101 options: elements,
22102 onChange: onChangeControl,
22103 hideLabelFromVision,
22104 allowReset: true,
22105 expandOnFocus: true
22106 }
22107 );
22108 }
22109
22110 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22111 var import_components31 = __toESM(require_components(), 1);
22112 var import_element60 = __toESM(require_element(), 1);
22113 var import_i18n33 = __toESM(require_i18n(), 1);
22114 var import_date3 = __toESM(require_date(), 1);
22115
22116 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22117 var import_components30 = __toESM(require_components(), 1);
22118 var import_element58 = __toESM(require_element(), 1);
22119 var import_i18n32 = __toESM(require_i18n(), 1);
22120 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22121 var TIME_UNITS_OPTIONS = {
22122 [OPERATOR_IN_THE_PAST]: [
22123 { value: "days", label: (0, import_i18n32.__)("Days") },
22124 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22125 { value: "months", label: (0, import_i18n32.__)("Months") },
22126 { value: "years", label: (0, import_i18n32.__)("Years") }
22127 ],
22128 [OPERATOR_OVER]: [
22129 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22130 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22131 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22132 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22133 ]
22134 };
22135 function RelativeDateControl({
22136 className,
22137 data,
22138 field,
22139 onChange,
22140 hideLabelFromVision,
22141 operator
22142 }) {
22143 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22144 const { id, label, description, getValue, setValue } = field;
22145 const disabled2 = field.isDisabled({ item: data, field });
22146 const fieldValue = getValue({ item: data });
22147 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22148 const onChangeValue = (0, import_element58.useCallback)(
22149 (newValue) => onChange(
22150 setValue({
22151 item: data,
22152 value: { value: Number(newValue), unit }
22153 })
22154 ),
22155 [onChange, setValue, data, unit]
22156 );
22157 const onChangeUnit = (0, import_element58.useCallback)(
22158 (newUnit) => onChange(
22159 setValue({
22160 item: data,
22161 value: { value: relValue, unit: newUnit }
22162 })
22163 ),
22164 [onChange, setValue, data, relValue]
22165 );
22166 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22167 import_components30.BaseControl,
22168 {
22169 id,
22170 className: clsx_default(className, "dataviews-controls__relative-date"),
22171 label,
22172 hideLabelFromVision,
22173 help: description,
22174 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22175 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22176 import_components30.__experimentalNumberControl,
22177 {
22178 __next40pxDefaultSize: true,
22179 className: "dataviews-controls__relative-date-number",
22180 spinControls: "none",
22181 min: 1,
22182 step: 1,
22183 value: relValue,
22184 onChange: onChangeValue,
22185 disabled: disabled2
22186 }
22187 ),
22188 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22189 import_components30.SelectControl,
22190 {
22191 className: "dataviews-controls__relative-date-unit",
22192 __next40pxDefaultSize: true,
22193 label: (0, import_i18n32.__)("Unit"),
22194 value: unit,
22195 options,
22196 onChange: onChangeUnit,
22197 hideLabelFromVision: true,
22198 disabled: disabled2
22199 }
22200 )
22201 ] })
22202 }
22203 );
22204 }
22205
22206 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22207 var import_element59 = __toESM(require_element(), 1);
22208 function useDisabledDateMatchers(isValid2, parseDateFn) {
22209 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22210 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22211 const disabledMatchers = (0, import_element59.useMemo)(() => {
22212 const matchers = [];
22213 if (minConstraint) {
22214 const minDate = parseDateFn(minConstraint);
22215 if (minDate) {
22216 matchers.push({ before: minDate });
22217 }
22218 }
22219 if (maxConstraint) {
22220 const maxDate = parseDateFn(maxConstraint);
22221 if (maxDate) {
22222 matchers.push({ after: maxDate });
22223 }
22224 }
22225 return matchers.length > 0 ? matchers : void 0;
22226 }, [minConstraint, maxConstraint, parseDateFn]);
22227 return { minConstraint, maxConstraint, disabledMatchers };
22228 }
22229
22230 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22231 var import_date2 = __toESM(require_date(), 1);
22232 function parseDateTime(dateTimeString) {
22233 if (!dateTimeString) {
22234 return null;
22235 }
22236 const parsed = (0, import_date2.getDate)(dateTimeString);
22237 return parsed && isValid(parsed) ? parsed : null;
22238 }
22239
22240 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22241 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22242 var { DateCalendar, ValidatedInputControl } = unlock3(import_components31.privateApis);
22243 var formatDateTime = (value) => {
22244 if (!value) {
22245 return "";
22246 }
22247 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22248 };
22249 function CalendarDateTimeControl({
22250 data,
22251 field,
22252 onChange,
22253 hideLabelFromVision,
22254 markWhenOptional,
22255 validity,
22256 config
22257 }) {
22258 const { compact } = config || {};
22259 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22260 const disabled2 = field.isDisabled({ item: data, field });
22261 const fieldValue = getValue({ item: data });
22262 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22263 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
22264 const parsedDate = parseDateTime(value);
22265 return parsedDate || /* @__PURE__ */ new Date();
22266 });
22267 const inputControlRef = (0, import_element60.useRef)(null);
22268 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
22269 const previousFocusRef = (0, import_element60.useRef)(null);
22270 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22271 const onChangeCallback = (0, import_element60.useCallback)(
22272 (newValue) => onChange(setValue({ item: data, value: newValue })),
22273 [data, onChange, setValue]
22274 );
22275 (0, import_element60.useEffect)(() => {
22276 return () => {
22277 if (validationTimeoutRef.current) {
22278 clearTimeout(validationTimeoutRef.current);
22279 }
22280 };
22281 }, []);
22282 const onSelectDate = (0, import_element60.useCallback)(
22283 (newDate) => {
22284 let dateTimeValue;
22285 if (newDate) {
22286 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22287 let wpTime;
22288 if (value) {
22289 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22290 } else {
22291 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22292 }
22293 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22294 dateTimeValue = finalDateTime.toISOString();
22295 onChangeCallback(dateTimeValue);
22296 if (validationTimeoutRef.current) {
22297 clearTimeout(validationTimeoutRef.current);
22298 }
22299 } else {
22300 onChangeCallback(void 0);
22301 }
22302 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22303 validationTimeoutRef.current = setTimeout(() => {
22304 if (inputControlRef.current) {
22305 inputControlRef.current.focus();
22306 inputControlRef.current.blur();
22307 onChangeCallback(dateTimeValue);
22308 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22309 previousFocusRef.current.focus();
22310 }
22311 }
22312 }, 0);
22313 },
22314 [onChangeCallback, value]
22315 );
22316 const handleManualDateTimeChange = (0, import_element60.useCallback)(
22317 (newValue) => {
22318 if (newValue) {
22319 const dateTime = (0, import_date3.getDate)(newValue);
22320 onChangeCallback(dateTime.toISOString());
22321 const parsedDate = parseDateTime(dateTime.toISOString());
22322 if (parsedDate) {
22323 setCalendarMonth(parsedDate);
22324 }
22325 } else {
22326 onChangeCallback(void 0);
22327 }
22328 },
22329 [onChangeCallback]
22330 );
22331 const { format: fieldFormat } = field;
22332 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22333 const {
22334 timezone: { string: timezoneString }
22335 } = (0, import_date3.getSettings)();
22336 let displayLabel = label;
22337 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22338 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22339 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22340 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22341 }
22342 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22343 import_components31.BaseControl,
22344 {
22345 id,
22346 label: displayLabel,
22347 help: description,
22348 hideLabelFromVision,
22349 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22350 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22351 ValidatedInputControl,
22352 {
22353 ref: inputControlRef,
22354 __next40pxDefaultSize: true,
22355 required: !!isValid2?.required,
22356 customValidity: getCustomValidity(isValid2, validity),
22357 type: "datetime-local",
22358 label: (0, import_i18n33.__)("Date time"),
22359 hideLabelFromVision: true,
22360 value: formatDateTime(value),
22361 onChange: handleManualDateTimeChange,
22362 disabled: disabled2,
22363 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22364 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22365 }
22366 ),
22367 !compact && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22368 DateCalendar,
22369 {
22370 style: { width: "100%" },
22371 selected: value ? parseDateTime(value) || void 0 : void 0,
22372 onSelect: onSelectDate,
22373 month: calendarMonth,
22374 onMonthChange: setCalendarMonth,
22375 timeZone: timezoneString || void 0,
22376 weekStartsOn,
22377 disabled: disabled2 || disabledMatchers
22378 }
22379 )
22380 ] })
22381 }
22382 );
22383 }
22384 function DateTime({
22385 data,
22386 field,
22387 onChange,
22388 hideLabelFromVision,
22389 markWhenOptional,
22390 operator,
22391 validity,
22392 config
22393 }) {
22394 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22395 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22396 RelativeDateControl,
22397 {
22398 className: "dataviews-controls__datetime",
22399 data,
22400 field,
22401 onChange,
22402 hideLabelFromVision,
22403 operator
22404 }
22405 );
22406 }
22407 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22408 CalendarDateTimeControl,
22409 {
22410 data,
22411 field,
22412 onChange,
22413 hideLabelFromVision,
22414 markWhenOptional,
22415 validity,
22416 config
22417 }
22418 );
22419 }
22420
22421 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22422 var import_components32 = __toESM(require_components(), 1);
22423 var import_element61 = __toESM(require_element(), 1);
22424 var import_i18n34 = __toESM(require_i18n(), 1);
22425 var import_date4 = __toESM(require_date(), 1);
22426 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22427 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components32.privateApis);
22428 var DATE_PRESETS = [
22429 {
22430 id: "today",
22431 label: (0, import_i18n34.__)("Today"),
22432 getValue: () => (0, import_date4.getDate)(null)
22433 },
22434 {
22435 id: "yesterday",
22436 label: (0, import_i18n34.__)("Yesterday"),
22437 getValue: () => {
22438 const today = (0, import_date4.getDate)(null);
22439 return subDays(today, 1);
22440 }
22441 },
22442 {
22443 id: "past-week",
22444 label: (0, import_i18n34.__)("Past week"),
22445 getValue: () => {
22446 const today = (0, import_date4.getDate)(null);
22447 return subDays(today, 7);
22448 }
22449 },
22450 {
22451 id: "past-month",
22452 label: (0, import_i18n34.__)("Past month"),
22453 getValue: () => {
22454 const today = (0, import_date4.getDate)(null);
22455 return subMonths(today, 1);
22456 }
22457 }
22458 ];
22459 var DATE_RANGE_PRESETS = [
22460 {
22461 id: "last-7-days",
22462 label: (0, import_i18n34.__)("Last 7 days"),
22463 getValue: () => {
22464 const today = (0, import_date4.getDate)(null);
22465 return [subDays(today, 7), today];
22466 }
22467 },
22468 {
22469 id: "last-30-days",
22470 label: (0, import_i18n34.__)("Last 30 days"),
22471 getValue: () => {
22472 const today = (0, import_date4.getDate)(null);
22473 return [subDays(today, 30), today];
22474 }
22475 },
22476 {
22477 id: "month-to-date",
22478 label: (0, import_i18n34.__)("Month to date"),
22479 getValue: () => {
22480 const today = (0, import_date4.getDate)(null);
22481 return [startOfMonth(today), today];
22482 }
22483 },
22484 {
22485 id: "last-year",
22486 label: (0, import_i18n34.__)("Last year"),
22487 getValue: () => {
22488 const today = (0, import_date4.getDate)(null);
22489 return [subYears(today, 1), today];
22490 }
22491 },
22492 {
22493 id: "year-to-date",
22494 label: (0, import_i18n34.__)("Year to date"),
22495 getValue: () => {
22496 const today = (0, import_date4.getDate)(null);
22497 return [startOfYear(today), today];
22498 }
22499 }
22500 ];
22501 var parseDate = (dateString) => {
22502 if (!dateString) {
22503 return null;
22504 }
22505 const parsed = (0, import_date4.getDate)(dateString);
22506 return parsed && isValid(parsed) ? parsed : null;
22507 };
22508 var formatDate = (date) => {
22509 if (!date) {
22510 return "";
22511 }
22512 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22513 };
22514 function ValidatedDateControl({
22515 field,
22516 validity,
22517 inputRefs,
22518 isTouched,
22519 setIsTouched,
22520 children
22521 }) {
22522 const { isValid: isValid2 } = field;
22523 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
22524 const validateRefs = (0, import_element61.useCallback)(() => {
22525 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22526 for (const ref of refs) {
22527 const input = ref.current;
22528 if (input && !input.validity.valid) {
22529 setCustomValidity({
22530 type: "invalid",
22531 message: input.validationMessage
22532 });
22533 return;
22534 }
22535 }
22536 setCustomValidity(void 0);
22537 }, [inputRefs]);
22538 (0, import_element61.useEffect)(() => {
22539 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22540 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22541 for (const ref of refs) {
22542 const input = ref.current;
22543 if (input) {
22544 input.setCustomValidity(
22545 result?.type === "invalid" && result.message ? result.message : ""
22546 );
22547 }
22548 }
22549 }, [inputRefs, isValid2, validity]);
22550 (0, import_element61.useEffect)(() => {
22551 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22552 const handleInvalid = (event) => {
22553 event.preventDefault();
22554 setIsTouched(true);
22555 };
22556 for (const ref of refs) {
22557 ref.current?.addEventListener("invalid", handleInvalid);
22558 }
22559 return () => {
22560 for (const ref of refs) {
22561 ref.current?.removeEventListener("invalid", handleInvalid);
22562 }
22563 };
22564 }, [inputRefs, setIsTouched]);
22565 (0, import_element61.useEffect)(() => {
22566 if (!isTouched) {
22567 return;
22568 }
22569 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22570 if (result) {
22571 setCustomValidity(result);
22572 } else {
22573 validateRefs();
22574 }
22575 }, [isTouched, isValid2, validity, validateRefs]);
22576 const onBlur = (event) => {
22577 if (isTouched) {
22578 return;
22579 }
22580 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
22581 setIsTouched(true);
22582 }
22583 };
22584 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { onBlur, children: [
22585 children,
22586 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22587 "p",
22588 {
22589 className: clsx_default(
22590 "components-validated-control__indicator",
22591 customValidity.type === "invalid" ? "is-invalid" : void 0
22592 ),
22593 children: [
22594 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22595 import_components32.Icon,
22596 {
22597 className: "components-validated-control__indicator-icon",
22598 icon: error_default,
22599 size: 16,
22600 fill: "currentColor"
22601 }
22602 ),
22603 customValidity.message
22604 ]
22605 }
22606 ) })
22607 ] });
22608 }
22609 function CalendarDateControl({
22610 data,
22611 field,
22612 onChange,
22613 hideLabelFromVision,
22614 markWhenOptional,
22615 validity
22616 }) {
22617 const {
22618 id,
22619 label,
22620 description,
22621 setValue,
22622 getValue,
22623 isValid: isValid2,
22624 format: fieldFormat
22625 } = field;
22626 const disabled2 = field.isDisabled({ item: data, field });
22627 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
22628 null
22629 );
22630 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22631 const fieldValue = getValue({ item: data });
22632 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22633 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
22634 const parsedDate = parseDate(value);
22635 return parsedDate || /* @__PURE__ */ new Date();
22636 });
22637 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
22638 const validityTargetRef = (0, import_element61.useRef)(null);
22639 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22640 const onChangeCallback = (0, import_element61.useCallback)(
22641 (newValue) => onChange(setValue({ item: data, value: newValue })),
22642 [data, onChange, setValue]
22643 );
22644 const onSelectDate = (0, import_element61.useCallback)(
22645 (newDate) => {
22646 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
22647 onChangeCallback(dateValue);
22648 setSelectedPresetId(null);
22649 setIsTouched(true);
22650 },
22651 [onChangeCallback]
22652 );
22653 const handlePresetClick = (0, import_element61.useCallback)(
22654 (preset) => {
22655 const presetDate = preset.getValue();
22656 const dateValue = formatDate(presetDate);
22657 setCalendarMonth(presetDate);
22658 onChangeCallback(dateValue);
22659 setSelectedPresetId(preset.id);
22660 setIsTouched(true);
22661 },
22662 [onChangeCallback]
22663 );
22664 const handleManualDateChange = (0, import_element61.useCallback)(
22665 (newValue) => {
22666 onChangeCallback(newValue);
22667 if (newValue) {
22668 const parsedDate = parseDate(newValue);
22669 if (parsedDate) {
22670 setCalendarMonth(parsedDate);
22671 }
22672 }
22673 setSelectedPresetId(null);
22674 setIsTouched(true);
22675 },
22676 [onChangeCallback]
22677 );
22678 const {
22679 timezone: { string: timezoneString }
22680 } = (0, import_date4.getSettings)();
22681 let displayLabel = label;
22682 if (isValid2?.required && !markWhenOptional) {
22683 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
22684 } else if (!isValid2?.required && markWhenOptional) {
22685 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
22686 }
22687 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22688 ValidatedDateControl,
22689 {
22690 field,
22691 validity,
22692 inputRefs: validityTargetRef,
22693 isTouched,
22694 setIsTouched,
22695 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22696 import_components32.BaseControl,
22697 {
22698 id,
22699 className: "dataviews-controls__date",
22700 label: displayLabel,
22701 help: description,
22702 hideLabelFromVision,
22703 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22704 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22705 Stack,
22706 {
22707 direction: "row",
22708 gap: "sm",
22709 wrap: "wrap",
22710 justify: "flex-start",
22711 children: [
22712 DATE_PRESETS.map((preset) => {
22713 const isSelected2 = selectedPresetId === preset.id;
22714 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22715 import_components32.Button,
22716 {
22717 className: "dataviews-controls__date-preset",
22718 variant: "tertiary",
22719 isPressed: isSelected2,
22720 size: "small",
22721 disabled: disabled2,
22722 accessibleWhenDisabled: true,
22723 onClick: () => handlePresetClick(preset),
22724 children: preset.label
22725 },
22726 preset.id
22727 );
22728 }),
22729 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22730 import_components32.Button,
22731 {
22732 className: "dataviews-controls__date-preset",
22733 variant: "tertiary",
22734 isPressed: !selectedPresetId,
22735 size: "small",
22736 disabled: !!selectedPresetId || disabled2,
22737 accessibleWhenDisabled: true,
22738 children: (0, import_i18n34.__)("Custom")
22739 }
22740 )
22741 ]
22742 }
22743 ),
22744 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22745 import_components32.__experimentalInputControl,
22746 {
22747 __next40pxDefaultSize: true,
22748 ref: validityTargetRef,
22749 type: "date",
22750 label: (0, import_i18n34.__)("Date"),
22751 hideLabelFromVision: true,
22752 value,
22753 onChange: handleManualDateChange,
22754 required: !!field.isValid?.required,
22755 disabled: disabled2,
22756 min: minConstraint,
22757 max: maxConstraint
22758 }
22759 ),
22760 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22761 DateCalendar2,
22762 {
22763 style: { width: "100%" },
22764 selected: value ? parseDate(value) || void 0 : void 0,
22765 onSelect: onSelectDate,
22766 month: calendarMonth,
22767 onMonthChange: setCalendarMonth,
22768 timeZone: timezoneString || void 0,
22769 weekStartsOn,
22770 disabled: disabled2 || disabledMatchers,
22771 disableNavigation: disabled2
22772 }
22773 )
22774 ] })
22775 }
22776 )
22777 }
22778 );
22779 }
22780 function CalendarDateRangeControl({
22781 data,
22782 field,
22783 onChange,
22784 hideLabelFromVision,
22785 markWhenOptional,
22786 validity
22787 }) {
22788 const {
22789 id,
22790 label,
22791 description,
22792 getValue,
22793 setValue,
22794 isValid: isValid2,
22795 format: fieldFormat
22796 } = field;
22797 const disabled2 = field.isDisabled({ item: data, field });
22798 let value;
22799 const fieldValue = getValue({ item: data });
22800 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
22801 value = fieldValue;
22802 }
22803 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22804 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22805 const onChangeCallback = (0, import_element61.useCallback)(
22806 (newValue) => {
22807 onChange(
22808 setValue({
22809 item: data,
22810 value: newValue
22811 })
22812 );
22813 },
22814 [data, onChange, setValue]
22815 );
22816 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
22817 null
22818 );
22819 const selectedRange = (0, import_element61.useMemo)(() => {
22820 if (!value) {
22821 return { from: void 0, to: void 0 };
22822 }
22823 const [from, to] = value;
22824 return {
22825 from: parseDate(from) || void 0,
22826 to: parseDate(to) || void 0
22827 };
22828 }, [value]);
22829 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
22830 return selectedRange.from || /* @__PURE__ */ new Date();
22831 });
22832 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
22833 const fromInputRef = (0, import_element61.useRef)(null);
22834 const toInputRef = (0, import_element61.useRef)(null);
22835 const updateDateRange = (0, import_element61.useCallback)(
22836 (fromDate, toDate2) => {
22837 if (fromDate && toDate2) {
22838 onChangeCallback([
22839 formatDate(fromDate),
22840 formatDate(toDate2)
22841 ]);
22842 } else if (!fromDate && !toDate2) {
22843 onChangeCallback(void 0);
22844 }
22845 },
22846 [onChangeCallback]
22847 );
22848 const onSelectCalendarRange = (0, import_element61.useCallback)(
22849 (newRange) => {
22850 updateDateRange(newRange?.from, newRange?.to);
22851 setSelectedPresetId(null);
22852 setIsTouched(true);
22853 },
22854 [updateDateRange]
22855 );
22856 const handlePresetClick = (0, import_element61.useCallback)(
22857 (preset) => {
22858 const [startDate, endDate] = preset.getValue();
22859 setCalendarMonth(startDate);
22860 updateDateRange(startDate, endDate);
22861 setSelectedPresetId(preset.id);
22862 setIsTouched(true);
22863 },
22864 [updateDateRange]
22865 );
22866 const handleManualDateChange = (0, import_element61.useCallback)(
22867 (fromOrTo, newValue) => {
22868 const [currentFrom, currentTo] = value || [
22869 void 0,
22870 void 0
22871 ];
22872 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
22873 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
22874 updateDateRange(updatedFrom, updatedTo);
22875 if (newValue) {
22876 const parsedDate = parseDate(newValue);
22877 if (parsedDate) {
22878 setCalendarMonth(parsedDate);
22879 }
22880 }
22881 setSelectedPresetId(null);
22882 setIsTouched(true);
22883 },
22884 [value, updateDateRange]
22885 );
22886 const { timezone } = (0, import_date4.getSettings)();
22887 let displayLabel = label;
22888 if (field.isValid?.required && !markWhenOptional) {
22889 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
22890 } else if (!field.isValid?.required && markWhenOptional) {
22891 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
22892 }
22893 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22894 ValidatedDateControl,
22895 {
22896 field,
22897 validity,
22898 inputRefs: [fromInputRef, toInputRef],
22899 isTouched,
22900 setIsTouched,
22901 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22902 import_components32.BaseControl,
22903 {
22904 id,
22905 className: "dataviews-controls__date",
22906 label: displayLabel,
22907 help: description,
22908 hideLabelFromVision,
22909 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22910 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22911 Stack,
22912 {
22913 direction: "row",
22914 gap: "sm",
22915 wrap: "wrap",
22916 justify: "flex-start",
22917 children: [
22918 DATE_RANGE_PRESETS.map((preset) => {
22919 const isSelected2 = selectedPresetId === preset.id;
22920 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22921 import_components32.Button,
22922 {
22923 className: "dataviews-controls__date-preset",
22924 variant: "tertiary",
22925 isPressed: isSelected2,
22926 size: "small",
22927 disabled: disabled2,
22928 accessibleWhenDisabled: true,
22929 onClick: () => handlePresetClick(preset),
22930 children: preset.label
22931 },
22932 preset.id
22933 );
22934 }),
22935 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22936 import_components32.Button,
22937 {
22938 className: "dataviews-controls__date-preset",
22939 variant: "tertiary",
22940 isPressed: !selectedPresetId,
22941 size: "small",
22942 accessibleWhenDisabled: true,
22943 disabled: !!selectedPresetId || disabled2,
22944 children: (0, import_i18n34.__)("Custom")
22945 }
22946 )
22947 ]
22948 }
22949 ),
22950 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22951 Stack,
22952 {
22953 direction: "row",
22954 gap: "sm",
22955 justify: "space-between",
22956 className: "dataviews-controls__date-range-inputs",
22957 children: [
22958 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22959 import_components32.__experimentalInputControl,
22960 {
22961 __next40pxDefaultSize: true,
22962 ref: fromInputRef,
22963 type: "date",
22964 label: (0, import_i18n34.__)("From"),
22965 hideLabelFromVision: true,
22966 value: value?.[0],
22967 onChange: (newValue) => handleManualDateChange("from", newValue),
22968 required: !!field.isValid?.required,
22969 disabled: disabled2,
22970 min: minConstraint,
22971 max: maxConstraint
22972 }
22973 ),
22974 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22975 import_components32.__experimentalInputControl,
22976 {
22977 __next40pxDefaultSize: true,
22978 ref: toInputRef,
22979 type: "date",
22980 label: (0, import_i18n34.__)("To"),
22981 hideLabelFromVision: true,
22982 value: value?.[1],
22983 onChange: (newValue) => handleManualDateChange("to", newValue),
22984 required: !!field.isValid?.required,
22985 disabled: disabled2,
22986 min: minConstraint,
22987 max: maxConstraint
22988 }
22989 )
22990 ]
22991 }
22992 ),
22993 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22994 DateRangeCalendar,
22995 {
22996 style: { width: "100%" },
22997 selected: selectedRange,
22998 onSelect: onSelectCalendarRange,
22999 month: calendarMonth,
23000 onMonthChange: setCalendarMonth,
23001 timeZone: timezone.string || void 0,
23002 weekStartsOn,
23003 disabled: disabled2 || disabledMatchers
23004 }
23005 )
23006 ] })
23007 }
23008 )
23009 }
23010 );
23011 }
23012 function DateControl({
23013 data,
23014 field,
23015 onChange,
23016 hideLabelFromVision,
23017 markWhenOptional,
23018 operator,
23019 validity
23020 }) {
23021 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23022 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23023 RelativeDateControl,
23024 {
23025 className: "dataviews-controls__date",
23026 data,
23027 field,
23028 onChange,
23029 hideLabelFromVision,
23030 operator
23031 }
23032 );
23033 }
23034 if (operator === OPERATOR_BETWEEN) {
23035 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23036 CalendarDateRangeControl,
23037 {
23038 data,
23039 field,
23040 onChange,
23041 hideLabelFromVision,
23042 markWhenOptional,
23043 validity
23044 }
23045 );
23046 }
23047 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23048 CalendarDateControl,
23049 {
23050 data,
23051 field,
23052 onChange,
23053 hideLabelFromVision,
23054 markWhenOptional,
23055 validity
23056 }
23057 );
23058 }
23059
23060 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23061 var import_components33 = __toESM(require_components(), 1);
23062 var import_element62 = __toESM(require_element(), 1);
23063 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23064 var { ValidatedSelectControl } = unlock3(import_components33.privateApis);
23065 function Select({
23066 data,
23067 field,
23068 onChange,
23069 hideLabelFromVision,
23070 markWhenOptional,
23071 validity
23072 }) {
23073 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23074 const disabled2 = field.isDisabled({ item: data, field });
23075 const isMultiple = type === "array";
23076 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23077 const onChangeControl = (0, import_element62.useCallback)(
23078 (newValue) => onChange(setValue({ item: data, value: newValue })),
23079 [data, onChange, setValue]
23080 );
23081 const { elements, isLoading } = useElements({
23082 elements: field.elements,
23083 getElements: field.getElements
23084 });
23085 if (isLoading) {
23086 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components33.Spinner, {});
23087 }
23088 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
23089 ValidatedSelectControl,
23090 {
23091 required: !!field.isValid?.required,
23092 markWhenOptional,
23093 customValidity: getCustomValidity(isValid2, validity),
23094 label,
23095 value,
23096 help: description,
23097 options: elements,
23098 onChange: onChangeControl,
23099 __next40pxDefaultSize: true,
23100 hideLabelFromVision,
23101 multiple: isMultiple,
23102 disabled: disabled2
23103 }
23104 );
23105 }
23106
23107 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23108 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23109 var ELEMENTS_THRESHOLD = 10;
23110 function AdaptiveSelect(props) {
23111 const { field } = props;
23112 const { elements } = useElements({
23113 elements: field.elements,
23114 getElements: field.getElements
23115 });
23116 if (elements.length >= ELEMENTS_THRESHOLD) {
23117 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Combobox3, { ...props });
23118 }
23119 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Select, { ...props });
23120 }
23121
23122 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23123 var import_components35 = __toESM(require_components(), 1);
23124
23125 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23126 var import_components34 = __toESM(require_components(), 1);
23127 var import_element63 = __toESM(require_element(), 1);
23128 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23129 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components34.privateApis);
23130 function ValidatedText({
23131 data,
23132 field,
23133 onChange,
23134 hideLabelFromVision,
23135 markWhenOptional,
23136 type,
23137 prefix,
23138 suffix,
23139 validity
23140 }) {
23141 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23142 const value = getValue({ item: data });
23143 const disabled2 = field.isDisabled({ item: data, field });
23144 const onChangeControl = (0, import_element63.useCallback)(
23145 (newValue) => onChange(
23146 setValue({
23147 item: data,
23148 value: newValue
23149 })
23150 ),
23151 [data, setValue, onChange]
23152 );
23153 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23154 ValidatedInputControl2,
23155 {
23156 required: !!isValid2.required,
23157 markWhenOptional,
23158 customValidity: getCustomValidity(isValid2, validity),
23159 label,
23160 placeholder,
23161 value: value ?? "",
23162 help: description,
23163 onChange: onChangeControl,
23164 hideLabelFromVision,
23165 type,
23166 prefix,
23167 suffix,
23168 disabled: disabled2,
23169 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23170 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23171 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23172 __next40pxDefaultSize: true
23173 }
23174 );
23175 }
23176
23177 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23178 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23179 function Email({
23180 data,
23181 field,
23182 onChange,
23183 hideLabelFromVision,
23184 markWhenOptional,
23185 validity
23186 }) {
23187 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23188 ValidatedText,
23189 {
23190 ...{
23191 data,
23192 field,
23193 onChange,
23194 hideLabelFromVision,
23195 markWhenOptional,
23196 validity,
23197 type: "email",
23198 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.Icon, { icon: envelope_default }) })
23199 }
23200 }
23201 );
23202 }
23203
23204 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23205 var import_components36 = __toESM(require_components(), 1);
23206 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23207 function Telephone({
23208 data,
23209 field,
23210 onChange,
23211 hideLabelFromVision,
23212 markWhenOptional,
23213 validity
23214 }) {
23215 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23216 ValidatedText,
23217 {
23218 ...{
23219 data,
23220 field,
23221 onChange,
23222 hideLabelFromVision,
23223 markWhenOptional,
23224 validity,
23225 type: "tel",
23226 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.Icon, { icon: mobile_default }) })
23227 }
23228 }
23229 );
23230 }
23231
23232 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23233 var import_components37 = __toESM(require_components(), 1);
23234 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23235 function Url({
23236 data,
23237 field,
23238 onChange,
23239 hideLabelFromVision,
23240 markWhenOptional,
23241 validity
23242 }) {
23243 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23244 ValidatedText,
23245 {
23246 ...{
23247 data,
23248 field,
23249 onChange,
23250 hideLabelFromVision,
23251 markWhenOptional,
23252 validity,
23253 type: "url",
23254 prefix: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.Icon, { icon: link_default }) })
23255 }
23256 }
23257 );
23258 }
23259
23260 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23261 var import_components38 = __toESM(require_components(), 1);
23262 var import_element64 = __toESM(require_element(), 1);
23263 var import_i18n35 = __toESM(require_i18n(), 1);
23264 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23265 var { ValidatedNumberControl } = unlock3(import_components38.privateApis);
23266 function toNumberOrEmpty(value) {
23267 if (value === "" || value === void 0) {
23268 return "";
23269 }
23270 const number = Number(value);
23271 return Number.isFinite(number) ? number : "";
23272 }
23273 function BetweenControls({
23274 value,
23275 onChange,
23276 hideLabelFromVision,
23277 step
23278 }) {
23279 const [min2 = "", max2 = ""] = value;
23280 const onChangeMin = (0, import_element64.useCallback)(
23281 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23282 [onChange, max2]
23283 );
23284 const onChangeMax = (0, import_element64.useCallback)(
23285 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23286 [onChange, min2]
23287 );
23288 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23289 import_components38.BaseControl,
23290 {
23291 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23292 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23293 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23294 import_components38.__experimentalNumberControl,
23295 {
23296 label: (0, import_i18n35.__)("Min."),
23297 value: min2,
23298 max: max2 ? Number(max2) - step : void 0,
23299 onChange: onChangeMin,
23300 __next40pxDefaultSize: true,
23301 hideLabelFromVision,
23302 step
23303 }
23304 ),
23305 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23306 import_components38.__experimentalNumberControl,
23307 {
23308 label: (0, import_i18n35.__)("Max."),
23309 value: max2,
23310 min: min2 ? Number(min2) + step : void 0,
23311 onChange: onChangeMax,
23312 __next40pxDefaultSize: true,
23313 hideLabelFromVision,
23314 step
23315 }
23316 )
23317 ] })
23318 }
23319 );
23320 }
23321 function ValidatedNumber({
23322 data,
23323 field,
23324 onChange,
23325 hideLabelFromVision,
23326 markWhenOptional,
23327 operator,
23328 validity
23329 }) {
23330 const decimals = field.format?.decimals ?? 0;
23331 const step = Math.pow(10, Math.abs(decimals) * -1);
23332 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23333 const value = getValue({ item: data }) ?? "";
23334 const disabled2 = field.isDisabled({ item: data, field });
23335 const onChangeControl = (0, import_element64.useCallback)(
23336 (newValue) => {
23337 onChange(
23338 setValue({
23339 item: data,
23340 // Do not convert an empty string or undefined to a number,
23341 // otherwise there's a mismatch between the UI control (empty)
23342 // and the data relied by onChange (0).
23343 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23344 })
23345 );
23346 },
23347 [data, onChange, setValue]
23348 );
23349 const onChangeBetweenControls = (0, import_element64.useCallback)(
23350 (newValue) => {
23351 onChange(
23352 setValue({
23353 item: data,
23354 value: newValue
23355 })
23356 );
23357 },
23358 [data, onChange, setValue]
23359 );
23360 if (operator === OPERATOR_BETWEEN) {
23361 let valueBetween = ["", ""];
23362 if (Array.isArray(value) && value.length === 2 && value.every(
23363 (element) => typeof element === "number" || element === ""
23364 )) {
23365 valueBetween = value;
23366 }
23367 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23368 BetweenControls,
23369 {
23370 value: valueBetween,
23371 onChange: onChangeBetweenControls,
23372 hideLabelFromVision,
23373 step
23374 }
23375 );
23376 }
23377 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23378 ValidatedNumberControl,
23379 {
23380 required: !!isValid2.required,
23381 markWhenOptional,
23382 customValidity: getCustomValidity(isValid2, validity),
23383 label,
23384 help: description,
23385 value,
23386 onChange: onChangeControl,
23387 __next40pxDefaultSize: true,
23388 hideLabelFromVision,
23389 step,
23390 min: isValid2.min ? isValid2.min.constraint : void 0,
23391 max: isValid2.max ? isValid2.max.constraint : void 0,
23392 disabled: disabled2
23393 }
23394 );
23395 }
23396
23397 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23398 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23399 function Integer(props) {
23400 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
23401 }
23402
23403 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23404 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23405 function Number2(props) {
23406 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ValidatedNumber, { ...props });
23407 }
23408
23409 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23410 var import_components39 = __toESM(require_components(), 1);
23411 var import_element65 = __toESM(require_element(), 1);
23412 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23413 var { ValidatedRadioControl } = unlock3(import_components39.privateApis);
23414 function Radio({
23415 data,
23416 field,
23417 onChange,
23418 hideLabelFromVision,
23419 markWhenOptional,
23420 validity
23421 }) {
23422 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23423 const disabled2 = field.isDisabled({ item: data, field });
23424 const { elements, isLoading } = useElements({
23425 elements: field.elements,
23426 getElements: field.getElements
23427 });
23428 const value = getValue({ item: data });
23429 const onChangeControl = (0, import_element65.useCallback)(
23430 (newValue) => onChange(setValue({ item: data, value: newValue })),
23431 [data, onChange, setValue]
23432 );
23433 if (isLoading) {
23434 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components39.Spinner, {});
23435 }
23436 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23437 ValidatedRadioControl,
23438 {
23439 required: !!field.isValid?.required,
23440 markWhenOptional,
23441 customValidity: getCustomValidity(isValid2, validity),
23442 label,
23443 help: description,
23444 onChange: onChangeControl,
23445 options: elements,
23446 selected: value,
23447 hideLabelFromVision,
23448 disabled: disabled2
23449 }
23450 );
23451 }
23452
23453 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23454 var import_element66 = __toESM(require_element(), 1);
23455 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23456 function Text3({
23457 data,
23458 field,
23459 onChange,
23460 hideLabelFromVision,
23461 markWhenOptional,
23462 config,
23463 validity
23464 }) {
23465 const { prefix, suffix } = config || {};
23466 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23467 ValidatedText,
23468 {
23469 ...{
23470 data,
23471 field,
23472 onChange,
23473 hideLabelFromVision,
23474 markWhenOptional,
23475 validity,
23476 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
23477 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
23478 }
23479 }
23480 );
23481 }
23482
23483 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23484 var import_components40 = __toESM(require_components(), 1);
23485 var import_element67 = __toESM(require_element(), 1);
23486 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23487 var { ValidatedToggleControl } = unlock3(import_components40.privateApis);
23488 function Toggle({
23489 field,
23490 onChange,
23491 data,
23492 hideLabelFromVision,
23493 markWhenOptional,
23494 validity
23495 }) {
23496 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23497 const disabled2 = field.isDisabled({ item: data, field });
23498 const onChangeControl = (0, import_element67.useCallback)(() => {
23499 onChange(
23500 setValue({ item: data, value: !getValue({ item: data }) })
23501 );
23502 }, [onChange, setValue, data, getValue]);
23503 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23504 ValidatedToggleControl,
23505 {
23506 required: !!isValid2.required,
23507 markWhenOptional,
23508 customValidity: getCustomValidity(isValid2, validity),
23509 hidden: hideLabelFromVision,
23510 label,
23511 help: description,
23512 checked: getValue({ item: data }),
23513 onChange: onChangeControl,
23514 disabled: disabled2
23515 }
23516 );
23517 }
23518
23519 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23520 var import_components41 = __toESM(require_components(), 1);
23521 var import_element68 = __toESM(require_element(), 1);
23522 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23523 var { ValidatedTextareaControl } = unlock3(import_components41.privateApis);
23524 function Textarea({
23525 data,
23526 field,
23527 onChange,
23528 hideLabelFromVision,
23529 markWhenOptional,
23530 config,
23531 validity
23532 }) {
23533 const { rows = 4 } = config || {};
23534 const disabled2 = field.isDisabled({ item: data, field });
23535 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23536 const value = field.getValue({ item: data });
23537 const onChangeControl = (0, import_element68.useCallback)(
23538 (newValue) => onChange(setValue({ item: data, value: newValue })),
23539 [data, onChange, setValue]
23540 );
23541 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23542 ValidatedTextareaControl,
23543 {
23544 required: !!isValid2.required,
23545 markWhenOptional,
23546 customValidity: getCustomValidity(isValid2, validity),
23547 label,
23548 placeholder,
23549 value: value ?? "",
23550 help: description,
23551 onChange: onChangeControl,
23552 rows,
23553 disabled: disabled2,
23554 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23555 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23556 __next40pxDefaultSize: true,
23557 hideLabelFromVision
23558 }
23559 );
23560 }
23561
23562 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
23563 var import_components42 = __toESM(require_components(), 1);
23564 var import_element69 = __toESM(require_element(), 1);
23565 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23566 var { ValidatedToggleGroupControl } = unlock3(import_components42.privateApis);
23567 function ToggleGroup({
23568 data,
23569 field,
23570 onChange,
23571 hideLabelFromVision,
23572 markWhenOptional,
23573 validity
23574 }) {
23575 const { getValue, setValue, isValid: isValid2 } = field;
23576 const disabled2 = field.isDisabled({ item: data, field });
23577 const value = getValue({ item: data });
23578 const onChangeControl = (0, import_element69.useCallback)(
23579 (newValue) => onChange(setValue({ item: data, value: newValue })),
23580 [data, onChange, setValue]
23581 );
23582 const { elements, isLoading } = useElements({
23583 elements: field.elements,
23584 getElements: field.getElements
23585 });
23586 if (isLoading) {
23587 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components42.Spinner, {});
23588 }
23589 if (elements.length === 0) {
23590 return null;
23591 }
23592 const selectedOption = elements.find((el) => el.value === value);
23593 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23594 ValidatedToggleGroupControl,
23595 {
23596 required: !!field.isValid?.required,
23597 markWhenOptional,
23598 customValidity: getCustomValidity(isValid2, validity),
23599 __next40pxDefaultSize: true,
23600 isBlock: true,
23601 label: field.label,
23602 help: selectedOption?.description || field.description,
23603 onChange: onChangeControl,
23604 value,
23605 hideLabelFromVision,
23606 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23607 import_components42.__experimentalToggleGroupControlOption,
23608 {
23609 label: el.label,
23610 value: el.value,
23611 disabled: disabled2
23612 },
23613 el.value
23614 ))
23615 }
23616 );
23617 }
23618
23619 // packages/dataviews/build-module/components/dataform-controls/array.mjs
23620 var import_components43 = __toESM(require_components(), 1);
23621 var import_element70 = __toESM(require_element(), 1);
23622 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23623 var { ValidatedFormTokenField } = unlock3(import_components43.privateApis);
23624 function ArrayControl({
23625 data,
23626 field,
23627 onChange,
23628 hideLabelFromVision,
23629 markWhenOptional,
23630 validity
23631 }) {
23632 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23633 const value = getValue({ item: data });
23634 const disabled2 = field.isDisabled({ item: data, field });
23635 const { elements, isLoading } = useElements({
23636 elements: field.elements,
23637 getElements: field.getElements
23638 });
23639 const arrayValueAsElements = (0, import_element70.useMemo)(
23640 () => Array.isArray(value) ? value.map((token) => {
23641 const element = elements?.find(
23642 (suggestion) => suggestion.value === token
23643 );
23644 return element || { value: token, label: token };
23645 }) : [],
23646 [value, elements]
23647 );
23648 const onChangeControl = (0, import_element70.useCallback)(
23649 (tokens) => {
23650 const valueTokens = tokens.map((token) => {
23651 if (typeof token === "object" && "value" in token) {
23652 return token.value;
23653 }
23654 return token;
23655 });
23656 onChange(setValue({ item: data, value: valueTokens }));
23657 },
23658 [onChange, setValue, data]
23659 );
23660 if (isLoading) {
23661 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.Spinner, {});
23662 }
23663 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23664 ValidatedFormTokenField,
23665 {
23666 required: !!isValid2?.required,
23667 markWhenOptional,
23668 customValidity: getCustomValidity(isValid2, validity),
23669 label: hideLabelFromVision ? void 0 : label,
23670 value: arrayValueAsElements,
23671 onChange: onChangeControl,
23672 placeholder,
23673 suggestions: elements?.map((element) => element.value),
23674 disabled: disabled2,
23675 __experimentalValidateInput: (token) => {
23676 if (field.isValid?.elements && elements) {
23677 return elements.some(
23678 (element) => element.value === token || element.label === token
23679 );
23680 }
23681 return true;
23682 },
23683 __experimentalExpandOnFocus: elements && elements.length > 0,
23684 help: description ?? (field.isValid?.elements ? "" : void 0),
23685 displayTransform: (token) => {
23686 if (typeof token === "object" && "label" in token) {
23687 return token.label;
23688 }
23689 if (typeof token === "string" && elements) {
23690 const element = elements.find(
23691 (el) => el.value === token
23692 );
23693 return element?.label || token;
23694 }
23695 return token;
23696 },
23697 __experimentalRenderItem: ({ item }) => {
23698 if (typeof item === "string" && elements) {
23699 const element = elements.find(
23700 (el) => el.value === item
23701 );
23702 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { children: element?.label || item });
23703 }
23704 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { children: item });
23705 }
23706 }
23707 );
23708 }
23709
23710 // node_modules/colord/index.mjs
23711 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
23712 var t = function(r3) {
23713 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
23714 };
23715 var n = function(r3, t2, n2) {
23716 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
23717 };
23718 var e = function(r3, t2, n2) {
23719 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
23720 };
23721 var u = function(r3) {
23722 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
23723 };
23724 var a = function(r3) {
23725 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
23726 };
23727 var o = function(r3) {
23728 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
23729 };
23730 var i = /^#([0-9a-f]{3,8})$/i;
23731 var s = function(r3) {
23732 var t2 = r3.toString(16);
23733 return t2.length < 2 ? "0" + t2 : t2;
23734 };
23735 var h = function(r3) {
23736 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;
23737 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
23738 };
23739 var b = function(r3) {
23740 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
23741 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
23742 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;
23743 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 };
23744 };
23745 var g = function(r3) {
23746 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
23747 };
23748 var d = function(r3) {
23749 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
23750 };
23751 var f = function(r3) {
23752 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 }));
23753 var t2, n2, e2;
23754 };
23755 var c = function(r3) {
23756 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 };
23757 var t2, n2, e2, u2;
23758 };
23759 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23760 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23761 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23762 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23763 var y = { string: [[function(r3) {
23764 var t2 = i.exec(r3);
23765 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;
23766 }, "hex"], [function(r3) {
23767 var t2 = v.exec(r3) || m.exec(r3);
23768 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;
23769 }, "rgb"], [function(t2) {
23770 var n2 = l.exec(t2) || p.exec(t2);
23771 if (!n2) return null;
23772 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) });
23773 return f(a2);
23774 }, "hsl"]], object: [[function(r3) {
23775 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
23776 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
23777 }, "rgb"], [function(r3) {
23778 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
23779 if (!t(n2) || !t(e2) || !t(u2)) return null;
23780 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
23781 return f(i2);
23782 }, "hsl"], [function(r3) {
23783 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
23784 if (!t(n2) || !t(a2) || !t(o2)) return null;
23785 var h2 = (function(r4) {
23786 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
23787 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
23788 return b(h2);
23789 }, "hsv"]] };
23790 var N = function(r3, t2) {
23791 for (var n2 = 0; n2 < t2.length; n2++) {
23792 var e2 = t2[n2][0](r3);
23793 if (e2) return [e2, t2[n2][1]];
23794 }
23795 return [null, void 0];
23796 };
23797 var x = function(r3) {
23798 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
23799 };
23800 var M = function(r3, t2) {
23801 var n2 = c(r3);
23802 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
23803 };
23804 var H = function(r3) {
23805 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
23806 };
23807 var $ = function(r3, t2) {
23808 var n2 = c(r3);
23809 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
23810 };
23811 var j = (function() {
23812 function r3(r4) {
23813 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
23814 }
23815 return r3.prototype.isValid = function() {
23816 return null !== this.parsed;
23817 }, r3.prototype.brightness = function() {
23818 return n(H(this.rgba), 2);
23819 }, r3.prototype.isDark = function() {
23820 return H(this.rgba) < 0.5;
23821 }, r3.prototype.isLight = function() {
23822 return H(this.rgba) >= 0.5;
23823 }, r3.prototype.toHex = function() {
23824 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;
23825 var r4, t2, e2, u2, a2, i2;
23826 }, r3.prototype.toRgb = function() {
23827 return o(this.rgba);
23828 }, r3.prototype.toRgbString = function() {
23829 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 + ")";
23830 var r4, t2, n2, e2, u2;
23831 }, r3.prototype.toHsl = function() {
23832 return d(c(this.rgba));
23833 }, r3.prototype.toHslString = function() {
23834 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 + "%)";
23835 var r4, t2, n2, e2, u2;
23836 }, r3.prototype.toHsv = function() {
23837 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
23838 var r4;
23839 }, r3.prototype.invert = function() {
23840 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
23841 var r4;
23842 }, r3.prototype.saturate = function(r4) {
23843 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
23844 }, r3.prototype.desaturate = function(r4) {
23845 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
23846 }, r3.prototype.grayscale = function() {
23847 return w(M(this.rgba, -1));
23848 }, r3.prototype.lighten = function(r4) {
23849 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
23850 }, r3.prototype.darken = function(r4) {
23851 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
23852 }, r3.prototype.rotate = function(r4) {
23853 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
23854 }, r3.prototype.alpha = function(r4) {
23855 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
23856 var t2;
23857 }, r3.prototype.hue = function(r4) {
23858 var t2 = c(this.rgba);
23859 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
23860 }, r3.prototype.isEqual = function(r4) {
23861 return this.toHex() === w(r4).toHex();
23862 }, r3;
23863 })();
23864 var w = function(r3) {
23865 return r3 instanceof j ? r3 : new j(r3);
23866 };
23867
23868 // packages/dataviews/build-module/components/dataform-controls/color.mjs
23869 var import_components44 = __toESM(require_components(), 1);
23870 var import_element71 = __toESM(require_element(), 1);
23871 var import_i18n36 = __toESM(require_i18n(), 1);
23872 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23873 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components44.privateApis);
23874 var ColorPickerDropdown = ({
23875 color,
23876 onColorChange,
23877 disabled: disabled2
23878 }) => {
23879 const validColor = color && w(color).isValid() ? color : "#ffffff";
23880 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23881 import_components44.Dropdown,
23882 {
23883 className: "dataviews-controls__color-picker-dropdown",
23884 popoverProps: { resize: false },
23885 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23886 import_components44.Button,
23887 {
23888 onClick: onToggle,
23889 "aria-label": (0, import_i18n36.__)("Open color picker"),
23890 size: "small",
23891 disabled: disabled2,
23892 accessibleWhenDisabled: true,
23893 icon: () => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
23894 }
23895 ),
23896 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23897 import_components44.ColorPicker,
23898 {
23899 color: validColor,
23900 onChange: onColorChange,
23901 enableAlpha: true
23902 }
23903 ) })
23904 }
23905 );
23906 };
23907 function Color({
23908 data,
23909 field,
23910 onChange,
23911 hideLabelFromVision,
23912 markWhenOptional,
23913 validity
23914 }) {
23915 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23916 const disabled2 = field.isDisabled({ item: data, field });
23917 const value = field.getValue({ item: data }) || "";
23918 const handleColorChange = (0, import_element71.useCallback)(
23919 (newColor) => {
23920 onChange(setValue({ item: data, value: newColor }));
23921 },
23922 [data, onChange, setValue]
23923 );
23924 const handleInputChange = (0, import_element71.useCallback)(
23925 (newValue) => {
23926 onChange(setValue({ item: data, value: newValue || "" }));
23927 },
23928 [data, onChange, setValue]
23929 );
23930 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23931 ValidatedInputControl3,
23932 {
23933 required: !!field.isValid?.required,
23934 markWhenOptional,
23935 customValidity: getCustomValidity(isValid2, validity),
23936 label,
23937 placeholder,
23938 value,
23939 help: description,
23940 onChange: handleInputChange,
23941 hideLabelFromVision,
23942 type: "text",
23943 disabled: disabled2,
23944 prefix: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23945 ColorPickerDropdown,
23946 {
23947 color: value,
23948 onColorChange: handleColorChange,
23949 disabled: disabled2
23950 }
23951 ) })
23952 }
23953 );
23954 }
23955
23956 // packages/dataviews/build-module/components/dataform-controls/password.mjs
23957 var import_components45 = __toESM(require_components(), 1);
23958 var import_element72 = __toESM(require_element(), 1);
23959 var import_i18n37 = __toESM(require_i18n(), 1);
23960 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23961 function Password({
23962 data,
23963 field,
23964 onChange,
23965 hideLabelFromVision,
23966 markWhenOptional,
23967 validity
23968 }) {
23969 const [isVisible2, setIsVisible] = (0, import_element72.useState)(false);
23970 const disabled2 = field.isDisabled({ item: data, field });
23971 const toggleVisibility = (0, import_element72.useCallback)(() => {
23972 setIsVisible((prev) => !prev);
23973 }, []);
23974 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23975 ValidatedText,
23976 {
23977 ...{
23978 data,
23979 field,
23980 onChange,
23981 hideLabelFromVision,
23982 markWhenOptional,
23983 validity,
23984 type: isVisible2 ? "text" : "password",
23985 suffix: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23986 import_components45.Button,
23987 {
23988 icon: isVisible2 ? unseen_default : seen_default,
23989 onClick: toggleVisibility,
23990 size: "small",
23991 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
23992 disabled: disabled2,
23993 accessibleWhenDisabled: true
23994 }
23995 ) })
23996 }
23997 }
23998 );
23999 }
24000
24001 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24002 function hasElements(field) {
24003 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24004 }
24005
24006 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24007 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24008 var FORM_CONTROLS = {
24009 adaptiveSelect: AdaptiveSelect,
24010 array: ArrayControl,
24011 checkbox: Checkbox,
24012 color: Color,
24013 combobox: Combobox3,
24014 datetime: DateTime,
24015 date: DateControl,
24016 email: Email,
24017 telephone: Telephone,
24018 url: Url,
24019 integer: Integer,
24020 number: Number2,
24021 password: Password,
24022 radio: Radio,
24023 select: Select,
24024 text: Text3,
24025 toggle: Toggle,
24026 textarea: Textarea,
24027 toggleGroup: ToggleGroup
24028 };
24029 function isEditConfig(value) {
24030 return value && typeof value === "object" && typeof value.control === "string";
24031 }
24032 function createConfiguredControl(config) {
24033 const { control, ...controlConfig } = config;
24034 const BaseControlType = getControlByType(control);
24035 if (BaseControlType === null) {
24036 return null;
24037 }
24038 return function ConfiguredControl(props) {
24039 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(BaseControlType, { ...props, config: controlConfig });
24040 };
24041 }
24042 function getControl(field, fallback) {
24043 if (typeof field.Edit === "function") {
24044 return field.Edit;
24045 }
24046 if (typeof field.Edit === "string") {
24047 return getControlByType(field.Edit);
24048 }
24049 if (isEditConfig(field.Edit)) {
24050 return createConfiguredControl(field.Edit);
24051 }
24052 if (hasElements(field) && field.type !== "array") {
24053 return getControlByType("adaptiveSelect");
24054 }
24055 if (fallback === null) {
24056 return null;
24057 }
24058 return getControlByType(fallback);
24059 }
24060 function getControlByType(type) {
24061 if (Object.keys(FORM_CONTROLS).includes(type)) {
24062 return FORM_CONTROLS[type];
24063 }
24064 return null;
24065 }
24066
24067 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24068 function getFilterBy(field, defaultOperators, validOperators) {
24069 if (field.filterBy === false) {
24070 return false;
24071 }
24072 const operators = field.filterBy?.operators?.filter(
24073 (op) => validOperators.includes(op)
24074 ) ?? defaultOperators;
24075 if (operators.length === 0) {
24076 return false;
24077 }
24078 return {
24079 isPrimary: !!field.filterBy?.isPrimary,
24080 operators
24081 };
24082 }
24083 var get_filter_by_default = getFilterBy;
24084
24085 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24086 var getValueFromId = (id) => ({ item }) => {
24087 const path = id.split(".");
24088 let value = item;
24089 for (const segment of path) {
24090 if (value.hasOwnProperty(segment)) {
24091 value = value[segment];
24092 } else {
24093 value = void 0;
24094 }
24095 }
24096 return value;
24097 };
24098 var get_value_from_id_default = getValueFromId;
24099
24100 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24101 var setValueFromId = (id) => ({ value }) => {
24102 const path = id.split(".");
24103 const result = {};
24104 let current = result;
24105 for (const segment of path.slice(0, -1)) {
24106 current[segment] = {};
24107 current = current[segment];
24108 }
24109 current[path.at(-1)] = value;
24110 return result;
24111 };
24112 var set_value_from_id_default = setValueFromId;
24113
24114 // packages/dataviews/build-module/field-types/email.mjs
24115 var import_i18n38 = __toESM(require_i18n(), 1);
24116
24117 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24118 function RenderFromElements({
24119 item,
24120 field
24121 }) {
24122 const { elements, isLoading } = useElements({
24123 elements: field.elements,
24124 getElements: field.getElements
24125 });
24126 const value = field.getValue({ item });
24127 if (isLoading) {
24128 return value;
24129 }
24130 if (elements.length === 0) {
24131 return value;
24132 }
24133 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24134 }
24135
24136 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24137 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24138 function render({
24139 item,
24140 field
24141 }) {
24142 if (field.hasElements) {
24143 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(RenderFromElements, { item, field });
24144 }
24145 return field.getValueFormatted({ item, field });
24146 }
24147
24148 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24149 var sort_text_default = (a2, b2, direction) => {
24150 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24151 };
24152
24153 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24154 function isValidRequired(item, field) {
24155 const value = field.getValue({ item });
24156 return ![void 0, "", null].includes(value);
24157 }
24158
24159 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24160 function isValidMinLength(item, field) {
24161 if (typeof field.isValid.minLength?.constraint !== "number") {
24162 return false;
24163 }
24164 const value = field.getValue({ item });
24165 if ([void 0, "", null].includes(value)) {
24166 return true;
24167 }
24168 return String(value).length >= field.isValid.minLength.constraint;
24169 }
24170
24171 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24172 function isValidMaxLength(item, field) {
24173 if (typeof field.isValid.maxLength?.constraint !== "number") {
24174 return false;
24175 }
24176 const value = field.getValue({ item });
24177 if ([void 0, "", null].includes(value)) {
24178 return true;
24179 }
24180 return String(value).length <= field.isValid.maxLength.constraint;
24181 }
24182
24183 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24184 function isValidPattern(item, field) {
24185 if (field.isValid.pattern?.constraint === void 0) {
24186 return true;
24187 }
24188 try {
24189 const regexp = new RegExp(field.isValid.pattern.constraint);
24190 const value = field.getValue({ item });
24191 if ([void 0, "", null].includes(value)) {
24192 return true;
24193 }
24194 return regexp.test(String(value));
24195 } catch {
24196 return false;
24197 }
24198 }
24199
24200 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24201 function isValidElements(item, field) {
24202 const elements = field.elements ?? [];
24203 const validValues = elements.map((el) => el.value);
24204 if (validValues.length === 0) {
24205 return true;
24206 }
24207 const value = field.getValue({ item });
24208 return [].concat(value).every((v2) => validValues.includes(v2));
24209 }
24210
24211 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24212 function getValueFormatted({
24213 item,
24214 field
24215 }) {
24216 return field.getValue({ item });
24217 }
24218 var get_value_formatted_default_default = getValueFormatted;
24219
24220 // packages/dataviews/build-module/field-types/email.mjs
24221 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])?)*$/;
24222 function isValidCustom(item, field) {
24223 const value = field.getValue({ item });
24224 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24225 return (0, import_i18n38.__)("Value must be a valid email address.");
24226 }
24227 return null;
24228 }
24229 var email_default = {
24230 type: "email",
24231 render,
24232 Edit: "email",
24233 sort: sort_text_default,
24234 enableSorting: true,
24235 enableGlobalSearch: false,
24236 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24237 validOperators: [
24238 OPERATOR_IS,
24239 OPERATOR_IS_NOT,
24240 OPERATOR_CONTAINS,
24241 OPERATOR_NOT_CONTAINS,
24242 OPERATOR_STARTS_WITH,
24243 // Multiple selection
24244 OPERATOR_IS_ANY,
24245 OPERATOR_IS_NONE,
24246 OPERATOR_IS_ALL,
24247 OPERATOR_IS_NOT_ALL
24248 ],
24249 format: {},
24250 getValueFormatted: get_value_formatted_default_default,
24251 validate: {
24252 required: isValidRequired,
24253 pattern: isValidPattern,
24254 minLength: isValidMinLength,
24255 maxLength: isValidMaxLength,
24256 elements: isValidElements,
24257 custom: isValidCustom
24258 }
24259 };
24260
24261 // packages/dataviews/build-module/field-types/integer.mjs
24262 var import_i18n39 = __toESM(require_i18n(), 1);
24263
24264 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24265 var sort_number_default = (a2, b2, direction) => {
24266 return direction === "asc" ? a2 - b2 : b2 - a2;
24267 };
24268
24269 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24270 function isValidMin(item, field) {
24271 if (typeof field.isValid.min?.constraint !== "number") {
24272 return false;
24273 }
24274 const value = field.getValue({ item });
24275 if ([void 0, "", null].includes(value)) {
24276 return true;
24277 }
24278 return Number(value) >= field.isValid.min.constraint;
24279 }
24280
24281 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24282 function isValidMax(item, field) {
24283 if (typeof field.isValid.max?.constraint !== "number") {
24284 return false;
24285 }
24286 const value = field.getValue({ item });
24287 if ([void 0, "", null].includes(value)) {
24288 return true;
24289 }
24290 return Number(value) <= field.isValid.max.constraint;
24291 }
24292
24293 // packages/dataviews/build-module/field-types/integer.mjs
24294 var format2 = {
24295 separatorThousand: ","
24296 };
24297 function getValueFormatted2({
24298 item,
24299 field
24300 }) {
24301 let value = field.getValue({ item });
24302 if (value === null || value === void 0) {
24303 return "";
24304 }
24305 value = Number(value);
24306 if (!Number.isFinite(value)) {
24307 return String(value);
24308 }
24309 let formatInteger;
24310 if (field.type !== "integer") {
24311 formatInteger = format2;
24312 } else {
24313 formatInteger = field.format;
24314 }
24315 const { separatorThousand } = formatInteger;
24316 const integerValue = Math.trunc(value);
24317 if (!separatorThousand) {
24318 return String(integerValue);
24319 }
24320 return String(integerValue).replace(
24321 /\B(?=(\d{3})+(?!\d))/g,
24322 separatorThousand
24323 );
24324 }
24325 function isValidCustom2(item, field) {
24326 const value = field.getValue({ item });
24327 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24328 return (0, import_i18n39.__)("Value must be an integer.");
24329 }
24330 return null;
24331 }
24332 var integer_default = {
24333 type: "integer",
24334 render,
24335 Edit: "integer",
24336 sort: sort_number_default,
24337 enableSorting: true,
24338 enableGlobalSearch: false,
24339 defaultOperators: [
24340 OPERATOR_IS,
24341 OPERATOR_IS_NOT,
24342 OPERATOR_LESS_THAN,
24343 OPERATOR_GREATER_THAN,
24344 OPERATOR_LESS_THAN_OR_EQUAL,
24345 OPERATOR_GREATER_THAN_OR_EQUAL,
24346 OPERATOR_BETWEEN
24347 ],
24348 validOperators: [
24349 // Single-selection
24350 OPERATOR_IS,
24351 OPERATOR_IS_NOT,
24352 OPERATOR_LESS_THAN,
24353 OPERATOR_GREATER_THAN,
24354 OPERATOR_LESS_THAN_OR_EQUAL,
24355 OPERATOR_GREATER_THAN_OR_EQUAL,
24356 OPERATOR_BETWEEN,
24357 // Multiple-selection
24358 OPERATOR_IS_ANY,
24359 OPERATOR_IS_NONE,
24360 OPERATOR_IS_ALL,
24361 OPERATOR_IS_NOT_ALL
24362 ],
24363 format: format2,
24364 getValueFormatted: getValueFormatted2,
24365 validate: {
24366 required: isValidRequired,
24367 min: isValidMin,
24368 max: isValidMax,
24369 elements: isValidElements,
24370 custom: isValidCustom2
24371 }
24372 };
24373
24374 // packages/dataviews/build-module/field-types/number.mjs
24375 var import_i18n40 = __toESM(require_i18n(), 1);
24376 var format3 = {
24377 separatorThousand: ",",
24378 separatorDecimal: ".",
24379 decimals: 2
24380 };
24381 function getValueFormatted3({
24382 item,
24383 field
24384 }) {
24385 let value = field.getValue({ item });
24386 if (value === null || value === void 0) {
24387 return "";
24388 }
24389 value = Number(value);
24390 if (!Number.isFinite(value)) {
24391 return String(value);
24392 }
24393 let formatNumber;
24394 if (field.type !== "number") {
24395 formatNumber = format3;
24396 } else {
24397 formatNumber = field.format;
24398 }
24399 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24400 const fixedValue = value.toFixed(decimals);
24401 const [integerPart, decimalPart] = fixedValue.split(".");
24402 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24403 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24404 }
24405 function isEmpty(value) {
24406 return value === "" || value === void 0 || value === null;
24407 }
24408 function isValidCustom3(item, field) {
24409 const value = field.getValue({ item });
24410 if (!isEmpty(value) && !Number.isFinite(value)) {
24411 return (0, import_i18n40.__)("Value must be a number.");
24412 }
24413 return null;
24414 }
24415 var number_default = {
24416 type: "number",
24417 render,
24418 Edit: "number",
24419 sort: sort_number_default,
24420 enableSorting: true,
24421 enableGlobalSearch: false,
24422 defaultOperators: [
24423 OPERATOR_IS,
24424 OPERATOR_IS_NOT,
24425 OPERATOR_LESS_THAN,
24426 OPERATOR_GREATER_THAN,
24427 OPERATOR_LESS_THAN_OR_EQUAL,
24428 OPERATOR_GREATER_THAN_OR_EQUAL,
24429 OPERATOR_BETWEEN
24430 ],
24431 validOperators: [
24432 // Single-selection
24433 OPERATOR_IS,
24434 OPERATOR_IS_NOT,
24435 OPERATOR_LESS_THAN,
24436 OPERATOR_GREATER_THAN,
24437 OPERATOR_LESS_THAN_OR_EQUAL,
24438 OPERATOR_GREATER_THAN_OR_EQUAL,
24439 OPERATOR_BETWEEN,
24440 // Multiple-selection
24441 OPERATOR_IS_ANY,
24442 OPERATOR_IS_NONE,
24443 OPERATOR_IS_ALL,
24444 OPERATOR_IS_NOT_ALL
24445 ],
24446 format: format3,
24447 getValueFormatted: getValueFormatted3,
24448 validate: {
24449 required: isValidRequired,
24450 min: isValidMin,
24451 max: isValidMax,
24452 elements: isValidElements,
24453 custom: isValidCustom3
24454 }
24455 };
24456
24457 // packages/dataviews/build-module/field-types/text.mjs
24458 var text_default = {
24459 type: "text",
24460 render,
24461 Edit: "text",
24462 sort: sort_text_default,
24463 enableSorting: true,
24464 enableGlobalSearch: false,
24465 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24466 validOperators: [
24467 // Single selection
24468 OPERATOR_IS,
24469 OPERATOR_IS_NOT,
24470 OPERATOR_CONTAINS,
24471 OPERATOR_NOT_CONTAINS,
24472 OPERATOR_STARTS_WITH,
24473 // Multiple selection
24474 OPERATOR_IS_ANY,
24475 OPERATOR_IS_NONE,
24476 OPERATOR_IS_ALL,
24477 OPERATOR_IS_NOT_ALL
24478 ],
24479 format: {},
24480 getValueFormatted: get_value_formatted_default_default,
24481 validate: {
24482 required: isValidRequired,
24483 pattern: isValidPattern,
24484 minLength: isValidMinLength,
24485 maxLength: isValidMaxLength,
24486 elements: isValidElements
24487 }
24488 };
24489
24490 // packages/dataviews/build-module/field-types/datetime.mjs
24491 var import_date7 = __toESM(require_date(), 1);
24492
24493 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24494 var import_date6 = __toESM(require_date(), 1);
24495 function parseDateLike(value) {
24496 if (!value) {
24497 return null;
24498 }
24499 if (!isValid(new Date(value))) {
24500 return null;
24501 }
24502 const parsed = (0, import_date6.getDate)(value);
24503 return parsed && isValid(parsed) ? parsed : null;
24504 }
24505 function validateDateLikeBoundary(item, field, boundary) {
24506 const constraint = field.isValid[boundary]?.constraint;
24507 if (typeof constraint !== "string") {
24508 return false;
24509 }
24510 const value = field.getValue({ item });
24511 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24512 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24513 return true;
24514 }
24515 const parsedConstraint = parseDateLike(constraint);
24516 const parsedValue = parseDateLike(String(boundaryValue));
24517 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24518 }
24519 function isValidMinDate(item, field) {
24520 return validateDateLikeBoundary(item, field, "min");
24521 }
24522 function isValidMaxDate(item, field) {
24523 return validateDateLikeBoundary(item, field, "max");
24524 }
24525
24526 // packages/dataviews/build-module/field-types/datetime.mjs
24527 var format4 = {
24528 datetime: (0, import_date7.getSettings)().formats.datetime,
24529 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24530 };
24531 function getValueFormatted4({
24532 item,
24533 field
24534 }) {
24535 const value = field.getValue({ item });
24536 if (["", void 0, null].includes(value)) {
24537 return "";
24538 }
24539 let formatDatetime;
24540 if (field.type !== "datetime") {
24541 formatDatetime = format4;
24542 } else {
24543 formatDatetime = field.format;
24544 }
24545 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
24546 }
24547 var sort = (a2, b2, direction) => {
24548 const timeA = new Date(a2).getTime();
24549 const timeB = new Date(b2).getTime();
24550 return direction === "asc" ? timeA - timeB : timeB - timeA;
24551 };
24552 var datetime_default = {
24553 type: "datetime",
24554 render,
24555 Edit: "datetime",
24556 sort,
24557 enableSorting: true,
24558 enableGlobalSearch: false,
24559 defaultOperators: [
24560 OPERATOR_ON,
24561 OPERATOR_NOT_ON,
24562 OPERATOR_BEFORE,
24563 OPERATOR_AFTER,
24564 OPERATOR_BEFORE_INC,
24565 OPERATOR_AFTER_INC,
24566 OPERATOR_IN_THE_PAST,
24567 OPERATOR_OVER
24568 ],
24569 validOperators: [
24570 OPERATOR_ON,
24571 OPERATOR_NOT_ON,
24572 OPERATOR_BEFORE,
24573 OPERATOR_AFTER,
24574 OPERATOR_BEFORE_INC,
24575 OPERATOR_AFTER_INC,
24576 OPERATOR_IN_THE_PAST,
24577 OPERATOR_OVER
24578 ],
24579 format: format4,
24580 getValueFormatted: getValueFormatted4,
24581 validate: {
24582 required: isValidRequired,
24583 elements: isValidElements,
24584 min: isValidMinDate,
24585 max: isValidMaxDate
24586 }
24587 };
24588
24589 // packages/dataviews/build-module/field-types/date.mjs
24590 var import_date8 = __toESM(require_date(), 1);
24591 var format5 = {
24592 date: (0, import_date8.getSettings)().formats.date,
24593 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
24594 };
24595 function getValueFormatted5({
24596 item,
24597 field
24598 }) {
24599 const value = field.getValue({ item });
24600 if (["", void 0, null].includes(value)) {
24601 return "";
24602 }
24603 let formatDate2;
24604 if (field.type !== "date") {
24605 formatDate2 = format5;
24606 } else {
24607 formatDate2 = field.format;
24608 }
24609 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
24610 }
24611 var sort2 = (a2, b2, direction) => {
24612 const timeA = new Date(a2).getTime();
24613 const timeB = new Date(b2).getTime();
24614 return direction === "asc" ? timeA - timeB : timeB - timeA;
24615 };
24616 var date_default = {
24617 type: "date",
24618 render,
24619 Edit: "date",
24620 sort: sort2,
24621 enableSorting: true,
24622 enableGlobalSearch: false,
24623 defaultOperators: [
24624 OPERATOR_ON,
24625 OPERATOR_NOT_ON,
24626 OPERATOR_BEFORE,
24627 OPERATOR_AFTER,
24628 OPERATOR_BEFORE_INC,
24629 OPERATOR_AFTER_INC,
24630 OPERATOR_IN_THE_PAST,
24631 OPERATOR_OVER,
24632 OPERATOR_BETWEEN
24633 ],
24634 validOperators: [
24635 OPERATOR_ON,
24636 OPERATOR_NOT_ON,
24637 OPERATOR_BEFORE,
24638 OPERATOR_AFTER,
24639 OPERATOR_BEFORE_INC,
24640 OPERATOR_AFTER_INC,
24641 OPERATOR_IN_THE_PAST,
24642 OPERATOR_OVER,
24643 OPERATOR_BETWEEN
24644 ],
24645 format: format5,
24646 getValueFormatted: getValueFormatted5,
24647 validate: {
24648 required: isValidRequired,
24649 elements: isValidElements,
24650 min: isValidMinDate,
24651 max: isValidMaxDate
24652 }
24653 };
24654
24655 // packages/dataviews/build-module/field-types/boolean.mjs
24656 var import_i18n41 = __toESM(require_i18n(), 1);
24657
24658 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
24659 function isValidRequiredForBool(item, field) {
24660 const value = field.getValue({ item });
24661 return value === true;
24662 }
24663
24664 // packages/dataviews/build-module/field-types/boolean.mjs
24665 function getValueFormatted6({
24666 item,
24667 field
24668 }) {
24669 const value = field.getValue({ item });
24670 if (value === true) {
24671 return (0, import_i18n41.__)("True");
24672 }
24673 if (value === false) {
24674 return (0, import_i18n41.__)("False");
24675 }
24676 return "";
24677 }
24678 function isValidCustom4(item, field) {
24679 const value = field.getValue({ item });
24680 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
24681 return (0, import_i18n41.__)("Value must be true, false, or undefined");
24682 }
24683 return null;
24684 }
24685 var sort3 = (a2, b2, direction) => {
24686 const boolA = Boolean(a2);
24687 const boolB = Boolean(b2);
24688 if (boolA === boolB) {
24689 return 0;
24690 }
24691 if (direction === "asc") {
24692 return boolA ? 1 : -1;
24693 }
24694 return boolA ? -1 : 1;
24695 };
24696 var boolean_default = {
24697 type: "boolean",
24698 render,
24699 Edit: "checkbox",
24700 sort: sort3,
24701 validate: {
24702 required: isValidRequiredForBool,
24703 elements: isValidElements,
24704 custom: isValidCustom4
24705 },
24706 enableSorting: true,
24707 enableGlobalSearch: false,
24708 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24709 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24710 format: {},
24711 getValueFormatted: getValueFormatted6
24712 };
24713
24714 // packages/dataviews/build-module/field-types/media.mjs
24715 var media_default = {
24716 type: "media",
24717 render: () => null,
24718 Edit: null,
24719 sort: () => 0,
24720 enableSorting: false,
24721 enableGlobalSearch: false,
24722 defaultOperators: [],
24723 validOperators: [],
24724 format: {},
24725 getValueFormatted: get_value_formatted_default_default,
24726 // cannot validate any constraint, so
24727 // the only available validation for the field author
24728 // would be providing a custom validator.
24729 validate: {}
24730 };
24731
24732 // packages/dataviews/build-module/field-types/array.mjs
24733 var import_i18n42 = __toESM(require_i18n(), 1);
24734
24735 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
24736 function isValidRequiredForArray(item, field) {
24737 const value = field.getValue({ item });
24738 return Array.isArray(value) && value.length > 0 && value.every(
24739 (element) => ![void 0, "", null].includes(element)
24740 );
24741 }
24742
24743 // packages/dataviews/build-module/field-types/array.mjs
24744 function getValueFormatted7({
24745 item,
24746 field
24747 }) {
24748 const value = field.getValue({ item });
24749 const arr = Array.isArray(value) ? value : [];
24750 return arr.join(", ");
24751 }
24752 function render2({ item, field }) {
24753 return getValueFormatted7({ item, field });
24754 }
24755 function isValidCustom5(item, field) {
24756 const value = field.getValue({ item });
24757 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
24758 return (0, import_i18n42.__)("Value must be an array.");
24759 }
24760 if (!value.every((v2) => typeof v2 === "string")) {
24761 return (0, import_i18n42.__)("Every value must be a string.");
24762 }
24763 return null;
24764 }
24765 var sort4 = (a2, b2, direction) => {
24766 const arrA = Array.isArray(a2) ? a2 : [];
24767 const arrB = Array.isArray(b2) ? b2 : [];
24768 if (arrA.length !== arrB.length) {
24769 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
24770 }
24771 const joinedA = arrA.join(",");
24772 const joinedB = arrB.join(",");
24773 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
24774 };
24775 var array_default = {
24776 type: "array",
24777 render: render2,
24778 Edit: "array",
24779 sort: sort4,
24780 enableSorting: true,
24781 enableGlobalSearch: false,
24782 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24783 validOperators: [
24784 OPERATOR_IS_ANY,
24785 OPERATOR_IS_NONE,
24786 OPERATOR_IS_ALL,
24787 OPERATOR_IS_NOT_ALL
24788 ],
24789 format: {},
24790 getValueFormatted: getValueFormatted7,
24791 validate: {
24792 required: isValidRequiredForArray,
24793 elements: isValidElements,
24794 custom: isValidCustom5
24795 }
24796 };
24797
24798 // packages/dataviews/build-module/field-types/password.mjs
24799 function getValueFormatted8({
24800 item,
24801 field
24802 }) {
24803 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
24804 }
24805 var password_default = {
24806 type: "password",
24807 render,
24808 Edit: "password",
24809 sort: () => 0,
24810 // Passwords should not be sortable for security reasons
24811 enableSorting: false,
24812 enableGlobalSearch: false,
24813 defaultOperators: [],
24814 validOperators: [],
24815 format: {},
24816 getValueFormatted: getValueFormatted8,
24817 validate: {
24818 required: isValidRequired,
24819 pattern: isValidPattern,
24820 minLength: isValidMinLength,
24821 maxLength: isValidMaxLength,
24822 elements: isValidElements
24823 }
24824 };
24825
24826 // packages/dataviews/build-module/field-types/telephone.mjs
24827 var telephone_default = {
24828 type: "telephone",
24829 render,
24830 Edit: "telephone",
24831 sort: sort_text_default,
24832 enableSorting: true,
24833 enableGlobalSearch: false,
24834 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24835 validOperators: [
24836 OPERATOR_IS,
24837 OPERATOR_IS_NOT,
24838 OPERATOR_CONTAINS,
24839 OPERATOR_NOT_CONTAINS,
24840 OPERATOR_STARTS_WITH,
24841 // Multiple selection
24842 OPERATOR_IS_ANY,
24843 OPERATOR_IS_NONE,
24844 OPERATOR_IS_ALL,
24845 OPERATOR_IS_NOT_ALL
24846 ],
24847 format: {},
24848 getValueFormatted: get_value_formatted_default_default,
24849 validate: {
24850 required: isValidRequired,
24851 pattern: isValidPattern,
24852 minLength: isValidMinLength,
24853 maxLength: isValidMaxLength,
24854 elements: isValidElements
24855 }
24856 };
24857
24858 // packages/dataviews/build-module/field-types/color.mjs
24859 var import_i18n43 = __toESM(require_i18n(), 1);
24860 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24861 function render3({ item, field }) {
24862 if (field.hasElements) {
24863 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(RenderFromElements, { item, field });
24864 }
24865 const value = get_value_formatted_default_default({ item, field });
24866 if (!value || !w(value).isValid()) {
24867 return value;
24868 }
24869 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
24870 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24871 "div",
24872 {
24873 style: {
24874 width: "16px",
24875 height: "16px",
24876 borderRadius: "50%",
24877 backgroundColor: value,
24878 border: "1px solid #ddd",
24879 flexShrink: 0
24880 }
24881 }
24882 ),
24883 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: value })
24884 ] });
24885 }
24886 function isValidCustom6(item, field) {
24887 const value = field.getValue({ item });
24888 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
24889 return (0, import_i18n43.__)("Value must be a valid color.");
24890 }
24891 return null;
24892 }
24893 var sort5 = (a2, b2, direction) => {
24894 const colorA = w(a2);
24895 const colorB = w(b2);
24896 if (!colorA.isValid() && !colorB.isValid()) {
24897 return 0;
24898 }
24899 if (!colorA.isValid()) {
24900 return direction === "asc" ? 1 : -1;
24901 }
24902 if (!colorB.isValid()) {
24903 return direction === "asc" ? -1 : 1;
24904 }
24905 const hslA = colorA.toHsl();
24906 const hslB = colorB.toHsl();
24907 if (hslA.h !== hslB.h) {
24908 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
24909 }
24910 if (hslA.s !== hslB.s) {
24911 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
24912 }
24913 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
24914 };
24915 var color_default = {
24916 type: "color",
24917 render: render3,
24918 Edit: "color",
24919 sort: sort5,
24920 enableSorting: true,
24921 enableGlobalSearch: false,
24922 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24923 validOperators: [
24924 OPERATOR_IS,
24925 OPERATOR_IS_NOT,
24926 OPERATOR_IS_ANY,
24927 OPERATOR_IS_NONE
24928 ],
24929 format: {},
24930 getValueFormatted: get_value_formatted_default_default,
24931 validate: {
24932 required: isValidRequired,
24933 elements: isValidElements,
24934 custom: isValidCustom6
24935 }
24936 };
24937
24938 // packages/dataviews/build-module/field-types/url.mjs
24939 var url_default = {
24940 type: "url",
24941 render,
24942 Edit: "url",
24943 sort: sort_text_default,
24944 enableSorting: true,
24945 enableGlobalSearch: false,
24946 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24947 validOperators: [
24948 OPERATOR_IS,
24949 OPERATOR_IS_NOT,
24950 OPERATOR_CONTAINS,
24951 OPERATOR_NOT_CONTAINS,
24952 OPERATOR_STARTS_WITH,
24953 // Multiple selection
24954 OPERATOR_IS_ANY,
24955 OPERATOR_IS_NONE,
24956 OPERATOR_IS_ALL,
24957 OPERATOR_IS_NOT_ALL
24958 ],
24959 format: {},
24960 getValueFormatted: get_value_formatted_default_default,
24961 validate: {
24962 required: isValidRequired,
24963 pattern: isValidPattern,
24964 minLength: isValidMinLength,
24965 maxLength: isValidMaxLength,
24966 elements: isValidElements
24967 }
24968 };
24969
24970 // packages/dataviews/build-module/field-types/no-type.mjs
24971 var sort6 = (a2, b2, direction) => {
24972 if (typeof a2 === "number" && typeof b2 === "number") {
24973 return sort_number_default(a2, b2, direction);
24974 }
24975 return sort_text_default(a2, b2, direction);
24976 };
24977 var no_type_default = {
24978 // type: no type for this one
24979 render,
24980 Edit: null,
24981 sort: sort6,
24982 enableSorting: true,
24983 enableGlobalSearch: false,
24984 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24985 validOperators: getAllOperatorNames(),
24986 format: {},
24987 getValueFormatted: get_value_formatted_default_default,
24988 validate: {
24989 required: isValidRequired,
24990 elements: isValidElements
24991 }
24992 };
24993
24994 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
24995 function supportsNumericRangeConstraint(type) {
24996 return type === "integer" || type === "number";
24997 }
24998 function supportsDateRangeConstraint(type) {
24999 return type === "date" || type === "datetime";
25000 }
25001 function normalizeRangeRule(value, fieldType, key) {
25002 const validator = fieldType.validate[key];
25003 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25004 return { constraint: value, validate: validator };
25005 }
25006 return void 0;
25007 }
25008 function getIsValid(field, fieldType) {
25009 const rules = field.isValid;
25010 let required;
25011 if (rules?.required === true && fieldType.validate.required !== void 0) {
25012 required = {
25013 constraint: true,
25014 validate: fieldType.validate.required
25015 };
25016 }
25017 let elements;
25018 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25019 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25020 elements = {
25021 constraint: true,
25022 validate: fieldType.validate.elements
25023 };
25024 }
25025 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25026 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25027 const minLengthValue = rules?.minLength;
25028 let minLength;
25029 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25030 minLength = {
25031 constraint: minLengthValue,
25032 validate: fieldType.validate.minLength
25033 };
25034 }
25035 const maxLengthValue = rules?.maxLength;
25036 let maxLength;
25037 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25038 maxLength = {
25039 constraint: maxLengthValue,
25040 validate: fieldType.validate.maxLength
25041 };
25042 }
25043 const patternValue = rules?.pattern;
25044 let pattern;
25045 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25046 pattern = {
25047 constraint: patternValue,
25048 validate: fieldType.validate.pattern
25049 };
25050 }
25051 const custom = rules?.custom ?? fieldType.validate.custom;
25052 return {
25053 required,
25054 elements,
25055 min: min2,
25056 max: max2,
25057 minLength,
25058 maxLength,
25059 pattern,
25060 custom
25061 };
25062 }
25063
25064 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25065 function getFilter(fieldType) {
25066 return fieldType.validOperators.reduce((accumulator, operator) => {
25067 const operatorObj = getOperatorByName(operator);
25068 if (operatorObj?.filter) {
25069 accumulator[operator] = operatorObj.filter;
25070 }
25071 return accumulator;
25072 }, {});
25073 }
25074
25075 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25076 function getFormat(field, fieldType) {
25077 return {
25078 ...fieldType.format,
25079 ...field.format
25080 };
25081 }
25082 var get_format_default = getFormat;
25083
25084 // packages/dataviews/build-module/field-types/index.mjs
25085 function getFieldTypeByName(type) {
25086 const found = [
25087 email_default,
25088 integer_default,
25089 number_default,
25090 text_default,
25091 datetime_default,
25092 date_default,
25093 boolean_default,
25094 media_default,
25095 array_default,
25096 password_default,
25097 telephone_default,
25098 color_default,
25099 url_default
25100 ].find((fieldType) => fieldType?.type === type);
25101 if (!!found) {
25102 return found;
25103 }
25104 return no_type_default;
25105 }
25106 function normalizeFields(fields) {
25107 return fields.map((field) => {
25108 const fieldType = getFieldTypeByName(field.type);
25109 const getValue = field.getValue || get_value_from_id_default(field.id);
25110 const sort7 = function(a2, b2, direction) {
25111 const aValue = getValue({ item: a2 });
25112 const bValue = getValue({ item: b2 });
25113 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25114 };
25115 return {
25116 id: field.id,
25117 label: field.label || field.id,
25118 header: field.header || field.label || field.id,
25119 description: field.description,
25120 placeholder: field.placeholder,
25121 getValue,
25122 setValue: field.setValue || set_value_from_id_default(field.id),
25123 elements: field.elements,
25124 getElements: field.getElements,
25125 hasElements: hasElements(field),
25126 isVisible: field.isVisible,
25127 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25128 enableHiding: field.enableHiding ?? true,
25129 readOnly: field.readOnly ?? false,
25130 // The type provides defaults for the following props
25131 type: fieldType.type,
25132 render: field.render ?? fieldType.render,
25133 Edit: getControl(field, fieldType.Edit),
25134 sort: sort7,
25135 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25136 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25137 isValid: getIsValid(field, fieldType),
25138 filterBy: get_filter_by_default(
25139 field,
25140 fieldType.defaultOperators,
25141 fieldType.validOperators
25142 ),
25143 filter: getFilter(fieldType),
25144 format: get_format_default(field, fieldType),
25145 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25146 };
25147 });
25148 }
25149
25150 // packages/dataviews/build-module/hooks/use-data.mjs
25151 var import_element73 = __toESM(require_element(), 1);
25152 function useData({
25153 view,
25154 data: shownData,
25155 getItemId,
25156 isLoading,
25157 paginationInfo,
25158 selection
25159 }) {
25160 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25161 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element73.useState)(
25162 !isLoading
25163 );
25164 (0, import_element73.useEffect)(() => {
25165 if (!isLoading) {
25166 setHasInitiallyLoaded(true);
25167 }
25168 }, [isLoading]);
25169 const previousDataRef = (0, import_element73.useRef)(shownData);
25170 const previousPaginationInfoRef = (0, import_element73.useRef)(paginationInfo);
25171 (0, import_element73.useEffect)(() => {
25172 if (!isLoading) {
25173 previousDataRef.current = shownData;
25174 previousPaginationInfoRef.current = paginationInfo;
25175 }
25176 }, [shownData, isLoading, paginationInfo]);
25177 const [visibleEntries, setVisibleEntries] = (0, import_element73.useState)([]);
25178 const positionMapRef = (0, import_element73.useRef)(/* @__PURE__ */ new Map());
25179 const allLoadedRecordsRef = (0, import_element73.useRef)([]);
25180 const prevViewParamsRef = (0, import_element73.useRef)({
25181 search: void 0,
25182 filters: void 0,
25183 perPage: void 0
25184 });
25185 const scrollDirectionRef = (0, import_element73.useRef)(void 0);
25186 const prevStartPositionRef = (0, import_element73.useRef)(void 0);
25187 const hasInitializedRef = (0, import_element73.useRef)(false);
25188 const allLoadedRecords = (0, import_element73.useMemo)(() => {
25189 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25190 if (view.startPosition < prevStartPositionRef.current) {
25191 scrollDirectionRef.current = "up";
25192 } else if (view.startPosition > prevStartPositionRef.current) {
25193 scrollDirectionRef.current = "down";
25194 }
25195 }
25196 prevStartPositionRef.current = view.startPosition;
25197 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25198 const prevFiltersKey = prevViewParamsRef.current.filters;
25199 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25200 hasInitializedRef.current = true;
25201 prevViewParamsRef.current = {
25202 search: view.search,
25203 filters: currentFiltersKey,
25204 perPage: view.perPage
25205 };
25206 if (shouldReset) {
25207 positionMapRef.current.clear();
25208 scrollDirectionRef.current = void 0;
25209 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25210 const records = shownData.map((record, index2) => {
25211 const position = startPosition + index2;
25212 positionMapRef.current.set(getItemId(record), position);
25213 return {
25214 ...record,
25215 position
25216 };
25217 });
25218 allLoadedRecordsRef.current = records;
25219 return records;
25220 }
25221 const prev = allLoadedRecordsRef.current;
25222 const shownDataIds = new Set(shownData.map(getItemId));
25223 const scrollDirection = scrollDirectionRef.current;
25224 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25225 const newRecords = shownData.map((record, index2) => {
25226 const itemId = getItemId(record);
25227 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25228 if (position !== void 0) {
25229 positionMapRef.current.set(itemId, position);
25230 }
25231 return {
25232 ...record,
25233 position
25234 };
25235 });
25236 if (newRecords.length === 0) {
25237 return prev;
25238 }
25239 const prevWithoutDuplicates = prev.filter(
25240 (record) => !shownDataIds.has(getItemId(record))
25241 );
25242 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25243 allRecords.sort((a2, b2) => {
25244 const posA = a2.position;
25245 const posB = b2.position;
25246 return posA - posB;
25247 });
25248 let result = allRecords;
25249 if (visibleEntries.length > 0) {
25250 const visibleMin = Math.min(...visibleEntries);
25251 const visibleMax = Math.max(...visibleEntries);
25252 const buffer = 20;
25253 const recordPositions = allRecords.map(
25254 (r3) => r3.position
25255 );
25256 const minRecordPos = Math.min(...recordPositions);
25257 const maxRecordPos = Math.max(...recordPositions);
25258 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25259 if (hasOverlap) {
25260 result = allRecords.filter((record) => {
25261 const itemId = getItemId(record);
25262 const isSelected2 = selection?.includes(itemId);
25263 if (isSelected2) {
25264 return true;
25265 }
25266 const itemPosition = record.position;
25267 if (scrollDirection === "up") {
25268 return itemPosition <= visibleMax + buffer;
25269 } else if (scrollDirection === "down") {
25270 return itemPosition >= visibleMin - buffer;
25271 }
25272 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25273 });
25274 }
25275 }
25276 allLoadedRecordsRef.current = result;
25277 return result;
25278 }, [
25279 shownData,
25280 view.search,
25281 view.filters,
25282 view.perPage,
25283 view.startPosition,
25284 view.infiniteScrollEnabled,
25285 visibleEntries,
25286 selection,
25287 getItemId
25288 ]);
25289 if (!isInfiniteScrollEnabled) {
25290 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25291 return {
25292 data: dataToReturn.map((item) => ({
25293 ...item,
25294 position: void 0
25295 })),
25296 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25297 hasInitiallyLoaded,
25298 setVisibleEntries: void 0
25299 };
25300 }
25301 return {
25302 data: allLoadedRecords,
25303 paginationInfo,
25304 hasInitiallyLoaded,
25305 setVisibleEntries
25306 };
25307 }
25308
25309 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25310 var import_element74 = __toESM(require_element(), 1);
25311 var import_compose12 = __toESM(require_compose(), 1);
25312 function captureAnchorElement(container, anchorElementRef, direction) {
25313 const containerRect = container.getBoundingClientRect();
25314 const centerY = containerRect.top + containerRect.height / 2;
25315 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25316 if (items.length === 0) {
25317 return false;
25318 }
25319 const bestAnchor = items.reduce((best, item) => {
25320 const itemRect = item.getBoundingClientRect();
25321 const itemCenterY = itemRect.top + itemRect.height / 2;
25322 const distance = Math.abs(itemCenterY - centerY);
25323 const bestRect = best.getBoundingClientRect();
25324 const bestCenterY = bestRect.top + bestRect.height / 2;
25325 const bestDistance = Math.abs(bestCenterY - centerY);
25326 return distance < bestDistance ? item : best;
25327 });
25328 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25329 const anchorRect = bestAnchor.getBoundingClientRect();
25330 anchorElementRef.current = {
25331 posinset,
25332 viewportOffset: anchorRect.top - containerRect.top,
25333 direction
25334 };
25335 return true;
25336 }
25337 function useInfiniteScroll({
25338 view,
25339 onChangeView,
25340 isLoading,
25341 paginationInfo,
25342 containerRef,
25343 setVisibleEntries
25344 }) {
25345 const anchorElementRef = (0, import_element74.useRef)(null);
25346 const viewRef = (0, import_element74.useRef)(view);
25347 const isLoadingRef = (0, import_element74.useRef)(isLoading);
25348 const onChangeViewRef = (0, import_element74.useRef)(onChangeView);
25349 const totalItemsRef = (0, import_element74.useRef)(paginationInfo.totalItems);
25350 (0, import_element74.useLayoutEffect)(() => {
25351 viewRef.current = view;
25352 isLoadingRef.current = isLoading;
25353 onChangeViewRef.current = onChangeView;
25354 totalItemsRef.current = paginationInfo.totalItems;
25355 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25356 const intersectionObserverCallback = (0, import_element74.useCallback)(
25357 (entries) => {
25358 if (!setVisibleEntries) {
25359 return;
25360 }
25361 setVisibleEntries((prev) => {
25362 const newVisibleEntries = new Set(prev);
25363 let hasChanged = false;
25364 entries.forEach((entry) => {
25365 const posInSet = Number(
25366 entry.target?.attributes?.getNamedItem(
25367 "aria-posinset"
25368 )?.value
25369 );
25370 if (isNaN(posInSet)) {
25371 return;
25372 }
25373 if (entry.isIntersecting) {
25374 if (!newVisibleEntries.has(posInSet)) {
25375 newVisibleEntries.add(posInSet);
25376 hasChanged = true;
25377 }
25378 } else if (newVisibleEntries.has(posInSet)) {
25379 newVisibleEntries.delete(posInSet);
25380 hasChanged = true;
25381 }
25382 });
25383 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25384 });
25385 },
25386 [setVisibleEntries]
25387 );
25388 (0, import_element74.useLayoutEffect)(() => {
25389 const container = containerRef.current;
25390 const anchor = anchorElementRef.current;
25391 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25392 return;
25393 }
25394 const anchorElement = container.querySelector(
25395 `[aria-posinset="${anchor.posinset}"]`
25396 );
25397 if (anchorElement) {
25398 const containerRect = container.getBoundingClientRect();
25399 const anchorRect = anchorElement.getBoundingClientRect();
25400 const currentOffset = anchorRect.top - containerRect.top;
25401 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25402 if (Math.abs(scrollAdjustment) > 1) {
25403 container.scrollTop += scrollAdjustment;
25404 }
25405 }
25406 anchorElementRef.current = null;
25407 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25408 const intersectionObserverRef = (0, import_element74.useRef)(
25409 null
25410 );
25411 (0, import_element74.useEffect)(() => {
25412 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25413 if (intersectionObserverRef.current) {
25414 intersectionObserverRef.current.disconnect();
25415 intersectionObserverRef.current = null;
25416 }
25417 return;
25418 }
25419 intersectionObserverRef.current = new IntersectionObserver(
25420 intersectionObserverCallback,
25421 { root: null, rootMargin: "0px", threshold: 0.1 }
25422 );
25423 return () => {
25424 if (intersectionObserverRef.current) {
25425 intersectionObserverRef.current.disconnect();
25426 intersectionObserverRef.current = null;
25427 }
25428 };
25429 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25430 (0, import_element74.useEffect)(() => {
25431 if (!view.infiniteScrollEnabled || !containerRef.current) {
25432 return;
25433 }
25434 let lastScrollTop = 0;
25435 const BOTTOM_THRESHOLD = 600;
25436 const TOP_THRESHOLD = 800;
25437 const handleScroll = (0, import_compose12.throttle)((event) => {
25438 const currentView = viewRef.current;
25439 const totalItems = totalItemsRef.current;
25440 const target = event.target;
25441 const scrollTop = target.scrollTop;
25442 const scrollHeight = target.scrollHeight;
25443 const clientHeight = target.clientHeight;
25444 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25445 lastScrollTop = scrollTop;
25446 if (isLoadingRef.current) {
25447 return;
25448 }
25449 const currentStartPosition = currentView.startPosition || 1;
25450 const batchSize = currentView.perPage || 10;
25451 const currentEndPosition = Math.min(
25452 currentStartPosition + batchSize,
25453 totalItems
25454 );
25455 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25456 if (currentEndPosition < totalItems) {
25457 const newStartPosition = currentEndPosition;
25458 captureAnchorElement(target, anchorElementRef, "down");
25459 onChangeViewRef.current({
25460 ...currentView,
25461 startPosition: newStartPosition
25462 });
25463 }
25464 }
25465 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25466 if (currentStartPosition > 1) {
25467 const calculatedStartPosition = currentStartPosition - batchSize;
25468 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25469 captureAnchorElement(target, anchorElementRef, "up");
25470 onChangeViewRef.current({
25471 ...currentView,
25472 startPosition: newStartPosition
25473 });
25474 }
25475 }
25476 }, 50);
25477 const container = containerRef.current;
25478 container.addEventListener("scroll", handleScroll);
25479 return () => {
25480 container.removeEventListener("scroll", handleScroll);
25481 handleScroll.cancel();
25482 };
25483 }, [containerRef, view.infiniteScrollEnabled]);
25484 return {
25485 intersectionObserver: intersectionObserverRef.current
25486 };
25487 }
25488
25489 // packages/dataviews/build-module/dataviews/index.mjs
25490 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25491 var defaultGetItemId = (item) => item.id;
25492 var defaultIsItemClickable = () => true;
25493 var EMPTY_ARRAY6 = [];
25494 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25495 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25496 (viewLayout) => !viewLayout.isPicker
25497 );
25498 function DefaultUI({
25499 header,
25500 search = true,
25501 searchLabel = void 0
25502 }) {
25503 const { view } = (0, import_element75.useContext)(dataviews_context_default);
25504 const isInfiniteScroll = view.infiniteScrollEnabled;
25505 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_jsx_runtime110.Fragment, { children: [
25506 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
25507 Stack,
25508 {
25509 direction: "row",
25510 align: "top",
25511 justify: "space-between",
25512 className: clsx_default("dataviews__view-actions", {
25513 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25514 }),
25515 gap: "xs",
25516 children: [
25517 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
25518 Stack,
25519 {
25520 direction: "row",
25521 justify: "start",
25522 gap: "sm",
25523 className: "dataviews__search",
25524 children: [
25525 search && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(dataviews_search_default, { label: searchLabel }),
25526 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(toggle_default, {})
25527 ]
25528 }
25529 ),
25530 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
25531 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(dataviews_view_config_default, {}),
25532 header
25533 ] })
25534 ]
25535 }
25536 ),
25537 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
25538 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(DataViewsLayout, {}),
25539 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(DataViewsFooter, {})
25540 ] });
25541 }
25542 function DataViews({
25543 view,
25544 onChangeView,
25545 fields,
25546 search = true,
25547 searchLabel = void 0,
25548 actions = EMPTY_ARRAY6,
25549 data,
25550 getItemId = defaultGetItemId,
25551 getItemLevel,
25552 isLoading = false,
25553 paginationInfo,
25554 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
25555 selection: selectionProperty,
25556 onChangeSelection,
25557 onClickItem,
25558 renderItemLink,
25559 isItemClickable = defaultIsItemClickable,
25560 header,
25561 children,
25562 config = { perPageSizes: [10, 20, 50, 100] },
25563 empty,
25564 onReset
25565 }) {
25566 const [selectionState, setSelectionState] = (0, import_element75.useState)([]);
25567 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
25568 const selection = isUncontrolled ? selectionState : selectionProperty;
25569 const {
25570 data: displayData,
25571 paginationInfo: displayPaginationInfo,
25572 hasInitiallyLoaded,
25573 setVisibleEntries
25574 } = useData({
25575 view,
25576 data,
25577 getItemId,
25578 isLoading,
25579 selection,
25580 paginationInfo
25581 });
25582 const containerRef = (0, import_element75.useRef)(null);
25583 const [containerWidth, setContainerWidth] = (0, import_element75.useState)(0);
25584 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
25585 (resizeObserverEntries) => {
25586 setContainerWidth(
25587 resizeObserverEntries[0].borderBoxSize[0].inlineSize
25588 );
25589 },
25590 { box: "border-box" }
25591 );
25592 const [openedFilter, setOpenedFilter] = (0, import_element75.useState)(null);
25593 function setSelectionWithChange(value) {
25594 const newValue = typeof value === "function" ? value(selection) : value;
25595 if (isUncontrolled) {
25596 setSelectionState(newValue);
25597 }
25598 if (onChangeSelection) {
25599 onChangeSelection(newValue);
25600 }
25601 }
25602 const _fields = (0, import_element75.useMemo)(() => normalizeFields(fields), [fields]);
25603 const _selection = (0, import_element75.useMemo)(() => {
25604 if (view.infiniteScrollEnabled) {
25605 return selection;
25606 }
25607 return selection.filter(
25608 (id) => data.some((item) => getItemId(item) === id)
25609 );
25610 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
25611 const filters = use_filters_default(_fields, view);
25612 const hasPrimaryOrLockedFilters = (0, import_element75.useMemo)(
25613 () => (filters || []).some(
25614 (filter) => filter.isPrimary || filter.isLocked
25615 ),
25616 [filters]
25617 );
25618 const [isShowingFilter, setIsShowingFilter] = (0, import_element75.useState)(
25619 hasPrimaryOrLockedFilters
25620 );
25621 const { intersectionObserver } = useInfiniteScroll({
25622 view,
25623 onChangeView,
25624 isLoading,
25625 paginationInfo,
25626 containerRef,
25627 setVisibleEntries
25628 });
25629 (0, import_element75.useEffect)(() => {
25630 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
25631 setIsShowingFilter(true);
25632 }
25633 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
25634 const defaultLayouts = (0, import_element75.useMemo)(
25635 () => Object.fromEntries(
25636 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
25637 return dataViewsLayouts.some(
25638 (viewLayout) => viewLayout.type === layoutType
25639 );
25640 }).map(([key, value]) => [
25641 key,
25642 value === true ? {} : value
25643 ])
25644 ),
25645 [defaultLayoutsProperty]
25646 );
25647 if (!defaultLayouts[view.type]) {
25648 return null;
25649 }
25650 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25651 dataviews_context_default.Provider,
25652 {
25653 value: {
25654 view,
25655 onChangeView,
25656 fields: _fields,
25657 actions,
25658 data: displayData,
25659 isLoading,
25660 paginationInfo: displayPaginationInfo,
25661 selection: _selection,
25662 onChangeSelection: setSelectionWithChange,
25663 openedFilter,
25664 setOpenedFilter,
25665 getItemId,
25666 getItemLevel,
25667 isItemClickable,
25668 onClickItem,
25669 renderItemLink,
25670 containerWidth,
25671 containerRef,
25672 resizeObserverRef,
25673 defaultLayouts,
25674 filters,
25675 isShowingFilter,
25676 setIsShowingFilter,
25677 config,
25678 empty,
25679 hasInitiallyLoaded,
25680 onReset,
25681 intersectionObserver
25682 },
25683 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25684 DefaultUI,
25685 {
25686 header,
25687 search,
25688 searchLabel
25689 }
25690 ) })
25691 }
25692 );
25693 }
25694 var DataViewsSubComponents = DataViews;
25695 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
25696 DataViewsSubComponents.Filters = filters_default;
25697 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
25698 DataViewsSubComponents.FiltersToggle = toggle_default;
25699 DataViewsSubComponents.Layout = DataViewsLayout;
25700 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
25701 DataViewsSubComponents.Pagination = DataViewsPagination;
25702 DataViewsSubComponents.Search = dataviews_search_default;
25703 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
25704 DataViewsSubComponents.Footer = DataViewsFooter;
25705 var dataviews_default = DataViewsSubComponents;
25706
25707 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
25708 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
25709 var import_deprecated = __toESM(require_deprecated(), 1);
25710 function normalizeSearchInput2(input = "") {
25711 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
25712 }
25713 var EMPTY_ARRAY7 = [];
25714 function filterSortAndPaginate(data, view, fields) {
25715 if (!data) {
25716 return {
25717 data: EMPTY_ARRAY7,
25718 paginationInfo: { totalItems: 0, totalPages: 0 }
25719 };
25720 }
25721 const _fields = normalizeFields(fields);
25722 let filteredData = [...data];
25723 if (view.search) {
25724 const normalizedSearch = normalizeSearchInput2(view.search);
25725 filteredData = filteredData.filter((item) => {
25726 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
25727 const fieldValue = field.getValue({ item });
25728 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
25729 return values.some(
25730 (value) => normalizeSearchInput2(String(value)).includes(
25731 normalizedSearch
25732 )
25733 );
25734 });
25735 });
25736 }
25737 if (view.filters && view.filters?.length > 0) {
25738 view.filters.forEach((filter) => {
25739 const field = _fields.find(
25740 (_field) => _field.id === filter.field
25741 );
25742 if (field) {
25743 if (filter.operator === OPERATOR_IS_NOT_ALL) {
25744 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
25745 since: "7.0",
25746 alternative: "'isNone'"
25747 });
25748 }
25749 const handler = field.filter[filter.operator];
25750 if (handler) {
25751 filteredData = filteredData.filter(
25752 (item) => handler(item, field, filter.value)
25753 );
25754 }
25755 }
25756 });
25757 }
25758 const sortByField = view.sort?.field ? _fields.find((field) => {
25759 return field.enableSorting !== false && field.id === view.sort?.field;
25760 }) : null;
25761 const groupByField = view.groupBy?.field ? _fields.find((field) => {
25762 return field.enableSorting !== false && field.id === view.groupBy?.field;
25763 }) : null;
25764 if (sortByField || groupByField) {
25765 filteredData.sort((a2, b2) => {
25766 if (groupByField) {
25767 const groupCompare = groupByField.sort(
25768 a2,
25769 b2,
25770 view.groupBy?.direction ?? "asc"
25771 );
25772 if (groupCompare !== 0) {
25773 return groupCompare;
25774 }
25775 }
25776 if (sortByField) {
25777 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
25778 }
25779 return 0;
25780 });
25781 }
25782 let totalItems = filteredData.length;
25783 let totalPages = 1;
25784 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
25785 const start = view.startPosition - 1;
25786 const end = Math.min(start + view.perPage, totalItems);
25787 filteredData = filteredData?.slice(start, end);
25788 } else if (view.page !== void 0 && view.perPage !== void 0) {
25789 const start = (view.page - 1) * view.perPage;
25790 totalItems = filteredData?.length || 0;
25791 totalPages = Math.ceil(totalItems / view.perPage);
25792 filteredData = filteredData?.slice(start, start + view.perPage);
25793 }
25794 return {
25795 data: filteredData,
25796 paginationInfo: {
25797 totalItems,
25798 totalPages
25799 }
25800 };
25801 }
25802
25803 // packages/admin-ui/build-module/navigable-region/index.mjs
25804 var import_element76 = __toESM(require_element(), 1);
25805 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25806 var NavigableRegion = (0, import_element76.forwardRef)(
25807 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
25808 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25809 Tag,
25810 {
25811 ref,
25812 className: clsx_default("admin-ui-navigable-region", className),
25813 "aria-label": ariaLabel,
25814 role: "region",
25815 tabIndex: "-1",
25816 ...props,
25817 children
25818 }
25819 );
25820 }
25821 );
25822 NavigableRegion.displayName = "NavigableRegion";
25823 var navigable_region_default = NavigableRegion;
25824
25825 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
25826 var import_components46 = __toESM(require_components(), 1);
25827 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components46.createSlotFill)("SidebarToggle");
25828
25829 // packages/admin-ui/build-module/page/header.mjs
25830 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25831 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
25832 function getRuntime7() {
25833 const globalScope = globalThis;
25834 if (globalScope.__wpStyleRuntime) {
25835 return globalScope.__wpStyleRuntime;
25836 }
25837 globalScope.__wpStyleRuntime = {
25838 documents: /* @__PURE__ */ new Map(),
25839 styles: /* @__PURE__ */ new Map(),
25840 injectedStyles: /* @__PURE__ */ new WeakMap()
25841 };
25842 if (typeof document !== "undefined") {
25843 registerDocument7(document);
25844 }
25845 return globalScope.__wpStyleRuntime;
25846 }
25847 function documentContainsStyleHash7(targetDocument, hash) {
25848 if (!targetDocument.head) {
25849 return false;
25850 }
25851 for (const style of targetDocument.head.querySelectorAll(
25852 `style[${STYLE_HASH_ATTRIBUTE7}]`
25853 )) {
25854 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
25855 return true;
25856 }
25857 }
25858 return false;
25859 }
25860 function injectStyle7(targetDocument, hash, css) {
25861 if (!targetDocument.head) {
25862 return;
25863 }
25864 const runtime = getRuntime7();
25865 let injectedStyles = runtime.injectedStyles.get(targetDocument);
25866 if (!injectedStyles) {
25867 injectedStyles = /* @__PURE__ */ new Set();
25868 runtime.injectedStyles.set(targetDocument, injectedStyles);
25869 }
25870 if (injectedStyles.has(hash)) {
25871 return;
25872 }
25873 if (documentContainsStyleHash7(targetDocument, hash)) {
25874 injectedStyles.add(hash);
25875 return;
25876 }
25877 const style = targetDocument.createElement("style");
25878 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
25879 style.appendChild(targetDocument.createTextNode(css));
25880 targetDocument.head.appendChild(style);
25881 injectedStyles.add(hash);
25882 }
25883 function registerDocument7(targetDocument) {
25884 const runtime = getRuntime7();
25885 runtime.documents.set(
25886 targetDocument,
25887 (runtime.documents.get(targetDocument) ?? 0) + 1
25888 );
25889 for (const [hash, css] of runtime.styles) {
25890 injectStyle7(targetDocument, hash, css);
25891 }
25892 return () => {
25893 const count = runtime.documents.get(targetDocument);
25894 if (count === void 0) {
25895 return;
25896 }
25897 if (count <= 1) {
25898 runtime.documents.delete(targetDocument);
25899 return;
25900 }
25901 runtime.documents.set(targetDocument, count - 1);
25902 };
25903 }
25904 function registerStyle7(hash, css) {
25905 const runtime = getRuntime7();
25906 runtime.styles.set(hash, css);
25907 for (const targetDocument of runtime.documents.keys()) {
25908 injectStyle7(targetDocument, hash, css);
25909 }
25910 }
25911 if (typeof process === "undefined" || true) {
25912 registerStyle7("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.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:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{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-foreground-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)}}");
25913 }
25914 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" };
25915 function Header({
25916 headingLevel = 1,
25917 breadcrumbs,
25918 badges,
25919 visual,
25920 title,
25921 subTitle,
25922 actions,
25923 showSidebarToggle = true
25924 }) {
25925 const HeadingTag = `h${headingLevel}`;
25926 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
25927 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
25928 Stack,
25929 {
25930 className: style_default6["header-content"],
25931 direction: "row",
25932 gap: "sm",
25933 justify: "space-between",
25934 children: [
25935 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
25936 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25937 SidebarToggleSlot,
25938 {
25939 bubblesVirtually: true,
25940 className: style_default6["sidebar-toggle-slot"]
25941 }
25942 ),
25943 visual && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25944 "div",
25945 {
25946 className: style_default6["header-visual"],
25947 "aria-hidden": "true",
25948 children: visual
25949 }
25950 ),
25951 title && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25952 Text,
25953 {
25954 className: style_default6["header-title"],
25955 render: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(HeadingTag, {}),
25956 variant: "heading-lg",
25957 children: title
25958 }
25959 ),
25960 breadcrumbs,
25961 badges
25962 ] }),
25963 actions && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25964 Stack,
25965 {
25966 align: "center",
25967 className: style_default6["header-actions"],
25968 direction: "row",
25969 gap: "sm",
25970 children: actions
25971 }
25972 )
25973 ]
25974 }
25975 ),
25976 subTitle && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25977 Text,
25978 {
25979 render: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("p", {}),
25980 variant: "body-md",
25981 className: style_default6["header-subtitle"],
25982 children: subTitle
25983 }
25984 )
25985 ] });
25986 }
25987
25988 // packages/admin-ui/build-module/page/index.mjs
25989 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25990 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
25991 function getRuntime8() {
25992 const globalScope = globalThis;
25993 if (globalScope.__wpStyleRuntime) {
25994 return globalScope.__wpStyleRuntime;
25995 }
25996 globalScope.__wpStyleRuntime = {
25997 documents: /* @__PURE__ */ new Map(),
25998 styles: /* @__PURE__ */ new Map(),
25999 injectedStyles: /* @__PURE__ */ new WeakMap()
26000 };
26001 if (typeof document !== "undefined") {
26002 registerDocument8(document);
26003 }
26004 return globalScope.__wpStyleRuntime;
26005 }
26006 function documentContainsStyleHash8(targetDocument, hash) {
26007 if (!targetDocument.head) {
26008 return false;
26009 }
26010 for (const style of targetDocument.head.querySelectorAll(
26011 `style[${STYLE_HASH_ATTRIBUTE8}]`
26012 )) {
26013 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
26014 return true;
26015 }
26016 }
26017 return false;
26018 }
26019 function injectStyle8(targetDocument, hash, css) {
26020 if (!targetDocument.head) {
26021 return;
26022 }
26023 const runtime = getRuntime8();
26024 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26025 if (!injectedStyles) {
26026 injectedStyles = /* @__PURE__ */ new Set();
26027 runtime.injectedStyles.set(targetDocument, injectedStyles);
26028 }
26029 if (injectedStyles.has(hash)) {
26030 return;
26031 }
26032 if (documentContainsStyleHash8(targetDocument, hash)) {
26033 injectedStyles.add(hash);
26034 return;
26035 }
26036 const style = targetDocument.createElement("style");
26037 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
26038 style.appendChild(targetDocument.createTextNode(css));
26039 targetDocument.head.appendChild(style);
26040 injectedStyles.add(hash);
26041 }
26042 function registerDocument8(targetDocument) {
26043 const runtime = getRuntime8();
26044 runtime.documents.set(
26045 targetDocument,
26046 (runtime.documents.get(targetDocument) ?? 0) + 1
26047 );
26048 for (const [hash, css] of runtime.styles) {
26049 injectStyle8(targetDocument, hash, css);
26050 }
26051 return () => {
26052 const count = runtime.documents.get(targetDocument);
26053 if (count === void 0) {
26054 return;
26055 }
26056 if (count <= 1) {
26057 runtime.documents.delete(targetDocument);
26058 return;
26059 }
26060 runtime.documents.set(targetDocument, count - 1);
26061 };
26062 }
26063 function registerStyle8(hash, css) {
26064 const runtime = getRuntime8();
26065 runtime.styles.set(hash, css);
26066 for (const targetDocument of runtime.documents.keys()) {
26067 injectStyle8(targetDocument, hash, css);
26068 }
26069 }
26070 if (typeof process === "undefined" || true) {
26071 registerStyle8("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.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:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{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-foreground-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)}}");
26072 }
26073 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" };
26074 function Page({
26075 headingLevel,
26076 breadcrumbs,
26077 badges,
26078 visual,
26079 title,
26080 subTitle,
26081 children,
26082 className,
26083 actions,
26084 ariaLabel,
26085 hasPadding = false,
26086 showSidebarToggle = true
26087 }) {
26088 const classes = clsx_default(style_default7.page, className);
26089 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
26090 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
26091 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26092 Header,
26093 {
26094 headingLevel,
26095 breadcrumbs,
26096 badges,
26097 visual,
26098 title,
26099 subTitle,
26100 actions,
26101 showSidebarToggle
26102 }
26103 ),
26104 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26105 "div",
26106 {
26107 className: clsx_default(
26108 style_default7.content,
26109 style_default7["has-padding"]
26110 ),
26111 children
26112 }
26113 ) : children
26114 ] });
26115 }
26116 Page.SidebarToggleFill = SidebarToggleFill;
26117 var page_default = Page;
26118
26119 // routes/pattern-list/stage.tsx
26120 var import_core_data4 = __toESM(require_core_data());
26121 var import_components47 = __toESM(require_components());
26122 var import_data11 = __toESM(require_data());
26123 var import_element79 = __toESM(require_element());
26124 var import_editor = __toESM(require_editor());
26125 var import_patterns3 = __toESM(require_patterns());
26126 var import_i18n48 = __toESM(require_i18n());
26127
26128 // routes/lock-unlock/index.ts
26129 var import_private_apis4 = __toESM(require_private_apis());
26130 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26131 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26132 "@wordpress/routes"
26133 );
26134
26135 // routes/pattern-list/view-utils.ts
26136 var import_i18n44 = __toESM(require_i18n());
26137 var LAYOUT_GRID2 = "grid";
26138 var LAYOUT_TABLE2 = "table";
26139 var DEFAULT_VIEW = {
26140 type: LAYOUT_GRID2,
26141 perPage: 20,
26142 sort: {
26143 field: "title",
26144 direction: "asc"
26145 },
26146 filters: [],
26147 fields: ["sync-status"],
26148 layout: {
26149 badgeFields: ["sync-status"]
26150 },
26151 titleField: "title",
26152 mediaField: "preview"
26153 };
26154 var DEFAULT_VIEWS = [
26155 {
26156 slug: "all",
26157 label: (0, import_i18n44.__)("All patterns")
26158 },
26159 {
26160 slug: "my-patterns",
26161 label: (0, import_i18n44.__)("My patterns")
26162 },
26163 {
26164 slug: "registered",
26165 label: (0, import_i18n44.__)("Registered")
26166 }
26167 ];
26168 var DEFAULT_LAYOUTS2 = {
26169 [LAYOUT_TABLE2]: true,
26170 [LAYOUT_GRID2]: {
26171 layout: {
26172 badgeFields: ["sync-status"]
26173 }
26174 }
26175 };
26176
26177 // routes/pattern-list/fields/preview.tsx
26178 var import_i18n45 = __toESM(require_i18n());
26179 import { Preview } from "@wordpress/lazy-editor";
26180 function PreviewField({ item }) {
26181 return /* @__PURE__ */ React.createElement(
26182 Preview,
26183 {
26184 blocks: item.blocks,
26185 content: item.content,
26186 description: item.description
26187 }
26188 );
26189 }
26190 var previewField = {
26191 label: (0, import_i18n45.__)("Preview"),
26192 id: "preview",
26193 render: PreviewField,
26194 enableSorting: false
26195 };
26196
26197 // routes/pattern-list/fields/sync-status.tsx
26198 var import_i18n46 = __toESM(require_i18n());
26199 var import_patterns = __toESM(require_patterns());
26200 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
26201 var OPERATOR_IS2 = "is";
26202 var SYNC_FILTERS = [
26203 {
26204 value: PATTERN_SYNC_TYPES.full,
26205 label: (0, import_i18n46._x)("Synced", "pattern (singular)"),
26206 description: (0, import_i18n46.__)("Patterns that are kept in sync across the site.")
26207 },
26208 {
26209 value: PATTERN_SYNC_TYPES.unsynced,
26210 label: (0, import_i18n46._x)("Not synced", "pattern (singular)"),
26211 description: (0, import_i18n46.__)(
26212 "Patterns that can be changed freely without affecting the site."
26213 )
26214 }
26215 ];
26216 var patternStatusField = {
26217 label: (0, import_i18n46.__)("Sync status"),
26218 id: "sync-status",
26219 render: ({ item }) => {
26220 const syncStatus = item.syncStatus;
26221 return /* @__PURE__ */ React.createElement(
26222 "span",
26223 {
26224 className: `routes-pattern-list__field-sync-status-${syncStatus}`
26225 },
26226 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
26227 );
26228 },
26229 elements: SYNC_FILTERS,
26230 filterBy: {
26231 operators: [OPERATOR_IS2],
26232 isPrimary: true
26233 },
26234 enableSorting: false
26235 };
26236
26237 // routes/pattern-list/fields/category.tsx
26238 var import_i18n47 = __toESM(require_i18n());
26239 var import_data9 = __toESM(require_data());
26240 var import_core_data2 = __toESM(require_core_data());
26241 var import_element77 = __toESM(require_element());
26242 var OPERATOR_IS3 = "is";
26243 function CategoryField({ item }) {
26244 const blockPatternCategories = (0, import_data9.useSelect)(
26245 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26246 []
26247 );
26248 const categoryLabels = (0, import_element77.useMemo)(() => {
26249 if (!item.categories || !Array.isArray(item.categories)) {
26250 return [];
26251 }
26252 return item.categories.map((catSlug) => {
26253 const category = blockPatternCategories?.find(
26254 (cat) => cat.name === catSlug
26255 );
26256 return category ? category.label || category.name : null;
26257 }).filter(Boolean);
26258 }, [item.categories, blockPatternCategories]);
26259 if (categoryLabels.length === 0) {
26260 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
26261 }
26262 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
26263 }
26264 function usePatternCategories() {
26265 const userPatternCategories = (0, import_data9.useSelect)(
26266 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
26267 []
26268 );
26269 const blockPatternCategories = (0, import_data9.useSelect)(
26270 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26271 []
26272 );
26273 return (0, import_element77.useMemo)(() => {
26274 const categoryMap = /* @__PURE__ */ new Map();
26275 userPatternCategories?.forEach((cat) => {
26276 if (!categoryMap.has(cat.name)) {
26277 categoryMap.set(cat.name, {
26278 value: cat.name,
26279 label: cat.label || cat.name
26280 });
26281 }
26282 });
26283 blockPatternCategories?.forEach((cat) => {
26284 if (!categoryMap.has(cat.name)) {
26285 categoryMap.set(cat.name, {
26286 value: cat.name,
26287 label: cat.label || cat.name
26288 });
26289 }
26290 });
26291 return Array.from(categoryMap.values()).sort(
26292 (a2, b2) => a2.label.localeCompare(b2.label)
26293 );
26294 }, [userPatternCategories, blockPatternCategories]);
26295 }
26296 function usePatternCategoryField() {
26297 const categories = usePatternCategories();
26298 return {
26299 label: (0, import_i18n47.__)("Category"),
26300 id: "category",
26301 render: CategoryField,
26302 elements: categories,
26303 getValue: ({ item }) => {
26304 return item.categories;
26305 },
26306 filterBy: {
26307 operators: [OPERATOR_IS3],
26308 isPrimary: true
26309 },
26310 enableSorting: false
26311 };
26312 }
26313
26314 // routes/pattern-list/use-patterns.ts
26315 var import_data10 = __toESM(require_data());
26316 var import_core_data3 = __toESM(require_core_data());
26317 var import_element78 = __toESM(require_element());
26318 var import_patterns2 = __toESM(require_patterns());
26319 var import_block_editor = __toESM(require_block_editor());
26320
26321 // routes/pattern-list/utils.ts
26322 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
26323
26324 // routes/pattern-list/use-patterns.ts
26325 var {
26326 PATTERN_TYPES,
26327 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
26328 EXCLUDED_PATTERN_SOURCES,
26329 PATTERN_DEFAULT_CATEGORY
26330 } = unlock4(import_patterns2.privateApis);
26331 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
26332 import_block_editor.privateApis
26333 );
26334 function normalizeThemePattern(pattern) {
26335 return {
26336 id: pattern.name,
26337 title: pattern.title,
26338 content: pattern.content,
26339 keywords: pattern.keywords || [],
26340 type: PATTERN_TYPES.theme,
26341 // Normalize categories to always be an array of slugs
26342 categories: pattern.categories || [],
26343 // Theme patterns are always unsynced
26344 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
26345 description: pattern.description || ""
26346 };
26347 }
26348 function normalizeUserPattern(pattern, userPatternCategories) {
26349 const categories = [];
26350 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
26351 pattern.wp_pattern_category.forEach((catId) => {
26352 const category = userPatternCategories?.find(
26353 (cat) => cat.id === catId
26354 );
26355 if (category) {
26356 categories.push(category.name);
26357 }
26358 });
26359 }
26360 const numericId = pattern.id;
26361 return {
26362 id: pattern.name || pattern.id.toString(),
26363 _recordId: numericId,
26364 // Keep numeric ID for permissions lookup
26365 keywords: [],
26366 type: PATTERN_TYPES.user,
26367 // Normalize categories to always be an array of slugs
26368 categories,
26369 // Normalize sync status
26370 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
26371 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
26372 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
26373 description: pattern.excerpt?.raw || "",
26374 blocks: pattern.blocks
26375 };
26376 }
26377 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
26378 return unmatchedTerms.filter(
26379 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
26380 (unprocessedTerm) => unprocessedTerm.includes(term)
26381 )
26382 );
26383 };
26384 function getItemSearchRank(item, searchTerm, config) {
26385 const { categoryId, hasCategory, onlyFilterByCategory } = config;
26386 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
26387 if (!rank || onlyFilterByCategory) {
26388 return rank;
26389 }
26390 const normalizedSearchInput = normalizeString2(searchTerm);
26391 const normalizedTitle = normalizeString2(item.title);
26392 if (normalizedSearchInput === normalizedTitle) {
26393 rank += 30;
26394 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
26395 rank += 20;
26396 } else {
26397 const terms = [
26398 item.id,
26399 item.title,
26400 item.description,
26401 ...item.keywords
26402 ].join(" ");
26403 const normalizedSearchTerms = extractWords(normalizedSearchInput);
26404 const unmatchedTerms = removeMatchingTerms(
26405 normalizedSearchTerms,
26406 terms
26407 );
26408 if (unmatchedTerms.length === 0) {
26409 rank += 10;
26410 }
26411 }
26412 return rank;
26413 }
26414 function searchItems(items = [], searchInput = "", config = {}) {
26415 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
26416 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
26417 const searchRankConfig = { ...config, onlyFilterByCategory };
26418 const threshold = onlyFilterByCategory ? 0 : 1;
26419 const rankedItems = items.map((item) => {
26420 return [
26421 item,
26422 getItemSearchRank(item, searchInput, searchRankConfig)
26423 ];
26424 }).filter(([, rank]) => rank > threshold);
26425 if (normalizedSearchTerms.length === 0) {
26426 return rankedItems.map(([item]) => item);
26427 }
26428 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
26429 return rankedItems.map(([item]) => item);
26430 }
26431 var selectThemePatterns = (0, import_data10.createSelector)(
26432 (select2) => {
26433 const { getBlockPatterns } = select2(import_core_data3.store);
26434 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
26435 const restBlockPatterns = getBlockPatterns();
26436 const patterns = (restBlockPatterns || []).filter(
26437 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
26438 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
26439 return {
26440 patterns,
26441 isResolving: isResolvingSelector("getBlockPatterns")
26442 };
26443 },
26444 (select2) => [
26445 select2(import_core_data3.store).getBlockPatterns(),
26446 select2(import_core_data3.store).isResolving("getBlockPatterns")
26447 ]
26448 );
26449 var selectUserPatterns = (0, import_data10.createSelector)(
26450 (select2, syncStatus = void 0, search = "") => {
26451 const {
26452 getEntityRecords,
26453 isResolving: isResolvingSelector,
26454 getUserPatternCategories
26455 } = select2(import_core_data3.store);
26456 const query = { per_page: -1 };
26457 const patternPosts = getEntityRecords(
26458 "postType",
26459 PATTERN_TYPES.user,
26460 query
26461 );
26462 const userPatternCategories = getUserPatternCategories();
26463 let patterns = (patternPosts ?? []).map(
26464 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
26465 );
26466 const isResolving = isResolvingSelector("getEntityRecords", [
26467 "postType",
26468 PATTERN_TYPES.user,
26469 query
26470 ]);
26471 if (syncStatus) {
26472 patterns = patterns.filter(
26473 (pattern) => pattern.syncStatus === syncStatus
26474 );
26475 }
26476 patterns = searchItems(patterns, search, {
26477 // We exit user pattern retrieval early if we aren't in the
26478 // catch-all category for user created patterns, so it has
26479 // to be in the category.
26480 categoryId: PATTERN_DEFAULT_CATEGORY,
26481 hasCategory: () => true
26482 });
26483 return {
26484 patterns,
26485 isResolving,
26486 categories: userPatternCategories
26487 };
26488 },
26489 (select2) => [
26490 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
26491 per_page: -1
26492 }),
26493 select2(import_core_data3.store).isResolving("getEntityRecords", [
26494 "postType",
26495 PATTERN_TYPES.user,
26496 { per_page: -1 }
26497 ]),
26498 select2(import_core_data3.store).getUserPatternCategories()
26499 ]
26500 );
26501 var selectPatterns = (0, import_data10.createSelector)(
26502 (select2, categoryId, syncStatus, search = "") => {
26503 const {
26504 patterns: themePatterns,
26505 isResolving: isResolvingThemePatterns
26506 } = selectThemePatterns(select2);
26507 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
26508 let patterns = [
26509 ...themePatterns || [],
26510 ...userPatterns || []
26511 ];
26512 if (syncStatus) {
26513 patterns = patterns.filter(
26514 (pattern) => pattern.syncStatus === syncStatus
26515 );
26516 }
26517 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26518 patterns = searchItems(patterns, search, {
26519 categoryId,
26520 hasCategory: (item, currentCategory) => {
26521 return item.categories?.includes(currentCategory);
26522 }
26523 });
26524 } else {
26525 patterns = searchItems(patterns, search, {
26526 categoryId: PATTERN_DEFAULT_CATEGORY,
26527 hasCategory: () => true
26528 });
26529 }
26530 return {
26531 patterns,
26532 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
26533 };
26534 },
26535 (select2) => [
26536 selectThemePatterns(select2),
26537 selectUserPatterns(select2)
26538 ]
26539 );
26540 function useAugmentPatternsWithPermissions(patterns) {
26541 const idsAndTypes = (0, import_element78.useMemo)(
26542 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
26543 record.type,
26544 record._recordId,
26545 record.id
26546 ]) ?? [],
26547 [patterns]
26548 );
26549 const permissions = (0, import_data10.useSelect)(
26550 (select2) => {
26551 const { getEntityRecordPermissions } = unlock4(
26552 select2(import_core_data3.store)
26553 );
26554 return idsAndTypes.reduce(
26555 (acc, [type, numericId, stringId]) => {
26556 acc[stringId] = getEntityRecordPermissions(
26557 "postType",
26558 type,
26559 numericId
26560 );
26561 return acc;
26562 },
26563 {}
26564 );
26565 },
26566 [idsAndTypes]
26567 );
26568 return (0, import_element78.useMemo)(
26569 () => patterns?.map((record) => ({
26570 ...record,
26571 permissions: permissions?.[record.id] ?? {}
26572 })) ?? [],
26573 [patterns, permissions]
26574 );
26575 }
26576 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
26577 return (0, import_data10.useSelect)(
26578 (select2) => {
26579 if (postType === PATTERN_TYPES.user) {
26580 const result = selectUserPatterns(select2, syncStatus, search);
26581 let { patterns } = result;
26582 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26583 patterns = patterns.filter(
26584 (pattern) => pattern.categories.includes(categoryId)
26585 );
26586 }
26587 return {
26588 patterns,
26589 isResolving: result.isResolving
26590 };
26591 } else if (postType === PATTERN_TYPES.theme) {
26592 const result = selectThemePatterns(select2);
26593 let { patterns } = result;
26594 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26595 patterns = patterns.filter(
26596 (pattern) => pattern.categories.includes(categoryId)
26597 );
26598 }
26599 patterns = searchItems(patterns, search, {
26600 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
26601 hasCategory: () => true
26602 });
26603 return {
26604 patterns,
26605 isResolving: result.isResolving
26606 };
26607 }
26608 return selectPatterns(select2, categoryId, syncStatus, search);
26609 },
26610 [categoryId, postType, search, syncStatus]
26611 );
26612 };
26613 var use_patterns_default = usePatterns;
26614
26615 // routes/pattern-list/style.scss
26616 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='a3942f3f8d']")) {
26617 const style = document.createElement("style");
26618 style.setAttribute("data-wp-hash", "a3942f3f8d");
26619 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}.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)}"));
26620 document.head.appendChild(style);
26621 }
26622
26623 // routes/pattern-list/stage.tsx
26624 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
26625 var { Tabs } = unlock4(import_components47.privateApis);
26626 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
26627 function PatternList() {
26628 const invalidate = useInvalidate();
26629 const { type = "all" } = useParams({
26630 from: "/patterns/list/$type"
26631 });
26632 const navigate = useNavigate();
26633 const searchParams = useSearch({ from: "/patterns/list/$type" });
26634 const postTypeObject = (0, import_data11.useSelect)(
26635 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
26636 []
26637 );
26638 const labels = postTypeObject?.labels;
26639 const canCreateRecord = (0, import_data11.useSelect)(
26640 (select2) => select2(import_core_data4.store).canUser("create", {
26641 kind: "postType",
26642 name: "wp_block"
26643 }),
26644 []
26645 );
26646 const [showPatternModal, setShowPatternModal] = (0, import_element79.useState)(false);
26647 const handleQueryParamsChange = (0, import_element79.useCallback)(
26648 (params) => {
26649 navigate({
26650 search: {
26651 ...searchParams,
26652 ...params
26653 }
26654 });
26655 },
26656 [searchParams, navigate]
26657 );
26658 const { view, isModified, updateView, resetToDefault } = useView({
26659 kind: "postType",
26660 name: "wp_block",
26661 slug: "default-new",
26662 defaultView: DEFAULT_VIEW,
26663 queryParams: searchParams,
26664 onChangeQueryParams: handleQueryParamsChange
26665 });
26666 const onReset = () => {
26667 resetToDefault();
26668 invalidate();
26669 };
26670 const onChangeView = (newView) => {
26671 updateView(newView);
26672 if (newView.type !== view.type) {
26673 invalidate();
26674 }
26675 };
26676 const categoryFilter = (0, import_element79.useMemo)(() => {
26677 const filter = view.filters?.find((f2) => f2.field === "category");
26678 return filter?.value || "all-patterns";
26679 }, [view.filters]);
26680 const syncStatusFilter = (0, import_element79.useMemo)(() => {
26681 const filter = view.filters?.find((f2) => f2.field === "sync-status");
26682 return filter?.value;
26683 }, [view.filters]);
26684 const patternType = (0, import_element79.useMemo)(() => {
26685 if (type === "my-patterns") {
26686 return PATTERN_TYPES2.user;
26687 } else if (type === "registered") {
26688 return PATTERN_TYPES2.theme;
26689 }
26690 return null;
26691 }, [type]);
26692 const { patterns, isResolving } = use_patterns_default(
26693 patternType,
26694 categoryFilter,
26695 {
26696 search: view.search,
26697 syncStatus: syncStatusFilter
26698 }
26699 );
26700 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
26701 const patternCategoryField = usePatternCategoryField();
26702 const fields = (0, import_element79.useMemo)(() => {
26703 const patternFields = [
26704 previewField,
26705 patternTitleField,
26706 patternCategoryField
26707 ];
26708 if (type === "my-patterns" || type === "all") {
26709 patternFields.push(patternStatusField);
26710 }
26711 return patternFields;
26712 }, [type, patternCategoryField]);
26713 const { data: posts, paginationInfo } = (0, import_element79.useMemo)(() => {
26714 const viewWithoutFilters = { ...view };
26715 delete viewWithoutFilters.search;
26716 viewWithoutFilters.filters = [];
26717 return filterSortAndPaginate(
26718 patternsWithPermissions,
26719 viewWithoutFilters,
26720 fields
26721 );
26722 }, [patternsWithPermissions, view, fields]);
26723 const { totalItems, totalPages } = paginationInfo;
26724 const cleanupDeletedPostIdsFromUrl = (0, import_element79.useCallback)(
26725 (deletedItems) => {
26726 const deletedIds = deletedItems.map((item) => item.id);
26727 const currentPostIds = searchParams.postIds || [];
26728 const remainingPostIds = currentPostIds.filter(
26729 (id) => !deletedIds.includes(id)
26730 );
26731 if (remainingPostIds.length !== currentPostIds.length) {
26732 navigate({
26733 search: {
26734 ...searchParams,
26735 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
26736 }
26737 });
26738 } else {
26739 invalidate();
26740 }
26741 },
26742 [invalidate, searchParams, navigate]
26743 );
26744 const postTypeActions = usePostActions({
26745 postType: "wp_block",
26746 context: "list",
26747 onActionPerformed: (actionId, items) => {
26748 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
26749 cleanupDeletedPostIdsFromUrl(items);
26750 }
26751 }
26752 });
26753 const actions = (0, import_element79.useMemo)(() => {
26754 return [
26755 ...postTypeActions?.flatMap((action) => {
26756 if (action.id === "view-post-revisions") {
26757 return [];
26758 }
26759 return [action];
26760 })
26761 ];
26762 }, [postTypeActions]);
26763 const handleTabChange = (0, import_element79.useCallback)(
26764 (typeSlug) => {
26765 navigate({
26766 to: `/patterns/list/${typeSlug}`
26767 });
26768 },
26769 [navigate]
26770 );
26771 if (!postTypeObject) {
26772 return null;
26773 }
26774 const selection = searchParams.postIds ?? [];
26775 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
26776 selection.push(posts[0].id);
26777 }
26778 if (view.type === "list") {
26779 selection.splice(1);
26780 }
26781 return /* @__PURE__ */ React.createElement(
26782 page_default,
26783 {
26784 title: (0, import_i18n48.__)("Patterns"),
26785 headingLevel: 2,
26786 subTitle: (0, import_i18n48.__)(
26787 "Reusable design elements for your site. Create once, use everywhere."
26788 ),
26789 className: "pattern-page",
26790 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
26791 import_components47.Button,
26792 {
26793 variant: "primary",
26794 onClick: () => setShowPatternModal(true),
26795 size: "compact"
26796 },
26797 labels.add_new_item
26798 ),
26799 hasPadding: false
26800 },
26801 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
26802 Tabs,
26803 {
26804 onSelect: handleTabChange,
26805 selectedTabId: type ?? "all"
26806 },
26807 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
26808 (filter) => /* @__PURE__ */ React.createElement(
26809 Tabs.Tab,
26810 {
26811 tabId: filter.slug,
26812 key: filter.slug
26813 },
26814 filter.label
26815 )
26816 ))
26817 )),
26818 /* @__PURE__ */ React.createElement(
26819 dataviews_default,
26820 {
26821 data: posts,
26822 fields,
26823 view,
26824 onChangeView,
26825 actions,
26826 isLoading: isResolving,
26827 paginationInfo: {
26828 totalItems,
26829 totalPages
26830 },
26831 defaultLayouts: DEFAULT_LAYOUTS2,
26832 selection,
26833 onReset: isModified ? onReset : false,
26834 onChangeSelection: (items) => {
26835 navigate({
26836 search: {
26837 ...searchParams,
26838 postIds: items.length > 0 ? items : void 0,
26839 edit: items.length === 0 ? void 0 : searchParams.edit
26840 }
26841 });
26842 },
26843 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
26844 renderItemLink: ({
26845 item,
26846 ...props
26847 }) => /* @__PURE__ */ React.createElement(
26848 Link,
26849 {
26850 to: `/types/wp_block/edit/${encodeURIComponent(
26851 item.id
26852 )}`,
26853 ...props,
26854 onClick: (event) => {
26855 event.stopPropagation();
26856 }
26857 }
26858 )
26859 }
26860 ),
26861 showPatternModal && /* @__PURE__ */ React.createElement(
26862 CreatePatternModal,
26863 {
26864 onClose: () => setShowPatternModal(false),
26865 onSuccess: ({
26866 pattern
26867 }) => {
26868 setShowPatternModal(false);
26869 navigate({
26870 to: `/types/wp_block/edit/${encodeURIComponent(
26871 pattern.id
26872 )}`
26873 });
26874 },
26875 content: []
26876 }
26877 )
26878 );
26879 }
26880 var stage = PatternList;
26881 export {
26882 stage
26883 };
26884 /*! Bundled license information:
26885
26886 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26887 (**
26888 * @license React
26889 * use-sync-external-store-shim.development.js
26890 *
26891 * Copyright (c) Meta Platforms, Inc. and affiliates.
26892 *
26893 * This source code is licensed under the MIT license found in the
26894 * LICENSE file in the root directory of this source tree.
26895 *)
26896
26897 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26898 (**
26899 * @license React
26900 * use-sync-external-store-shim/with-selector.development.js
26901 *
26902 * Copyright (c) Meta Platforms, Inc. and affiliates.
26903 *
26904 * This source code is licensed under the MIT license found in the
26905 * LICENSE file in the root directory of this source tree.
26906 *)
26907 */
26908