PluginProbe
Gutenberg / 23.6.0
Gutenberg v23.6.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / routes / pattern-list / content.js

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

27,910 lines 956.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 = useState37({
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 useEffect32(
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, useState37 = React50.useState, useEffect32 = React50.useEffect, useLayoutEffect5 = React50.useLayoutEffect, useDebugValue2 = React50.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
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, useRef48 = React50.useRef, useEffect32 = React50.useEffect, useMemo44 = React50.useMemo, useDebugValue2 = React50.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef48(null);
182 if (null === instRef.current) {
183 var inst = { hasValue: false, value: null };
184 instRef.current = inst;
185 } else inst = instRef.current;
186 instRef = useMemo44(
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 useEffect32(
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/rich-text
837 var require_rich_text = __commonJS({
838 "package-external:@wordpress/rich-text"(exports, module) {
839 module.exports = window.wp.richText;
840 }
841 });
842
843 // package-external:@wordpress/deprecated
844 var require_deprecated = __commonJS({
845 "package-external:@wordpress/deprecated"(exports, module) {
846 module.exports = window.wp.deprecated;
847 }
848 });
849
850 // package-external:@wordpress/editor
851 var require_editor = __commonJS({
852 "package-external:@wordpress/editor"(exports, module) {
853 module.exports = window.wp.editor;
854 }
855 });
856
857 // package-external:@wordpress/patterns
858 var require_patterns = __commonJS({
859 "package-external:@wordpress/patterns"(exports, module) {
860 module.exports = window.wp.patterns;
861 }
862 });
863
864 // package-external:@wordpress/block-editor
865 var require_block_editor = __commonJS({
866 "package-external:@wordpress/block-editor"(exports, module) {
867 module.exports = window.wp.blockEditor;
868 }
869 });
870
871 // routes/pattern-list/stage.tsx
872 import {
873 useParams,
874 useNavigate,
875 useSearch,
876 Link,
877 useInvalidate
878 } from "@wordpress/route";
879
880 // node_modules/dequal/dist/index.mjs
881 var has = Object.prototype.hasOwnProperty;
882 function find(iter, tar, key) {
883 for (key of iter.keys()) {
884 if (dequal(key, tar)) return key;
885 }
886 }
887 function dequal(foo, bar) {
888 var ctor, len, tmp;
889 if (foo === bar) return true;
890 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
891 if (ctor === Date) return foo.getTime() === bar.getTime();
892 if (ctor === RegExp) return foo.toString() === bar.toString();
893 if (ctor === Array) {
894 if ((len = foo.length) === bar.length) {
895 while (len-- && dequal(foo[len], bar[len])) ;
896 }
897 return len === -1;
898 }
899 if (ctor === Set) {
900 if (foo.size !== bar.size) {
901 return false;
902 }
903 for (len of foo) {
904 tmp = len;
905 if (tmp && typeof tmp === "object") {
906 tmp = find(bar, tmp);
907 if (!tmp) return false;
908 }
909 if (!bar.has(tmp)) return false;
910 }
911 return true;
912 }
913 if (ctor === Map) {
914 if (foo.size !== bar.size) {
915 return false;
916 }
917 for (len of foo) {
918 tmp = len[0];
919 if (tmp && typeof tmp === "object") {
920 tmp = find(bar, tmp);
921 if (!tmp) return false;
922 }
923 if (!dequal(len[1], bar.get(tmp))) {
924 return false;
925 }
926 }
927 return true;
928 }
929 if (ctor === ArrayBuffer) {
930 foo = new Uint8Array(foo);
931 bar = new Uint8Array(bar);
932 } else if (ctor === DataView) {
933 if ((len = foo.byteLength) === bar.byteLength) {
934 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
935 }
936 return len === -1;
937 }
938 if (ArrayBuffer.isView(foo)) {
939 if ((len = foo.byteLength) === bar.byteLength) {
940 while (len-- && foo[len] === bar[len]) ;
941 }
942 return len === -1;
943 }
944 if (!ctor || typeof foo === "object") {
945 len = 0;
946 for (ctor in foo) {
947 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
948 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
949 }
950 return Object.keys(bar).length === len;
951 }
952 }
953 return foo !== foo && bar !== bar;
954 }
955
956 // packages/views/build-module/use-view.mjs
957 var import_element = __toESM(require_element(), 1);
958 var import_data = __toESM(require_data(), 1);
959 var import_preferences = __toESM(require_preferences(), 1);
960
961 // packages/views/build-module/preference-keys.mjs
962 function generatePreferenceKey(kind, name, slug) {
963 return `dataviews-${kind}-${name}-${slug}`;
964 }
965
966 // packages/views/build-module/filter-utils.mjs
967 var SCALAR_VALUES = [
968 "titleField",
969 "mediaField",
970 "descriptionField",
971 "showTitle",
972 "showMedia",
973 "showDescription",
974 "showLevels",
975 "infiniteScrollEnabled"
976 ];
977 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
978 if (!activeViewOverrides) {
979 return view;
980 }
981 let result = view;
982 for (const key of SCALAR_VALUES) {
983 if (key in activeViewOverrides) {
984 result = { ...result, [key]: activeViewOverrides[key] };
985 }
986 }
987 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
988 const activeFields = new Set(
989 activeViewOverrides.filters.map((f2) => f2.field)
990 );
991 const preserved = (view.filters ?? []).filter(
992 (f2) => !activeFields.has(f2.field)
993 );
994 result = {
995 ...result,
996 filters: [...preserved, ...activeViewOverrides.filters]
997 };
998 }
999 if (activeViewOverrides.sort) {
1000 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
1001 if (isDefaultSort) {
1002 result = {
1003 ...result,
1004 sort: activeViewOverrides.sort
1005 };
1006 }
1007 }
1008 if (activeViewOverrides.layout) {
1009 result = {
1010 ...result,
1011 layout: {
1012 ...result.layout,
1013 ...activeViewOverrides.layout
1014 }
1015 };
1016 }
1017 if (activeViewOverrides.groupBy) {
1018 result = {
1019 ...result,
1020 groupBy: activeViewOverrides.groupBy
1021 };
1022 }
1023 return result;
1024 }
1025 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
1026 if (!activeViewOverrides) {
1027 return view;
1028 }
1029 let result = view;
1030 for (const key of SCALAR_VALUES) {
1031 if (key in activeViewOverrides) {
1032 const { [key]: _, ...rest } = result;
1033 result = rest;
1034 }
1035 }
1036 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
1037 const activeFields = new Set(
1038 activeViewOverrides.filters.map((f2) => f2.field)
1039 );
1040 result = {
1041 ...result,
1042 filters: (view.filters ?? []).filter(
1043 (f2) => !activeFields.has(f2.field)
1044 )
1045 };
1046 }
1047 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
1048 result = {
1049 ...result,
1050 sort: defaultView?.sort
1051 };
1052 }
1053 if (activeViewOverrides.layout && "layout" in result && result.layout) {
1054 const layout = { ...result.layout };
1055 for (const key of Object.keys(activeViewOverrides.layout)) {
1056 delete layout[key];
1057 }
1058 result = {
1059 ...result,
1060 layout: Object.keys(layout).length > 0 ? layout : void 0
1061 };
1062 }
1063 if (activeViewOverrides.groupBy && "groupBy" in result) {
1064 const { groupBy: _, ...rest } = result;
1065 result = rest;
1066 }
1067 return result;
1068 }
1069
1070 // packages/views/build-module/use-view.mjs
1071 function omit(obj, keys) {
1072 const result = { ...obj };
1073 for (const key of keys) {
1074 delete result[key];
1075 }
1076 return result;
1077 }
1078 function useView(config) {
1079 const {
1080 kind,
1081 name,
1082 slug,
1083 defaultView,
1084 activeViewOverrides,
1085 queryParams,
1086 onChangeQueryParams
1087 } = config;
1088 const preferenceKey = generatePreferenceKey(kind, name, slug);
1089 const persistedView = (0, import_data.useSelect)(
1090 (select2) => {
1091 return select2(import_preferences.store).get(
1092 "core/views",
1093 preferenceKey
1094 );
1095 },
1096 [preferenceKey]
1097 );
1098 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1099 const baseView = (0, import_element.useMemo)(
1100 () => persistedView ?? defaultView ?? {},
1101 [persistedView, defaultView]
1102 );
1103 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1104 const search = queryParams?.search ?? baseView.search ?? "";
1105 const combinedOverrides = (0, import_element.useMemo)(() => {
1106 const rawDefaults = config.defaultLayouts?.[baseView.type];
1107 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1108 return { ...layoutTypeDefaults, ...activeViewOverrides };
1109 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1110 const view = (0, import_element.useMemo)(() => {
1111 return mergeActiveViewOverrides(
1112 {
1113 ...baseView,
1114 page,
1115 search
1116 },
1117 combinedOverrides,
1118 defaultView
1119 );
1120 }, [baseView, page, search, combinedOverrides, defaultView]);
1121 const isModified = !!persistedView;
1122 const updateView = (0, import_element.useCallback)(
1123 (newView) => {
1124 const urlParams = {
1125 page: newView?.page,
1126 search: newView?.search
1127 };
1128 const preferenceView = stripActiveViewOverrides(
1129 omit(newView, ["page", "search"]),
1130 combinedOverrides,
1131 defaultView
1132 );
1133 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1134 onChangeQueryParams(urlParams);
1135 }
1136 const comparableBaseView = stripActiveViewOverrides(
1137 baseView,
1138 combinedOverrides,
1139 defaultView
1140 );
1141 const comparableDefaultView = stripActiveViewOverrides(
1142 defaultView,
1143 combinedOverrides,
1144 defaultView
1145 );
1146 if (!dequal(comparableBaseView, preferenceView)) {
1147 if (dequal(preferenceView, comparableDefaultView)) {
1148 set2("core/views", preferenceKey, void 0);
1149 } else {
1150 set2("core/views", preferenceKey, preferenceView);
1151 }
1152 }
1153 },
1154 [
1155 onChangeQueryParams,
1156 page,
1157 search,
1158 baseView,
1159 defaultView,
1160 combinedOverrides,
1161 set2,
1162 preferenceKey
1163 ]
1164 );
1165 const resetToDefault = (0, import_element.useCallback)(() => {
1166 set2("core/views", preferenceKey, void 0);
1167 }, [preferenceKey, set2]);
1168 return {
1169 view,
1170 isModified,
1171 updateView,
1172 resetToDefault
1173 };
1174 }
1175
1176 // packages/views/build-module/load-view.mjs
1177 var import_data2 = __toESM(require_data(), 1);
1178 var import_preferences2 = __toESM(require_preferences(), 1);
1179
1180 // packages/views/build-module/use-view-config.mjs
1181 var import_data3 = __toESM(require_data(), 1);
1182 var import_core_data = __toESM(require_core_data(), 1);
1183
1184 // packages/views/build-module/lock-unlock.mjs
1185 var import_private_apis = __toESM(require_private_apis(), 1);
1186 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1187 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1188 "@wordpress/views"
1189 );
1190
1191 // node_modules/clsx/dist/clsx.mjs
1192 function r(e2) {
1193 var t2, f2, n2 = "";
1194 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1195 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1196 var o2 = e2.length;
1197 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1198 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1199 return n2;
1200 }
1201 function clsx() {
1202 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1203 return n2;
1204 }
1205 var clsx_default = clsx;
1206
1207 // packages/dataviews/build-module/dataviews/index.mjs
1208 var import_element78 = __toESM(require_element(), 1);
1209 var import_compose14 = __toESM(require_compose(), 1);
1210
1211 // node_modules/@base-ui/utils/safeReact.mjs
1212 var React2 = __toESM(require_react(), 1);
1213 var SafeReact = {
1214 ...React2
1215 };
1216
1217 // node_modules/@base-ui/utils/useRefWithInit.mjs
1218 var React3 = __toESM(require_react(), 1);
1219 var UNINITIALIZED = {};
1220 function useRefWithInit(init2, initArg) {
1221 const ref = React3.useRef(UNINITIALIZED);
1222 if (ref.current === UNINITIALIZED) {
1223 ref.current = init2(initArg);
1224 }
1225 return ref;
1226 }
1227
1228 // node_modules/@base-ui/utils/useStableCallback.mjs
1229 var useInsertionEffect = SafeReact.useInsertionEffect;
1230 var useSafeInsertionEffect = (
1231 // React 17 doesn't have useInsertionEffect.
1232 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1233 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1234 );
1235 function useStableCallback(callback) {
1236 const stable = useRefWithInit(createStableCallback).current;
1237 stable.next = callback;
1238 useSafeInsertionEffect(stable.effect);
1239 return stable.trampoline;
1240 }
1241 function createStableCallback() {
1242 const stable = {
1243 next: void 0,
1244 callback: assertNotCalled,
1245 trampoline: (...args) => stable.callback?.(...args),
1246 effect: () => {
1247 stable.callback = stable.next;
1248 }
1249 };
1250 return stable;
1251 }
1252 function assertNotCalled() {
1253 if (true) {
1254 throw (
1255 /* minify-error-disabled */
1256 new Error("Base UI: Cannot call an event handler while rendering.")
1257 );
1258 }
1259 }
1260
1261 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1262 var React4 = __toESM(require_react(), 1);
1263 var noop = () => {
1264 };
1265 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1266
1267 // node_modules/@base-ui/utils/warn.mjs
1268 var set;
1269 if (true) {
1270 set = /* @__PURE__ */ new Set();
1271 }
1272 function warn(...messages) {
1273 if (true) {
1274 const messageKey = messages.join(" ");
1275 if (!set.has(messageKey)) {
1276 set.add(messageKey);
1277 console.warn(`Base UI: ${messageKey}`);
1278 }
1279 }
1280 }
1281
1282 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1283 var React5 = __toESM(require_react(), 1);
1284 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1285 if (true) DirectionContext.displayName = "DirectionContext";
1286 function useDirection() {
1287 const context = React5.useContext(DirectionContext);
1288 return context?.direction ?? "ltr";
1289 }
1290
1291 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1292 var React8 = __toESM(require_react(), 1);
1293
1294 // node_modules/@base-ui/utils/useMergedRefs.mjs
1295 function useMergedRefs(a2, b2, c2, d2) {
1296 const forkRef = useRefWithInit(createForkRef).current;
1297 if (didChange(forkRef, a2, b2, c2, d2)) {
1298 update(forkRef, [a2, b2, c2, d2]);
1299 }
1300 return forkRef.callback;
1301 }
1302 function useMergedRefsN(refs) {
1303 const forkRef = useRefWithInit(createForkRef).current;
1304 if (didChangeN(forkRef, refs)) {
1305 update(forkRef, refs);
1306 }
1307 return forkRef.callback;
1308 }
1309 function createForkRef() {
1310 return {
1311 callback: null,
1312 cleanup: null,
1313 refs: []
1314 };
1315 }
1316 function didChange(forkRef, a2, b2, c2, d2) {
1317 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1318 }
1319 function didChangeN(forkRef, newRefs) {
1320 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1321 }
1322 function update(forkRef, refs) {
1323 forkRef.refs = refs;
1324 if (refs.every((ref) => ref == null)) {
1325 forkRef.callback = null;
1326 return;
1327 }
1328 forkRef.callback = (instance) => {
1329 if (forkRef.cleanup) {
1330 forkRef.cleanup();
1331 forkRef.cleanup = null;
1332 }
1333 if (instance != null) {
1334 const cleanupCallbacks = Array(refs.length).fill(null);
1335 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1336 const ref = refs[i2];
1337 if (ref == null) {
1338 continue;
1339 }
1340 switch (typeof ref) {
1341 case "function": {
1342 const refCleanup = ref(instance);
1343 if (typeof refCleanup === "function") {
1344 cleanupCallbacks[i2] = refCleanup;
1345 }
1346 break;
1347 }
1348 case "object": {
1349 ref.current = instance;
1350 break;
1351 }
1352 default:
1353 }
1354 }
1355 forkRef.cleanup = () => {
1356 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1357 const ref = refs[i2];
1358 if (ref == null) {
1359 continue;
1360 }
1361 switch (typeof ref) {
1362 case "function": {
1363 const cleanupCallback = cleanupCallbacks[i2];
1364 if (typeof cleanupCallback === "function") {
1365 cleanupCallback();
1366 } else {
1367 ref(null);
1368 }
1369 break;
1370 }
1371 case "object": {
1372 ref.current = null;
1373 break;
1374 }
1375 default:
1376 }
1377 }
1378 };
1379 }
1380 };
1381 }
1382
1383 // node_modules/@base-ui/utils/getReactElementRef.mjs
1384 var React7 = __toESM(require_react(), 1);
1385
1386 // node_modules/@base-ui/utils/reactVersion.mjs
1387 var React6 = __toESM(require_react(), 1);
1388 var majorVersion = parseInt(React6.version, 10);
1389 function isReactVersionAtLeast(reactVersionToCheck) {
1390 return majorVersion >= reactVersionToCheck;
1391 }
1392
1393 // node_modules/@base-ui/utils/getReactElementRef.mjs
1394 function getReactElementRef(element) {
1395 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1396 return null;
1397 }
1398 const reactElement = element;
1399 const propsWithRef = reactElement.props;
1400 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1401 }
1402
1403 // node_modules/@base-ui/utils/mergeObjects.mjs
1404 function mergeObjects(a2, b2) {
1405 if (a2 && !b2) {
1406 return a2;
1407 }
1408 if (!a2 && b2) {
1409 return b2;
1410 }
1411 if (a2 || b2) {
1412 return {
1413 ...a2,
1414 ...b2
1415 };
1416 }
1417 return void 0;
1418 }
1419
1420 // node_modules/@base-ui/utils/empty.mjs
1421 function NOOP() {
1422 }
1423 var EMPTY_ARRAY = Object.freeze([]);
1424 var EMPTY_OBJECT = Object.freeze({});
1425
1426 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1427 function getStateAttributesProps(state, customMapping) {
1428 const props = {};
1429 for (const key in state) {
1430 const value = state[key];
1431 if (customMapping?.hasOwnProperty(key)) {
1432 const customProps = customMapping[key](value);
1433 if (customProps != null) {
1434 Object.assign(props, customProps);
1435 }
1436 continue;
1437 }
1438 if (value === true) {
1439 props[`data-${key.toLowerCase()}`] = "";
1440 } else if (value) {
1441 props[`data-${key.toLowerCase()}`] = value.toString();
1442 }
1443 }
1444 return props;
1445 }
1446
1447 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1448 function resolveClassName(className, state) {
1449 return typeof className === "function" ? className(state) : className;
1450 }
1451
1452 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1453 function resolveStyle(style, state) {
1454 return typeof style === "function" ? style(state) : style;
1455 }
1456
1457 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1458 var EMPTY_PROPS = {};
1459 function mergeProps(a2, b2, c2, d2, e2) {
1460 if (!c2 && !d2 && !e2 && !a2) {
1461 return createInitialMergedProps(b2);
1462 }
1463 let merged = createInitialMergedProps(a2);
1464 if (b2) {
1465 merged = mergeInto(merged, b2);
1466 }
1467 if (c2) {
1468 merged = mergeInto(merged, c2);
1469 }
1470 if (d2) {
1471 merged = mergeInto(merged, d2);
1472 }
1473 if (e2) {
1474 merged = mergeInto(merged, e2);
1475 }
1476 return merged;
1477 }
1478 function mergePropsN(props) {
1479 if (props.length === 0) {
1480 return EMPTY_PROPS;
1481 }
1482 if (props.length === 1) {
1483 return createInitialMergedProps(props[0]);
1484 }
1485 let merged = createInitialMergedProps(props[0]);
1486 for (let i2 = 1; i2 < props.length; i2 += 1) {
1487 merged = mergeInto(merged, props[i2]);
1488 }
1489 return merged;
1490 }
1491 function createInitialMergedProps(inputProps) {
1492 if (isPropsGetter(inputProps)) {
1493 return {
1494 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1495 };
1496 }
1497 return copyInitialProps(inputProps);
1498 }
1499 function mergeInto(merged, inputProps) {
1500 if (isPropsGetter(inputProps)) {
1501 return resolvePropsGetter(inputProps, merged);
1502 }
1503 return mutablyMergeInto(merged, inputProps);
1504 }
1505 function copyInitialProps(inputProps) {
1506 const copiedProps = {
1507 ...inputProps
1508 };
1509 for (const propName in copiedProps) {
1510 const propValue = copiedProps[propName];
1511 if (isEventHandler(propName, propValue)) {
1512 copiedProps[propName] = wrapEventHandler(propValue);
1513 }
1514 }
1515 return copiedProps;
1516 }
1517 function mutablyMergeInto(mergedProps, externalProps) {
1518 if (!externalProps) {
1519 return mergedProps;
1520 }
1521 for (const propName in externalProps) {
1522 const externalPropValue = externalProps[propName];
1523 switch (propName) {
1524 case "style": {
1525 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1526 break;
1527 }
1528 case "className": {
1529 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1530 break;
1531 }
1532 default: {
1533 if (isEventHandler(propName, externalPropValue)) {
1534 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1535 } else {
1536 mergedProps[propName] = externalPropValue;
1537 }
1538 }
1539 }
1540 }
1541 return mergedProps;
1542 }
1543 function isEventHandler(key, value) {
1544 const code0 = key.charCodeAt(0);
1545 const code1 = key.charCodeAt(1);
1546 const code2 = key.charCodeAt(2);
1547 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1548 }
1549 function isPropsGetter(inputProps) {
1550 return typeof inputProps === "function";
1551 }
1552 function resolvePropsGetter(inputProps, previousProps) {
1553 if (isPropsGetter(inputProps)) {
1554 return inputProps(previousProps);
1555 }
1556 return inputProps ?? EMPTY_PROPS;
1557 }
1558 function mergeEventHandlers(ourHandler, theirHandler) {
1559 if (!theirHandler) {
1560 return ourHandler;
1561 }
1562 if (!ourHandler) {
1563 return wrapEventHandler(theirHandler);
1564 }
1565 return (...args) => {
1566 const event = args[0];
1567 if (isSyntheticEvent(event)) {
1568 const baseUIEvent = event;
1569 makeEventPreventable(baseUIEvent);
1570 const result2 = theirHandler(...args);
1571 if (!baseUIEvent.baseUIHandlerPrevented) {
1572 ourHandler?.(...args);
1573 }
1574 return result2;
1575 }
1576 const result = theirHandler(...args);
1577 ourHandler?.(...args);
1578 return result;
1579 };
1580 }
1581 function wrapEventHandler(handler) {
1582 if (!handler) {
1583 return handler;
1584 }
1585 return (...args) => {
1586 const event = args[0];
1587 if (isSyntheticEvent(event)) {
1588 makeEventPreventable(event);
1589 }
1590 return handler(...args);
1591 };
1592 }
1593 function makeEventPreventable(event) {
1594 event.preventBaseUIHandler = () => {
1595 event.baseUIHandlerPrevented = true;
1596 };
1597 return event;
1598 }
1599 function mergeClassNames(ourClassName, theirClassName) {
1600 if (theirClassName) {
1601 if (ourClassName) {
1602 return theirClassName + " " + ourClassName;
1603 }
1604 return theirClassName;
1605 }
1606 return ourClassName;
1607 }
1608 function isSyntheticEvent(event) {
1609 return event != null && typeof event === "object" && "nativeEvent" in event;
1610 }
1611
1612 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1613 var import_react = __toESM(require_react(), 1);
1614 function useRenderElement(element, componentProps, params = {}) {
1615 const renderProp = componentProps.render;
1616 const outProps = useRenderElementProps(componentProps, params);
1617 if (params.enabled === false) {
1618 return null;
1619 }
1620 const state = params.state ?? EMPTY_OBJECT;
1621 return evaluateRenderProp(element, renderProp, outProps, state);
1622 }
1623 function useRenderElementProps(componentProps, params = {}) {
1624 const {
1625 className: classNameProp,
1626 style: styleProp,
1627 render: renderProp
1628 } = componentProps;
1629 const {
1630 state = EMPTY_OBJECT,
1631 ref,
1632 props,
1633 stateAttributesMapping: stateAttributesMapping3,
1634 enabled = true
1635 } = params;
1636 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1637 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1638 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1639 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1640 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1641 if (typeof document !== "undefined") {
1642 if (!enabled) {
1643 useMergedRefs(null, null);
1644 } else if (Array.isArray(ref)) {
1645 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1646 } else {
1647 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1648 }
1649 }
1650 if (!enabled) {
1651 return EMPTY_OBJECT;
1652 }
1653 if (className !== void 0) {
1654 outProps.className = mergeClassNames(outProps.className, className);
1655 }
1656 if (style !== void 0) {
1657 outProps.style = mergeObjects(outProps.style, style);
1658 }
1659 return outProps;
1660 }
1661 function resolveRenderFunctionProps(props) {
1662 if (Array.isArray(props)) {
1663 return mergePropsN(props);
1664 }
1665 return mergeProps(void 0, props);
1666 }
1667 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1668 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1669 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1670 function evaluateRenderProp(element, render4, props, state) {
1671 if (render4) {
1672 if (typeof render4 === "function") {
1673 if (true) {
1674 warnIfRenderPropLooksLikeComponent(render4);
1675 }
1676 return render4(props, state);
1677 }
1678 const mergedProps = mergeProps(props, render4.props);
1679 mergedProps.ref = props.ref;
1680 let newElement = render4;
1681 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1682 const children = React8.Children.toArray(render4);
1683 newElement = children[0];
1684 }
1685 if (true) {
1686 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1687 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"));
1688 }
1689 }
1690 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1691 }
1692 if (element) {
1693 if (typeof element === "string") {
1694 return renderTag(element, props);
1695 }
1696 }
1697 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1698 }
1699 function warnIfRenderPropLooksLikeComponent(renderFn) {
1700 const functionName = renderFn.name;
1701 if (functionName.length === 0) {
1702 return;
1703 }
1704 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1705 return;
1706 }
1707 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1708 return;
1709 }
1710 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");
1711 }
1712 function renderTag(Tag, props) {
1713 if (Tag === "button") {
1714 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1715 type: "button",
1716 ...props,
1717 key: props.key
1718 });
1719 }
1720 if (Tag === "img") {
1721 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1722 alt: "",
1723 ...props,
1724 key: props.key
1725 });
1726 }
1727 return /* @__PURE__ */ React8.createElement(Tag, props);
1728 }
1729
1730 // node_modules/@base-ui/utils/useId.mjs
1731 var React9 = __toESM(require_react(), 1);
1732 var globalId = 0;
1733 function useGlobalId(idOverride, prefix = "mui") {
1734 const [defaultId, setDefaultId] = React9.useState(idOverride);
1735 const id = idOverride || defaultId;
1736 React9.useEffect(() => {
1737 if (defaultId == null) {
1738 globalId += 1;
1739 setDefaultId(`${prefix}-${globalId}`);
1740 }
1741 }, [defaultId, prefix]);
1742 return id;
1743 }
1744 var maybeReactUseId = SafeReact.useId;
1745 function useId(idOverride, prefix) {
1746 if (maybeReactUseId !== void 0) {
1747 const reactId = maybeReactUseId();
1748 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1749 }
1750 return useGlobalId(idOverride, prefix);
1751 }
1752
1753 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1754 function useBaseUiId(idOverride) {
1755 return useId(idOverride, "base-ui");
1756 }
1757
1758 // node_modules/@base-ui/react/internals/reason-parts.mjs
1759 var reason_parts_exports = {};
1760 __export(reason_parts_exports, {
1761 cancelOpen: () => cancelOpen,
1762 chipRemovePress: () => chipRemovePress,
1763 clearPress: () => clearPress,
1764 closePress: () => closePress,
1765 closeWatcher: () => closeWatcher,
1766 decrementPress: () => decrementPress,
1767 disabled: () => disabled,
1768 drag: () => drag,
1769 escapeKey: () => escapeKey,
1770 focusOut: () => focusOut,
1771 imperativeAction: () => imperativeAction,
1772 incrementPress: () => incrementPress,
1773 initial: () => initial,
1774 inputBlur: () => inputBlur,
1775 inputChange: () => inputChange,
1776 inputClear: () => inputClear,
1777 inputPaste: () => inputPaste,
1778 inputPress: () => inputPress,
1779 itemPress: () => itemPress,
1780 keyboard: () => keyboard,
1781 linkPress: () => linkPress,
1782 listNavigation: () => listNavigation,
1783 missing: () => missing,
1784 none: () => none,
1785 outsidePress: () => outsidePress,
1786 pointer: () => pointer,
1787 scrub: () => scrub,
1788 siblingOpen: () => siblingOpen,
1789 swipe: () => swipe,
1790 trackPress: () => trackPress,
1791 triggerFocus: () => triggerFocus,
1792 triggerHover: () => triggerHover,
1793 triggerPress: () => triggerPress,
1794 wheel: () => wheel,
1795 windowResize: () => windowResize
1796 });
1797 var none = "none";
1798 var triggerPress = "trigger-press";
1799 var triggerHover = "trigger-hover";
1800 var triggerFocus = "trigger-focus";
1801 var outsidePress = "outside-press";
1802 var itemPress = "item-press";
1803 var closePress = "close-press";
1804 var linkPress = "link-press";
1805 var clearPress = "clear-press";
1806 var chipRemovePress = "chip-remove-press";
1807 var trackPress = "track-press";
1808 var incrementPress = "increment-press";
1809 var decrementPress = "decrement-press";
1810 var inputChange = "input-change";
1811 var inputClear = "input-clear";
1812 var inputBlur = "input-blur";
1813 var inputPaste = "input-paste";
1814 var inputPress = "input-press";
1815 var focusOut = "focus-out";
1816 var escapeKey = "escape-key";
1817 var closeWatcher = "close-watcher";
1818 var listNavigation = "list-navigation";
1819 var keyboard = "keyboard";
1820 var pointer = "pointer";
1821 var drag = "drag";
1822 var wheel = "wheel";
1823 var scrub = "scrub";
1824 var cancelOpen = "cancel-open";
1825 var siblingOpen = "sibling-open";
1826 var disabled = "disabled";
1827 var missing = "missing";
1828 var initial = "initial";
1829 var imperativeAction = "imperative-action";
1830 var swipe = "swipe";
1831 var windowResize = "window-resize";
1832
1833 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1834 function createChangeEventDetails(reason, event, trigger, customProperties) {
1835 let canceled = false;
1836 let allowPropagation = false;
1837 const custom = customProperties ?? EMPTY_OBJECT;
1838 const details = {
1839 reason,
1840 event: event ?? new Event("base-ui"),
1841 cancel() {
1842 canceled = true;
1843 },
1844 allowPropagation() {
1845 allowPropagation = true;
1846 },
1847 get isCanceled() {
1848 return canceled;
1849 },
1850 get isPropagationAllowed() {
1851 return allowPropagation;
1852 },
1853 trigger,
1854 ...custom
1855 };
1856 return details;
1857 }
1858
1859 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1860 var React11 = __toESM(require_react(), 1);
1861
1862 // node_modules/@base-ui/utils/useOnMount.mjs
1863 var React10 = __toESM(require_react(), 1);
1864 var EMPTY = [];
1865 function useOnMount(fn) {
1866 React10.useEffect(fn, EMPTY);
1867 }
1868
1869 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1870 var EMPTY2 = null;
1871 var LAST_RAF = globalThis.requestAnimationFrame;
1872 var Scheduler = class {
1873 /* This implementation uses an array as a backing data-structure for frame callbacks.
1874 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1875 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1876 * be much more efficient if there is a call pattern that alterns as
1877 * "request-cancel-request-cancel-…".
1878 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1879 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1880 callbacks = [];
1881 callbacksCount = 0;
1882 nextId = 1;
1883 startId = 1;
1884 isScheduled = false;
1885 tick = (timestamp) => {
1886 this.isScheduled = false;
1887 const currentCallbacks = this.callbacks;
1888 const currentCallbacksCount = this.callbacksCount;
1889 this.callbacks = [];
1890 this.callbacksCount = 0;
1891 this.startId = this.nextId;
1892 if (currentCallbacksCount > 0) {
1893 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1894 currentCallbacks[i2]?.(timestamp);
1895 }
1896 }
1897 };
1898 request(fn) {
1899 const id = this.nextId;
1900 this.nextId += 1;
1901 this.callbacks.push(fn);
1902 this.callbacksCount += 1;
1903 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1904 if (!this.isScheduled || didRAFChange) {
1905 requestAnimationFrame(this.tick);
1906 this.isScheduled = true;
1907 }
1908 return id;
1909 }
1910 cancel(id) {
1911 const index2 = id - this.startId;
1912 if (index2 < 0 || index2 >= this.callbacks.length) {
1913 return;
1914 }
1915 this.callbacks[index2] = null;
1916 this.callbacksCount -= 1;
1917 }
1918 };
1919 var scheduler = new Scheduler();
1920 var AnimationFrame = class _AnimationFrame {
1921 static create() {
1922 return new _AnimationFrame();
1923 }
1924 static request(fn) {
1925 return scheduler.request(fn);
1926 }
1927 static cancel(id) {
1928 return scheduler.cancel(id);
1929 }
1930 currentId = EMPTY2;
1931 /**
1932 * Executes `fn` after `delay`, clearing any previously scheduled call.
1933 */
1934 request(fn) {
1935 this.cancel();
1936 this.currentId = scheduler.request(() => {
1937 this.currentId = EMPTY2;
1938 fn();
1939 });
1940 }
1941 cancel = () => {
1942 if (this.currentId !== EMPTY2) {
1943 scheduler.cancel(this.currentId);
1944 this.currentId = EMPTY2;
1945 }
1946 };
1947 disposeEffect = () => {
1948 return this.cancel;
1949 };
1950 };
1951 function useAnimationFrame() {
1952 const timeout = useRefWithInit(AnimationFrame.create).current;
1953 useOnMount(timeout.disposeEffect);
1954 return timeout;
1955 }
1956
1957 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1958 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1959 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1960 const [mounted, setMounted] = React11.useState(open);
1961 if (open && !mounted) {
1962 setMounted(true);
1963 setTransitionStatus("starting");
1964 }
1965 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1966 setTransitionStatus("ending");
1967 }
1968 if (!open && !mounted && transitionStatus === "ending") {
1969 setTransitionStatus(void 0);
1970 }
1971 useIsoLayoutEffect(() => {
1972 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1973 const frame = AnimationFrame.request(() => {
1974 setTransitionStatus("ending");
1975 });
1976 return () => {
1977 AnimationFrame.cancel(frame);
1978 };
1979 }
1980 return void 0;
1981 }, [open, mounted, transitionStatus, deferEndingState]);
1982 useIsoLayoutEffect(() => {
1983 if (!open || enableIdleState) {
1984 return void 0;
1985 }
1986 const frame = AnimationFrame.request(() => {
1987 setTransitionStatus(void 0);
1988 });
1989 return () => {
1990 AnimationFrame.cancel(frame);
1991 };
1992 }, [enableIdleState, open]);
1993 useIsoLayoutEffect(() => {
1994 if (!open || !enableIdleState) {
1995 return void 0;
1996 }
1997 if (open && mounted && transitionStatus !== "idle") {
1998 setTransitionStatus("starting");
1999 }
2000 const frame = AnimationFrame.request(() => {
2001 setTransitionStatus("idle");
2002 });
2003 return () => {
2004 AnimationFrame.cancel(frame);
2005 };
2006 }, [enableIdleState, open, mounted, transitionStatus]);
2007 return {
2008 mounted,
2009 setMounted,
2010 transitionStatus
2011 };
2012 }
2013
2014 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
2015 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2016 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2017 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2018 return TransitionStatusDataAttributes2;
2019 })({});
2020 var STARTING_HOOK = {
2021 [TransitionStatusDataAttributes.startingStyle]: ""
2022 };
2023 var ENDING_HOOK = {
2024 [TransitionStatusDataAttributes.endingStyle]: ""
2025 };
2026 var transitionStatusMapping = {
2027 transitionStatus(value) {
2028 if (value === "starting") {
2029 return STARTING_HOOK;
2030 }
2031 if (value === "ending") {
2032 return ENDING_HOOK;
2033 }
2034 return null;
2035 }
2036 };
2037
2038 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2039 function hasWindow() {
2040 return typeof window !== "undefined";
2041 }
2042 function getNodeName(node) {
2043 if (isNode(node)) {
2044 return (node.nodeName || "").toLowerCase();
2045 }
2046 return "#document";
2047 }
2048 function getWindow(node) {
2049 var _node$ownerDocument;
2050 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2051 }
2052 function getDocumentElement(node) {
2053 var _ref;
2054 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2055 }
2056 function isNode(value) {
2057 if (!hasWindow()) {
2058 return false;
2059 }
2060 return value instanceof Node || value instanceof getWindow(value).Node;
2061 }
2062 function isElement(value) {
2063 if (!hasWindow()) {
2064 return false;
2065 }
2066 return value instanceof Element || value instanceof getWindow(value).Element;
2067 }
2068 function isHTMLElement(value) {
2069 if (!hasWindow()) {
2070 return false;
2071 }
2072 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2073 }
2074 function isShadowRoot(value) {
2075 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2076 return false;
2077 }
2078 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2079 }
2080 function isOverflowElement(element) {
2081 const {
2082 overflow,
2083 overflowX,
2084 overflowY,
2085 display
2086 } = getComputedStyle2(element);
2087 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2088 }
2089 function isTableElement(element) {
2090 return /^(table|td|th)$/.test(getNodeName(element));
2091 }
2092 function isTopLayer(element) {
2093 try {
2094 if (element.matches(":popover-open")) {
2095 return true;
2096 }
2097 } catch (_e) {
2098 }
2099 try {
2100 return element.matches(":modal");
2101 } catch (_e) {
2102 return false;
2103 }
2104 }
2105 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2106 var containRe = /paint|layout|strict|content/;
2107 var isNotNone = (value) => !!value && value !== "none";
2108 var isWebKitValue;
2109 function isContainingBlock(elementOrCss) {
2110 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2111 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 || "");
2112 }
2113 function getContainingBlock(element) {
2114 let currentNode = getParentNode(element);
2115 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2116 if (isContainingBlock(currentNode)) {
2117 return currentNode;
2118 } else if (isTopLayer(currentNode)) {
2119 return null;
2120 }
2121 currentNode = getParentNode(currentNode);
2122 }
2123 return null;
2124 }
2125 function isWebKit() {
2126 if (isWebKitValue == null) {
2127 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2128 }
2129 return isWebKitValue;
2130 }
2131 function isLastTraversableNode(node) {
2132 return /^(html|body|#document)$/.test(getNodeName(node));
2133 }
2134 function getComputedStyle2(element) {
2135 return getWindow(element).getComputedStyle(element);
2136 }
2137 function getNodeScroll(element) {
2138 if (isElement(element)) {
2139 return {
2140 scrollLeft: element.scrollLeft,
2141 scrollTop: element.scrollTop
2142 };
2143 }
2144 return {
2145 scrollLeft: element.scrollX,
2146 scrollTop: element.scrollY
2147 };
2148 }
2149 function getParentNode(node) {
2150 if (getNodeName(node) === "html") {
2151 return node;
2152 }
2153 const result = (
2154 // Step into the shadow DOM of the parent of a slotted node.
2155 node.assignedSlot || // DOM Element detected.
2156 node.parentNode || // ShadowRoot detected.
2157 isShadowRoot(node) && node.host || // Fallback.
2158 getDocumentElement(node)
2159 );
2160 return isShadowRoot(result) ? result.host : result;
2161 }
2162 function getNearestOverflowAncestor(node) {
2163 const parentNode = getParentNode(node);
2164 if (isLastTraversableNode(parentNode)) {
2165 return node.ownerDocument ? node.ownerDocument.body : node.body;
2166 }
2167 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2168 return parentNode;
2169 }
2170 return getNearestOverflowAncestor(parentNode);
2171 }
2172 function getOverflowAncestors(node, list, traverseIframes) {
2173 var _node$ownerDocument2;
2174 if (list === void 0) {
2175 list = [];
2176 }
2177 if (traverseIframes === void 0) {
2178 traverseIframes = true;
2179 }
2180 const scrollableAncestor = getNearestOverflowAncestor(node);
2181 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2182 const win = getWindow(scrollableAncestor);
2183 if (isBody) {
2184 const frameElement = getFrameElement(win);
2185 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2186 } else {
2187 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2188 }
2189 }
2190 function getFrameElement(win) {
2191 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2192 }
2193
2194 // node_modules/@base-ui/utils/addEventListener.mjs
2195 function addEventListener(target, type, listener, options) {
2196 target.addEventListener(type, listener, options);
2197 return () => {
2198 target.removeEventListener(type, listener, options);
2199 };
2200 }
2201
2202 // node_modules/@base-ui/utils/useValueAsRef.mjs
2203 function useValueAsRef(value) {
2204 const latest = useRefWithInit(createLatestRef, value).current;
2205 latest.next = value;
2206 useIsoLayoutEffect(latest.effect);
2207 return latest;
2208 }
2209 function createLatestRef(value) {
2210 const latest = {
2211 current: value,
2212 next: value,
2213 effect: () => {
2214 latest.current = latest.next;
2215 }
2216 };
2217 return latest;
2218 }
2219
2220 // node_modules/@base-ui/utils/owner.mjs
2221 function ownerDocument(node) {
2222 return node?.ownerDocument || document;
2223 }
2224
2225 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2226 var React12 = __toESM(require_react(), 1);
2227
2228 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2229 var ReactDOM = __toESM(require_react_dom(), 1);
2230
2231 // node_modules/@base-ui/react/utils/resolveRef.mjs
2232 function resolveRef(maybeRef) {
2233 if (maybeRef == null) {
2234 return maybeRef;
2235 }
2236 return "current" in maybeRef ? maybeRef.current : maybeRef;
2237 }
2238
2239 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2240 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2241 const frame = useAnimationFrame();
2242 return useStableCallback((fnToExecute, signal = null) => {
2243 frame.cancel();
2244 const element = resolveRef(elementOrRef);
2245 if (element == null) {
2246 return;
2247 }
2248 const resolvedElement = element;
2249 const done = () => {
2250 ReactDOM.flushSync(fnToExecute);
2251 };
2252 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2253 fnToExecute();
2254 return;
2255 }
2256 function exec() {
2257 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2258 if (!signal?.aborted) {
2259 done();
2260 }
2261 }).catch(() => {
2262 if (treatAbortedAsFinished) {
2263 if (!signal?.aborted) {
2264 done();
2265 }
2266 return;
2267 }
2268 const currentAnimations = resolvedElement.getAnimations();
2269 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2270 exec();
2271 }
2272 });
2273 }
2274 if (waitForStartingStyleRemoved) {
2275 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2276 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2277 frame.request(exec);
2278 return;
2279 }
2280 const attributeObserver = new MutationObserver(() => {
2281 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2282 attributeObserver.disconnect();
2283 exec();
2284 }
2285 });
2286 attributeObserver.observe(resolvedElement, {
2287 attributes: true,
2288 attributeFilter: [startingStyleAttribute]
2289 });
2290 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2291 once: true
2292 });
2293 return;
2294 }
2295 frame.request(exec);
2296 });
2297 }
2298
2299 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2300 function useOpenChangeComplete(parameters) {
2301 const {
2302 enabled = true,
2303 open,
2304 ref,
2305 onComplete: onCompleteParam
2306 } = parameters;
2307 const onComplete = useStableCallback(onCompleteParam);
2308 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2309 React12.useEffect(() => {
2310 if (!enabled) {
2311 return void 0;
2312 }
2313 const abortController = new AbortController();
2314 runOnceAnimationsFinish(onComplete, abortController.signal);
2315 return () => {
2316 abortController.abort();
2317 };
2318 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2319 }
2320
2321 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2322 var React13 = __toESM(require_react(), 1);
2323 function useOnFirstRender(fn) {
2324 const ref = React13.useRef(true);
2325 if (ref.current) {
2326 ref.current = false;
2327 fn();
2328 }
2329 }
2330
2331 // node_modules/@base-ui/utils/platform/parts.mjs
2332 var parts_exports = {};
2333 __export(parts_exports, {
2334 engine: () => engine_exports,
2335 env: () => env_exports,
2336 os: () => os_exports,
2337 screenReader: () => screen_reader_exports
2338 });
2339
2340 // node_modules/@base-ui/utils/platform/os.mjs
2341 var os_exports = {};
2342 __export(os_exports, {
2343 android: () => android,
2344 apple: () => apple,
2345 ios: () => ios,
2346 linux: () => linux,
2347 mac: () => mac,
2348 windows: () => windows
2349 });
2350
2351 // node_modules/@base-ui/utils/platform/shared.mjs
2352 function readRawData() {
2353 if (typeof navigator === "undefined") {
2354 return {
2355 userAgent: "",
2356 platform: "",
2357 maxTouchPoints: 0
2358 };
2359 }
2360 if (true) {
2361 const uaData = navigator.userAgentData;
2362 if (uaData && Array.isArray(uaData.brands)) {
2363 return {
2364 userAgent: uaData.brands.map(({
2365 brand,
2366 version: version2
2367 }) => `${brand}/${version2}`).join(" "),
2368 platform: uaData.platform ?? navigator.platform ?? "",
2369 maxTouchPoints: navigator.maxTouchPoints ?? 0
2370 };
2371 }
2372 }
2373 return {
2374 userAgent: navigator.userAgent,
2375 platform: navigator.platform ?? "",
2376 maxTouchPoints: navigator.maxTouchPoints ?? 0
2377 };
2378 }
2379 var {
2380 userAgent,
2381 platform,
2382 maxTouchPoints
2383 } = readRawData();
2384 var lowerUserAgent = userAgent.toLowerCase();
2385 var lowerPlatform = platform.toLowerCase();
2386
2387 // node_modules/@base-ui/utils/platform/os.mjs
2388 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2389 var ANDROID_STRING = "android";
2390 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2391 var mac = !ios && lowerPlatform.startsWith("mac");
2392 var windows = lowerPlatform.startsWith("win");
2393 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2394 var apple = mac || ios;
2395
2396 // node_modules/@base-ui/utils/platform/engine.mjs
2397 var engine_exports = {};
2398 __export(engine_exports, {
2399 blink: () => blink,
2400 gecko: () => gecko,
2401 webkit: () => webkit
2402 });
2403 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2404 var gecko = !webkit && lowerUserAgent.includes("firefox");
2405 var blink = !webkit && lowerUserAgent.includes("chrom");
2406
2407 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2408 var screen_reader_exports = {};
2409 __export(screen_reader_exports, {
2410 voiceOver: () => voiceOver
2411 });
2412 var voiceOver = apple;
2413
2414 // node_modules/@base-ui/utils/platform/env.mjs
2415 var env_exports = {};
2416 __export(env_exports, {
2417 jsdom: () => jsdom
2418 });
2419 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2420
2421 // node_modules/@base-ui/utils/useTimeout.mjs
2422 var EMPTY3 = 0;
2423 var Timeout = class _Timeout {
2424 static create() {
2425 return new _Timeout();
2426 }
2427 currentId = EMPTY3;
2428 /**
2429 * Executes `fn` after `delay`, clearing any previously scheduled call.
2430 */
2431 start(delay, fn) {
2432 this.clear();
2433 this.currentId = setTimeout(() => {
2434 this.currentId = EMPTY3;
2435 fn();
2436 }, delay);
2437 }
2438 isStarted() {
2439 return this.currentId !== EMPTY3;
2440 }
2441 clear = () => {
2442 if (this.currentId !== EMPTY3) {
2443 clearTimeout(this.currentId);
2444 this.currentId = EMPTY3;
2445 }
2446 };
2447 disposeEffect = () => {
2448 return this.clear;
2449 };
2450 };
2451 function useTimeout() {
2452 const timeout = useRefWithInit(Timeout.create).current;
2453 useOnMount(timeout.disposeEffect);
2454 return timeout;
2455 }
2456
2457 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2458 var React14 = __toESM(require_react(), 1);
2459
2460 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2461 function isReactEvent(event) {
2462 return "nativeEvent" in event;
2463 }
2464 function isMouseLikePointerType(pointerType, strict) {
2465 const values = ["mouse", "pen"];
2466 if (!strict) {
2467 values.push("", void 0);
2468 }
2469 return values.includes(pointerType);
2470 }
2471 function isClickLikeEvent(event) {
2472 const type = event.type;
2473 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2474 }
2475
2476 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2477 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2478 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2479
2480 // node_modules/@base-ui/react/internals/shadowDom.mjs
2481 function activeElement(doc) {
2482 let element = doc.activeElement;
2483 while (element?.shadowRoot?.activeElement != null) {
2484 element = element.shadowRoot.activeElement;
2485 }
2486 return element;
2487 }
2488 function contains(parent, child) {
2489 if (!parent || !child) {
2490 return false;
2491 }
2492 const rootNode = child.getRootNode?.();
2493 if (parent.contains(child)) {
2494 return true;
2495 }
2496 if (rootNode && isShadowRoot(rootNode)) {
2497 let next = child;
2498 while (next) {
2499 if (parent === next) {
2500 return true;
2501 }
2502 next = next.parentNode || next.host;
2503 }
2504 }
2505 return false;
2506 }
2507 function getTarget(event) {
2508 if ("composedPath" in event) {
2509 return event.composedPath()[0];
2510 }
2511 return event.target;
2512 }
2513
2514 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2515 function isTargetInsideEnabledTrigger(target, triggerElements) {
2516 if (!isElement(target)) {
2517 return false;
2518 }
2519 const targetElement = target;
2520 if (triggerElements.hasElement(targetElement)) {
2521 return !targetElement.hasAttribute("data-trigger-disabled");
2522 }
2523 for (const [, trigger] of triggerElements.entries()) {
2524 if (contains(trigger, targetElement)) {
2525 return !trigger.hasAttribute("data-trigger-disabled");
2526 }
2527 }
2528 return false;
2529 }
2530 function isEventTargetWithin(event, node) {
2531 if (node == null) {
2532 return false;
2533 }
2534 if ("composedPath" in event) {
2535 return event.composedPath().includes(node);
2536 }
2537 const eventAgain = event;
2538 return eventAgain.target != null && node.contains(eventAgain.target);
2539 }
2540 function isRootElement(element) {
2541 return element.matches("html,body");
2542 }
2543 function isTypeableElement(element) {
2544 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2545 }
2546 function isInteractiveElement(element) {
2547 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2548 }
2549 function matchesFocusVisible(element) {
2550 if (!element || parts_exports.env.jsdom) {
2551 return true;
2552 }
2553 try {
2554 return element.matches(":focus-visible");
2555 } catch (_e) {
2556 return true;
2557 }
2558 }
2559
2560 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
2561 function resolveValue(value, pointerType) {
2562 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2563 return 0;
2564 }
2565 if (typeof value === "function") {
2566 return value();
2567 }
2568 return value;
2569 }
2570 function getDelay(value, prop, pointerType) {
2571 const result = resolveValue(value, pointerType);
2572 if (typeof result === "number") {
2573 return result;
2574 }
2575 return result?.[prop];
2576 }
2577 function getRestMs(value) {
2578 if (typeof value === "function") {
2579 return value();
2580 }
2581 return value;
2582 }
2583 function isClickLikeOpenEvent(openEventType, interactedInside) {
2584 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2585 }
2586 function isHoverOpenEvent(openEventType) {
2587 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2588 }
2589
2590 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2591 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2592 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2593 hasProvider: false,
2594 timeoutMs: 0,
2595 delayRef: {
2596 current: 0
2597 },
2598 initialDelayRef: {
2599 current: 0
2600 },
2601 timeout: new Timeout(),
2602 currentIdRef: {
2603 current: null
2604 },
2605 currentContextRef: {
2606 current: null
2607 }
2608 });
2609 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2610 function resetDelayRef(delayRef, initialDelayRef) {
2611 delayRef.current = initialDelayRef.current;
2612 }
2613 function FloatingDelayGroup(props) {
2614 const {
2615 children,
2616 delay,
2617 timeoutMs = 0
2618 } = props;
2619 const delayRef = React14.useRef(delay);
2620 const initialDelayRef = React14.useRef(delay);
2621 const currentIdRef = React14.useRef(null);
2622 const currentContextRef = React14.useRef(null);
2623 const timeout = useTimeout();
2624 useIsoLayoutEffect(() => {
2625 initialDelayRef.current = delay;
2626 if (!currentIdRef.current) {
2627 delayRef.current = delay;
2628 return;
2629 }
2630 delayRef.current = {
2631 open: getDelay(delayRef.current, "open"),
2632 close: getDelay(delay, "close")
2633 };
2634 }, [delay, currentIdRef, delayRef, initialDelayRef]);
2635 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2636 value: React14.useMemo(() => ({
2637 hasProvider: true,
2638 delayRef,
2639 initialDelayRef,
2640 currentIdRef,
2641 timeoutMs,
2642 currentContextRef,
2643 timeout
2644 }), [timeoutMs, timeout]),
2645 children
2646 });
2647 }
2648 function useDelayGroup(context, options = {
2649 open: false
2650 }) {
2651 const {
2652 open
2653 } = options;
2654 const store = "rootStore" in context ? context.rootStore : context;
2655 const floatingId = store.useState("floatingId");
2656 const groupContext = React14.useContext(FloatingDelayGroupContext);
2657 const {
2658 currentIdRef,
2659 delayRef,
2660 timeoutMs,
2661 initialDelayRef,
2662 currentContextRef,
2663 hasProvider,
2664 timeout
2665 } = groupContext;
2666 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2667 const openRef = React14.useRef(open);
2668 const isUnmountedRef = React14.useRef(false);
2669 useIsoLayoutEffect(() => {
2670 openRef.current = open;
2671 }, [open]);
2672 useIsoLayoutEffect(() => {
2673 return () => {
2674 isUnmountedRef.current = true;
2675 };
2676 }, []);
2677 useIsoLayoutEffect(() => {
2678 function unset() {
2679 if (!isUnmountedRef.current) {
2680 setIsInstantPhase(false);
2681 }
2682 currentContextRef.current?.setIsInstantPhase(false);
2683 currentIdRef.current = null;
2684 currentContextRef.current = null;
2685 delayRef.current = initialDelayRef.current;
2686 timeout.clear();
2687 }
2688 if (!currentIdRef.current) {
2689 return void 0;
2690 }
2691 if (!open && currentIdRef.current === floatingId) {
2692 setIsInstantPhase(false);
2693 if (timeoutMs) {
2694 const closingId = floatingId;
2695 timeout.start(timeoutMs, () => {
2696 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2697 return;
2698 }
2699 unset();
2700 });
2701 return () => {
2702 if (openRef.current || currentIdRef.current !== closingId) {
2703 timeout.clear();
2704 }
2705 };
2706 }
2707 unset();
2708 }
2709 return void 0;
2710 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2711 useIsoLayoutEffect(() => {
2712 if (!open) {
2713 return;
2714 }
2715 const prevContext = currentContextRef.current;
2716 const prevId = currentIdRef.current;
2717 timeout.clear();
2718 currentContextRef.current = {
2719 onOpenChange: store.setOpen,
2720 setIsInstantPhase
2721 };
2722 currentIdRef.current = floatingId;
2723 delayRef.current = {
2724 open: 0,
2725 close: getDelay(initialDelayRef.current, "close")
2726 };
2727 if (prevId !== null && prevId !== floatingId) {
2728 setIsInstantPhase(true);
2729 prevContext?.setIsInstantPhase(true);
2730 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2731 } else {
2732 setIsInstantPhase(false);
2733 prevContext?.setIsInstantPhase(false);
2734 }
2735 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2736 useIsoLayoutEffect(() => {
2737 return () => {
2738 if (currentIdRef.current === floatingId) {
2739 currentContextRef.current = null;
2740 if (!openRef.current) {
2741 return;
2742 }
2743 currentIdRef.current = null;
2744 resetDelayRef(delayRef, initialDelayRef);
2745 timeout.clear();
2746 }
2747 };
2748 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
2749 return React14.useMemo(() => ({
2750 hasProvider,
2751 delayRef,
2752 isInstantPhase
2753 }), [hasProvider, delayRef, isInstantPhase]);
2754 }
2755
2756 // node_modules/@base-ui/utils/mergeCleanups.mjs
2757 function mergeCleanups(...cleanups) {
2758 return () => {
2759 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2760 const cleanup = cleanups[i2];
2761 if (cleanup) {
2762 cleanup();
2763 }
2764 }
2765 };
2766 }
2767
2768 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2769 var React15 = __toESM(require_react(), 1);
2770
2771 // node_modules/@base-ui/utils/visuallyHidden.mjs
2772 var visuallyHiddenBase = {
2773 clipPath: "inset(50%)",
2774 overflow: "hidden",
2775 whiteSpace: "nowrap",
2776 border: 0,
2777 padding: 0,
2778 width: 1,
2779 height: 1,
2780 margin: -1
2781 };
2782 var visuallyHidden = {
2783 ...visuallyHiddenBase,
2784 position: "fixed",
2785 top: 0,
2786 left: 0
2787 };
2788 var visuallyHiddenInput = {
2789 ...visuallyHiddenBase,
2790 position: "absolute"
2791 };
2792
2793 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2794 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2795 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2796 const [role, setRole] = React15.useState();
2797 useIsoLayoutEffect(() => {
2798 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
2799 setRole("button");
2800 }
2801 }, []);
2802 const restProps = {
2803 tabIndex: 0,
2804 // Role is only for VoiceOver
2805 role
2806 };
2807 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2808 ...props,
2809 ref,
2810 style: visuallyHidden,
2811 "aria-hidden": role ? void 0 : true,
2812 ...restProps,
2813 "data-base-ui-focus-guard": ""
2814 });
2815 });
2816 if (true) FocusGuard.displayName = "FocusGuard";
2817
2818 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2819 var sides = ["top", "right", "bottom", "left"];
2820 var min = Math.min;
2821 var max = Math.max;
2822 var round = Math.round;
2823 var floor = Math.floor;
2824 var createCoords = (v2) => ({
2825 x: v2,
2826 y: v2
2827 });
2828 var oppositeSideMap = {
2829 left: "right",
2830 right: "left",
2831 bottom: "top",
2832 top: "bottom"
2833 };
2834 function clamp(start, value, end) {
2835 return max(start, min(value, end));
2836 }
2837 function evaluate(value, param) {
2838 return typeof value === "function" ? value(param) : value;
2839 }
2840 function getSide(placement) {
2841 return placement.split("-")[0];
2842 }
2843 function getAlignment(placement) {
2844 return placement.split("-")[1];
2845 }
2846 function getOppositeAxis(axis) {
2847 return axis === "x" ? "y" : "x";
2848 }
2849 function getAxisLength(axis) {
2850 return axis === "y" ? "height" : "width";
2851 }
2852 function getSideAxis(placement) {
2853 const firstChar = placement[0];
2854 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2855 }
2856 function getAlignmentAxis(placement) {
2857 return getOppositeAxis(getSideAxis(placement));
2858 }
2859 function getAlignmentSides(placement, rects, rtl) {
2860 if (rtl === void 0) {
2861 rtl = false;
2862 }
2863 const alignment = getAlignment(placement);
2864 const alignmentAxis = getAlignmentAxis(placement);
2865 const length = getAxisLength(alignmentAxis);
2866 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2867 if (rects.reference[length] > rects.floating[length]) {
2868 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2869 }
2870 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2871 }
2872 function getExpandedPlacements(placement) {
2873 const oppositePlacement = getOppositePlacement(placement);
2874 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2875 }
2876 function getOppositeAlignmentPlacement(placement) {
2877 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2878 }
2879 var lrPlacement = ["left", "right"];
2880 var rlPlacement = ["right", "left"];
2881 var tbPlacement = ["top", "bottom"];
2882 var btPlacement = ["bottom", "top"];
2883 function getSideList(side, isStart, rtl) {
2884 switch (side) {
2885 case "top":
2886 case "bottom":
2887 if (rtl) return isStart ? rlPlacement : lrPlacement;
2888 return isStart ? lrPlacement : rlPlacement;
2889 case "left":
2890 case "right":
2891 return isStart ? tbPlacement : btPlacement;
2892 default:
2893 return [];
2894 }
2895 }
2896 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2897 const alignment = getAlignment(placement);
2898 let list = getSideList(getSide(placement), direction === "start", rtl);
2899 if (alignment) {
2900 list = list.map((side) => side + "-" + alignment);
2901 if (flipAlignment) {
2902 list = list.concat(list.map(getOppositeAlignmentPlacement));
2903 }
2904 }
2905 return list;
2906 }
2907 function getOppositePlacement(placement) {
2908 const side = getSide(placement);
2909 return oppositeSideMap[side] + placement.slice(side.length);
2910 }
2911 function expandPaddingObject(padding) {
2912 return {
2913 top: 0,
2914 right: 0,
2915 bottom: 0,
2916 left: 0,
2917 ...padding
2918 };
2919 }
2920 function getPaddingObject(padding) {
2921 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2922 top: padding,
2923 right: padding,
2924 bottom: padding,
2925 left: padding
2926 };
2927 }
2928 function rectToClientRect(rect) {
2929 const {
2930 x: x2,
2931 y: y2,
2932 width,
2933 height
2934 } = rect;
2935 return {
2936 width,
2937 height,
2938 top: y2,
2939 left: x2,
2940 right: x2 + width,
2941 bottom: y2 + height,
2942 x: x2,
2943 y: y2
2944 };
2945 }
2946
2947 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
2948 function isHiddenByStyles(styles) {
2949 return styles.visibility === "hidden" || styles.visibility === "collapse";
2950 }
2951 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2952 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2953 return false;
2954 }
2955 if (typeof element.checkVisibility === "function") {
2956 return element.checkVisibility();
2957 }
2958 return styles.display !== "none" && styles.display !== "contents";
2959 }
2960
2961 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
2962 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2963 function getParentElement(element) {
2964 const assignedSlot = element.assignedSlot;
2965 if (assignedSlot) {
2966 return assignedSlot;
2967 }
2968 if (element.parentElement) {
2969 return element.parentElement;
2970 }
2971 const rootNode = element.getRootNode();
2972 return isShadowRoot(rootNode) ? rootNode.host : null;
2973 }
2974 function getDetailsSummary(details) {
2975 for (const child of Array.from(details.children)) {
2976 if (getNodeName(child) === "summary") {
2977 return child;
2978 }
2979 }
2980 return null;
2981 }
2982 function isWithinOpenDetailsSummary(element, details) {
2983 const summary = getDetailsSummary(details);
2984 return !!summary && (element === summary || contains(summary, element));
2985 }
2986 function isFocusableCandidate(element) {
2987 const nodeName = element ? getNodeName(element) : "";
2988 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");
2989 }
2990 function isFocusableElement(element) {
2991 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2992 return false;
2993 }
2994 for (let current = element; current; current = getParentElement(current)) {
2995 const isAncestor = current !== element;
2996 const isSlot = getNodeName(current) === "slot";
2997 if (current.hasAttribute("inert")) {
2998 return false;
2999 }
3000 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3001 return false;
3002 }
3003 }
3004 return true;
3005 }
3006 function isVisibleInTabbableTree(element, isAncestor) {
3007 const styles = getComputedStyle2(element);
3008 if (!isAncestor) {
3009 return isElementVisible(element, styles);
3010 }
3011 return styles.display !== "none";
3012 }
3013 function getTabIndex(element) {
3014 const tabIndex = element.tabIndex;
3015 if (tabIndex < 0) {
3016 const nodeName = getNodeName(element);
3017 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3018 return 0;
3019 }
3020 }
3021 return tabIndex;
3022 }
3023 function getNamedRadioInput(element) {
3024 if (getNodeName(element) !== "input") {
3025 return null;
3026 }
3027 const input = element;
3028 return input.type === "radio" && input.name !== "" ? input : null;
3029 }
3030 function isTabbableRadio(element, candidates) {
3031 const input = getNamedRadioInput(element);
3032 if (!input) {
3033 return true;
3034 }
3035 const checkedRadio = candidates.find((candidate) => {
3036 const radio = getNamedRadioInput(candidate);
3037 return radio?.name === input.name && radio.form === input.form && radio.checked;
3038 });
3039 if (checkedRadio) {
3040 return checkedRadio === input;
3041 }
3042 return candidates.find((candidate) => {
3043 const radio = getNamedRadioInput(candidate);
3044 return radio?.name === input.name && radio.form === input.form;
3045 }) === input;
3046 }
3047 function getComposedChildren(container) {
3048 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3049 const assignedElements = container.assignedElements({
3050 flatten: true
3051 });
3052 if (assignedElements.length > 0) {
3053 return assignedElements;
3054 }
3055 }
3056 if (isHTMLElement(container) && container.shadowRoot) {
3057 return Array.from(container.shadowRoot.children);
3058 }
3059 return Array.from(container.children);
3060 }
3061 function appendCandidates(container, list) {
3062 getComposedChildren(container).forEach((child) => {
3063 if (isFocusableCandidate(child)) {
3064 list.push(child);
3065 }
3066 appendCandidates(child, list);
3067 });
3068 }
3069 function appendMatchingElements(container, selector2, list) {
3070 getComposedChildren(container).forEach((child) => {
3071 if (isHTMLElement(child) && child.matches(selector2)) {
3072 list.push(child);
3073 }
3074 appendMatchingElements(child, selector2, list);
3075 });
3076 }
3077 function focusable(container) {
3078 const candidates = [];
3079 appendCandidates(container, candidates);
3080 return candidates.filter(isFocusableElement);
3081 }
3082 function tabbable(container) {
3083 const candidates = focusable(container);
3084 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3085 }
3086 function getTabbableIn(container, dir) {
3087 const list = tabbable(container);
3088 const len = list.length;
3089 if (len === 0) {
3090 return void 0;
3091 }
3092 const active = activeElement(ownerDocument(container));
3093 const index2 = list.indexOf(active);
3094 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3095 return list[nextIndex];
3096 }
3097 function getNextTabbable(referenceElement) {
3098 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3099 }
3100 function getPreviousTabbable(referenceElement) {
3101 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3102 }
3103 function isOutsideEvent(event, container) {
3104 const containerElement = container || event.currentTarget;
3105 const relatedTarget = event.relatedTarget;
3106 return !relatedTarget || !contains(containerElement, relatedTarget);
3107 }
3108 function disableFocusInside(container) {
3109 const tabbableElements = tabbable(container);
3110 tabbableElements.forEach((element) => {
3111 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3112 element.setAttribute("tabindex", "-1");
3113 });
3114 }
3115 function enableFocusInside(container) {
3116 const elements = [];
3117 appendMatchingElements(container, "[data-tabindex]", elements);
3118 elements.forEach((element) => {
3119 const tabindex = element.dataset.tabindex;
3120 delete element.dataset.tabindex;
3121 if (tabindex) {
3122 element.setAttribute("tabindex", tabindex);
3123 } else {
3124 element.removeAttribute("tabindex");
3125 }
3126 });
3127 }
3128
3129 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3130 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3131 const directChildren = nodes.filter((node) => node.parentId === id);
3132 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3133 }
3134
3135 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3136 function createAttribute(name) {
3137 return `data-base-ui-${name}`;
3138 }
3139
3140 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3141 var React16 = __toESM(require_react(), 1);
3142 var ReactDOM2 = __toESM(require_react_dom(), 1);
3143
3144 // node_modules/@base-ui/react/internals/constants.mjs
3145 var DISABLED_TRANSITIONS_STYLE = {
3146 style: {
3147 transition: "none"
3148 }
3149 };
3150 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3151 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3152 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3153 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3154 var POPUP_COLLISION_AVOIDANCE = {
3155 fallbackAxisSide: "end"
3156 };
3157 var ownerVisuallyHidden = {
3158 clipPath: "inset(50%)",
3159 position: "fixed",
3160 top: 0,
3161 left: 0
3162 };
3163
3164 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3165 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3166 var PortalContext = /* @__PURE__ */ React16.createContext(null);
3167 if (true) PortalContext.displayName = "PortalContext";
3168 var usePortalContext = () => React16.useContext(PortalContext);
3169 var attr = createAttribute("portal");
3170 function useFloatingPortalNode(props = {}) {
3171 const {
3172 ref,
3173 container: containerProp,
3174 componentProps = EMPTY_OBJECT,
3175 elementProps
3176 } = props;
3177 const uniqueId = useId();
3178 const portalContext = usePortalContext();
3179 const parentPortalNode = portalContext?.portalNode;
3180 const [containerElement, setContainerElement] = React16.useState(null);
3181 const [portalNode, setPortalNode] = React16.useState(null);
3182 const setPortalNodeRef = useStableCallback((node) => {
3183 if (node !== null) {
3184 setPortalNode(node);
3185 }
3186 });
3187 const containerRef = React16.useRef(null);
3188 useIsoLayoutEffect(() => {
3189 if (containerProp === null) {
3190 if (containerRef.current) {
3191 containerRef.current = null;
3192 setPortalNode(null);
3193 setContainerElement(null);
3194 }
3195 return;
3196 }
3197 if (uniqueId == null) {
3198 return;
3199 }
3200 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3201 if (resolvedContainer == null) {
3202 if (containerRef.current) {
3203 containerRef.current = null;
3204 setPortalNode(null);
3205 setContainerElement(null);
3206 }
3207 return;
3208 }
3209 if (containerRef.current !== resolvedContainer) {
3210 containerRef.current = resolvedContainer;
3211 setPortalNode(null);
3212 setContainerElement(resolvedContainer);
3213 }
3214 }, [containerProp, parentPortalNode, uniqueId]);
3215 const portalElement = useRenderElement("div", componentProps, {
3216 ref: [ref, setPortalNodeRef],
3217 props: [{
3218 id: uniqueId,
3219 [attr]: ""
3220 }, elementProps]
3221 });
3222 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3223 return {
3224 portalNode,
3225 portalSubtree
3226 };
3227 }
3228 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3229 const {
3230 render: render4,
3231 className,
3232 style,
3233 children,
3234 container,
3235 renderGuards,
3236 ...elementProps
3237 } = componentProps;
3238 const {
3239 portalNode,
3240 portalSubtree
3241 } = useFloatingPortalNode({
3242 container,
3243 ref: forwardedRef,
3244 componentProps,
3245 elementProps
3246 });
3247 const beforeOutsideRef = React16.useRef(null);
3248 const afterOutsideRef = React16.useRef(null);
3249 const beforeInsideRef = React16.useRef(null);
3250 const afterInsideRef = React16.useRef(null);
3251 const [focusManagerState, setFocusManagerState] = React16.useState(null);
3252 const focusInsideDisabledRef = React16.useRef(false);
3253 const modal = focusManagerState?.modal;
3254 const open = focusManagerState?.open;
3255 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3256 React16.useEffect(() => {
3257 if (!portalNode || modal) {
3258 return void 0;
3259 }
3260 function onFocus(event) {
3261 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3262 if (event.type === "focusin") {
3263 if (focusInsideDisabledRef.current) {
3264 enableFocusInside(portalNode);
3265 focusInsideDisabledRef.current = false;
3266 }
3267 } else {
3268 disableFocusInside(portalNode);
3269 focusInsideDisabledRef.current = true;
3270 }
3271 }
3272 }
3273 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3274 }, [portalNode, modal]);
3275 useIsoLayoutEffect(() => {
3276 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3277 return;
3278 }
3279 enableFocusInside(portalNode);
3280 focusInsideDisabledRef.current = false;
3281 }, [open, portalNode]);
3282 const portalContextValue = React16.useMemo(() => ({
3283 beforeOutsideRef,
3284 afterOutsideRef,
3285 beforeInsideRef,
3286 afterInsideRef,
3287 portalNode,
3288 setFocusManagerState
3289 }), [portalNode]);
3290 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
3291 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3292 value: portalContextValue,
3293 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3294 "data-type": "outside",
3295 ref: beforeOutsideRef,
3296 onFocus: (event) => {
3297 if (isOutsideEvent(event, portalNode)) {
3298 beforeInsideRef.current?.focus();
3299 } else {
3300 const domReference = focusManagerState ? focusManagerState.domReference : null;
3301 const prevTabbable = getPreviousTabbable(domReference);
3302 prevTabbable?.focus();
3303 }
3304 }
3305 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3306 "aria-owns": portalNode.id,
3307 style: ownerVisuallyHidden
3308 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3309 "data-type": "outside",
3310 ref: afterOutsideRef,
3311 onFocus: (event) => {
3312 if (isOutsideEvent(event, portalNode)) {
3313 afterInsideRef.current?.focus();
3314 } else {
3315 const domReference = focusManagerState ? focusManagerState.domReference : null;
3316 const nextTabbable = getNextTabbable(domReference);
3317 nextTabbable?.focus();
3318 if (focusManagerState?.closeOnFocusOut) {
3319 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3320 }
3321 }
3322 }
3323 })]
3324 })]
3325 });
3326 });
3327 if (true) FloatingPortal.displayName = "FloatingPortal";
3328
3329 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3330 var React17 = __toESM(require_react(), 1);
3331
3332 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3333 function createEventEmitter() {
3334 const map = /* @__PURE__ */ new Map();
3335 return {
3336 emit(event, data) {
3337 map.get(event)?.forEach((listener) => listener(data));
3338 },
3339 on(event, listener) {
3340 if (!map.has(event)) {
3341 map.set(event, /* @__PURE__ */ new Set());
3342 }
3343 map.get(event).add(listener);
3344 },
3345 off(event, listener) {
3346 map.get(event)?.delete(listener);
3347 }
3348 };
3349 }
3350
3351 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3352 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3353 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3354 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3355 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3356 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3357 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3358 var useFloatingTree = (externalTree) => {
3359 const contextTree = React17.useContext(FloatingTreeContext);
3360 return externalTree ?? contextTree;
3361 };
3362
3363 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3364 var React18 = __toESM(require_react(), 1);
3365 function createVirtualElement(domElement, data) {
3366 let offsetX = null;
3367 let offsetY = null;
3368 let isAutoUpdateEvent = false;
3369 return {
3370 contextElement: domElement || void 0,
3371 getBoundingClientRect() {
3372 const domRect = domElement?.getBoundingClientRect() || {
3373 width: 0,
3374 height: 0,
3375 x: 0,
3376 y: 0
3377 };
3378 const isXAxis = data.axis === "x" || data.axis === "both";
3379 const isYAxis = data.axis === "y" || data.axis === "both";
3380 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3381 let width = domRect.width;
3382 let height = domRect.height;
3383 let x2 = domRect.x;
3384 let y2 = domRect.y;
3385 if (offsetX == null && data.x && isXAxis) {
3386 offsetX = domRect.x - data.x;
3387 }
3388 if (offsetY == null && data.y && isYAxis) {
3389 offsetY = domRect.y - data.y;
3390 }
3391 x2 -= offsetX || 0;
3392 y2 -= offsetY || 0;
3393 width = 0;
3394 height = 0;
3395 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3396 width = data.axis === "y" ? domRect.width : 0;
3397 height = data.axis === "x" ? domRect.height : 0;
3398 x2 = isXAxis && data.x != null ? data.x : x2;
3399 y2 = isYAxis && data.y != null ? data.y : y2;
3400 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3401 height = data.axis === "x" ? domRect.height : height;
3402 width = data.axis === "y" ? domRect.width : width;
3403 }
3404 isAutoUpdateEvent = true;
3405 return {
3406 width,
3407 height,
3408 x: x2,
3409 y: y2,
3410 top: y2,
3411 right: x2 + width,
3412 bottom: y2 + height,
3413 left: x2
3414 };
3415 }
3416 };
3417 }
3418 function isMouseBasedEvent(event) {
3419 return event != null && event.clientX != null;
3420 }
3421 function useClientPoint(context, props = {}) {
3422 const {
3423 enabled = true,
3424 axis = "both"
3425 } = props;
3426 const store = "rootStore" in context ? context.rootStore : context;
3427 const open = store.useState("open");
3428 const floating = store.useState("floatingElement");
3429 const domReference = store.useState("domReferenceElement");
3430 const dataRef = store.context.dataRef;
3431 const initialRef = React18.useRef(false);
3432 const cleanupListenerRef = React18.useRef(null);
3433 const [pointerType, setPointerType] = React18.useState();
3434 const [reactive, setReactive] = React18.useState([]);
3435 const resetReference = useStableCallback((reference2) => {
3436 store.set("positionReference", reference2);
3437 });
3438 const setReference = useStableCallback((newX, newY, referenceElement) => {
3439 if (initialRef.current) {
3440 return;
3441 }
3442 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3443 return;
3444 }
3445 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3446 x: newX,
3447 y: newY,
3448 axis,
3449 dataRef,
3450 pointerType
3451 }));
3452 });
3453 const handleReferenceEnterOrMove = useStableCallback((event) => {
3454 if (!open) {
3455 setReference(event.clientX, event.clientY, event.currentTarget);
3456 } else if (!cleanupListenerRef.current) {
3457 setReference(event.clientX, event.clientY, event.currentTarget);
3458 setReactive([]);
3459 }
3460 });
3461 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3462 React18.useEffect(() => {
3463 if (!enabled) {
3464 resetReference(domReference);
3465 return void 0;
3466 }
3467 if (!openCheck) {
3468 return void 0;
3469 }
3470 function cleanupListener() {
3471 cleanupListenerRef.current?.();
3472 cleanupListenerRef.current = null;
3473 }
3474 const win = getWindow(floating);
3475 function handleMouseMove(event) {
3476 const target = getTarget(event);
3477 if (!contains(floating, target)) {
3478 setReference(event.clientX, event.clientY);
3479 } else {
3480 cleanupListener();
3481 }
3482 }
3483 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3484 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3485 } else {
3486 resetReference(domReference);
3487 }
3488 return cleanupListener;
3489 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3490 React18.useEffect(() => () => {
3491 store.set("positionReference", null);
3492 }, [store]);
3493 React18.useEffect(() => {
3494 if (enabled && !floating) {
3495 initialRef.current = false;
3496 }
3497 }, [enabled, floating]);
3498 React18.useEffect(() => {
3499 if (!enabled && open) {
3500 initialRef.current = true;
3501 }
3502 }, [enabled, open]);
3503 const reference = React18.useMemo(() => {
3504 function setPointerTypeRef(event) {
3505 setPointerType(event.pointerType);
3506 }
3507 return {
3508 onPointerDown: setPointerTypeRef,
3509 onPointerEnter: setPointerTypeRef,
3510 onMouseMove: handleReferenceEnterOrMove,
3511 onMouseEnter: handleReferenceEnterOrMove
3512 };
3513 }, [handleReferenceEnterOrMove]);
3514 return React18.useMemo(() => enabled ? {
3515 reference,
3516 trigger: reference
3517 } : {}, [enabled, reference]);
3518 }
3519
3520 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
3521 var React19 = __toESM(require_react(), 1);
3522 function alwaysFalse() {
3523 return false;
3524 }
3525 function normalizeProp(normalizable) {
3526 return {
3527 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3528 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3529 };
3530 }
3531 function useDismiss(context, props = {}) {
3532 const {
3533 enabled = true,
3534 escapeKey: escapeKey2 = true,
3535 outsidePress: outsidePressProp = true,
3536 outsidePressEvent = "sloppy",
3537 referencePress = alwaysFalse,
3538 bubbles,
3539 externalTree
3540 } = props;
3541 const store = "rootStore" in context ? context.rootStore : context;
3542 const open = store.useState("open");
3543 const floatingElement = store.useState("floatingElement");
3544 const {
3545 dataRef
3546 } = store.context;
3547 const tree = useFloatingTree(externalTree);
3548 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3549 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3550 const outsidePressEnabled = outsidePress2 !== false;
3551 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3552 const {
3553 escapeKey: escapeKeyBubbles,
3554 outsidePress: outsidePressBubbles
3555 } = normalizeProp(bubbles);
3556 const pressStartedInsideRef = React19.useRef(false);
3557 const pressStartPreventedRef = React19.useRef(false);
3558 const suppressNextOutsideClickRef = React19.useRef(false);
3559 const isComposingRef = React19.useRef(false);
3560 const currentPointerTypeRef = React19.useRef("");
3561 const touchStateRef = React19.useRef(null);
3562 const cancelDismissOnEndTimeout = useTimeout();
3563 const clearInsideReactTreeTimeout = useTimeout();
3564 const clearInsideReactTree = useStableCallback(() => {
3565 clearInsideReactTreeTimeout.clear();
3566 dataRef.current.insideReactTree = false;
3567 });
3568 const hasBlockingChild = useStableCallback((bubbleKey) => {
3569 const nodeId = dataRef.current.floatingContext?.nodeId;
3570 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3571 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3572 });
3573 const isEventWithinOwnElements = useStableCallback((event) => {
3574 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3575 });
3576 const closeOnReferencePress = useStableCallback((event) => {
3577 if (!referencePress()) {
3578 return;
3579 }
3580 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3581 });
3582 const closeOnEscapeKeyDown = useStableCallback((event) => {
3583 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3584 return;
3585 }
3586 if (isComposingRef.current) {
3587 return;
3588 }
3589 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3590 return;
3591 }
3592 const native = isReactEvent(event) ? event.nativeEvent : event;
3593 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3594 store.setOpen(false, eventDetails);
3595 if (!eventDetails.isCanceled) {
3596 event.preventDefault();
3597 }
3598 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3599 event.stopPropagation();
3600 }
3601 });
3602 const markInsideReactTree = useStableCallback(() => {
3603 dataRef.current.insideReactTree = true;
3604 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3605 });
3606 const markPressStartedInsideReactTree = useStableCallback((event) => {
3607 if (!open || !enabled || event.button !== 0) {
3608 return;
3609 }
3610 const target = getTarget(event.nativeEvent);
3611 if (!contains(store.select("floatingElement"), target)) {
3612 return;
3613 }
3614 if (!pressStartedInsideRef.current) {
3615 pressStartedInsideRef.current = true;
3616 pressStartPreventedRef.current = false;
3617 }
3618 });
3619 const markInsidePressStartPrevented = useStableCallback((event) => {
3620 if (!open || !enabled) {
3621 return;
3622 }
3623 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3624 return;
3625 }
3626 if (pressStartedInsideRef.current) {
3627 pressStartPreventedRef.current = true;
3628 }
3629 });
3630 React19.useEffect(() => {
3631 if (!open || !enabled) {
3632 return void 0;
3633 }
3634 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3635 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3636 const compositionTimeout = new Timeout();
3637 const preventedPressSuppressionTimeout = new Timeout();
3638 function handleCompositionStart() {
3639 compositionTimeout.clear();
3640 isComposingRef.current = true;
3641 }
3642 function handleCompositionEnd() {
3643 compositionTimeout.start(
3644 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3645 // Only apply to WebKit for the test to remain 0ms.
3646 parts_exports.engine.webkit ? 5 : 0,
3647 () => {
3648 isComposingRef.current = false;
3649 }
3650 );
3651 }
3652 function suppressImmediateOutsideClickAfterPreventedStart() {
3653 suppressNextOutsideClickRef.current = true;
3654 preventedPressSuppressionTimeout.start(0, () => {
3655 suppressNextOutsideClickRef.current = false;
3656 });
3657 }
3658 function resetPressStartState() {
3659 pressStartedInsideRef.current = false;
3660 pressStartPreventedRef.current = false;
3661 }
3662 function getOutsidePressEvent() {
3663 const type = currentPointerTypeRef.current;
3664 const computedType = type === "pen" || !type ? "mouse" : type;
3665 const outsidePressEventValue = getOutsidePressEventProp();
3666 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3667 if (typeof resolved === "string") {
3668 return resolved;
3669 }
3670 return resolved[computedType];
3671 }
3672 function shouldIgnoreEvent(event) {
3673 const computedOutsidePressEvent = getOutsidePressEvent();
3674 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3675 }
3676 function isEventWithinFloatingTree(event) {
3677 const nodeId = dataRef.current.floatingContext?.nodeId;
3678 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3679 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3680 }
3681 function closeOnPressOutside(event) {
3682 if (shouldIgnoreEvent(event)) {
3683 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3684 preventedPressSuppressionTimeout.clear();
3685 suppressNextOutsideClickRef.current = false;
3686 }
3687 clearInsideReactTree();
3688 return;
3689 }
3690 if (dataRef.current.insideReactTree) {
3691 clearInsideReactTree();
3692 return;
3693 }
3694 const target = getTarget(event);
3695 const inertSelector = `[${createAttribute("inert")}]`;
3696 const targetRoot = isElement(target) ? target.getRootNode() : null;
3697 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3698 const triggers = store.context.triggerElements;
3699 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3700 return;
3701 }
3702 let targetRootAncestor = isElement(target) ? target : null;
3703 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3704 const nextParent = getParentNode(targetRootAncestor);
3705 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3706 break;
3707 }
3708 targetRootAncestor = nextParent;
3709 }
3710 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3711 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3712 // element was injected after the floating element rendered.
3713 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3714 return;
3715 }
3716 if (isHTMLElement(target) && !("touches" in event)) {
3717 const lastTraversableNode = isLastTraversableNode(target);
3718 const style = getComputedStyle2(target);
3719 const scrollRe = /auto|scroll/;
3720 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3721 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3722 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3723 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3724 const isRTL7 = style.direction === "rtl";
3725 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3726 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3727 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3728 return;
3729 }
3730 }
3731 if (isEventWithinFloatingTree(event)) {
3732 return;
3733 }
3734 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3735 preventedPressSuppressionTimeout.clear();
3736 suppressNextOutsideClickRef.current = false;
3737 return;
3738 }
3739 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3740 return;
3741 }
3742 if (hasBlockingChild("__outsidePressBubbles")) {
3743 return;
3744 }
3745 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3746 clearInsideReactTree();
3747 }
3748 function handlePointerDown(event) {
3749 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3750 return;
3751 }
3752 closeOnPressOutside(event);
3753 }
3754 function handleTouchStart(event) {
3755 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3756 return;
3757 }
3758 const touch = event.touches[0];
3759 if (touch) {
3760 touchStateRef.current = {
3761 startTime: Date.now(),
3762 startX: touch.clientX,
3763 startY: touch.clientY,
3764 dismissOnTouchEnd: false,
3765 dismissOnMouseDown: true
3766 };
3767 cancelDismissOnEndTimeout.start(1e3, () => {
3768 if (touchStateRef.current) {
3769 touchStateRef.current.dismissOnTouchEnd = false;
3770 touchStateRef.current.dismissOnMouseDown = false;
3771 }
3772 });
3773 }
3774 }
3775 function addTargetEventListenerOnce(event, listener) {
3776 const target = getTarget(event);
3777 if (!target) {
3778 return;
3779 }
3780 const unsubscribe2 = addEventListener(target, event.type, () => {
3781 listener(event);
3782 unsubscribe2();
3783 });
3784 }
3785 function handleTouchStartCapture(event) {
3786 currentPointerTypeRef.current = "touch";
3787 addTargetEventListenerOnce(event, handleTouchStart);
3788 }
3789 function closeOnPressOutsideCapture(event) {
3790 cancelDismissOnEndTimeout.clear();
3791 if (event.type === "pointerdown") {
3792 currentPointerTypeRef.current = event.pointerType;
3793 }
3794 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3795 return;
3796 }
3797 addTargetEventListenerOnce(event, (targetEvent) => {
3798 if (targetEvent.type === "pointerdown") {
3799 handlePointerDown(targetEvent);
3800 } else {
3801 closeOnPressOutside(targetEvent);
3802 }
3803 });
3804 }
3805 function handlePressEndCapture(event) {
3806 if (!pressStartedInsideRef.current) {
3807 return;
3808 }
3809 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3810 resetPressStartState();
3811 if (getOutsidePressEvent() !== "intentional") {
3812 return;
3813 }
3814 if (event.type === "pointercancel") {
3815 if (pressStartedInsideDefaultPrevented) {
3816 suppressImmediateOutsideClickAfterPreventedStart();
3817 }
3818 return;
3819 }
3820 if (isEventWithinFloatingTree(event)) {
3821 return;
3822 }
3823 if (pressStartedInsideDefaultPrevented) {
3824 suppressImmediateOutsideClickAfterPreventedStart();
3825 return;
3826 }
3827 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3828 return;
3829 }
3830 preventedPressSuppressionTimeout.clear();
3831 suppressNextOutsideClickRef.current = true;
3832 clearInsideReactTree();
3833 }
3834 function handleTouchMove(event) {
3835 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3836 return;
3837 }
3838 const touch = event.touches[0];
3839 if (!touch) {
3840 return;
3841 }
3842 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3843 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3844 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3845 if (distance > 5) {
3846 touchStateRef.current.dismissOnTouchEnd = true;
3847 }
3848 if (distance > 10) {
3849 closeOnPressOutside(event);
3850 cancelDismissOnEndTimeout.clear();
3851 touchStateRef.current = null;
3852 }
3853 }
3854 function handleTouchMoveCapture(event) {
3855 addTargetEventListenerOnce(event, handleTouchMove);
3856 }
3857 function handleTouchEnd(event) {
3858 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3859 return;
3860 }
3861 if (touchStateRef.current.dismissOnTouchEnd) {
3862 closeOnPressOutside(event);
3863 }
3864 cancelDismissOnEndTimeout.clear();
3865 touchStateRef.current = null;
3866 }
3867 function handleTouchEndCapture(event) {
3868 addTargetEventListenerOnce(event, handleTouchEnd);
3869 }
3870 const doc = ownerDocument(floatingElement);
3871 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)));
3872 return () => {
3873 unsubscribe();
3874 compositionTimeout.clear();
3875 preventedPressSuppressionTimeout.clear();
3876 resetPressStartState();
3877 suppressNextOutsideClickRef.current = false;
3878 };
3879 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3880 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3881 const reference = React19.useMemo(() => ({
3882 onKeyDown: closeOnEscapeKeyDown,
3883 onPointerDown: closeOnReferencePress,
3884 onClick: closeOnReferencePress
3885 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
3886 const floating = React19.useMemo(() => ({
3887 onKeyDown: closeOnEscapeKeyDown,
3888 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3889 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3890 // See https://github.com/mui/base-ui/pull/3379
3891 onPointerDown: markInsidePressStartPrevented,
3892 onMouseDown: markInsidePressStartPrevented,
3893 onClickCapture: markInsideReactTree,
3894 onMouseDownCapture(event) {
3895 markInsideReactTree();
3896 markPressStartedInsideReactTree(event);
3897 },
3898 onPointerDownCapture(event) {
3899 markInsideReactTree();
3900 markPressStartedInsideReactTree(event);
3901 },
3902 onMouseUpCapture: markInsideReactTree,
3903 onTouchEndCapture: markInsideReactTree,
3904 onTouchMoveCapture: markInsideReactTree
3905 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3906 return React19.useMemo(() => enabled ? {
3907 reference,
3908 floating,
3909 trigger: reference
3910 } : {}, [enabled, reference, floating]);
3911 }
3912
3913 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
3914 var React26 = __toESM(require_react(), 1);
3915
3916 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3917 function computeCoordsFromPlacement(_ref, placement, rtl) {
3918 let {
3919 reference,
3920 floating
3921 } = _ref;
3922 const sideAxis = getSideAxis(placement);
3923 const alignmentAxis = getAlignmentAxis(placement);
3924 const alignLength = getAxisLength(alignmentAxis);
3925 const side = getSide(placement);
3926 const isVertical = sideAxis === "y";
3927 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3928 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3929 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3930 let coords;
3931 switch (side) {
3932 case "top":
3933 coords = {
3934 x: commonX,
3935 y: reference.y - floating.height
3936 };
3937 break;
3938 case "bottom":
3939 coords = {
3940 x: commonX,
3941 y: reference.y + reference.height
3942 };
3943 break;
3944 case "right":
3945 coords = {
3946 x: reference.x + reference.width,
3947 y: commonY
3948 };
3949 break;
3950 case "left":
3951 coords = {
3952 x: reference.x - floating.width,
3953 y: commonY
3954 };
3955 break;
3956 default:
3957 coords = {
3958 x: reference.x,
3959 y: reference.y
3960 };
3961 }
3962 switch (getAlignment(placement)) {
3963 case "start":
3964 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3965 break;
3966 case "end":
3967 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3968 break;
3969 }
3970 return coords;
3971 }
3972 async function detectOverflow(state, options) {
3973 var _await$platform$isEle;
3974 if (options === void 0) {
3975 options = {};
3976 }
3977 const {
3978 x: x2,
3979 y: y2,
3980 platform: platform3,
3981 rects,
3982 elements,
3983 strategy
3984 } = state;
3985 const {
3986 boundary = "clippingAncestors",
3987 rootBoundary = "viewport",
3988 elementContext = "floating",
3989 altBoundary = false,
3990 padding = 0
3991 } = evaluate(options, state);
3992 const paddingObject = getPaddingObject(padding);
3993 const altContext = elementContext === "floating" ? "reference" : "floating";
3994 const element = elements[altBoundary ? altContext : elementContext];
3995 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3996 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)),
3997 boundary,
3998 rootBoundary,
3999 strategy
4000 }));
4001 const rect = elementContext === "floating" ? {
4002 x: x2,
4003 y: y2,
4004 width: rects.floating.width,
4005 height: rects.floating.height
4006 } : rects.reference;
4007 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4008 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4009 x: 1,
4010 y: 1
4011 } : {
4012 x: 1,
4013 y: 1
4014 };
4015 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4016 elements,
4017 rect,
4018 offsetParent,
4019 strategy
4020 }) : rect);
4021 return {
4022 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4023 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4024 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4025 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4026 };
4027 }
4028 var MAX_RESET_COUNT = 50;
4029 var computePosition = async (reference, floating, config) => {
4030 const {
4031 placement = "bottom",
4032 strategy = "absolute",
4033 middleware = [],
4034 platform: platform3
4035 } = config;
4036 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4037 ...platform3,
4038 detectOverflow
4039 };
4040 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4041 let rects = await platform3.getElementRects({
4042 reference,
4043 floating,
4044 strategy
4045 });
4046 let {
4047 x: x2,
4048 y: y2
4049 } = computeCoordsFromPlacement(rects, placement, rtl);
4050 let statefulPlacement = placement;
4051 let resetCount = 0;
4052 const middlewareData = {};
4053 for (let i2 = 0; i2 < middleware.length; i2++) {
4054 const currentMiddleware = middleware[i2];
4055 if (!currentMiddleware) {
4056 continue;
4057 }
4058 const {
4059 name,
4060 fn
4061 } = currentMiddleware;
4062 const {
4063 x: nextX,
4064 y: nextY,
4065 data,
4066 reset
4067 } = await fn({
4068 x: x2,
4069 y: y2,
4070 initialPlacement: placement,
4071 placement: statefulPlacement,
4072 strategy,
4073 middlewareData,
4074 rects,
4075 platform: platformWithDetectOverflow,
4076 elements: {
4077 reference,
4078 floating
4079 }
4080 });
4081 x2 = nextX != null ? nextX : x2;
4082 y2 = nextY != null ? nextY : y2;
4083 middlewareData[name] = {
4084 ...middlewareData[name],
4085 ...data
4086 };
4087 if (reset && resetCount < MAX_RESET_COUNT) {
4088 resetCount++;
4089 if (typeof reset === "object") {
4090 if (reset.placement) {
4091 statefulPlacement = reset.placement;
4092 }
4093 if (reset.rects) {
4094 rects = reset.rects === true ? await platform3.getElementRects({
4095 reference,
4096 floating,
4097 strategy
4098 }) : reset.rects;
4099 }
4100 ({
4101 x: x2,
4102 y: y2
4103 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4104 }
4105 i2 = -1;
4106 }
4107 }
4108 return {
4109 x: x2,
4110 y: y2,
4111 placement: statefulPlacement,
4112 strategy,
4113 middlewareData
4114 };
4115 };
4116 var flip = function(options) {
4117 if (options === void 0) {
4118 options = {};
4119 }
4120 return {
4121 name: "flip",
4122 options,
4123 async fn(state) {
4124 var _middlewareData$arrow, _middlewareData$flip;
4125 const {
4126 placement,
4127 middlewareData,
4128 rects,
4129 initialPlacement,
4130 platform: platform3,
4131 elements
4132 } = state;
4133 const {
4134 mainAxis: checkMainAxis = true,
4135 crossAxis: checkCrossAxis = true,
4136 fallbackPlacements: specifiedFallbackPlacements,
4137 fallbackStrategy = "bestFit",
4138 fallbackAxisSideDirection = "none",
4139 flipAlignment = true,
4140 ...detectOverflowOptions
4141 } = evaluate(options, state);
4142 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4143 return {};
4144 }
4145 const side = getSide(placement);
4146 const initialSideAxis = getSideAxis(initialPlacement);
4147 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4148 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4149 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4150 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4151 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4152 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4153 }
4154 const placements2 = [initialPlacement, ...fallbackPlacements];
4155 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4156 const overflows = [];
4157 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4158 if (checkMainAxis) {
4159 overflows.push(overflow[side]);
4160 }
4161 if (checkCrossAxis) {
4162 const sides2 = getAlignmentSides(placement, rects, rtl);
4163 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4164 }
4165 overflowsData = [...overflowsData, {
4166 placement,
4167 overflows
4168 }];
4169 if (!overflows.every((side2) => side2 <= 0)) {
4170 var _middlewareData$flip2, _overflowsData$filter;
4171 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4172 const nextPlacement = placements2[nextIndex];
4173 if (nextPlacement) {
4174 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4175 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4176 // overflows the main axis.
4177 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4178 return {
4179 data: {
4180 index: nextIndex,
4181 overflows: overflowsData
4182 },
4183 reset: {
4184 placement: nextPlacement
4185 }
4186 };
4187 }
4188 }
4189 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;
4190 if (!resetPlacement) {
4191 switch (fallbackStrategy) {
4192 case "bestFit": {
4193 var _overflowsData$filter2;
4194 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4195 if (hasFallbackAxisSideDirection) {
4196 const currentSideAxis = getSideAxis(d2.placement);
4197 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4198 // reading directions favoring greater width.
4199 currentSideAxis === "y";
4200 }
4201 return true;
4202 }).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];
4203 if (placement2) {
4204 resetPlacement = placement2;
4205 }
4206 break;
4207 }
4208 case "initialPlacement":
4209 resetPlacement = initialPlacement;
4210 break;
4211 }
4212 }
4213 if (placement !== resetPlacement) {
4214 return {
4215 reset: {
4216 placement: resetPlacement
4217 }
4218 };
4219 }
4220 }
4221 return {};
4222 }
4223 };
4224 };
4225 function getSideOffsets(overflow, rect) {
4226 return {
4227 top: overflow.top - rect.height,
4228 right: overflow.right - rect.width,
4229 bottom: overflow.bottom - rect.height,
4230 left: overflow.left - rect.width
4231 };
4232 }
4233 function isAnySideFullyClipped(overflow) {
4234 return sides.some((side) => overflow[side] >= 0);
4235 }
4236 var hide = function(options) {
4237 if (options === void 0) {
4238 options = {};
4239 }
4240 return {
4241 name: "hide",
4242 options,
4243 async fn(state) {
4244 const {
4245 rects,
4246 platform: platform3
4247 } = state;
4248 const {
4249 strategy = "referenceHidden",
4250 ...detectOverflowOptions
4251 } = evaluate(options, state);
4252 switch (strategy) {
4253 case "referenceHidden": {
4254 const overflow = await platform3.detectOverflow(state, {
4255 ...detectOverflowOptions,
4256 elementContext: "reference"
4257 });
4258 const offsets = getSideOffsets(overflow, rects.reference);
4259 return {
4260 data: {
4261 referenceHiddenOffsets: offsets,
4262 referenceHidden: isAnySideFullyClipped(offsets)
4263 }
4264 };
4265 }
4266 case "escaped": {
4267 const overflow = await platform3.detectOverflow(state, {
4268 ...detectOverflowOptions,
4269 altBoundary: true
4270 });
4271 const offsets = getSideOffsets(overflow, rects.floating);
4272 return {
4273 data: {
4274 escapedOffsets: offsets,
4275 escaped: isAnySideFullyClipped(offsets)
4276 }
4277 };
4278 }
4279 default: {
4280 return {};
4281 }
4282 }
4283 }
4284 };
4285 };
4286 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4287 async function convertValueToCoords(state, options) {
4288 const {
4289 placement,
4290 platform: platform3,
4291 elements
4292 } = state;
4293 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4294 const side = getSide(placement);
4295 const alignment = getAlignment(placement);
4296 const isVertical = getSideAxis(placement) === "y";
4297 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4298 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4299 const rawValue = evaluate(options, state);
4300 let {
4301 mainAxis,
4302 crossAxis,
4303 alignmentAxis
4304 } = typeof rawValue === "number" ? {
4305 mainAxis: rawValue,
4306 crossAxis: 0,
4307 alignmentAxis: null
4308 } : {
4309 mainAxis: rawValue.mainAxis || 0,
4310 crossAxis: rawValue.crossAxis || 0,
4311 alignmentAxis: rawValue.alignmentAxis
4312 };
4313 if (alignment && typeof alignmentAxis === "number") {
4314 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4315 }
4316 return isVertical ? {
4317 x: crossAxis * crossAxisMulti,
4318 y: mainAxis * mainAxisMulti
4319 } : {
4320 x: mainAxis * mainAxisMulti,
4321 y: crossAxis * crossAxisMulti
4322 };
4323 }
4324 var offset = function(options) {
4325 if (options === void 0) {
4326 options = 0;
4327 }
4328 return {
4329 name: "offset",
4330 options,
4331 async fn(state) {
4332 var _middlewareData$offse, _middlewareData$arrow;
4333 const {
4334 x: x2,
4335 y: y2,
4336 placement,
4337 middlewareData
4338 } = state;
4339 const diffCoords = await convertValueToCoords(state, options);
4340 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4341 return {};
4342 }
4343 return {
4344 x: x2 + diffCoords.x,
4345 y: y2 + diffCoords.y,
4346 data: {
4347 ...diffCoords,
4348 placement
4349 }
4350 };
4351 }
4352 };
4353 };
4354 var shift = function(options) {
4355 if (options === void 0) {
4356 options = {};
4357 }
4358 return {
4359 name: "shift",
4360 options,
4361 async fn(state) {
4362 const {
4363 x: x2,
4364 y: y2,
4365 placement,
4366 platform: platform3
4367 } = state;
4368 const {
4369 mainAxis: checkMainAxis = true,
4370 crossAxis: checkCrossAxis = false,
4371 limiter = {
4372 fn: (_ref) => {
4373 let {
4374 x: x3,
4375 y: y3
4376 } = _ref;
4377 return {
4378 x: x3,
4379 y: y3
4380 };
4381 }
4382 },
4383 ...detectOverflowOptions
4384 } = evaluate(options, state);
4385 const coords = {
4386 x: x2,
4387 y: y2
4388 };
4389 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4390 const crossAxis = getSideAxis(getSide(placement));
4391 const mainAxis = getOppositeAxis(crossAxis);
4392 let mainAxisCoord = coords[mainAxis];
4393 let crossAxisCoord = coords[crossAxis];
4394 if (checkMainAxis) {
4395 const minSide = mainAxis === "y" ? "top" : "left";
4396 const maxSide = mainAxis === "y" ? "bottom" : "right";
4397 const min2 = mainAxisCoord + overflow[minSide];
4398 const max2 = mainAxisCoord - overflow[maxSide];
4399 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4400 }
4401 if (checkCrossAxis) {
4402 const minSide = crossAxis === "y" ? "top" : "left";
4403 const maxSide = crossAxis === "y" ? "bottom" : "right";
4404 const min2 = crossAxisCoord + overflow[minSide];
4405 const max2 = crossAxisCoord - overflow[maxSide];
4406 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4407 }
4408 const limitedCoords = limiter.fn({
4409 ...state,
4410 [mainAxis]: mainAxisCoord,
4411 [crossAxis]: crossAxisCoord
4412 });
4413 return {
4414 ...limitedCoords,
4415 data: {
4416 x: limitedCoords.x - x2,
4417 y: limitedCoords.y - y2,
4418 enabled: {
4419 [mainAxis]: checkMainAxis,
4420 [crossAxis]: checkCrossAxis
4421 }
4422 }
4423 };
4424 }
4425 };
4426 };
4427 var limitShift = function(options) {
4428 if (options === void 0) {
4429 options = {};
4430 }
4431 return {
4432 options,
4433 fn(state) {
4434 const {
4435 x: x2,
4436 y: y2,
4437 placement,
4438 rects,
4439 middlewareData
4440 } = state;
4441 const {
4442 offset: offset4 = 0,
4443 mainAxis: checkMainAxis = true,
4444 crossAxis: checkCrossAxis = true
4445 } = evaluate(options, state);
4446 const coords = {
4447 x: x2,
4448 y: y2
4449 };
4450 const crossAxis = getSideAxis(placement);
4451 const mainAxis = getOppositeAxis(crossAxis);
4452 let mainAxisCoord = coords[mainAxis];
4453 let crossAxisCoord = coords[crossAxis];
4454 const rawOffset = evaluate(offset4, state);
4455 const computedOffset = typeof rawOffset === "number" ? {
4456 mainAxis: rawOffset,
4457 crossAxis: 0
4458 } : {
4459 mainAxis: 0,
4460 crossAxis: 0,
4461 ...rawOffset
4462 };
4463 if (checkMainAxis) {
4464 const len = mainAxis === "y" ? "height" : "width";
4465 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4466 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4467 if (mainAxisCoord < limitMin) {
4468 mainAxisCoord = limitMin;
4469 } else if (mainAxisCoord > limitMax) {
4470 mainAxisCoord = limitMax;
4471 }
4472 }
4473 if (checkCrossAxis) {
4474 var _middlewareData$offse, _middlewareData$offse2;
4475 const len = mainAxis === "y" ? "width" : "height";
4476 const isOriginSide = originSides.has(getSide(placement));
4477 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);
4478 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);
4479 if (crossAxisCoord < limitMin) {
4480 crossAxisCoord = limitMin;
4481 } else if (crossAxisCoord > limitMax) {
4482 crossAxisCoord = limitMax;
4483 }
4484 }
4485 return {
4486 [mainAxis]: mainAxisCoord,
4487 [crossAxis]: crossAxisCoord
4488 };
4489 }
4490 };
4491 };
4492 var size = function(options) {
4493 if (options === void 0) {
4494 options = {};
4495 }
4496 return {
4497 name: "size",
4498 options,
4499 async fn(state) {
4500 var _state$middlewareData, _state$middlewareData2;
4501 const {
4502 placement,
4503 rects,
4504 platform: platform3,
4505 elements
4506 } = state;
4507 const {
4508 apply = () => {
4509 },
4510 ...detectOverflowOptions
4511 } = evaluate(options, state);
4512 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4513 const side = getSide(placement);
4514 const alignment = getAlignment(placement);
4515 const isYAxis = getSideAxis(placement) === "y";
4516 const {
4517 width,
4518 height
4519 } = rects.floating;
4520 let heightSide;
4521 let widthSide;
4522 if (side === "top" || side === "bottom") {
4523 heightSide = side;
4524 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4525 } else {
4526 widthSide = side;
4527 heightSide = alignment === "end" ? "top" : "bottom";
4528 }
4529 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4530 const maximumClippingWidth = width - overflow.left - overflow.right;
4531 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4532 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4533 const noShift = !state.middlewareData.shift;
4534 let availableHeight = overflowAvailableHeight;
4535 let availableWidth = overflowAvailableWidth;
4536 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4537 availableWidth = maximumClippingWidth;
4538 }
4539 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4540 availableHeight = maximumClippingHeight;
4541 }
4542 if (noShift && !alignment) {
4543 const xMin = max(overflow.left, 0);
4544 const xMax = max(overflow.right, 0);
4545 const yMin = max(overflow.top, 0);
4546 const yMax = max(overflow.bottom, 0);
4547 if (isYAxis) {
4548 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4549 } else {
4550 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4551 }
4552 }
4553 await apply({
4554 ...state,
4555 availableWidth,
4556 availableHeight
4557 });
4558 const nextDimensions = await platform3.getDimensions(elements.floating);
4559 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4560 return {
4561 reset: {
4562 rects: true
4563 }
4564 };
4565 }
4566 return {};
4567 }
4568 };
4569 };
4570
4571 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4572 function getCssDimensions(element) {
4573 const css = getComputedStyle2(element);
4574 let width = parseFloat(css.width) || 0;
4575 let height = parseFloat(css.height) || 0;
4576 const hasOffset = isHTMLElement(element);
4577 const offsetWidth = hasOffset ? element.offsetWidth : width;
4578 const offsetHeight = hasOffset ? element.offsetHeight : height;
4579 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4580 if (shouldFallback) {
4581 width = offsetWidth;
4582 height = offsetHeight;
4583 }
4584 return {
4585 width,
4586 height,
4587 $: shouldFallback
4588 };
4589 }
4590 function unwrapElement(element) {
4591 return !isElement(element) ? element.contextElement : element;
4592 }
4593 function getScale(element) {
4594 const domElement = unwrapElement(element);
4595 if (!isHTMLElement(domElement)) {
4596 return createCoords(1);
4597 }
4598 const rect = domElement.getBoundingClientRect();
4599 const {
4600 width,
4601 height,
4602 $: $2
4603 } = getCssDimensions(domElement);
4604 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4605 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4606 if (!x2 || !Number.isFinite(x2)) {
4607 x2 = 1;
4608 }
4609 if (!y2 || !Number.isFinite(y2)) {
4610 y2 = 1;
4611 }
4612 return {
4613 x: x2,
4614 y: y2
4615 };
4616 }
4617 var noOffsets = /* @__PURE__ */ createCoords(0);
4618 function getVisualOffsets(element) {
4619 const win = getWindow(element);
4620 if (!isWebKit() || !win.visualViewport) {
4621 return noOffsets;
4622 }
4623 return {
4624 x: win.visualViewport.offsetLeft,
4625 y: win.visualViewport.offsetTop
4626 };
4627 }
4628 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4629 if (isFixed === void 0) {
4630 isFixed = false;
4631 }
4632 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4633 return false;
4634 }
4635 return isFixed;
4636 }
4637 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4638 if (includeScale === void 0) {
4639 includeScale = false;
4640 }
4641 if (isFixedStrategy === void 0) {
4642 isFixedStrategy = false;
4643 }
4644 const clientRect = element.getBoundingClientRect();
4645 const domElement = unwrapElement(element);
4646 let scale = createCoords(1);
4647 if (includeScale) {
4648 if (offsetParent) {
4649 if (isElement(offsetParent)) {
4650 scale = getScale(offsetParent);
4651 }
4652 } else {
4653 scale = getScale(element);
4654 }
4655 }
4656 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4657 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4658 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4659 let width = clientRect.width / scale.x;
4660 let height = clientRect.height / scale.y;
4661 if (domElement) {
4662 const win = getWindow(domElement);
4663 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4664 let currentWin = win;
4665 let currentIFrame = getFrameElement(currentWin);
4666 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4667 const iframeScale = getScale(currentIFrame);
4668 const iframeRect = currentIFrame.getBoundingClientRect();
4669 const css = getComputedStyle2(currentIFrame);
4670 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4671 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4672 x2 *= iframeScale.x;
4673 y2 *= iframeScale.y;
4674 width *= iframeScale.x;
4675 height *= iframeScale.y;
4676 x2 += left;
4677 y2 += top;
4678 currentWin = getWindow(currentIFrame);
4679 currentIFrame = getFrameElement(currentWin);
4680 }
4681 }
4682 return rectToClientRect({
4683 width,
4684 height,
4685 x: x2,
4686 y: y2
4687 });
4688 }
4689 function getWindowScrollBarX(element, rect) {
4690 const leftScroll = getNodeScroll(element).scrollLeft;
4691 if (!rect) {
4692 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4693 }
4694 return rect.left + leftScroll;
4695 }
4696 function getHTMLOffset(documentElement, scroll) {
4697 const htmlRect = documentElement.getBoundingClientRect();
4698 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4699 const y2 = htmlRect.top + scroll.scrollTop;
4700 return {
4701 x: x2,
4702 y: y2
4703 };
4704 }
4705 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4706 let {
4707 elements,
4708 rect,
4709 offsetParent,
4710 strategy
4711 } = _ref;
4712 const isFixed = strategy === "fixed";
4713 const documentElement = getDocumentElement(offsetParent);
4714 const topLayer = elements ? isTopLayer(elements.floating) : false;
4715 if (offsetParent === documentElement || topLayer && isFixed) {
4716 return rect;
4717 }
4718 let scroll = {
4719 scrollLeft: 0,
4720 scrollTop: 0
4721 };
4722 let scale = createCoords(1);
4723 const offsets = createCoords(0);
4724 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4725 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4726 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4727 scroll = getNodeScroll(offsetParent);
4728 }
4729 if (isOffsetParentAnElement) {
4730 const offsetRect = getBoundingClientRect(offsetParent);
4731 scale = getScale(offsetParent);
4732 offsets.x = offsetRect.x + offsetParent.clientLeft;
4733 offsets.y = offsetRect.y + offsetParent.clientTop;
4734 }
4735 }
4736 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4737 return {
4738 width: rect.width * scale.x,
4739 height: rect.height * scale.y,
4740 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4741 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4742 };
4743 }
4744 function getClientRects(element) {
4745 return Array.from(element.getClientRects());
4746 }
4747 function getDocumentRect(element) {
4748 const html = getDocumentElement(element);
4749 const scroll = getNodeScroll(element);
4750 const body = element.ownerDocument.body;
4751 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4752 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4753 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4754 const y2 = -scroll.scrollTop;
4755 if (getComputedStyle2(body).direction === "rtl") {
4756 x2 += max(html.clientWidth, body.clientWidth) - width;
4757 }
4758 return {
4759 width,
4760 height,
4761 x: x2,
4762 y: y2
4763 };
4764 }
4765 var SCROLLBAR_MAX = 25;
4766 function getViewportRect(element, strategy) {
4767 const win = getWindow(element);
4768 const html = getDocumentElement(element);
4769 const visualViewport = win.visualViewport;
4770 let width = html.clientWidth;
4771 let height = html.clientHeight;
4772 let x2 = 0;
4773 let y2 = 0;
4774 if (visualViewport) {
4775 width = visualViewport.width;
4776 height = visualViewport.height;
4777 const visualViewportBased = isWebKit();
4778 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4779 x2 = visualViewport.offsetLeft;
4780 y2 = visualViewport.offsetTop;
4781 }
4782 }
4783 const windowScrollbarX = getWindowScrollBarX(html);
4784 if (windowScrollbarX <= 0) {
4785 const doc = html.ownerDocument;
4786 const body = doc.body;
4787 const bodyStyles = getComputedStyle(body);
4788 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4789 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4790 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4791 width -= clippingStableScrollbarWidth;
4792 }
4793 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4794 width += windowScrollbarX;
4795 }
4796 return {
4797 width,
4798 height,
4799 x: x2,
4800 y: y2
4801 };
4802 }
4803 function getInnerBoundingClientRect(element, strategy) {
4804 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4805 const top = clientRect.top + element.clientTop;
4806 const left = clientRect.left + element.clientLeft;
4807 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4808 const width = element.clientWidth * scale.x;
4809 const height = element.clientHeight * scale.y;
4810 const x2 = left * scale.x;
4811 const y2 = top * scale.y;
4812 return {
4813 width,
4814 height,
4815 x: x2,
4816 y: y2
4817 };
4818 }
4819 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4820 let rect;
4821 if (clippingAncestor === "viewport") {
4822 rect = getViewportRect(element, strategy);
4823 } else if (clippingAncestor === "document") {
4824 rect = getDocumentRect(getDocumentElement(element));
4825 } else if (isElement(clippingAncestor)) {
4826 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4827 } else {
4828 const visualOffsets = getVisualOffsets(element);
4829 rect = {
4830 x: clippingAncestor.x - visualOffsets.x,
4831 y: clippingAncestor.y - visualOffsets.y,
4832 width: clippingAncestor.width,
4833 height: clippingAncestor.height
4834 };
4835 }
4836 return rectToClientRect(rect);
4837 }
4838 function hasFixedPositionAncestor(element, stopNode) {
4839 const parentNode = getParentNode(element);
4840 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4841 return false;
4842 }
4843 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4844 }
4845 function getClippingElementAncestors(element, cache) {
4846 const cachedResult = cache.get(element);
4847 if (cachedResult) {
4848 return cachedResult;
4849 }
4850 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4851 let currentContainingBlockComputedStyle = null;
4852 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4853 let currentNode = elementIsFixed ? getParentNode(element) : element;
4854 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4855 const computedStyle = getComputedStyle2(currentNode);
4856 const currentNodeIsContaining = isContainingBlock(currentNode);
4857 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4858 currentContainingBlockComputedStyle = null;
4859 }
4860 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4861 if (shouldDropCurrentNode) {
4862 result = result.filter((ancestor) => ancestor !== currentNode);
4863 } else {
4864 currentContainingBlockComputedStyle = computedStyle;
4865 }
4866 currentNode = getParentNode(currentNode);
4867 }
4868 cache.set(element, result);
4869 return result;
4870 }
4871 function getClippingRect(_ref) {
4872 let {
4873 element,
4874 boundary,
4875 rootBoundary,
4876 strategy
4877 } = _ref;
4878 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4879 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4880 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4881 let top = firstRect.top;
4882 let right = firstRect.right;
4883 let bottom = firstRect.bottom;
4884 let left = firstRect.left;
4885 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4886 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4887 top = max(rect.top, top);
4888 right = min(rect.right, right);
4889 bottom = min(rect.bottom, bottom);
4890 left = max(rect.left, left);
4891 }
4892 return {
4893 width: right - left,
4894 height: bottom - top,
4895 x: left,
4896 y: top
4897 };
4898 }
4899 function getDimensions(element) {
4900 const {
4901 width,
4902 height
4903 } = getCssDimensions(element);
4904 return {
4905 width,
4906 height
4907 };
4908 }
4909 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4910 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4911 const documentElement = getDocumentElement(offsetParent);
4912 const isFixed = strategy === "fixed";
4913 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4914 let scroll = {
4915 scrollLeft: 0,
4916 scrollTop: 0
4917 };
4918 const offsets = createCoords(0);
4919 function setLeftRTLScrollbarOffset() {
4920 offsets.x = getWindowScrollBarX(documentElement);
4921 }
4922 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4923 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4924 scroll = getNodeScroll(offsetParent);
4925 }
4926 if (isOffsetParentAnElement) {
4927 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4928 offsets.x = offsetRect.x + offsetParent.clientLeft;
4929 offsets.y = offsetRect.y + offsetParent.clientTop;
4930 } else if (documentElement) {
4931 setLeftRTLScrollbarOffset();
4932 }
4933 }
4934 if (isFixed && !isOffsetParentAnElement && documentElement) {
4935 setLeftRTLScrollbarOffset();
4936 }
4937 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4938 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4939 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4940 return {
4941 x: x2,
4942 y: y2,
4943 width: rect.width,
4944 height: rect.height
4945 };
4946 }
4947 function isStaticPositioned(element) {
4948 return getComputedStyle2(element).position === "static";
4949 }
4950 function getTrueOffsetParent(element, polyfill) {
4951 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4952 return null;
4953 }
4954 if (polyfill) {
4955 return polyfill(element);
4956 }
4957 let rawOffsetParent = element.offsetParent;
4958 if (getDocumentElement(element) === rawOffsetParent) {
4959 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4960 }
4961 return rawOffsetParent;
4962 }
4963 function getOffsetParent(element, polyfill) {
4964 const win = getWindow(element);
4965 if (isTopLayer(element)) {
4966 return win;
4967 }
4968 if (!isHTMLElement(element)) {
4969 let svgOffsetParent = getParentNode(element);
4970 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4971 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4972 return svgOffsetParent;
4973 }
4974 svgOffsetParent = getParentNode(svgOffsetParent);
4975 }
4976 return win;
4977 }
4978 let offsetParent = getTrueOffsetParent(element, polyfill);
4979 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4980 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4981 }
4982 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4983 return win;
4984 }
4985 return offsetParent || getContainingBlock(element) || win;
4986 }
4987 var getElementRects = async function(data) {
4988 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4989 const getDimensionsFn = this.getDimensions;
4990 const floatingDimensions = await getDimensionsFn(data.floating);
4991 return {
4992 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4993 floating: {
4994 x: 0,
4995 y: 0,
4996 width: floatingDimensions.width,
4997 height: floatingDimensions.height
4998 }
4999 };
5000 };
5001 function isRTL(element) {
5002 return getComputedStyle2(element).direction === "rtl";
5003 }
5004 var platform2 = {
5005 convertOffsetParentRelativeRectToViewportRelativeRect,
5006 getDocumentElement,
5007 getClippingRect,
5008 getOffsetParent,
5009 getElementRects,
5010 getClientRects,
5011 getDimensions,
5012 getScale,
5013 isElement,
5014 isRTL
5015 };
5016 function rectsAreEqual(a2, b2) {
5017 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5018 }
5019 function observeMove(element, onMove) {
5020 let io = null;
5021 let timeoutId;
5022 const root = getDocumentElement(element);
5023 function cleanup() {
5024 var _io;
5025 clearTimeout(timeoutId);
5026 (_io = io) == null || _io.disconnect();
5027 io = null;
5028 }
5029 function refresh(skip, threshold) {
5030 if (skip === void 0) {
5031 skip = false;
5032 }
5033 if (threshold === void 0) {
5034 threshold = 1;
5035 }
5036 cleanup();
5037 const elementRectForRootMargin = element.getBoundingClientRect();
5038 const {
5039 left,
5040 top,
5041 width,
5042 height
5043 } = elementRectForRootMargin;
5044 if (!skip) {
5045 onMove();
5046 }
5047 if (!width || !height) {
5048 return;
5049 }
5050 const insetTop = floor(top);
5051 const insetRight = floor(root.clientWidth - (left + width));
5052 const insetBottom = floor(root.clientHeight - (top + height));
5053 const insetLeft = floor(left);
5054 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5055 const options = {
5056 rootMargin,
5057 threshold: max(0, min(1, threshold)) || 1
5058 };
5059 let isFirstUpdate = true;
5060 function handleObserve(entries) {
5061 const ratio = entries[0].intersectionRatio;
5062 if (ratio !== threshold) {
5063 if (!isFirstUpdate) {
5064 return refresh();
5065 }
5066 if (!ratio) {
5067 timeoutId = setTimeout(() => {
5068 refresh(false, 1e-7);
5069 }, 1e3);
5070 } else {
5071 refresh(false, ratio);
5072 }
5073 }
5074 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5075 refresh();
5076 }
5077 isFirstUpdate = false;
5078 }
5079 try {
5080 io = new IntersectionObserver(handleObserve, {
5081 ...options,
5082 // Handle <iframe>s
5083 root: root.ownerDocument
5084 });
5085 } catch (_e) {
5086 io = new IntersectionObserver(handleObserve, options);
5087 }
5088 io.observe(element);
5089 }
5090 refresh(true);
5091 return cleanup;
5092 }
5093 function autoUpdate(reference, floating, update2, options) {
5094 if (options === void 0) {
5095 options = {};
5096 }
5097 const {
5098 ancestorScroll = true,
5099 ancestorResize = true,
5100 elementResize = typeof ResizeObserver === "function",
5101 layoutShift = typeof IntersectionObserver === "function",
5102 animationFrame = false
5103 } = options;
5104 const referenceEl = unwrapElement(reference);
5105 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5106 ancestors.forEach((ancestor) => {
5107 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5108 passive: true
5109 });
5110 ancestorResize && ancestor.addEventListener("resize", update2);
5111 });
5112 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5113 let reobserveFrame = -1;
5114 let resizeObserver = null;
5115 if (elementResize) {
5116 resizeObserver = new ResizeObserver((_ref) => {
5117 let [firstEntry] = _ref;
5118 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5119 resizeObserver.unobserve(floating);
5120 cancelAnimationFrame(reobserveFrame);
5121 reobserveFrame = requestAnimationFrame(() => {
5122 var _resizeObserver;
5123 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5124 });
5125 }
5126 update2();
5127 });
5128 if (referenceEl && !animationFrame) {
5129 resizeObserver.observe(referenceEl);
5130 }
5131 if (floating) {
5132 resizeObserver.observe(floating);
5133 }
5134 }
5135 let frameId;
5136 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5137 if (animationFrame) {
5138 frameLoop();
5139 }
5140 function frameLoop() {
5141 const nextRefRect = getBoundingClientRect(reference);
5142 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5143 update2();
5144 }
5145 prevRefRect = nextRefRect;
5146 frameId = requestAnimationFrame(frameLoop);
5147 }
5148 update2();
5149 return () => {
5150 var _resizeObserver2;
5151 ancestors.forEach((ancestor) => {
5152 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5153 ancestorResize && ancestor.removeEventListener("resize", update2);
5154 });
5155 cleanupIo == null || cleanupIo();
5156 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5157 resizeObserver = null;
5158 if (animationFrame) {
5159 cancelAnimationFrame(frameId);
5160 }
5161 };
5162 }
5163 var offset2 = offset;
5164 var shift2 = shift;
5165 var flip2 = flip;
5166 var size2 = size;
5167 var hide2 = hide;
5168 var limitShift2 = limitShift;
5169 var computePosition2 = (reference, floating, options) => {
5170 const cache = /* @__PURE__ */ new Map();
5171 const mergedOptions = {
5172 platform: platform2,
5173 ...options
5174 };
5175 const platformWithCache = {
5176 ...mergedOptions.platform,
5177 _c: cache
5178 };
5179 return computePosition(reference, floating, {
5180 ...mergedOptions,
5181 platform: platformWithCache
5182 });
5183 };
5184
5185 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5186 var React20 = __toESM(require_react(), 1);
5187 var import_react2 = __toESM(require_react(), 1);
5188 var ReactDOM3 = __toESM(require_react_dom(), 1);
5189 var isClient = typeof document !== "undefined";
5190 var noop2 = function noop3() {
5191 };
5192 var index = isClient ? import_react2.useLayoutEffect : noop2;
5193 function deepEqual(a2, b2) {
5194 if (a2 === b2) {
5195 return true;
5196 }
5197 if (typeof a2 !== typeof b2) {
5198 return false;
5199 }
5200 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5201 return true;
5202 }
5203 let length;
5204 let i2;
5205 let keys;
5206 if (a2 && b2 && typeof a2 === "object") {
5207 if (Array.isArray(a2)) {
5208 length = a2.length;
5209 if (length !== b2.length) return false;
5210 for (i2 = length; i2-- !== 0; ) {
5211 if (!deepEqual(a2[i2], b2[i2])) {
5212 return false;
5213 }
5214 }
5215 return true;
5216 }
5217 keys = Object.keys(a2);
5218 length = keys.length;
5219 if (length !== Object.keys(b2).length) {
5220 return false;
5221 }
5222 for (i2 = length; i2-- !== 0; ) {
5223 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5224 return false;
5225 }
5226 }
5227 for (i2 = length; i2-- !== 0; ) {
5228 const key = keys[i2];
5229 if (key === "_owner" && a2.$$typeof) {
5230 continue;
5231 }
5232 if (!deepEqual(a2[key], b2[key])) {
5233 return false;
5234 }
5235 }
5236 return true;
5237 }
5238 return a2 !== a2 && b2 !== b2;
5239 }
5240 function getDPR(element) {
5241 if (typeof window === "undefined") {
5242 return 1;
5243 }
5244 const win = element.ownerDocument.defaultView || window;
5245 return win.devicePixelRatio || 1;
5246 }
5247 function roundByDPR(element, value) {
5248 const dpr = getDPR(element);
5249 return Math.round(value * dpr) / dpr;
5250 }
5251 function useLatestRef(value) {
5252 const ref = React20.useRef(value);
5253 index(() => {
5254 ref.current = value;
5255 });
5256 return ref;
5257 }
5258 function useFloating(options) {
5259 if (options === void 0) {
5260 options = {};
5261 }
5262 const {
5263 placement = "bottom",
5264 strategy = "absolute",
5265 middleware = [],
5266 platform: platform3,
5267 elements: {
5268 reference: externalReference,
5269 floating: externalFloating
5270 } = {},
5271 transform = true,
5272 whileElementsMounted,
5273 open
5274 } = options;
5275 const [data, setData] = React20.useState({
5276 x: 0,
5277 y: 0,
5278 strategy,
5279 placement,
5280 middlewareData: {},
5281 isPositioned: false
5282 });
5283 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5284 if (!deepEqual(latestMiddleware, middleware)) {
5285 setLatestMiddleware(middleware);
5286 }
5287 const [_reference, _setReference] = React20.useState(null);
5288 const [_floating, _setFloating] = React20.useState(null);
5289 const setReference = React20.useCallback((node) => {
5290 if (node !== referenceRef.current) {
5291 referenceRef.current = node;
5292 _setReference(node);
5293 }
5294 }, []);
5295 const setFloating = React20.useCallback((node) => {
5296 if (node !== floatingRef.current) {
5297 floatingRef.current = node;
5298 _setFloating(node);
5299 }
5300 }, []);
5301 const referenceEl = externalReference || _reference;
5302 const floatingEl = externalFloating || _floating;
5303 const referenceRef = React20.useRef(null);
5304 const floatingRef = React20.useRef(null);
5305 const dataRef = React20.useRef(data);
5306 const hasWhileElementsMounted = whileElementsMounted != null;
5307 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5308 const platformRef = useLatestRef(platform3);
5309 const openRef = useLatestRef(open);
5310 const update2 = React20.useCallback(() => {
5311 if (!referenceRef.current || !floatingRef.current) {
5312 return;
5313 }
5314 const config = {
5315 placement,
5316 strategy,
5317 middleware: latestMiddleware
5318 };
5319 if (platformRef.current) {
5320 config.platform = platformRef.current;
5321 }
5322 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5323 const fullData = {
5324 ...data2,
5325 // The floating element's position may be recomputed while it's closed
5326 // but still mounted (such as when transitioning out). To ensure
5327 // `isPositioned` will be `false` initially on the next open, avoid
5328 // setting it to `true` when `open === false` (must be specified).
5329 isPositioned: openRef.current !== false
5330 };
5331 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5332 dataRef.current = fullData;
5333 ReactDOM3.flushSync(() => {
5334 setData(fullData);
5335 });
5336 }
5337 });
5338 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5339 index(() => {
5340 if (open === false && dataRef.current.isPositioned) {
5341 dataRef.current.isPositioned = false;
5342 setData((data2) => ({
5343 ...data2,
5344 isPositioned: false
5345 }));
5346 }
5347 }, [open]);
5348 const isMountedRef = React20.useRef(false);
5349 index(() => {
5350 isMountedRef.current = true;
5351 return () => {
5352 isMountedRef.current = false;
5353 };
5354 }, []);
5355 index(() => {
5356 if (referenceEl) referenceRef.current = referenceEl;
5357 if (floatingEl) floatingRef.current = floatingEl;
5358 if (referenceEl && floatingEl) {
5359 if (whileElementsMountedRef.current) {
5360 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5361 }
5362 update2();
5363 }
5364 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5365 const refs = React20.useMemo(() => ({
5366 reference: referenceRef,
5367 floating: floatingRef,
5368 setReference,
5369 setFloating
5370 }), [setReference, setFloating]);
5371 const elements = React20.useMemo(() => ({
5372 reference: referenceEl,
5373 floating: floatingEl
5374 }), [referenceEl, floatingEl]);
5375 const floatingStyles = React20.useMemo(() => {
5376 const initialStyles = {
5377 position: strategy,
5378 left: 0,
5379 top: 0
5380 };
5381 if (!elements.floating) {
5382 return initialStyles;
5383 }
5384 const x2 = roundByDPR(elements.floating, data.x);
5385 const y2 = roundByDPR(elements.floating, data.y);
5386 if (transform) {
5387 return {
5388 ...initialStyles,
5389 transform: "translate(" + x2 + "px, " + y2 + "px)",
5390 ...getDPR(elements.floating) >= 1.5 && {
5391 willChange: "transform"
5392 }
5393 };
5394 }
5395 return {
5396 position: strategy,
5397 left: x2,
5398 top: y2
5399 };
5400 }, [strategy, transform, elements.floating, data.x, data.y]);
5401 return React20.useMemo(() => ({
5402 ...data,
5403 update: update2,
5404 refs,
5405 elements,
5406 floatingStyles
5407 }), [data, update2, refs, elements, floatingStyles]);
5408 }
5409 var offset3 = (options, deps) => {
5410 const result = offset2(options);
5411 return {
5412 name: result.name,
5413 fn: result.fn,
5414 options: [options, deps]
5415 };
5416 };
5417 var shift3 = (options, deps) => {
5418 const result = shift2(options);
5419 return {
5420 name: result.name,
5421 fn: result.fn,
5422 options: [options, deps]
5423 };
5424 };
5425 var limitShift3 = (options, deps) => {
5426 const result = limitShift2(options);
5427 return {
5428 fn: result.fn,
5429 options: [options, deps]
5430 };
5431 };
5432 var flip3 = (options, deps) => {
5433 const result = flip2(options);
5434 return {
5435 name: result.name,
5436 fn: result.fn,
5437 options: [options, deps]
5438 };
5439 };
5440 var size3 = (options, deps) => {
5441 const result = size2(options);
5442 return {
5443 name: result.name,
5444 fn: result.fn,
5445 options: [options, deps]
5446 };
5447 };
5448 var hide3 = (options, deps) => {
5449 const result = hide2(options);
5450 return {
5451 name: result.name,
5452 fn: result.fn,
5453 options: [options, deps]
5454 };
5455 };
5456
5457 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5458 var React25 = __toESM(require_react(), 1);
5459 var ReactDOM4 = __toESM(require_react_dom(), 1);
5460
5461 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5462 var React24 = __toESM(require_react(), 1);
5463
5464 // node_modules/@base-ui/utils/store/createSelector.mjs
5465 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5466 if (other.length > 0) {
5467 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5468 }
5469 let selector2;
5470 if (a2 && b2 && c2 && d2 && e2 && f2) {
5471 selector2 = (state, a1, a22, a3) => {
5472 const va = a2(state, a1, a22, a3);
5473 const vb = b2(state, a1, a22, a3);
5474 const vc = c2(state, a1, a22, a3);
5475 const vd = d2(state, a1, a22, a3);
5476 const ve = e2(state, a1, a22, a3);
5477 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5478 };
5479 } else if (a2 && b2 && c2 && d2 && e2) {
5480 selector2 = (state, a1, a22, a3) => {
5481 const va = a2(state, a1, a22, a3);
5482 const vb = b2(state, a1, a22, a3);
5483 const vc = c2(state, a1, a22, a3);
5484 const vd = d2(state, a1, a22, a3);
5485 return e2(va, vb, vc, vd, a1, a22, a3);
5486 };
5487 } else if (a2 && b2 && c2 && d2) {
5488 selector2 = (state, a1, a22, a3) => {
5489 const va = a2(state, a1, a22, a3);
5490 const vb = b2(state, a1, a22, a3);
5491 const vc = c2(state, a1, a22, a3);
5492 return d2(va, vb, vc, a1, a22, a3);
5493 };
5494 } else if (a2 && b2 && c2) {
5495 selector2 = (state, a1, a22, a3) => {
5496 const va = a2(state, a1, a22, a3);
5497 const vb = b2(state, a1, a22, a3);
5498 return c2(va, vb, a1, a22, a3);
5499 };
5500 } else if (a2 && b2) {
5501 selector2 = (state, a1, a22, a3) => {
5502 const va = a2(state, a1, a22, a3);
5503 return b2(va, a1, a22, a3);
5504 };
5505 } else if (a2) {
5506 selector2 = a2;
5507 } else {
5508 throw (
5509 /* minify-error-disabled */
5510 new Error("Missing arguments")
5511 );
5512 }
5513 return selector2;
5514 };
5515
5516 // node_modules/@base-ui/utils/store/useStore.mjs
5517 var React22 = __toESM(require_react(), 1);
5518 var import_shim = __toESM(require_shim(), 1);
5519 var import_with_selector = __toESM(require_with_selector(), 1);
5520
5521 // node_modules/@base-ui/utils/fastHooks.mjs
5522 var React21 = __toESM(require_react(), 1);
5523 var hooks = [];
5524 var currentInstance = void 0;
5525 function getInstance() {
5526 return currentInstance;
5527 }
5528 function register(hook) {
5529 hooks.push(hook);
5530 }
5531 function fastComponent(fn) {
5532 const FastComponent = (props, forwardedRef) => {
5533 const instance = useRefWithInit(createInstance).current;
5534 let result;
5535 try {
5536 currentInstance = instance;
5537 for (const hook of hooks) {
5538 hook.before(instance);
5539 }
5540 result = fn(props, forwardedRef);
5541 for (const hook of hooks) {
5542 hook.after(instance);
5543 }
5544 instance.didInitialize = true;
5545 } finally {
5546 currentInstance = void 0;
5547 }
5548 return result;
5549 };
5550 FastComponent.displayName = fn.displayName || fn.name;
5551 return FastComponent;
5552 }
5553 function fastComponentRef(fn) {
5554 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5555 }
5556 function createInstance() {
5557 return {
5558 didInitialize: false
5559 };
5560 }
5561
5562 // node_modules/@base-ui/utils/store/useStore.mjs
5563 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5564 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5565 function useStore(store, selector2, a1, a2, a3) {
5566 return useStoreImplementation(store, selector2, a1, a2, a3);
5567 }
5568 function useStoreR19(store, selector2, a1, a2, a3) {
5569 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5570 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5571 }
5572 register({
5573 before(instance) {
5574 instance.syncIndex = 0;
5575 if (!instance.didInitialize) {
5576 instance.syncTick = 1;
5577 instance.syncHooks = [];
5578 instance.didChangeStore = true;
5579 instance.getSnapshot = () => {
5580 let didChange2 = false;
5581 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5582 const hook = instance.syncHooks[i2];
5583 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5584 if (!Object.is(hook.value, value)) {
5585 didChange2 = true;
5586 hook.value = value;
5587 }
5588 }
5589 if (didChange2) {
5590 instance.syncTick += 1;
5591 }
5592 return instance.syncTick;
5593 };
5594 }
5595 },
5596 after(instance) {
5597 if (instance.syncHooks.length > 0) {
5598 if (instance.didChangeStore) {
5599 instance.didChangeStore = false;
5600 instance.subscribe = (onStoreChange) => {
5601 const stores = /* @__PURE__ */ new Set();
5602 for (const hook of instance.syncHooks) {
5603 stores.add(hook.store);
5604 }
5605 const unsubscribes = [];
5606 for (const store of stores) {
5607 unsubscribes.push(store.subscribe(onStoreChange));
5608 }
5609 return () => {
5610 for (const unsubscribe of unsubscribes) {
5611 unsubscribe();
5612 }
5613 };
5614 };
5615 }
5616 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5617 }
5618 }
5619 });
5620 function useStoreFast(store, selector2, a1, a2, a3) {
5621 const instance = getInstance();
5622 if (!instance) {
5623 return useStoreR19(store, selector2, a1, a2, a3);
5624 }
5625 const index2 = instance.syncIndex;
5626 instance.syncIndex += 1;
5627 let hook;
5628 if (!instance.didInitialize) {
5629 hook = {
5630 store,
5631 selector: selector2,
5632 a1,
5633 a2,
5634 a3,
5635 value: selector2(store.getSnapshot(), a1, a2, a3)
5636 };
5637 instance.syncHooks.push(hook);
5638 } else {
5639 hook = instance.syncHooks[index2];
5640 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5641 if (hook.store !== store) {
5642 instance.didChangeStore = true;
5643 }
5644 hook.store = store;
5645 hook.selector = selector2;
5646 hook.a1 = a1;
5647 hook.a2 = a2;
5648 hook.a3 = a3;
5649 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
5650 }
5651 }
5652 return hook.value;
5653 }
5654 function useStoreLegacy(store, selector2, a1, a2, a3) {
5655 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5656 }
5657
5658 // node_modules/@base-ui/utils/store/Store.mjs
5659 var Store = class {
5660 /**
5661 * The current state of the store.
5662 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5663 * 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).
5664 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5665 *
5666 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5667 */
5668 // Internal state to handle recursive `setState()` calls
5669 constructor(state) {
5670 this.state = state;
5671 this.listeners = /* @__PURE__ */ new Set();
5672 this.updateTick = 0;
5673 }
5674 /**
5675 * Registers a listener that will be called whenever the store's state changes.
5676 *
5677 * @param fn The listener function to be called on state changes.
5678 * @returns A function to unsubscribe the listener.
5679 */
5680 subscribe = (fn) => {
5681 this.listeners.add(fn);
5682 return () => {
5683 this.listeners.delete(fn);
5684 };
5685 };
5686 /**
5687 * Returns the current state of the store.
5688 */
5689 getSnapshot = () => {
5690 return this.state;
5691 };
5692 /**
5693 * Updates the entire store's state and notifies all registered listeners.
5694 *
5695 * @param newState The new state to set for the store.
5696 */
5697 setState(newState) {
5698 if (this.state === newState) {
5699 return;
5700 }
5701 this.state = newState;
5702 this.updateTick += 1;
5703 const currentTick = this.updateTick;
5704 for (const listener of this.listeners) {
5705 if (currentTick !== this.updateTick) {
5706 return;
5707 }
5708 listener(newState);
5709 }
5710 }
5711 /**
5712 * Merges the provided changes into the current state and notifies listeners if there are changes.
5713 *
5714 * @param changes An object containing the changes to apply to the current state.
5715 */
5716 update(changes) {
5717 for (const key in changes) {
5718 if (!Object.is(this.state[key], changes[key])) {
5719 this.setState({
5720 ...this.state,
5721 ...changes
5722 });
5723 return;
5724 }
5725 }
5726 }
5727 /**
5728 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5729 *
5730 * @param key The key in the store's state to update.
5731 * @param value The new value to set for the specified key.
5732 */
5733 set(key, value) {
5734 if (!Object.is(this.state[key], value)) {
5735 this.setState({
5736 ...this.state,
5737 [key]: value
5738 });
5739 }
5740 }
5741 /**
5742 * Gives the state a new reference and updates all registered listeners.
5743 */
5744 notifyAll() {
5745 const newState = {
5746 ...this.state
5747 };
5748 this.setState(newState);
5749 }
5750 use(selector2, a1, a2, a3) {
5751 return useStore(this, selector2, a1, a2, a3);
5752 }
5753 };
5754
5755 // node_modules/@base-ui/utils/store/ReactStore.mjs
5756 var React23 = __toESM(require_react(), 1);
5757 var ReactStore = class extends Store {
5758 /**
5759 * Creates a new ReactStore instance.
5760 *
5761 * @param state Initial state of the store.
5762 * @param context Non-reactive context values.
5763 * @param selectors Optional selectors for use with `useState`.
5764 */
5765 constructor(state, context = {}, selectors3) {
5766 super(state);
5767 this.context = context;
5768 this.selectors = selectors3;
5769 }
5770 /**
5771 * Non-reactive values such as refs, callbacks, etc.
5772 */
5773 /**
5774 * Synchronizes a single external value into the store.
5775 *
5776 * Note that the while the value in `state` is updated immediately, the value returned
5777 * by `useState` is updated before the next render (similarly to React's `useState`).
5778 */
5779 useSyncedValue(key, value) {
5780 React23.useDebugValue(key);
5781 const store = this;
5782 useIsoLayoutEffect(() => {
5783 if (store.state[key] !== value) {
5784 store.set(key, value);
5785 }
5786 }, [store, key, value]);
5787 }
5788 /**
5789 * Synchronizes a single external value into the store and
5790 * cleans it up (sets to `undefined`) on unmount.
5791 *
5792 * Note that the while the value in `state` is updated immediately, the value returned
5793 * by `useState` is updated before the next render (similarly to React's `useState`).
5794 */
5795 useSyncedValueWithCleanup(key, value) {
5796 const store = this;
5797 useIsoLayoutEffect(() => {
5798 if (store.state[key] !== value) {
5799 store.set(key, value);
5800 }
5801 return () => {
5802 store.set(key, void 0);
5803 };
5804 }, [store, key, value]);
5805 }
5806 /**
5807 * Synchronizes multiple external values into the store.
5808 *
5809 * Note that the while the values in `state` are updated immediately, the values returned
5810 * by `useState` are updated before the next render (similarly to React's `useState`).
5811 */
5812 useSyncedValues(statePart) {
5813 const store = this;
5814 if (true) {
5815 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5816 const keys = React23.useRef(Object.keys(statePart)).current;
5817 const nextKeys = Object.keys(statePart);
5818 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5819 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5820 }
5821 }
5822 const dependencies = Object.values(statePart);
5823 useIsoLayoutEffect(() => {
5824 store.update(statePart);
5825 }, [store, ...dependencies]);
5826 }
5827 /**
5828 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5829 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5830 */
5831 useControlledProp(key, controlled) {
5832 React23.useDebugValue(key);
5833 const store = this;
5834 const isControlled = controlled !== void 0;
5835 useIsoLayoutEffect(() => {
5836 if (isControlled && !Object.is(store.state[key], controlled)) {
5837 store.setState({
5838 ...store.state,
5839 [key]: controlled
5840 });
5841 }
5842 }, [store, key, controlled, isControlled]);
5843 if (true) {
5844 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5845 if (!cache.has(key)) {
5846 cache.set(key, isControlled);
5847 }
5848 const previouslyControlled = cache.get(key);
5849 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5850 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).`);
5851 }
5852 }
5853 }
5854 /** Gets the current value from the store using a selector with the provided key.
5855 *
5856 * @param key Key of the selector to use.
5857 */
5858 select(key, a1, a2, a3) {
5859 const selector2 = this.selectors[key];
5860 return selector2(this.state, a1, a2, a3);
5861 }
5862 /**
5863 * Returns a value from the store's state using a selector function.
5864 * Used to subscribe to specific parts of the state.
5865 * This methods causes a rerender whenever the selected state changes.
5866 *
5867 * @param key Key of the selector to use.
5868 */
5869 useState(key, a1, a2, a3) {
5870 React23.useDebugValue(key);
5871 return useStore(this, this.selectors[key], a1, a2, a3);
5872 }
5873 /**
5874 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5875 * and assigns it to the context.
5876 *
5877 * @param key Key of the event callback. Must be a function in the context.
5878 * @param fn Function to assign.
5879 */
5880 useContextCallback(key, fn) {
5881 React23.useDebugValue(key);
5882 const stableFunction = useStableCallback(fn ?? NOOP);
5883 this.context[key] = stableFunction;
5884 }
5885 /**
5886 * Returns a stable setter function for a specific key in the store's state.
5887 * It's commonly used to pass as a ref callback to React elements.
5888 *
5889 * @param key Key of the state to set.
5890 */
5891 useStateSetter(key) {
5892 const ref = React23.useRef(void 0);
5893 if (ref.current === void 0) {
5894 ref.current = (value) => {
5895 this.set(key, value);
5896 };
5897 }
5898 return ref.current;
5899 }
5900 /**
5901 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5902 *
5903 * @param key Key of the selector to observe.
5904 * @param listener Listener function called when the selector result changes.
5905 */
5906 observe(selector2, listener) {
5907 let selectFn;
5908 if (typeof selector2 === "function") {
5909 selectFn = selector2;
5910 } else {
5911 selectFn = this.selectors[selector2];
5912 }
5913 let prevValue = selectFn(this.state);
5914 listener(prevValue, prevValue, this);
5915 return this.subscribe((nextState) => {
5916 const nextValue = selectFn(nextState);
5917 if (!Object.is(prevValue, nextValue)) {
5918 const oldValue = prevValue;
5919 prevValue = nextValue;
5920 listener(nextValue, oldValue, this);
5921 }
5922 });
5923 }
5924 };
5925
5926 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
5927 var selectors = {
5928 open: createSelector((state) => state.open),
5929 transitionStatus: createSelector((state) => state.transitionStatus),
5930 domReferenceElement: createSelector((state) => state.domReferenceElement),
5931 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5932 floatingElement: createSelector((state) => state.floatingElement),
5933 floatingId: createSelector((state) => state.floatingId)
5934 };
5935 var FloatingRootStore = class extends ReactStore {
5936 constructor(options) {
5937 const {
5938 syncOnly,
5939 nested,
5940 onOpenChange,
5941 triggerElements,
5942 ...initialState
5943 } = options;
5944 super({
5945 ...initialState,
5946 positionReference: initialState.referenceElement,
5947 domReferenceElement: initialState.referenceElement
5948 }, {
5949 onOpenChange,
5950 dataRef: {
5951 current: {}
5952 },
5953 events: createEventEmitter(),
5954 nested,
5955 triggerElements
5956 }, selectors);
5957 this.syncOnly = syncOnly;
5958 }
5959 /**
5960 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5961 */
5962 syncOpenEvent = (newOpen, event) => {
5963 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5964 // click events to upgrade a hover-open.
5965 event != null && isClickLikeEvent(event)) {
5966 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5967 }
5968 };
5969 /**
5970 * Runs the root-owned side effects for an open state change.
5971 */
5972 dispatchOpenChange = (newOpen, eventDetails) => {
5973 this.syncOpenEvent(newOpen, eventDetails.event);
5974 const details = {
5975 open: newOpen,
5976 reason: eventDetails.reason,
5977 nativeEvent: eventDetails.event,
5978 nested: this.context.nested,
5979 triggerElement: eventDetails.trigger
5980 };
5981 this.context.events.emit("openchange", details);
5982 };
5983 /**
5984 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5985 *
5986 * @param newOpen The new open state.
5987 * @param eventDetails Details about the event that triggered the open state change.
5988 */
5989 setOpen = (newOpen, eventDetails) => {
5990 if (this.syncOnly) {
5991 this.context.onOpenChange?.(newOpen, eventDetails);
5992 return;
5993 }
5994 this.dispatchOpenChange(newOpen, eventDetails);
5995 this.context.onOpenChange?.(newOpen, eventDetails);
5996 };
5997 };
5998
5999 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6000 function useSyncedFloatingRootContext(options) {
6001 const {
6002 popupStore,
6003 treatPopupAsFloatingElement = false,
6004 floatingRootContext: floatingRootContextProp,
6005 floatingId,
6006 nested,
6007 onOpenChange
6008 } = options;
6009 const open = popupStore.useState("open");
6010 const referenceElement = popupStore.useState("activeTriggerElement");
6011 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6012 const triggerElements = popupStore.context.triggerElements;
6013 const handleOpenChange = onOpenChange;
6014 const internalStoreRef = React24.useRef(null);
6015 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6016 internalStoreRef.current = new FloatingRootStore({
6017 open,
6018 transitionStatus: void 0,
6019 referenceElement,
6020 floatingElement,
6021 triggerElements,
6022 onOpenChange: handleOpenChange,
6023 floatingId,
6024 syncOnly: true,
6025 nested
6026 });
6027 }
6028 const store = floatingRootContextProp ?? internalStoreRef.current;
6029 popupStore.useSyncedValue("floatingId", floatingId);
6030 useIsoLayoutEffect(() => {
6031 const valuesToSync = {
6032 open,
6033 floatingId,
6034 referenceElement,
6035 floatingElement
6036 };
6037 if (isElement(referenceElement)) {
6038 valuesToSync.domReferenceElement = referenceElement;
6039 }
6040 if (store.state.positionReference === store.state.referenceElement) {
6041 valuesToSync.positionReference = referenceElement;
6042 }
6043 store.update(valuesToSync);
6044 }, [open, floatingId, referenceElement, floatingElement, store]);
6045 store.context.onOpenChange = handleOpenChange;
6046 store.context.nested = nested;
6047 return store;
6048 }
6049
6050 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6051 var FOCUSABLE_POPUP_PROPS = {
6052 tabIndex: -1,
6053 [FOCUSABLE_ATTRIBUTE]: ""
6054 };
6055 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6056 const floatingId = useId();
6057 const nested = useFloatingParentNodeId() != null;
6058 const internalStoreRef = React25.useRef(null);
6059 if (externalStore === void 0 && internalStoreRef.current === null) {
6060 internalStoreRef.current = createStore2(floatingId, nested);
6061 }
6062 const store = externalStore ?? internalStoreRef.current;
6063 useSyncedFloatingRootContext({
6064 popupStore: store,
6065 treatPopupAsFloatingElement,
6066 floatingRootContext: store.state.floatingRootContext,
6067 floatingId,
6068 nested,
6069 onOpenChange: store.setOpen
6070 });
6071 return {
6072 store,
6073 internalStore: internalStoreRef.current
6074 };
6075 }
6076 function useTriggerRegistration(id, store) {
6077 const registeredElementIdRef = React25.useRef(null);
6078 const registeredElementRef = React25.useRef(null);
6079 return React25.useCallback((element) => {
6080 if (id === void 0) {
6081 return;
6082 }
6083 let shouldSyncTriggerCount = false;
6084 if (registeredElementIdRef.current !== null) {
6085 const registeredId = registeredElementIdRef.current;
6086 const registeredElement = registeredElementRef.current;
6087 const currentElement = store.context.triggerElements.getById(registeredId);
6088 if (registeredElement && currentElement === registeredElement) {
6089 store.context.triggerElements.delete(registeredId);
6090 shouldSyncTriggerCount = true;
6091 }
6092 registeredElementIdRef.current = null;
6093 registeredElementRef.current = null;
6094 }
6095 if (element !== null) {
6096 registeredElementIdRef.current = id;
6097 registeredElementRef.current = element;
6098 store.context.triggerElements.add(id, element);
6099 shouldSyncTriggerCount = true;
6100 }
6101 if (shouldSyncTriggerCount) {
6102 const triggerCount = store.context.triggerElements.size;
6103 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6104 store.set("triggerCount", triggerCount);
6105 }
6106 }
6107 }, [store, id]);
6108 }
6109 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6110 if (open) {
6111 state.preventUnmountingOnClose = false;
6112 } else if (preventUnmountOnClose) {
6113 state.preventUnmountingOnClose = true;
6114 }
6115 const triggerId = trigger?.id ?? null;
6116 if (triggerId || open) {
6117 state.activeTriggerId = triggerId;
6118 state.activeTriggerElement = trigger ?? null;
6119 }
6120 }
6121 function attachPreventUnmountOnClose(eventDetails) {
6122 let preventUnmountOnClose = false;
6123 eventDetails.preventUnmountOnClose = () => {
6124 preventUnmountOnClose = true;
6125 };
6126 return () => preventUnmountOnClose;
6127 }
6128 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6129 const reason = eventDetails.reason;
6130 const isHover = reason === reason_parts_exports.triggerHover;
6131 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6132 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6133 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6134 store.context.onOpenChange?.(nextOpen, eventDetails);
6135 if (eventDetails.isCanceled) {
6136 return;
6137 }
6138 options.onBeforeDispatch?.();
6139 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6140 const changeState = () => {
6141 const updatedState = {
6142 ...options.extraState,
6143 open: nextOpen
6144 };
6145 if (isFocusOpen) {
6146 updatedState.instantType = "focus";
6147 } else if (isDismissClose) {
6148 updatedState.instantType = "dismiss";
6149 } else if (isHover) {
6150 updatedState.instantType = void 0;
6151 }
6152 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6153 store.update(updatedState);
6154 };
6155 if (isHover) {
6156 ReactDOM4.flushSync(changeState);
6157 } else {
6158 changeState();
6159 }
6160 }
6161 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6162 useOnFirstRender(() => {
6163 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6164 store.state = {
6165 ...store.state,
6166 open: true,
6167 activeTriggerId: defaultTriggerId,
6168 preventUnmountingOnClose: false
6169 };
6170 }
6171 });
6172 }
6173 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6174 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6175 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6176 const registerTrigger = useStableCallback((element) => {
6177 baseRegisterTrigger(element);
6178 if (!element) {
6179 return;
6180 }
6181 const open = store.select("open");
6182 const activeTriggerId = store.select("activeTriggerId");
6183 if (activeTriggerId === triggerId) {
6184 store.update({
6185 activeTriggerElement: element,
6186 ...open ? stateUpdates : null
6187 });
6188 return;
6189 }
6190 if (activeTriggerId == null && open) {
6191 store.update({
6192 activeTriggerId: triggerId,
6193 activeTriggerElement: element,
6194 ...stateUpdates
6195 });
6196 }
6197 });
6198 useIsoLayoutEffect(() => {
6199 if (isMountedByThisTrigger) {
6200 store.update({
6201 activeTriggerElement: triggerElementRef.current,
6202 ...stateUpdates
6203 });
6204 }
6205 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6206 return {
6207 registerTrigger,
6208 isMountedByThisTrigger
6209 };
6210 }
6211 function useImplicitActiveTrigger(store, options = {}) {
6212 const {
6213 closeOnActiveTriggerUnmount = false
6214 } = options;
6215 const open = store.useState("open");
6216 const reactiveTriggerCount = store.useState("triggerCount");
6217 useIsoLayoutEffect(() => {
6218 if (!open) {
6219 if (store.state.triggerCount !== 0) {
6220 store.set("triggerCount", 0);
6221 }
6222 return;
6223 }
6224 const triggerCount = store.context.triggerElements.size;
6225 const stateUpdates = {};
6226 if (store.state.triggerCount !== triggerCount) {
6227 stateUpdates.triggerCount = triggerCount;
6228 }
6229 const activeTriggerId = store.select("activeTriggerId");
6230 let lostActiveTriggerId = null;
6231 if (activeTriggerId) {
6232 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6233 if (!activeTriggerElement) {
6234 lostActiveTriggerId = activeTriggerId;
6235 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6236 stateUpdates.activeTriggerElement = activeTriggerElement;
6237 }
6238 }
6239 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6240 const iteratorResult = store.context.triggerElements.entries().next();
6241 if (!iteratorResult.done) {
6242 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6243 stateUpdates.activeTriggerId = implicitTriggerId;
6244 stateUpdates.activeTriggerElement = implicitTriggerElement;
6245 }
6246 }
6247 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6248 store.update(stateUpdates);
6249 }
6250 if (lostActiveTriggerId) {
6251 if (closeOnActiveTriggerUnmount) {
6252 queueMicrotask(() => {
6253 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6254 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6255 store.setOpen(false, eventDetails);
6256 if (!eventDetails.isCanceled) {
6257 store.update({
6258 activeTriggerId: null,
6259 activeTriggerElement: null
6260 });
6261 }
6262 }
6263 });
6264 }
6265 }
6266 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6267 }
6268 function useOpenStateTransitions(open, store, onUnmount) {
6269 const {
6270 mounted,
6271 setMounted,
6272 transitionStatus
6273 } = useTransitionStatus(open);
6274 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6275 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6276 store.useSyncedValues({
6277 mounted,
6278 transitionStatus,
6279 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6280 });
6281 const forceUnmount = useStableCallback(() => {
6282 setMounted(false);
6283 store.update({
6284 activeTriggerId: null,
6285 activeTriggerElement: null,
6286 mounted: false,
6287 preventUnmountingOnClose: false
6288 });
6289 onUnmount?.();
6290 store.context.onOpenChangeComplete?.(false);
6291 });
6292 useOpenChangeComplete({
6293 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6294 open,
6295 ref: store.context.popupRef,
6296 onComplete() {
6297 if (!open) {
6298 forceUnmount();
6299 }
6300 }
6301 });
6302 return {
6303 forceUnmount,
6304 transitionStatus
6305 };
6306 }
6307 function usePopupInteractionProps(store, statePart) {
6308 store.useSyncedValues(statePart);
6309 useIsoLayoutEffect(() => () => {
6310 store.update({
6311 activeTriggerProps: EMPTY_OBJECT,
6312 inactiveTriggerProps: EMPTY_OBJECT,
6313 popupProps: EMPTY_OBJECT
6314 });
6315 }, [store]);
6316 }
6317
6318 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6319 var PopupTriggerMap = class {
6320 constructor() {
6321 this.elementsSet = /* @__PURE__ */ new Set();
6322 this.idMap = /* @__PURE__ */ new Map();
6323 }
6324 /**
6325 * Adds a trigger element with the given ID.
6326 *
6327 * Note: The provided element is assumed to not be registered under multiple IDs.
6328 */
6329 add(id, element) {
6330 const existingElement = this.idMap.get(id);
6331 if (existingElement === element) {
6332 return;
6333 }
6334 if (existingElement !== void 0) {
6335 this.elementsSet.delete(existingElement);
6336 }
6337 this.elementsSet.add(element);
6338 this.idMap.set(id, element);
6339 if (true) {
6340 if (this.elementsSet.size !== this.idMap.size) {
6341 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6342 }
6343 }
6344 }
6345 /**
6346 * Removes the trigger element with the given ID.
6347 */
6348 delete(id) {
6349 const element = this.idMap.get(id);
6350 if (element) {
6351 this.elementsSet.delete(element);
6352 this.idMap.delete(id);
6353 }
6354 }
6355 /**
6356 * Whether the given element is registered as a trigger.
6357 */
6358 hasElement(element) {
6359 return this.elementsSet.has(element);
6360 }
6361 /**
6362 * Whether there is a registered trigger element matching the given predicate.
6363 */
6364 hasMatchingElement(predicate) {
6365 for (const element of this.elementsSet) {
6366 if (predicate(element)) {
6367 return true;
6368 }
6369 }
6370 return false;
6371 }
6372 /**
6373 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6374 */
6375 getById(id) {
6376 return this.idMap.get(id);
6377 }
6378 /**
6379 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6380 */
6381 entries() {
6382 return this.idMap.entries();
6383 }
6384 /**
6385 * Returns an iterable of all registered trigger elements.
6386 */
6387 elements() {
6388 return this.elementsSet.values();
6389 }
6390 /**
6391 * Returns the number of registered trigger elements.
6392 */
6393 get size() {
6394 return this.idMap.size;
6395 }
6396 };
6397
6398 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
6399 function getEmptyRootContext() {
6400 return new FloatingRootStore({
6401 open: false,
6402 transitionStatus: void 0,
6403 floatingElement: null,
6404 referenceElement: null,
6405 triggerElements: new PopupTriggerMap(),
6406 floatingId: void 0,
6407 syncOnly: false,
6408 nested: false,
6409 onOpenChange: void 0
6410 });
6411 }
6412
6413 // node_modules/@base-ui/react/utils/popups/store.mjs
6414 function createInitialPopupStoreState() {
6415 return {
6416 open: false,
6417 openProp: void 0,
6418 mounted: false,
6419 transitionStatus: void 0,
6420 floatingRootContext: getEmptyRootContext(),
6421 floatingId: void 0,
6422 triggerCount: 0,
6423 preventUnmountingOnClose: false,
6424 payload: void 0,
6425 activeTriggerId: null,
6426 activeTriggerElement: null,
6427 triggerIdProp: void 0,
6428 popupElement: null,
6429 positionerElement: null,
6430 activeTriggerProps: EMPTY_OBJECT,
6431 inactiveTriggerProps: EMPTY_OBJECT,
6432 popupProps: EMPTY_OBJECT
6433 };
6434 }
6435 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6436 return new FloatingRootStore({
6437 open: false,
6438 transitionStatus: void 0,
6439 floatingElement: null,
6440 referenceElement: null,
6441 triggerElements,
6442 floatingId,
6443 syncOnly: true,
6444 nested,
6445 onOpenChange: void 0
6446 });
6447 }
6448 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6449 var openSelector = createSelector((state) => state.openProp ?? state.open);
6450 var popupIdSelector = createSelector((state) => {
6451 const popupId = state.popupElement?.id ?? state.floatingId;
6452 return popupId || void 0;
6453 });
6454 function triggerOwnsOpenPopup(state, triggerId) {
6455 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6456 }
6457 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6458 if (triggerOwnsOpenPopup(state, triggerId)) {
6459 return true;
6460 }
6461 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6462 }
6463 var popupStoreSelectors = {
6464 open: openSelector,
6465 mounted: createSelector((state) => state.mounted),
6466 transitionStatus: createSelector((state) => state.transitionStatus),
6467 floatingRootContext: createSelector((state) => state.floatingRootContext),
6468 triggerCount: createSelector((state) => state.triggerCount),
6469 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6470 payload: createSelector((state) => state.payload),
6471 activeTriggerId: activeTriggerIdSelector,
6472 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6473 popupId: popupIdSelector,
6474 /**
6475 * Whether the trigger with the given ID was used to open the popup.
6476 */
6477 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6478 /**
6479 * Whether the popup is open and was activated by a trigger with the given ID.
6480 */
6481 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6482 /**
6483 * Whether the popup is mounted and was activated by a trigger with the given ID.
6484 */
6485 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6486 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6487 /**
6488 * Popup id for the trigger that currently owns the open popup.
6489 */
6490 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6491 popupProps: createSelector((state) => state.popupProps),
6492 popupElement: createSelector((state) => state.popupElement),
6493 positionerElement: createSelector((state) => state.positionerElement)
6494 };
6495
6496 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
6497 function useFloatingRootContext(options) {
6498 const {
6499 open = false,
6500 onOpenChange,
6501 elements = {}
6502 } = options;
6503 const floatingId = useId();
6504 const nested = useFloatingParentNodeId() != null;
6505 if (true) {
6506 const optionDomReference = elements.reference;
6507 if (optionDomReference && !isElement(optionDomReference)) {
6508 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6509 }
6510 }
6511 const store = useRefWithInit(() => new FloatingRootStore({
6512 open,
6513 transitionStatus: void 0,
6514 onOpenChange,
6515 referenceElement: elements.reference ?? null,
6516 floatingElement: elements.floating ?? null,
6517 triggerElements: new PopupTriggerMap(),
6518 floatingId,
6519 syncOnly: false,
6520 nested
6521 })).current;
6522 useIsoLayoutEffect(() => {
6523 const valuesToSync = {
6524 open,
6525 floatingId
6526 };
6527 if (elements.reference !== void 0) {
6528 valuesToSync.referenceElement = elements.reference;
6529 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6530 }
6531 if (elements.floating !== void 0) {
6532 valuesToSync.floatingElement = elements.floating;
6533 }
6534 store.update(valuesToSync);
6535 }, [open, floatingId, elements.reference, elements.floating, store]);
6536 store.context.onOpenChange = onOpenChange;
6537 store.context.nested = nested;
6538 return store;
6539 }
6540
6541 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
6542 function useFloating2(options = {}) {
6543 const {
6544 nodeId,
6545 externalTree
6546 } = options;
6547 const internalStore = useFloatingRootContext(options);
6548 const store = options.rootContext || internalStore;
6549 const referenceElement = store.useState("referenceElement");
6550 const floatingElement = store.useState("floatingElement");
6551 const domReferenceElement = store.useState("domReferenceElement");
6552 const open = store.useState("open");
6553 const floatingId = store.useState("floatingId");
6554 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6555 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6556 const [localFloatingElement, setLocalFloatingElement] = React26.useState(void 0);
6557 const domReferenceRef = React26.useRef(null);
6558 const tree = useFloatingTree(externalTree);
6559 const storeElements = React26.useMemo(() => ({
6560 reference: referenceElement,
6561 floating: floatingElement,
6562 domReference: domReferenceElement
6563 }), [referenceElement, floatingElement, domReferenceElement]);
6564 const position = useFloating({
6565 ...options,
6566 elements: {
6567 ...storeElements,
6568 ...positionReference && {
6569 reference: positionReference
6570 }
6571 }
6572 });
6573 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6574 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6575 store.useSyncedValue("referenceElement", localDomReference ?? null);
6576 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6577 store.useSyncedValue("floatingElement", syncedFloatingElement);
6578 const setPositionReference = React26.useCallback((node) => {
6579 const computedPositionReference = isElement(node) ? {
6580 getBoundingClientRect: () => node.getBoundingClientRect(),
6581 getClientRects: () => node.getClientRects(),
6582 contextElement: node
6583 } : node;
6584 setPositionReferenceRaw(computedPositionReference);
6585 position.refs.setReference(computedPositionReference);
6586 }, [position.refs]);
6587 const setReference = React26.useCallback((node) => {
6588 if (isElement(node) || node === null) {
6589 domReferenceRef.current = node;
6590 setLocalDomReference(node);
6591 }
6592 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6593 // `null` to support `positionReference` + an unstable `reference`
6594 // callback ref.
6595 node !== null && !isElement(node)) {
6596 position.refs.setReference(node);
6597 }
6598 }, [position.refs, setLocalDomReference]);
6599 const setFloating = React26.useCallback((node) => {
6600 setLocalFloatingElement(node);
6601 position.refs.setFloating(node);
6602 }, [position.refs]);
6603 const refs = React26.useMemo(() => ({
6604 ...position.refs,
6605 setReference,
6606 setFloating,
6607 setPositionReference,
6608 domReference: domReferenceRef
6609 }), [position.refs, setReference, setFloating, setPositionReference]);
6610 const elements = React26.useMemo(() => ({
6611 ...position.elements,
6612 domReference: domReferenceElement
6613 }), [position.elements, domReferenceElement]);
6614 const context = React26.useMemo(() => ({
6615 ...position,
6616 dataRef: store.context.dataRef,
6617 open,
6618 onOpenChange: store.setOpen,
6619 events: store.context.events,
6620 floatingId,
6621 refs,
6622 elements,
6623 nodeId,
6624 rootStore: store
6625 }), [position, refs, elements, nodeId, store, open, floatingId]);
6626 useIsoLayoutEffect(() => {
6627 if (domReferenceElement) {
6628 domReferenceRef.current = domReferenceElement;
6629 }
6630 }, [domReferenceElement]);
6631 useIsoLayoutEffect(() => {
6632 store.context.dataRef.current.floatingContext = context;
6633 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6634 if (node) {
6635 node.context = context;
6636 }
6637 });
6638 return React26.useMemo(() => ({
6639 ...position,
6640 context,
6641 refs,
6642 elements,
6643 rootStore: store
6644 }), [position, refs, elements, context, store]);
6645 }
6646
6647 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
6648 var React27 = __toESM(require_react(), 1);
6649 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
6650 function useFocus(context, props = {}) {
6651 const {
6652 enabled = true,
6653 delay
6654 } = props;
6655 const store = "rootStore" in context ? context.rootStore : context;
6656 const {
6657 events,
6658 dataRef
6659 } = store.context;
6660 const blockFocusRef = React27.useRef(false);
6661 const blockedReferenceRef = React27.useRef(null);
6662 const keyboardModalityRef = React27.useRef(true);
6663 const timeout = useTimeout();
6664 React27.useEffect(() => {
6665 const domReference = store.select("domReferenceElement");
6666 if (!enabled) {
6667 return void 0;
6668 }
6669 const win = getWindow(domReference);
6670 function onBlur() {
6671 const currentDomReference = store.select("domReferenceElement");
6672 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6673 blockFocusRef.current = true;
6674 }
6675 }
6676 function onKeyDown() {
6677 keyboardModalityRef.current = true;
6678 }
6679 function onPointerDown() {
6680 keyboardModalityRef.current = false;
6681 }
6682 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6683 }, [store, enabled]);
6684 React27.useEffect(() => {
6685 if (!enabled) {
6686 return void 0;
6687 }
6688 function onOpenChangeLocal(details) {
6689 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6690 const referenceElement = store.select("domReferenceElement");
6691 if (isElement(referenceElement)) {
6692 blockedReferenceRef.current = referenceElement;
6693 blockFocusRef.current = true;
6694 }
6695 }
6696 }
6697 events.on("openchange", onOpenChangeLocal);
6698 return () => {
6699 events.off("openchange", onOpenChangeLocal);
6700 };
6701 }, [events, enabled, store]);
6702 const reference = React27.useMemo(() => {
6703 function resetBlockedFocus() {
6704 blockFocusRef.current = false;
6705 blockedReferenceRef.current = null;
6706 }
6707 return {
6708 onMouseLeave() {
6709 resetBlockedFocus();
6710 },
6711 onFocus(event) {
6712 const focusTarget = event.currentTarget;
6713 if (blockFocusRef.current) {
6714 if (blockedReferenceRef.current === focusTarget) {
6715 return;
6716 }
6717 resetBlockedFocus();
6718 }
6719 const target = getTarget(event.nativeEvent);
6720 if (isElement(target)) {
6721 if (isMacSafari && !event.relatedTarget) {
6722 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6723 return;
6724 }
6725 } else if (!matchesFocusVisible(target)) {
6726 return;
6727 }
6728 }
6729 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6730 const {
6731 nativeEvent,
6732 currentTarget
6733 } = event;
6734 const delayValue = typeof delay === "function" ? delay() : delay;
6735 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6736 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6737 return;
6738 }
6739 timeout.start(delayValue, () => {
6740 if (blockFocusRef.current) {
6741 return;
6742 }
6743 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6744 });
6745 },
6746 onBlur(event) {
6747 resetBlockedFocus();
6748 const relatedTarget = event.relatedTarget;
6749 const nativeEvent = event.nativeEvent;
6750 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6751 timeout.start(0, () => {
6752 const domReference = store.select("domReferenceElement");
6753 const activeEl = activeElement(ownerDocument(domReference));
6754 if (!relatedTarget && activeEl === domReference) {
6755 return;
6756 }
6757 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6758 return;
6759 }
6760 const nextFocusedElement = relatedTarget ?? activeEl;
6761 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6762 return;
6763 }
6764 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6765 });
6766 }
6767 };
6768 }, [dataRef, delay, store, timeout]);
6769 return React27.useMemo(() => enabled ? {
6770 reference,
6771 trigger: reference
6772 } : {}, [enabled, reference]);
6773 }
6774
6775 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6776 var React28 = __toESM(require_react(), 1);
6777
6778 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
6779 var HoverInteraction = class _HoverInteraction {
6780 constructor() {
6781 this.pointerType = void 0;
6782 this.interactedInside = false;
6783 this.handler = void 0;
6784 this.blockMouseMove = true;
6785 this.performedPointerEventsMutation = false;
6786 this.pointerEventsScopeElement = null;
6787 this.pointerEventsReferenceElement = null;
6788 this.pointerEventsFloatingElement = null;
6789 this.restTimeoutPending = false;
6790 this.openChangeTimeout = new Timeout();
6791 this.restTimeout = new Timeout();
6792 this.handleCloseOptions = void 0;
6793 }
6794 static create() {
6795 return new _HoverInteraction();
6796 }
6797 dispose = () => {
6798 this.openChangeTimeout.clear();
6799 this.restTimeout.clear();
6800 };
6801 disposeEffect = () => {
6802 return this.dispose;
6803 };
6804 };
6805 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6806 function clearSafePolygonPointerEventsMutation(instance) {
6807 if (!instance.performedPointerEventsMutation) {
6808 return;
6809 }
6810 const scopeElement = instance.pointerEventsScopeElement;
6811 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6812 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6813 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6814 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6815 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6816 }
6817 instance.performedPointerEventsMutation = false;
6818 instance.pointerEventsScopeElement = null;
6819 instance.pointerEventsReferenceElement = null;
6820 instance.pointerEventsFloatingElement = null;
6821 }
6822 function applySafePolygonPointerEventsMutation(instance, options) {
6823 const {
6824 scopeElement,
6825 referenceElement,
6826 floatingElement
6827 } = options;
6828 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6829 if (existingOwner && existingOwner !== instance) {
6830 clearSafePolygonPointerEventsMutation(existingOwner);
6831 }
6832 clearSafePolygonPointerEventsMutation(instance);
6833 instance.performedPointerEventsMutation = true;
6834 instance.pointerEventsScopeElement = scopeElement;
6835 instance.pointerEventsReferenceElement = referenceElement;
6836 instance.pointerEventsFloatingElement = floatingElement;
6837 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6838 scopeElement.style.pointerEvents = "none";
6839 referenceElement.style.pointerEvents = "auto";
6840 floatingElement.style.pointerEvents = "auto";
6841 }
6842 function useHoverInteractionSharedState(store) {
6843 const data = store.context.dataRef.current;
6844 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6845 if (!data.hoverInteractionState) {
6846 data.hoverInteractionState = instance;
6847 }
6848 useOnMount(data.hoverInteractionState.disposeEffect);
6849 return data.hoverInteractionState;
6850 }
6851
6852 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6853 function useHoverFloatingInteraction(context, parameters = {}) {
6854 const {
6855 enabled = true,
6856 closeDelay: closeDelayProp = 0,
6857 nodeId: nodeIdProp
6858 } = parameters;
6859 const store = "rootStore" in context ? context.rootStore : context;
6860 const open = store.useState("open");
6861 const floatingElement = store.useState("floatingElement");
6862 const domReferenceElement = store.useState("domReferenceElement");
6863 const {
6864 dataRef
6865 } = store.context;
6866 const tree = useFloatingTree();
6867 const parentId = useFloatingParentNodeId();
6868 const instance = useHoverInteractionSharedState(store);
6869 const childClosedTimeout = useTimeout();
6870 const isClickLikeOpenEvent2 = useStableCallback(() => {
6871 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6872 });
6873 const isHoverOpen = useStableCallback(() => {
6874 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6875 });
6876 const clearPointerEvents = useStableCallback(() => {
6877 clearSafePolygonPointerEventsMutation(instance);
6878 });
6879 useIsoLayoutEffect(() => {
6880 if (!open) {
6881 instance.pointerType = void 0;
6882 instance.restTimeoutPending = false;
6883 instance.interactedInside = false;
6884 clearPointerEvents();
6885 }
6886 }, [open, instance, clearPointerEvents]);
6887 React28.useEffect(() => {
6888 return clearPointerEvents;
6889 }, [clearPointerEvents]);
6890 useIsoLayoutEffect(() => {
6891 if (!enabled) {
6892 return void 0;
6893 }
6894 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6895 const ref = domReferenceElement;
6896 const floatingEl = floatingElement;
6897 const doc = ownerDocument(floatingElement);
6898 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6899 if (parentFloating) {
6900 parentFloating.style.pointerEvents = "";
6901 }
6902 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6903 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6904 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6905 applySafePolygonPointerEventsMutation(instance, {
6906 scopeElement,
6907 referenceElement: ref,
6908 floatingElement: floatingEl
6909 });
6910 return () => {
6911 clearPointerEvents();
6912 };
6913 }
6914 return void 0;
6915 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6916 React28.useEffect(() => {
6917 if (!enabled) {
6918 return void 0;
6919 }
6920 function hasParentChildren() {
6921 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6922 }
6923 function closeWithDelay(event) {
6924 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6925 const close = () => {
6926 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6927 tree?.events.emit("floating.closed", event);
6928 };
6929 if (closeDelay) {
6930 instance.openChangeTimeout.start(closeDelay, close);
6931 } else {
6932 instance.openChangeTimeout.clear();
6933 close();
6934 }
6935 }
6936 function handleInteractInside(event) {
6937 const target = getTarget(event);
6938 if (!isInteractiveElement(target)) {
6939 instance.interactedInside = false;
6940 return;
6941 }
6942 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6943 }
6944 function onFloatingMouseEnter() {
6945 instance.openChangeTimeout.clear();
6946 childClosedTimeout.clear();
6947 tree?.events.off("floating.closed", onNodeClosed);
6948 clearPointerEvents();
6949 }
6950 function onFloatingMouseLeave(event) {
6951 if (hasParentChildren() && tree) {
6952 tree.events.on("floating.closed", onNodeClosed);
6953 return;
6954 }
6955 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6956 return;
6957 }
6958 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6959 const relatedTarget = event.relatedTarget;
6960 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6961 if (isMovingIntoDescendantFloating) {
6962 return;
6963 }
6964 if (instance.handler) {
6965 instance.handler(event);
6966 return;
6967 }
6968 clearPointerEvents();
6969 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
6970 closeWithDelay(event);
6971 }
6972 }
6973 function onNodeClosed(event) {
6974 if (!tree || !parentId || hasParentChildren()) {
6975 return;
6976 }
6977 childClosedTimeout.start(0, () => {
6978 tree.events.off("floating.closed", onNodeClosed);
6979 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6980 tree.events.emit("floating.closed", event);
6981 });
6982 }
6983 const floating = floatingElement;
6984 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6985 tree?.events.off("floating.closed", onNodeClosed);
6986 });
6987 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6988 }
6989
6990 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
6991 var React29 = __toESM(require_react(), 1);
6992 var ReactDOM5 = __toESM(require_react_dom(), 1);
6993 var EMPTY_REF = {
6994 current: null
6995 };
6996 function useHoverReferenceInteraction(context, props = {}) {
6997 const {
6998 enabled = true,
6999 delay = 0,
7000 handleClose = null,
7001 mouseOnly = false,
7002 restMs = 0,
7003 move = true,
7004 triggerElementRef = EMPTY_REF,
7005 externalTree,
7006 isActiveTrigger = true,
7007 getHandleCloseContext,
7008 isClosing,
7009 shouldOpen: shouldOpenProp
7010 } = props;
7011 const store = "rootStore" in context ? context.rootStore : context;
7012 const {
7013 dataRef,
7014 events
7015 } = store.context;
7016 const tree = useFloatingTree(externalTree);
7017 const instance = useHoverInteractionSharedState(store);
7018 const isHoverCloseActiveRef = React29.useRef(false);
7019 const handleCloseRef = useValueAsRef(handleClose);
7020 const delayRef = useValueAsRef(delay);
7021 const restMsRef = useValueAsRef(restMs);
7022 const enabledRef = useValueAsRef(enabled);
7023 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7024 const isClosingRef = useValueAsRef(isClosing);
7025 const isClickLikeOpenEvent2 = useStableCallback(() => {
7026 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7027 });
7028 const checkShouldOpen = useStableCallback(() => {
7029 return shouldOpenRef.current?.() !== false;
7030 });
7031 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7032 const allTriggers = store.context.triggerElements;
7033 if (allTriggers.hasElement(currentTarget)) {
7034 return !currentDomReference || !contains(currentDomReference, currentTarget);
7035 }
7036 if (!isElement(target)) {
7037 return false;
7038 }
7039 const targetElement = target;
7040 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7041 });
7042 const cleanupMouseMoveHandler = useStableCallback(() => {
7043 if (!instance.handler) {
7044 return;
7045 }
7046 const doc = ownerDocument(store.select("domReferenceElement"));
7047 doc.removeEventListener("mousemove", instance.handler);
7048 instance.handler = void 0;
7049 });
7050 const clearPointerEvents = useStableCallback(() => {
7051 clearSafePolygonPointerEventsMutation(instance);
7052 });
7053 if (isActiveTrigger) {
7054 instance.handleCloseOptions = handleCloseRef.current?.__options;
7055 }
7056 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7057 React29.useEffect(() => {
7058 if (!enabled) {
7059 return void 0;
7060 }
7061 function onOpenChangeLocal(details) {
7062 if (!details.open) {
7063 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7064 cleanupMouseMoveHandler();
7065 instance.openChangeTimeout.clear();
7066 instance.restTimeout.clear();
7067 instance.blockMouseMove = true;
7068 instance.restTimeoutPending = false;
7069 } else {
7070 isHoverCloseActiveRef.current = false;
7071 }
7072 }
7073 events.on("openchange", onOpenChangeLocal);
7074 return () => {
7075 events.off("openchange", onOpenChangeLocal);
7076 };
7077 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7078 React29.useEffect(() => {
7079 if (!enabled) {
7080 return void 0;
7081 }
7082 function closeWithDelay(event, runElseBranch = true) {
7083 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7084 if (closeDelay) {
7085 instance.openChangeTimeout.start(closeDelay, () => {
7086 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7087 tree?.events.emit("floating.closed", event);
7088 });
7089 } else if (runElseBranch) {
7090 instance.openChangeTimeout.clear();
7091 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7092 tree?.events.emit("floating.closed", event);
7093 }
7094 }
7095 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7096 if (!isElement(trigger)) {
7097 return void 0;
7098 }
7099 function onMouseEnter(event) {
7100 instance.openChangeTimeout.clear();
7101 instance.blockMouseMove = false;
7102 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7103 return;
7104 }
7105 const restMsValue = getRestMs(restMsRef.current);
7106 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7107 const eventTarget = getTarget(event);
7108 const currentTarget = event.currentTarget ?? null;
7109 const currentDomReference = store.select("domReferenceElement");
7110 let triggerNode = currentTarget;
7111 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7112 for (const triggerElement of store.context.triggerElements.elements()) {
7113 if (contains(triggerElement, eventTarget)) {
7114 triggerNode = triggerElement;
7115 break;
7116 }
7117 }
7118 }
7119 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7120 triggerNode = currentDomReference;
7121 }
7122 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7123 const isOpen = store.select("open");
7124 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7125 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7126 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7127 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7128 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7129 const shouldOpen = !isOpen || isOverInactive;
7130 if (shouldOpenImmediately) {
7131 if (checkShouldOpen()) {
7132 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7133 }
7134 return;
7135 }
7136 if (isRestOnlyDelay) {
7137 return;
7138 }
7139 if (openDelay) {
7140 instance.openChangeTimeout.start(openDelay, () => {
7141 if (shouldOpen && checkShouldOpen()) {
7142 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7143 }
7144 });
7145 } else if (shouldOpen) {
7146 if (checkShouldOpen()) {
7147 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7148 }
7149 }
7150 }
7151 function onMouseLeave(event) {
7152 if (isClickLikeOpenEvent2()) {
7153 clearPointerEvents();
7154 return;
7155 }
7156 cleanupMouseMoveHandler();
7157 const domReferenceElement = store.select("domReferenceElement");
7158 const doc = ownerDocument(domReferenceElement);
7159 instance.restTimeout.clear();
7160 instance.restTimeoutPending = false;
7161 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7162 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7163 return;
7164 }
7165 if (handleCloseRef.current && handleCloseContextBase) {
7166 if (!store.select("open")) {
7167 instance.openChangeTimeout.clear();
7168 }
7169 const currentTrigger = triggerElementRef.current;
7170 instance.handler = handleCloseRef.current({
7171 ...handleCloseContextBase,
7172 tree,
7173 x: event.clientX,
7174 y: event.clientY,
7175 onClose() {
7176 clearPointerEvents();
7177 cleanupMouseMoveHandler();
7178 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7179 closeWithDelay(event, true);
7180 }
7181 }
7182 });
7183 doc.addEventListener("mousemove", instance.handler);
7184 instance.handler(event);
7185 return;
7186 }
7187 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7188 if (shouldClose) {
7189 closeWithDelay(event);
7190 }
7191 }
7192 if (move) {
7193 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7194 once: true
7195 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7196 }
7197 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7198 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7199 return React29.useMemo(() => {
7200 if (!enabled) {
7201 return void 0;
7202 }
7203 function setPointerRef(event) {
7204 instance.pointerType = event.pointerType;
7205 }
7206 return {
7207 onPointerDown: setPointerRef,
7208 onPointerEnter: setPointerRef,
7209 onMouseMove(event) {
7210 const {
7211 nativeEvent
7212 } = event;
7213 const trigger = event.currentTarget;
7214 const currentDomReference = store.select("domReferenceElement");
7215 const currentOpen = store.select("open");
7216 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7217 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7218 return;
7219 }
7220 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7221 const floatingElement = store.select("floatingElement");
7222 if (floatingElement) {
7223 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7224 applySafePolygonPointerEventsMutation(instance, {
7225 scopeElement,
7226 referenceElement: trigger,
7227 floatingElement
7228 });
7229 }
7230 }
7231 const restMsValue = getRestMs(restMsRef.current);
7232 if (currentOpen && !isOverInactive || restMsValue === 0) {
7233 return;
7234 }
7235 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7236 return;
7237 }
7238 instance.restTimeout.clear();
7239 function handleMouseMove() {
7240 instance.restTimeoutPending = false;
7241 if (isClickLikeOpenEvent2()) {
7242 return;
7243 }
7244 const latestOpen = store.select("open");
7245 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7246 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7247 }
7248 }
7249 if (instance.pointerType === "touch") {
7250 ReactDOM5.flushSync(() => {
7251 handleMouseMove();
7252 });
7253 } else if (isOverInactive && currentOpen) {
7254 handleMouseMove();
7255 } else {
7256 instance.restTimeoutPending = true;
7257 instance.restTimeout.start(restMsValue, handleMouseMove);
7258 }
7259 }
7260 };
7261 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7262 }
7263
7264 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7265 var CURSOR_SPEED_THRESHOLD = 0.1;
7266 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7267 var POLYGON_BUFFER = 0.5;
7268 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7269 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7270 }
7271 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7272 let isInsideValue = false;
7273 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7274 isInsideValue = !isInsideValue;
7275 }
7276 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7277 isInsideValue = !isInsideValue;
7278 }
7279 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7280 isInsideValue = !isInsideValue;
7281 }
7282 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7283 isInsideValue = !isInsideValue;
7284 }
7285 return isInsideValue;
7286 }
7287 function isInsideRect(pointX, pointY, rect) {
7288 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7289 }
7290 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7291 const minX = Math.min(x1, x2);
7292 const maxX = Math.max(x1, x2);
7293 const minY = Math.min(y1, y2);
7294 const maxY = Math.max(y1, y2);
7295 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7296 }
7297 function safePolygon(options = {}) {
7298 const {
7299 blockPointerEvents = false
7300 } = options;
7301 const timeout = new Timeout();
7302 const fn = ({
7303 x: x2,
7304 y: y2,
7305 placement,
7306 elements,
7307 onClose,
7308 nodeId,
7309 tree
7310 }) => {
7311 const side = placement?.split("-")[0];
7312 let hasLanded = false;
7313 let lastX = null;
7314 let lastY = null;
7315 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7316 function isCursorMovingSlowly(nextX, nextY) {
7317 const currentTime = performance.now();
7318 const elapsedTime = currentTime - lastCursorTime;
7319 if (lastX === null || lastY === null || elapsedTime === 0) {
7320 lastX = nextX;
7321 lastY = nextY;
7322 lastCursorTime = currentTime;
7323 return false;
7324 }
7325 const deltaX = nextX - lastX;
7326 const deltaY = nextY - lastY;
7327 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7328 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7329 lastX = nextX;
7330 lastY = nextY;
7331 lastCursorTime = currentTime;
7332 return distanceSquared < thresholdSquared;
7333 }
7334 function close() {
7335 timeout.clear();
7336 onClose();
7337 }
7338 return function onMouseMove(event) {
7339 timeout.clear();
7340 const domReference = elements.domReference;
7341 const floating = elements.floating;
7342 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7343 return void 0;
7344 }
7345 const {
7346 clientX,
7347 clientY
7348 } = event;
7349 const target = getTarget(event);
7350 const isLeave = event.type === "mouseleave";
7351 const isOverFloatingEl = contains(floating, target);
7352 const isOverReferenceEl = contains(domReference, target);
7353 if (isOverFloatingEl) {
7354 hasLanded = true;
7355 if (!isLeave) {
7356 return void 0;
7357 }
7358 }
7359 if (isOverReferenceEl) {
7360 hasLanded = false;
7361 if (!isLeave) {
7362 hasLanded = true;
7363 return void 0;
7364 }
7365 }
7366 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7367 return void 0;
7368 }
7369 function hasOpenChildNode() {
7370 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7371 }
7372 function closeIfNoOpenChild() {
7373 if (!hasOpenChildNode()) {
7374 close();
7375 }
7376 }
7377 if (hasOpenChildNode()) {
7378 return void 0;
7379 }
7380 const refRect = domReference.getBoundingClientRect();
7381 const rect = floating.getBoundingClientRect();
7382 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7383 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7384 const isFloatingWider = rect.width > refRect.width;
7385 const isFloatingTaller = rect.height > refRect.height;
7386 const left = (isFloatingWider ? refRect : rect).left;
7387 const right = (isFloatingWider ? refRect : rect).right;
7388 const top = (isFloatingTaller ? refRect : rect).top;
7389 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7390 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) {
7391 closeIfNoOpenChild();
7392 return void 0;
7393 }
7394 let isInsideTroughRect = false;
7395 switch (side) {
7396 case "top":
7397 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7398 break;
7399 case "bottom":
7400 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7401 break;
7402 case "left":
7403 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7404 break;
7405 case "right":
7406 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7407 break;
7408 default:
7409 }
7410 if (isInsideTroughRect) {
7411 return void 0;
7412 }
7413 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7414 closeIfNoOpenChild();
7415 return void 0;
7416 }
7417 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7418 closeIfNoOpenChild();
7419 return void 0;
7420 }
7421 let isInsidePolygon = false;
7422 switch (side) {
7423 case "top": {
7424 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7425 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7426 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7427 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7428 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7429 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7430 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7431 break;
7432 }
7433 case "bottom": {
7434 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7435 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7436 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7437 const cursorPointY = y2 - POLYGON_BUFFER;
7438 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7439 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7440 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7441 break;
7442 }
7443 case "left": {
7444 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7445 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7446 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7447 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7448 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7449 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7450 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7451 break;
7452 }
7453 case "right": {
7454 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7455 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7456 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7457 const cursorPointX = x2 - POLYGON_BUFFER;
7458 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7459 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7460 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7461 break;
7462 }
7463 default:
7464 }
7465 if (!isInsidePolygon) {
7466 closeIfNoOpenChild();
7467 } else if (!hasLanded) {
7468 timeout.start(40, closeIfNoOpenChild);
7469 }
7470 return void 0;
7471 };
7472 };
7473 fn.__options = {
7474 ...options,
7475 blockPointerEvents
7476 };
7477 return fn;
7478 }
7479
7480 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
7481 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7482 CommonPopupDataAttributes2["open"] = "data-open";
7483 CommonPopupDataAttributes2["closed"] = "data-closed";
7484 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7485 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7486 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7487 CommonPopupDataAttributes2["side"] = "data-side";
7488 CommonPopupDataAttributes2["align"] = "data-align";
7489 return CommonPopupDataAttributes2;
7490 })({});
7491 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7492 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7493 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7494 return CommonTriggerDataAttributes2;
7495 })({});
7496 var TRIGGER_HOOK = {
7497 [CommonTriggerDataAttributes.popupOpen]: ""
7498 };
7499 var PRESSABLE_TRIGGER_HOOK = {
7500 [CommonTriggerDataAttributes.popupOpen]: "",
7501 [CommonTriggerDataAttributes.pressed]: ""
7502 };
7503 var POPUP_OPEN_HOOK = {
7504 [CommonPopupDataAttributes.open]: ""
7505 };
7506 var POPUP_CLOSED_HOOK = {
7507 [CommonPopupDataAttributes.closed]: ""
7508 };
7509 var ANCHOR_HIDDEN_HOOK = {
7510 [CommonPopupDataAttributes.anchorHidden]: ""
7511 };
7512 var triggerOpenStateMapping = {
7513 open(value) {
7514 if (value) {
7515 return TRIGGER_HOOK;
7516 }
7517 return null;
7518 }
7519 };
7520 var popupStateMapping = {
7521 open(value) {
7522 if (value) {
7523 return POPUP_OPEN_HOOK;
7524 }
7525 return POPUP_CLOSED_HOOK;
7526 },
7527 anchorHidden(value) {
7528 if (value) {
7529 return ANCHOR_HIDDEN_HOOK;
7530 }
7531 return null;
7532 }
7533 };
7534
7535 // node_modules/@base-ui/utils/inertValue.mjs
7536 function inertValue(value) {
7537 if (isReactVersionAtLeast(19)) {
7538 return value;
7539 }
7540 return value ? "true" : void 0;
7541 }
7542
7543 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7544 var React30 = __toESM(require_react(), 1);
7545
7546 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
7547 var baseArrow = (options) => ({
7548 name: "arrow",
7549 options,
7550 async fn(state) {
7551 const {
7552 x: x2,
7553 y: y2,
7554 placement,
7555 rects,
7556 platform: platform3,
7557 elements,
7558 middlewareData
7559 } = state;
7560 const {
7561 element,
7562 padding = 0,
7563 offsetParent = "real"
7564 } = evaluate(options, state) || {};
7565 if (element == null) {
7566 return {};
7567 }
7568 const paddingObject = getPaddingObject(padding);
7569 const coords = {
7570 x: x2,
7571 y: y2
7572 };
7573 const axis = getAlignmentAxis(placement);
7574 const length = getAxisLength(axis);
7575 const arrowDimensions = await platform3.getDimensions(element);
7576 const isYAxis = axis === "y";
7577 const minProp = isYAxis ? "top" : "left";
7578 const maxProp = isYAxis ? "bottom" : "right";
7579 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7580 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7581 const startDiff = coords[axis] - rects.reference[axis];
7582 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7583 let clientSize = elements.floating[clientProp] || rects.floating[length];
7584 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7585 clientSize = elements.floating[clientProp] || rects.floating[length];
7586 }
7587 const centerToReference = endDiff / 2 - startDiff / 2;
7588 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7589 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7590 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7591 const min2 = minPadding;
7592 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7593 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7594 const offset4 = clamp(min2, center, max2);
7595 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7596 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7597 return {
7598 [axis]: coords[axis] + alignmentOffset,
7599 data: {
7600 [axis]: offset4,
7601 centerOffset: center - offset4 - alignmentOffset,
7602 ...shouldAddOffset && {
7603 alignmentOffset
7604 }
7605 },
7606 reset: shouldAddOffset
7607 };
7608 }
7609 });
7610 var arrow4 = (options, deps) => ({
7611 ...baseArrow(options),
7612 options: [options, deps]
7613 });
7614
7615 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
7616 var nativeHideFn = hide3().fn;
7617 var hide4 = {
7618 name: "hide",
7619 async fn(state) {
7620 const {
7621 width,
7622 height,
7623 x: x2,
7624 y: y2
7625 } = state.rects.reference;
7626 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7627 const nativeHideResult = await nativeHideFn(state);
7628 return {
7629 data: {
7630 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7631 }
7632 };
7633 }
7634 };
7635
7636 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
7637 var DEFAULT_SIDES = {
7638 sideX: "left",
7639 sideY: "top"
7640 };
7641 var adaptiveOrigin = {
7642 name: "adaptiveOrigin",
7643 async fn(state) {
7644 const {
7645 x: rawX,
7646 y: rawY,
7647 rects: {
7648 floating: floatRect
7649 },
7650 elements: {
7651 floating
7652 },
7653 platform: platform3,
7654 strategy,
7655 placement
7656 } = state;
7657 const win = getWindow(floating);
7658 const styles = win.getComputedStyle(floating);
7659 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7660 if (!hasTransition) {
7661 return {
7662 x: rawX,
7663 y: rawY,
7664 data: DEFAULT_SIDES
7665 };
7666 }
7667 const offsetParent = await platform3.getOffsetParent?.(floating);
7668 let offsetDimensions = {
7669 width: 0,
7670 height: 0
7671 };
7672 if (strategy === "fixed" && win?.visualViewport) {
7673 offsetDimensions = {
7674 width: win.visualViewport.width,
7675 height: win.visualViewport.height
7676 };
7677 } else if (offsetParent === win) {
7678 const doc = ownerDocument(floating);
7679 offsetDimensions = {
7680 width: doc.documentElement.clientWidth,
7681 height: doc.documentElement.clientHeight
7682 };
7683 } else if (await platform3.isElement?.(offsetParent)) {
7684 offsetDimensions = await platform3.getDimensions(offsetParent);
7685 }
7686 const currentSide = getSide(placement);
7687 let x2 = rawX;
7688 let y2 = rawY;
7689 if (currentSide === "left") {
7690 x2 = offsetDimensions.width - (rawX + floatRect.width);
7691 }
7692 if (currentSide === "top") {
7693 y2 = offsetDimensions.height - (rawY + floatRect.height);
7694 }
7695 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7696 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7697 return {
7698 x: x2,
7699 y: y2,
7700 data: {
7701 sideX,
7702 sideY
7703 }
7704 };
7705 }
7706 };
7707
7708 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7709 function getLogicalSide(sideParam, renderedSide, isRtl) {
7710 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7711 const logicalRight = isRtl ? "inline-start" : "inline-end";
7712 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7713 return {
7714 top: "top",
7715 right: isLogicalSideParam ? logicalRight : "right",
7716 bottom: "bottom",
7717 left: isLogicalSideParam ? logicalLeft : "left"
7718 }[renderedSide];
7719 }
7720 function getOffsetData(state, sideParam, isRtl) {
7721 const {
7722 rects,
7723 placement
7724 } = state;
7725 const data = {
7726 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7727 align: getAlignment(placement) || "center",
7728 anchor: {
7729 width: rects.reference.width,
7730 height: rects.reference.height
7731 },
7732 positioner: {
7733 width: rects.floating.width,
7734 height: rects.floating.height
7735 }
7736 };
7737 return data;
7738 }
7739 function useAnchorPositioning(params) {
7740 const {
7741 // Public parameters
7742 anchor,
7743 positionMethod = "absolute",
7744 side: sideParam = "bottom",
7745 sideOffset = 0,
7746 align = "center",
7747 alignOffset = 0,
7748 collisionBoundary,
7749 collisionPadding: collisionPaddingParam = 5,
7750 sticky = false,
7751 arrowPadding = 5,
7752 disableAnchorTracking = false,
7753 inline: inlineMiddleware,
7754 // Private parameters
7755 keepMounted = false,
7756 floatingRootContext,
7757 mounted,
7758 collisionAvoidance,
7759 shiftCrossAxis = false,
7760 nodeId,
7761 adaptiveOrigin: adaptiveOrigin2,
7762 lazyFlip = false,
7763 externalTree
7764 } = params;
7765 const [mountSide, setMountSide] = React30.useState(null);
7766 if (!mounted && mountSide !== null) {
7767 setMountSide(null);
7768 }
7769 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7770 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7771 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7772 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7773 const anchorFnCallback = useStableCallback(anchorFn);
7774 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7775 const anchorValueRef = useValueAsRef(anchor);
7776 const mountedRef = useValueAsRef(mounted);
7777 const direction = useDirection();
7778 const isRtl = direction === "rtl";
7779 const side = mountSide || {
7780 top: "top",
7781 right: "right",
7782 bottom: "bottom",
7783 left: "left",
7784 "inline-end": isRtl ? "left" : "right",
7785 "inline-start": isRtl ? "right" : "left"
7786 }[sideParam];
7787 const placement = align === "center" ? side : `${side}-${align}`;
7788 let collisionPadding = collisionPaddingParam;
7789 const bias = 1;
7790 const biasTop = sideParam === "bottom" ? bias : 0;
7791 const biasBottom = sideParam === "top" ? bias : 0;
7792 const biasLeft = sideParam === "right" ? bias : 0;
7793 const biasRight = sideParam === "left" ? bias : 0;
7794 if (typeof collisionPadding === "number") {
7795 collisionPadding = {
7796 top: collisionPadding + biasTop,
7797 right: collisionPadding + biasRight,
7798 bottom: collisionPadding + biasBottom,
7799 left: collisionPadding + biasLeft
7800 };
7801 } else if (collisionPadding) {
7802 collisionPadding = {
7803 top: (collisionPadding.top || 0) + biasTop,
7804 right: (collisionPadding.right || 0) + biasRight,
7805 bottom: (collisionPadding.bottom || 0) + biasBottom,
7806 left: (collisionPadding.left || 0) + biasLeft
7807 };
7808 }
7809 const commonCollisionProps = {
7810 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7811 padding: collisionPadding
7812 };
7813 const arrowRef = React30.useRef(null);
7814 const sideOffsetRef = useValueAsRef(sideOffset);
7815 const alignOffsetRef = useValueAsRef(alignOffset);
7816 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7817 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7818 const middleware = [];
7819 if (inlineMiddleware) {
7820 middleware.push(inlineMiddleware);
7821 }
7822 middleware.push(offset3((state) => {
7823 const data = getOffsetData(state, sideParam, isRtl);
7824 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7825 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7826 return {
7827 mainAxis: sideAxis,
7828 crossAxis: alignAxis,
7829 alignmentAxis: alignAxis
7830 };
7831 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7832 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7833 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7834 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7835 ...commonCollisionProps,
7836 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7837 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7838 padding: {
7839 top: collisionPadding.top + bias,
7840 right: collisionPadding.right + bias,
7841 bottom: collisionPadding.bottom + bias,
7842 left: collisionPadding.left + bias
7843 },
7844 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7845 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7846 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7847 });
7848 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7849 const html = ownerDocument(data.elements.floating).documentElement;
7850 return {
7851 ...commonCollisionProps,
7852 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7853 // for context menus.
7854 rootBoundary: shiftCrossAxis ? {
7855 x: 0,
7856 y: 0,
7857 width: html.clientWidth,
7858 height: html.clientHeight
7859 } : void 0,
7860 mainAxis: collisionAvoidanceAlign !== "none",
7861 crossAxis: crossAxisShiftEnabled,
7862 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7863 if (!arrowRef.current) {
7864 return {};
7865 }
7866 const {
7867 width,
7868 height
7869 } = arrowRef.current.getBoundingClientRect();
7870 const sideAxis = getSideAxis(getSide(limitData.placement));
7871 const arrowSize = sideAxis === "y" ? width : height;
7872 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7873 return {
7874 offset: arrowSize / 2 + offsetAmount / 2
7875 };
7876 })
7877 };
7878 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7879 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7880 middleware.push(shiftMiddleware, flipMiddleware);
7881 } else {
7882 middleware.push(flipMiddleware, shiftMiddleware);
7883 }
7884 middleware.push(size3({
7885 ...commonCollisionProps,
7886 apply({
7887 elements: {
7888 floating
7889 },
7890 availableWidth,
7891 availableHeight,
7892 rects
7893 }) {
7894 if (!mountedRef.current) {
7895 return;
7896 }
7897 const floatingStyle = floating.style;
7898 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7899 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7900 const dpr = getWindow(floating).devicePixelRatio || 1;
7901 const {
7902 x: x3,
7903 y: y3,
7904 width,
7905 height
7906 } = rects.reference;
7907 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7908 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7909 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7910 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7911 }
7912 }), arrow4((state) => ({
7913 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7914 // we'll create a fake element.
7915 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7916 padding: arrowPadding,
7917 offsetParent: "floating"
7918 }), [arrowPadding]), {
7919 name: "transformOrigin",
7920 fn(state) {
7921 const {
7922 elements: elements2,
7923 middlewareData: middlewareData2,
7924 placement: renderedPlacement2,
7925 rects,
7926 y: y3
7927 } = state;
7928 const currentRenderedSide = getSide(renderedPlacement2);
7929 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7930 const arrowEl = arrowRef.current;
7931 const arrowX = middlewareData2.arrow?.x || 0;
7932 const arrowY = middlewareData2.arrow?.y || 0;
7933 const arrowWidth = arrowEl?.clientWidth || 0;
7934 const arrowHeight = arrowEl?.clientHeight || 0;
7935 const transformX = arrowX + arrowWidth / 2;
7936 const transformY = arrowY + arrowHeight / 2;
7937 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7938 const halfAnchorHeight = rects.reference.height / 2;
7939 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7940 const isOverlappingAnchor = shiftY > sideOffsetValue;
7941 const adjacentTransformOrigin = {
7942 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7943 bottom: `${transformX}px ${-sideOffsetValue}px`,
7944 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7945 right: `${-sideOffsetValue}px ${transformY}px`
7946 }[currentRenderedSide];
7947 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7948 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7949 return {};
7950 }
7951 }, hide4, adaptiveOrigin2);
7952 useIsoLayoutEffect(() => {
7953 if (!mounted && floatingRootContext) {
7954 floatingRootContext.update({
7955 referenceElement: null,
7956 floatingElement: null,
7957 domReferenceElement: null,
7958 positionReference: null
7959 });
7960 }
7961 }, [mounted, floatingRootContext]);
7962 const autoUpdateOptions = React30.useMemo(() => ({
7963 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7964 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7965 }), [disableAnchorTracking]);
7966 const {
7967 refs,
7968 elements,
7969 x: x2,
7970 y: y2,
7971 middlewareData,
7972 update: update2,
7973 placement: renderedPlacement,
7974 context,
7975 isPositioned,
7976 floatingStyles: originalFloatingStyles
7977 } = useFloating2({
7978 rootContext: floatingRootContext,
7979 open: keepMounted ? mounted : void 0,
7980 placement,
7981 middleware,
7982 strategy: positionMethod,
7983 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7984 nodeId,
7985 externalTree
7986 });
7987 const {
7988 sideX,
7989 sideY
7990 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7991 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7992 const floatingStyles = React30.useMemo(() => {
7993 const base = adaptiveOrigin2 ? {
7994 position: resolvedPosition,
7995 [sideX]: x2,
7996 [sideY]: y2
7997 } : {
7998 position: resolvedPosition,
7999 ...originalFloatingStyles
8000 };
8001 if (!isPositioned) {
8002 base.opacity = 0;
8003 }
8004 return base;
8005 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8006 const registeredPositionReferenceRef = React30.useRef(null);
8007 useIsoLayoutEffect(() => {
8008 if (!mounted) {
8009 return;
8010 }
8011 const anchorValue = anchorValueRef.current;
8012 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8013 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8014 const finalAnchor = unwrappedElement || null;
8015 if (finalAnchor !== registeredPositionReferenceRef.current) {
8016 refs.setPositionReference(finalAnchor);
8017 registeredPositionReferenceRef.current = finalAnchor;
8018 }
8019 }, [mounted, refs, anchorDep, anchorValueRef]);
8020 React30.useEffect(() => {
8021 if (!mounted) {
8022 return;
8023 }
8024 const anchorValue = anchorValueRef.current;
8025 if (typeof anchorValue === "function") {
8026 return;
8027 }
8028 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8029 refs.setPositionReference(anchorValue.current);
8030 registeredPositionReferenceRef.current = anchorValue.current;
8031 }
8032 }, [mounted, refs, anchorDep, anchorValueRef]);
8033 React30.useEffect(() => {
8034 if (keepMounted && mounted && elements.reference && elements.floating) {
8035 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8036 }
8037 return void 0;
8038 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8039 const renderedSide = getSide(renderedPlacement);
8040 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8041 const renderedAlign = getAlignment(renderedPlacement) || "center";
8042 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8043 useIsoLayoutEffect(() => {
8044 if (lazyFlip && mounted && isPositioned) {
8045 setMountSide(renderedSide);
8046 }
8047 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8048 const arrowStyles = React30.useMemo(() => ({
8049 position: "absolute",
8050 top: middlewareData.arrow?.y,
8051 left: middlewareData.arrow?.x
8052 }), [middlewareData.arrow]);
8053 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8054 return React30.useMemo(() => ({
8055 positionerStyles: floatingStyles,
8056 arrowStyles,
8057 arrowRef,
8058 arrowUncentered,
8059 side: logicalRenderedSide,
8060 align: renderedAlign,
8061 physicalSide: renderedSide,
8062 anchorHidden,
8063 refs,
8064 context,
8065 isPositioned,
8066 update: update2
8067 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8068 }
8069 function isRef(param) {
8070 return param != null && "current" in param;
8071 }
8072
8073 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8074 function getDisabledMountTransitionStyles(transitionStatus) {
8075 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8076 }
8077
8078 // node_modules/@base-ui/react/utils/usePositioner.mjs
8079 function usePositioner(componentProps, state, {
8080 styles,
8081 transitionStatus,
8082 props,
8083 refs,
8084 hidden,
8085 inert = false
8086 }) {
8087 const style = {
8088 ...styles
8089 };
8090 if (inert) {
8091 style.pointerEvents = "none";
8092 }
8093 return useRenderElement("div", componentProps, {
8094 state,
8095 ref: refs,
8096 props: [{
8097 role: "presentation",
8098 hidden,
8099 style
8100 }, getDisabledMountTransitionStyles(transitionStatus), props],
8101 stateAttributesMapping: popupStateMapping
8102 });
8103 }
8104
8105 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8106 var React33 = __toESM(require_react(), 1);
8107 var ReactDOM6 = __toESM(require_react_dom(), 1);
8108
8109 // node_modules/@base-ui/utils/usePreviousValue.mjs
8110 var React31 = __toESM(require_react(), 1);
8111 function usePreviousValue(value) {
8112 const [state, setState] = React31.useState({
8113 current: value,
8114 previous: null
8115 });
8116 if (value !== state.current) {
8117 setState({
8118 current: value,
8119 previous: state.current
8120 });
8121 }
8122 return state.previous;
8123 }
8124
8125 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8126 var React32 = __toESM(require_react(), 1);
8127
8128 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8129 function getCssDimensions2(element) {
8130 const css = getComputedStyle2(element);
8131 let width = parseFloat(css.width) || 0;
8132 let height = parseFloat(css.height) || 0;
8133 const hasOffset = isHTMLElement(element);
8134 const offsetWidth = hasOffset ? element.offsetWidth : width;
8135 const offsetHeight = hasOffset ? element.offsetHeight : height;
8136 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8137 if (shouldFallback) {
8138 width = offsetWidth;
8139 height = offsetHeight;
8140 }
8141 return {
8142 width,
8143 height
8144 };
8145 }
8146
8147 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8148 function usePopupAutoResize(parameters) {
8149 const {
8150 popupElement,
8151 positionerElement,
8152 content,
8153 mounted,
8154 onMeasureLayout: onMeasureLayoutParam,
8155 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8156 side,
8157 direction
8158 } = parameters;
8159 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8160 const animationFrame = useAnimationFrame();
8161 const committedDimensionsRef = React32.useRef(null);
8162 const isInitialRenderRef = React32.useRef(true);
8163 const restoreAnchoringStylesRef = React32.useRef(NOOP);
8164 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8165 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8166 const anchoringStyles = React32.useMemo(() => {
8167 let isOriginSide = side === "top";
8168 let isPhysicalLeft = side === "left";
8169 if (direction === "rtl") {
8170 isOriginSide = isOriginSide || side === "inline-end";
8171 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8172 } else {
8173 isOriginSide = isOriginSide || side === "inline-start";
8174 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8175 }
8176 return isOriginSide ? {
8177 position: "absolute",
8178 [side === "top" ? "bottom" : "top"]: "0",
8179 [isPhysicalLeft ? "right" : "left"]: "0"
8180 } : EMPTY_OBJECT;
8181 }, [side, direction]);
8182 useIsoLayoutEffect(() => {
8183 if (!mounted) {
8184 restoreAnchoringStylesRef.current = NOOP;
8185 isInitialRenderRef.current = true;
8186 committedDimensionsRef.current = null;
8187 return void 0;
8188 }
8189 if (!popupElement || !positionerElement) {
8190 return void 0;
8191 }
8192 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8193 setPopupCssSize(popupElement, "auto");
8194 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8195 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8196 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8197 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8198 "--available-width": "max-content",
8199 "--available-height": "max-content"
8200 });
8201 function restoreMeasurementOverrides() {
8202 restorePopupPosition();
8203 restorePopupTransform();
8204 restorePositionerAvailableSize();
8205 }
8206 function restoreMeasurementOverridesIncludingScale() {
8207 restoreMeasurementOverrides();
8208 restorePopupScale();
8209 }
8210 onMeasureLayout?.();
8211 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8212 setPositionerCssSize(positionerElement, "max-content");
8213 const dimensions = getCssDimensions2(popupElement);
8214 committedDimensionsRef.current = dimensions;
8215 setPositionerCssSize(positionerElement, dimensions);
8216 restoreMeasurementOverridesIncludingScale();
8217 onMeasureLayoutComplete?.(null, dimensions);
8218 isInitialRenderRef.current = false;
8219 return () => {
8220 restoreAnchoringStylesRef.current();
8221 restoreAnchoringStylesRef.current = NOOP;
8222 };
8223 }
8224 setPositionerCssSize(positionerElement, "max-content");
8225 const previousDimensions = committedDimensionsRef.current;
8226 const newDimensions = getCssDimensions2(popupElement);
8227 committedDimensionsRef.current = newDimensions;
8228 setPopupCssSize(popupElement, previousDimensions);
8229 restoreMeasurementOverridesIncludingScale();
8230 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8231 setPositionerCssSize(positionerElement, newDimensions);
8232 const abortController = new AbortController();
8233 animationFrame.request(() => {
8234 setPopupCssSize(popupElement, newDimensions);
8235 runOnceAnimationsFinish(() => {
8236 popupElement.style.setProperty("--popup-width", "auto");
8237 popupElement.style.setProperty("--popup-height", "auto");
8238 }, abortController.signal);
8239 });
8240 return () => {
8241 abortController.abort();
8242 animationFrame.cancel();
8243 restoreAnchoringStylesRef.current();
8244 restoreAnchoringStylesRef.current = NOOP;
8245 };
8246 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8247 }
8248 function overrideElementStyle(element, property, value) {
8249 const originalValue = element.style.getPropertyValue(property);
8250 element.style.setProperty(property, value);
8251 return () => {
8252 element.style.setProperty(property, originalValue);
8253 };
8254 }
8255 function applyElementStyles(element, styles) {
8256 const restorers = [];
8257 for (const [key, value] of Object.entries(styles)) {
8258 restorers.push(overrideElementStyle(element, key, value));
8259 }
8260 return restorers.length ? () => {
8261 restorers.forEach((restore) => restore());
8262 } : NOOP;
8263 }
8264 function setPopupCssSize(popupElement, size4) {
8265 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8266 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8267 popupElement.style.setProperty("--popup-width", width);
8268 popupElement.style.setProperty("--popup-height", height);
8269 }
8270 function setPositionerCssSize(positionerElement, size4) {
8271 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8272 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8273 positionerElement.style.setProperty("--positioner-width", width);
8274 positionerElement.style.setProperty("--positioner-height", height);
8275 }
8276
8277 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8278 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8279 function usePopupViewport(parameters) {
8280 const {
8281 store,
8282 side,
8283 cssVars,
8284 children
8285 } = parameters;
8286 const direction = useDirection();
8287 const activeTrigger = store.useState("activeTriggerElement");
8288 const activeTriggerId = store.useState("activeTriggerId");
8289 const open = store.useState("open");
8290 const payload = store.useState("payload");
8291 const mounted = store.useState("mounted");
8292 const popupElement = store.useState("popupElement");
8293 const positionerElement = store.useState("positionerElement");
8294 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8295 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8296 const capturedNodeRef = React33.useRef(null);
8297 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
8298 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
8299 const currentContainerRef = React33.useRef(null);
8300 const previousContainerRef = React33.useRef(null);
8301 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8302 const cleanupFrame = useAnimationFrame();
8303 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
8304 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
8305 useIsoLayoutEffect(() => {
8306 store.set("hasViewport", true);
8307 return () => {
8308 store.set("hasViewport", false);
8309 };
8310 }, [store]);
8311 const handleMeasureLayout = useStableCallback(() => {
8312 currentContainerRef.current?.style.setProperty("animation", "none");
8313 currentContainerRef.current?.style.setProperty("transition", "none");
8314 previousContainerRef.current?.style.setProperty("display", "none");
8315 });
8316 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8317 currentContainerRef.current?.style.removeProperty("animation");
8318 currentContainerRef.current?.style.removeProperty("transition");
8319 previousContainerRef.current?.style.removeProperty("display");
8320 if (previousDimensions) {
8321 setPreviousContentDimensions(previousDimensions);
8322 }
8323 });
8324 const lastHandledTriggerRef = React33.useRef(null);
8325 useIsoLayoutEffect(() => {
8326 if (!open || !mounted) {
8327 lastHandledTriggerRef.current = null;
8328 }
8329 }, [open, mounted]);
8330 useIsoLayoutEffect(() => {
8331 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8332 setPreviousContentNode(capturedNodeRef.current);
8333 setShowStartingStyleAttribute(true);
8334 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8335 setNewTriggerOffset(offset4);
8336 cleanupFrame.request(() => {
8337 ReactDOM6.flushSync(() => {
8338 setShowStartingStyleAttribute(false);
8339 });
8340 onAnimationsFinished(() => {
8341 setPreviousContentNode(null);
8342 setPreviousContentDimensions(null);
8343 capturedNodeRef.current = null;
8344 });
8345 });
8346 lastHandledTriggerRef.current = activeTrigger;
8347 }
8348 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8349 useIsoLayoutEffect(() => {
8350 const source = currentContainerRef.current;
8351 if (!source) {
8352 return;
8353 }
8354 const wrapper = ownerDocument(source).createElement("div");
8355 for (const child of Array.from(source.childNodes)) {
8356 wrapper.appendChild(child.cloneNode(true));
8357 }
8358 capturedNodeRef.current = wrapper;
8359 });
8360 const isTransitioning = previousContentNode != null;
8361 let childrenToRender;
8362 if (!isTransitioning) {
8363 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8364 "data-current": true,
8365 ref: currentContainerRef,
8366 children
8367 }, currentContentKey);
8368 } else {
8369 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
8370 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8371 "data-previous": true,
8372 inert: inertValue(true),
8373 ref: previousContainerRef,
8374 style: {
8375 ...previousContentDimensions ? {
8376 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8377 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8378 } : null,
8379 position: "absolute"
8380 },
8381 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8382 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8383 "data-current": true,
8384 ref: currentContainerRef,
8385 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8386 children
8387 }, currentContentKey)]
8388 });
8389 }
8390 useIsoLayoutEffect(() => {
8391 const container = previousContainerRef.current;
8392 if (!container || !previousContentNode) {
8393 return;
8394 }
8395 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8396 }, [previousContentNode]);
8397 usePopupAutoResize({
8398 popupElement,
8399 positionerElement,
8400 mounted,
8401 content: payload,
8402 onMeasureLayout: handleMeasureLayout,
8403 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8404 side,
8405 direction
8406 });
8407 const state = {
8408 activationDirection: getActivationDirection(newTriggerOffset),
8409 transitioning: isTransitioning
8410 };
8411 return {
8412 children: childrenToRender,
8413 state
8414 };
8415 }
8416 function getActivationDirection(offset4) {
8417 if (!offset4) {
8418 return void 0;
8419 }
8420 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8421 }
8422 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8423 if (value > tolerance) {
8424 return positiveLabel;
8425 }
8426 if (value < -tolerance) {
8427 return negativeLabel;
8428 }
8429 return "";
8430 }
8431 function calculateRelativePosition(from, to) {
8432 const fromRect = from.getBoundingClientRect();
8433 const toRect = to.getBoundingClientRect();
8434 const fromCenter = {
8435 x: fromRect.left + fromRect.width / 2,
8436 y: fromRect.top + fromRect.height / 2
8437 };
8438 const toCenter = {
8439 x: toRect.left + toRect.width / 2,
8440 y: toRect.top + toRect.height / 2
8441 };
8442 return {
8443 horizontal: toCenter.x - fromCenter.x,
8444 vertical: toCenter.y - fromCenter.y
8445 };
8446 }
8447 function usePopupContentKey(activeTriggerId, payload) {
8448 const [contentKey, setContentKey] = React33.useState(0);
8449 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8450 const previousPayloadRef = React33.useRef(payload);
8451 const pendingPayloadUpdateRef = React33.useRef(false);
8452 useIsoLayoutEffect(() => {
8453 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8454 const previousPayload = previousPayloadRef.current;
8455 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8456 const payloadChanged = payload !== previousPayload;
8457 if (triggerIdChanged) {
8458 setContentKey((value) => value + 1);
8459 pendingPayloadUpdateRef.current = !payloadChanged;
8460 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8461 setContentKey((value) => value + 1);
8462 pendingPayloadUpdateRef.current = false;
8463 }
8464 previousActiveTriggerIdRef.current = activeTriggerId;
8465 previousPayloadRef.current = payload;
8466 }, [activeTriggerId, payload]);
8467 return `${activeTriggerId ?? "current"}-${contentKey}`;
8468 }
8469
8470 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
8471 var React34 = __toESM(require_react(), 1);
8472 var ReactDOM7 = __toESM(require_react_dom(), 1);
8473 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8474 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8475 const {
8476 children,
8477 container,
8478 className,
8479 render: render4,
8480 style,
8481 ...elementProps
8482 } = componentProps;
8483 const {
8484 portalNode,
8485 portalSubtree
8486 } = useFloatingPortalNode({
8487 container,
8488 ref: forwardedRef,
8489 componentProps,
8490 elementProps
8491 });
8492 if (!portalSubtree && !portalNode) {
8493 return null;
8494 }
8495 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
8496 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
8497 });
8498 });
8499 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8500
8501 // node_modules/@base-ui/react/tooltip/index.parts.mjs
8502 var index_parts_exports = {};
8503 __export(index_parts_exports, {
8504 Arrow: () => TooltipArrow,
8505 Handle: () => TooltipHandle,
8506 Popup: () => TooltipPopup,
8507 Portal: () => TooltipPortal,
8508 Positioner: () => TooltipPositioner,
8509 Provider: () => TooltipProvider,
8510 Root: () => TooltipRoot,
8511 Trigger: () => TooltipTrigger,
8512 Viewport: () => TooltipViewport,
8513 createHandle: () => createTooltipHandle
8514 });
8515
8516 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8517 var React37 = __toESM(require_react(), 1);
8518
8519 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
8520 var React35 = __toESM(require_react(), 1);
8521 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8522 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8523 function useTooltipRootContext(optional) {
8524 const context = React35.useContext(TooltipRootContext);
8525 if (context === void 0 && !optional) {
8526 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8527 }
8528 return context;
8529 }
8530
8531 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
8532 var React36 = __toESM(require_react(), 1);
8533 var selectors2 = {
8534 ...popupStoreSelectors,
8535 disabled: createSelector((state) => state.disabled),
8536 instantType: createSelector((state) => state.instantType),
8537 isInstantPhase: createSelector((state) => state.isInstantPhase),
8538 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8539 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8540 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8541 closeOnClick: createSelector((state) => state.closeOnClick),
8542 closeDelay: createSelector((state) => state.closeDelay),
8543 hasViewport: createSelector((state) => state.hasViewport)
8544 };
8545 var TooltipStore = class _TooltipStore extends ReactStore {
8546 constructor(initialState, floatingId, nested = false) {
8547 const triggerElements = new PopupTriggerMap();
8548 const state = {
8549 ...createInitialState(),
8550 ...initialState
8551 };
8552 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8553 super(state, {
8554 popupRef: /* @__PURE__ */ React36.createRef(),
8555 onOpenChange: void 0,
8556 onOpenChangeComplete: void 0,
8557 triggerElements
8558 }, selectors2);
8559 }
8560 setOpen = (nextOpen, eventDetails) => {
8561 applyPopupOpenChange(this, nextOpen, eventDetails, {
8562 extraState: {
8563 openChangeReason: eventDetails.reason
8564 }
8565 });
8566 };
8567 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8568 cancelPendingOpen(event) {
8569 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8570 }
8571 static useStore(externalStore, initialState) {
8572 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8573 return store;
8574 }
8575 };
8576 function createInitialState() {
8577 return {
8578 ...createInitialPopupStoreState(),
8579 disabled: false,
8580 instantType: void 0,
8581 isInstantPhase: false,
8582 trackCursorAxis: "none",
8583 disableHoverablePopup: false,
8584 openChangeReason: null,
8585 closeOnClick: true,
8586 closeDelay: 0,
8587 hasViewport: false
8588 };
8589 }
8590
8591 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8592 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8593 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8594 const {
8595 disabled: disabled2 = false,
8596 defaultOpen = false,
8597 open: openProp,
8598 disableHoverablePopup = false,
8599 trackCursorAxis = "none",
8600 actionsRef,
8601 onOpenChange,
8602 onOpenChangeComplete,
8603 handle,
8604 triggerId: triggerIdProp,
8605 defaultTriggerId: defaultTriggerIdProp = null,
8606 children
8607 } = props;
8608 const store = TooltipStore.useStore(handle?.store, {
8609 open: defaultOpen,
8610 openProp,
8611 activeTriggerId: defaultTriggerIdProp,
8612 triggerIdProp
8613 });
8614 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
8615 store.useControlledProp("openProp", openProp);
8616 store.useControlledProp("triggerIdProp", triggerIdProp);
8617 store.useContextCallback("onOpenChange", onOpenChange);
8618 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8619 const openState = store.useState("open");
8620 const open = !disabled2 && openState;
8621 const activeTriggerId = store.useState("activeTriggerId");
8622 const mounted = store.useState("mounted");
8623 const payload = store.useState("payload");
8624 store.useSyncedValues({
8625 trackCursorAxis,
8626 disableHoverablePopup
8627 });
8628 store.useSyncedValue("disabled", disabled2);
8629 useImplicitActiveTrigger(store, {
8630 closeOnActiveTriggerUnmount: true
8631 });
8632 const {
8633 forceUnmount,
8634 transitionStatus
8635 } = useOpenStateTransitions(open, store);
8636 const isInstantPhase = store.useState("isInstantPhase");
8637 const instantType = store.useState("instantType");
8638 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8639 const previousInstantTypeRef = React37.useRef(null);
8640 useIsoLayoutEffect(() => {
8641 if (openState && disabled2) {
8642 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8643 }
8644 }, [openState, disabled2, store]);
8645 useIsoLayoutEffect(() => {
8646 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8647 if (instantType !== "delay") {
8648 previousInstantTypeRef.current = instantType;
8649 }
8650 store.set("instantType", "delay");
8651 } else if (previousInstantTypeRef.current !== null) {
8652 store.set("instantType", previousInstantTypeRef.current);
8653 previousInstantTypeRef.current = null;
8654 }
8655 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8656 useIsoLayoutEffect(() => {
8657 if (open) {
8658 if (activeTriggerId == null) {
8659 store.set("payload", void 0);
8660 }
8661 }
8662 }, [store, activeTriggerId, open]);
8663 const handleImperativeClose = React37.useCallback(() => {
8664 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8665 }, [store]);
8666 React37.useImperativeHandle(actionsRef, () => ({
8667 unmount: forceUnmount,
8668 close: handleImperativeClose
8669 }), [forceUnmount, handleImperativeClose]);
8670 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8671 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8672 value: store,
8673 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8674 store,
8675 disabled: disabled2,
8676 trackCursorAxis
8677 }), typeof children === "function" ? children({
8678 payload
8679 }) : children]
8680 });
8681 });
8682 if (true) TooltipRoot.displayName = "TooltipRoot";
8683 function TooltipInteractions({
8684 store,
8685 disabled: disabled2,
8686 trackCursorAxis
8687 }) {
8688 const floatingRootContext = store.useState("floatingRootContext");
8689 const dismiss = useDismiss(floatingRootContext, {
8690 enabled: !disabled2,
8691 referencePress: () => store.select("closeOnClick")
8692 });
8693 const clientPoint = useClientPoint(floatingRootContext, {
8694 enabled: !disabled2 && trackCursorAxis !== "none",
8695 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8696 });
8697 const activeTriggerProps = React37.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8698 const inactiveTriggerProps = React37.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8699 const popupProps = React37.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8700 usePopupInteractionProps(store, {
8701 activeTriggerProps,
8702 inactiveTriggerProps,
8703 popupProps
8704 });
8705 return null;
8706 }
8707
8708 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8709 var React39 = __toESM(require_react(), 1);
8710
8711 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
8712 var React38 = __toESM(require_react(), 1);
8713 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8714 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8715 function useTooltipProviderContext() {
8716 return React38.useContext(TooltipProviderContext);
8717 }
8718
8719 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
8720 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8721 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8722 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8723 return TooltipTriggerDataAttributes2;
8724 })({});
8725
8726 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
8727 var OPEN_DELAY = 600;
8728
8729 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8730 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8731 function getTargetElement(event) {
8732 if ("composedPath" in event) {
8733 const path = event.composedPath();
8734 for (let i2 = 0; i2 < path.length; i2 += 1) {
8735 const element = path[i2];
8736 if (isElement(element)) {
8737 return element;
8738 }
8739 }
8740 }
8741 const target = event.target;
8742 if (isElement(target)) {
8743 return target;
8744 }
8745 return null;
8746 }
8747 function closestEnabledTooltipTrigger(element) {
8748 let current = element;
8749 while (current) {
8750 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8751 return current;
8752 }
8753 const parentElement = current.parentElement;
8754 if (parentElement) {
8755 current = parentElement;
8756 continue;
8757 }
8758 const root = current.getRootNode();
8759 current = "host" in root && isElement(root.host) ? root.host : null;
8760 }
8761 return null;
8762 }
8763 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8764 const {
8765 render: render4,
8766 className,
8767 style,
8768 handle,
8769 payload,
8770 disabled: disabledProp,
8771 delay,
8772 closeOnClick = true,
8773 closeDelay,
8774 id: idProp,
8775 ...elementProps
8776 } = componentProps;
8777 const rootContext = useTooltipRootContext(true);
8778 const store = handle?.store ?? rootContext;
8779 if (!store) {
8780 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));
8781 }
8782 const thisTriggerId = useBaseUiId(idProp);
8783 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8784 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8785 const floatingRootContext = store.useState("floatingRootContext");
8786 const triggerElementRef = React39.useRef(null);
8787 const delayWithDefault = delay ?? OPEN_DELAY;
8788 const closeDelayWithDefault = closeDelay ?? 0;
8789 const {
8790 registerTrigger,
8791 isMountedByThisTrigger
8792 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8793 payload,
8794 closeOnClick,
8795 closeDelay: closeDelayWithDefault
8796 });
8797 const providerContext = useTooltipProviderContext();
8798 const {
8799 delayRef,
8800 isInstantPhase,
8801 hasProvider
8802 } = useDelayGroup(floatingRootContext, {
8803 open: isOpenedByThisTrigger
8804 });
8805 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8806 store.useSyncedValue("isInstantPhase", isInstantPhase);
8807 const rootDisabled = store.useState("disabled");
8808 const disabled2 = disabledProp ?? rootDisabled;
8809 const disabledRef = useValueAsRef(disabled2);
8810 const trackCursorAxis = store.useState("trackCursorAxis");
8811 const disableHoverablePopup = store.useState("disableHoverablePopup");
8812 const isNestedTriggerHoveredRef = React39.useRef(false);
8813 const nestedTriggerOpenTimeout = useTimeout();
8814 const pointerTypeRef = React39.useRef(void 0);
8815 function getOpenDelay() {
8816 const providerDelay = providerContext?.delay;
8817 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8818 let computedOpenDelay = delayWithDefault;
8819 if (hasProvider) {
8820 if (groupOpenValue !== 0) {
8821 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8822 } else {
8823 computedOpenDelay = 0;
8824 }
8825 }
8826 return computedOpenDelay;
8827 }
8828 function isEnabledNestedTriggerTarget(target) {
8829 const triggerEl = triggerElementRef.current;
8830 if (!triggerEl || !target) {
8831 return false;
8832 }
8833 const nearestTrigger = closestEnabledTooltipTrigger(target);
8834 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8835 }
8836 function detectNestedTriggerHover(target) {
8837 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8838 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8839 if (nestedTriggerHovered) {
8840 hoverInteraction.openChangeTimeout.clear();
8841 hoverInteraction.restTimeout.clear();
8842 hoverInteraction.restTimeoutPending = false;
8843 nestedTriggerOpenTimeout.clear();
8844 }
8845 return nestedTriggerHovered;
8846 }
8847 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8848 enabled: !disabled2,
8849 mouseOnly: true,
8850 move: false,
8851 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8852 restMs: getOpenDelay,
8853 delay() {
8854 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8855 let computedCloseDelay = closeDelayWithDefault;
8856 if (closeDelay == null && hasProvider) {
8857 computedCloseDelay = closeValue;
8858 }
8859 return {
8860 close: computedCloseDelay
8861 };
8862 },
8863 triggerElementRef,
8864 isActiveTrigger: isTriggerActive,
8865 isClosing: () => store.select("transitionStatus") === "ending",
8866 shouldOpen() {
8867 return !isNestedTriggerHoveredRef.current;
8868 }
8869 });
8870 const focusProps = useFocus(floatingRootContext, {
8871 enabled: !disabled2
8872 }).reference;
8873 const handleNestedTriggerHover = (event) => {
8874 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8875 const target = getTargetElement(event);
8876 const nestedTriggerHovered = detectNestedTriggerHover(target);
8877 const triggerEl = triggerElementRef.current;
8878 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8879 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8880 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8881 return;
8882 }
8883 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8884 isMouseLikePointerType(pointerTypeRef.current)) {
8885 const open = () => {
8886 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8887 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8888 }
8889 };
8890 const openDelay = getOpenDelay();
8891 if (openDelay === 0) {
8892 nestedTriggerOpenTimeout.clear();
8893 open();
8894 } else {
8895 nestedTriggerOpenTimeout.start(openDelay, open);
8896 }
8897 }
8898 };
8899 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8900 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8901 const state = {
8902 open: isOpenedByThisTrigger
8903 };
8904 const element = useRenderElement("button", componentProps, {
8905 state,
8906 ref: [forwardedRef, registerTrigger, triggerElementRef],
8907 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8908 onMouseOver(event) {
8909 handleNestedTriggerHover(event.nativeEvent);
8910 },
8911 onFocus(event) {
8912 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8913 event.preventBaseUIHandler();
8914 }
8915 },
8916 onMouseLeave() {
8917 isNestedTriggerHoveredRef.current = false;
8918 nestedTriggerOpenTimeout.clear();
8919 pointerTypeRef.current = void 0;
8920 },
8921 onPointerEnter(event) {
8922 pointerTypeRef.current = event.pointerType;
8923 },
8924 onPointerDown(event) {
8925 pointerTypeRef.current = event.pointerType;
8926 store.set("closeOnClick", closeOnClick);
8927 if (closeOnClick && !store.select("open")) {
8928 store.cancelPendingOpen(event.nativeEvent);
8929 }
8930 },
8931 onClick(event) {
8932 if (closeOnClick && !store.select("open")) {
8933 store.cancelPendingOpen(event.nativeEvent);
8934 }
8935 },
8936 id: thisTriggerId,
8937 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8938 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8939 }, elementProps],
8940 stateAttributesMapping: triggerOpenStateMapping
8941 });
8942 return element;
8943 });
8944 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8945
8946 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8947 var React41 = __toESM(require_react(), 1);
8948
8949 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
8950 var React40 = __toESM(require_react(), 1);
8951 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8952 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8953 function useTooltipPortalContext() {
8954 const value = React40.useContext(TooltipPortalContext);
8955 if (value === void 0) {
8956 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8957 }
8958 return value;
8959 }
8960
8961 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8962 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8963 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8964 const {
8965 keepMounted = false,
8966 ...portalProps
8967 } = props;
8968 const store = useTooltipRootContext();
8969 const mounted = store.useState("mounted");
8970 const shouldRender = mounted || keepMounted;
8971 if (!shouldRender) {
8972 return null;
8973 }
8974 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8975 value: keepMounted,
8976 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8977 ref: forwardedRef,
8978 ...portalProps
8979 })
8980 });
8981 });
8982 if (true) TooltipPortal.displayName = "TooltipPortal";
8983
8984 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
8985 var React43 = __toESM(require_react(), 1);
8986
8987 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
8988 var React42 = __toESM(require_react(), 1);
8989 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8990 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8991 function useTooltipPositionerContext() {
8992 const context = React42.useContext(TooltipPositionerContext);
8993 if (context === void 0) {
8994 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8995 }
8996 return context;
8997 }
8998
8999 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9000 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9001 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9002 const {
9003 render: render4,
9004 className,
9005 anchor,
9006 positionMethod = "absolute",
9007 side = "top",
9008 align = "center",
9009 sideOffset = 0,
9010 alignOffset = 0,
9011 collisionBoundary = "clipping-ancestors",
9012 collisionPadding = 5,
9013 arrowPadding = 5,
9014 sticky = false,
9015 disableAnchorTracking = false,
9016 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9017 style,
9018 ...elementProps
9019 } = componentProps;
9020 const store = useTooltipRootContext();
9021 const keepMounted = useTooltipPortalContext();
9022 const open = store.useState("open");
9023 const mounted = store.useState("mounted");
9024 const trackCursorAxis = store.useState("trackCursorAxis");
9025 const disableHoverablePopup = store.useState("disableHoverablePopup");
9026 const floatingRootContext = store.useState("floatingRootContext");
9027 const instantType = store.useState("instantType");
9028 const transitionStatus = store.useState("transitionStatus");
9029 const hasViewport = store.useState("hasViewport");
9030 const positioning = useAnchorPositioning({
9031 anchor,
9032 positionMethod,
9033 floatingRootContext,
9034 mounted,
9035 side,
9036 sideOffset,
9037 align,
9038 alignOffset,
9039 collisionBoundary,
9040 collisionPadding,
9041 sticky,
9042 arrowPadding,
9043 disableAnchorTracking,
9044 keepMounted,
9045 collisionAvoidance,
9046 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9047 });
9048 const state = React43.useMemo(() => ({
9049 open,
9050 side: positioning.side,
9051 align: positioning.align,
9052 anchorHidden: positioning.anchorHidden,
9053 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9054 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9055 const element = usePositioner(componentProps, state, {
9056 styles: positioning.positionerStyles,
9057 transitionStatus,
9058 props: elementProps,
9059 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9060 hidden: !mounted,
9061 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9062 });
9063 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
9064 value: positioning,
9065 children: element
9066 });
9067 });
9068 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9069
9070 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9071 var React44 = __toESM(require_react(), 1);
9072 var stateAttributesMapping = {
9073 ...popupStateMapping,
9074 ...transitionStatusMapping
9075 };
9076 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9077 const {
9078 render: render4,
9079 className,
9080 style,
9081 ...elementProps
9082 } = componentProps;
9083 const store = useTooltipRootContext();
9084 const {
9085 side,
9086 align
9087 } = useTooltipPositionerContext();
9088 const open = store.useState("open");
9089 const instantType = store.useState("instantType");
9090 const transitionStatus = store.useState("transitionStatus");
9091 const popupProps = store.useState("popupProps");
9092 const floatingContext = store.useState("floatingRootContext");
9093 const disabled2 = store.useState("disabled");
9094 const closeDelay = store.useState("closeDelay");
9095 useOpenChangeComplete({
9096 open,
9097 ref: store.context.popupRef,
9098 onComplete() {
9099 if (open) {
9100 store.context.onOpenChangeComplete?.(true);
9101 }
9102 }
9103 });
9104 useHoverFloatingInteraction(floatingContext, {
9105 enabled: !disabled2,
9106 closeDelay
9107 });
9108 const setPopupElement = store.useStateSetter("popupElement");
9109 const state = {
9110 open,
9111 side,
9112 align,
9113 instant: instantType,
9114 transitionStatus
9115 };
9116 const element = useRenderElement("div", componentProps, {
9117 state,
9118 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9119 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9120 stateAttributesMapping
9121 });
9122 return element;
9123 });
9124 if (true) TooltipPopup.displayName = "TooltipPopup";
9125
9126 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9127 var React45 = __toESM(require_react(), 1);
9128 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9129 const {
9130 render: render4,
9131 className,
9132 style,
9133 ...elementProps
9134 } = componentProps;
9135 const store = useTooltipRootContext();
9136 const {
9137 arrowRef,
9138 side,
9139 align,
9140 arrowUncentered,
9141 arrowStyles
9142 } = useTooltipPositionerContext();
9143 const open = store.useState("open");
9144 const instantType = store.useState("instantType");
9145 const state = {
9146 open,
9147 side,
9148 align,
9149 uncentered: arrowUncentered,
9150 instant: instantType
9151 };
9152 const element = useRenderElement("div", componentProps, {
9153 state,
9154 ref: [forwardedRef, arrowRef],
9155 props: [{
9156 style: arrowStyles,
9157 "aria-hidden": true
9158 }, elementProps],
9159 stateAttributesMapping: popupStateMapping
9160 });
9161 return element;
9162 });
9163 if (true) TooltipArrow.displayName = "TooltipArrow";
9164
9165 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9166 var React46 = __toESM(require_react(), 1);
9167 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9168 var TooltipProvider = function TooltipProvider2(props) {
9169 const {
9170 delay,
9171 closeDelay,
9172 timeout = 400
9173 } = props;
9174 const contextValue = React46.useMemo(() => ({
9175 delay,
9176 closeDelay
9177 }), [delay, closeDelay]);
9178 const delayValue = React46.useMemo(() => ({
9179 open: delay,
9180 close: closeDelay
9181 }), [delay, closeDelay]);
9182 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
9183 value: contextValue,
9184 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
9185 delay: delayValue,
9186 timeoutMs: timeout,
9187 children: props.children
9188 })
9189 });
9190 };
9191 if (true) TooltipProvider.displayName = "TooltipProvider";
9192
9193 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9194 var React47 = __toESM(require_react(), 1);
9195
9196 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9197 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9198 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9199 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9200 return TooltipViewportCssVars2;
9201 })({});
9202
9203 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9204 var stateAttributesMapping2 = {
9205 activationDirection: (value) => value ? {
9206 "data-activation-direction": value
9207 } : null
9208 };
9209 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9210 const {
9211 render: render4,
9212 className,
9213 style,
9214 children,
9215 ...elementProps
9216 } = componentProps;
9217 const store = useTooltipRootContext();
9218 const positioner = useTooltipPositionerContext();
9219 const instantType = store.useState("instantType");
9220 const {
9221 children: childrenToRender,
9222 state: viewportState
9223 } = usePopupViewport({
9224 store,
9225 side: positioner.side,
9226 cssVars: TooltipViewportCssVars,
9227 children
9228 });
9229 const state = {
9230 activationDirection: viewportState.activationDirection,
9231 transitioning: viewportState.transitioning,
9232 instant: instantType
9233 };
9234 return useRenderElement("div", componentProps, {
9235 state,
9236 ref: forwardedRef,
9237 props: [elementProps, {
9238 children: childrenToRender
9239 }],
9240 stateAttributesMapping: stateAttributesMapping2
9241 });
9242 });
9243 if (true) TooltipViewport.displayName = "TooltipViewport";
9244
9245 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9246 var TooltipHandle = class {
9247 /**
9248 * Internal store holding the tooltip state.
9249 * @internal
9250 */
9251 constructor() {
9252 this.store = new TooltipStore();
9253 }
9254 /**
9255 * Opens the tooltip and associates it with the trigger with the given ID.
9256 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9257 *
9258 * This method should only be called in an event handler or an effect (not during rendering).
9259 *
9260 * @param triggerId ID of the trigger to associate with the tooltip.
9261 */
9262 open(triggerId) {
9263 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9264 if (triggerId && !triggerElement) {
9265 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9266 }
9267 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9268 }
9269 /**
9270 * Closes the tooltip.
9271 */
9272 close() {
9273 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9274 }
9275 /**
9276 * Indicates whether the tooltip is currently open.
9277 */
9278 get isOpen() {
9279 return this.store.select("open");
9280 }
9281 };
9282 function createTooltipHandle() {
9283 return new TooltipHandle();
9284 }
9285
9286 // node_modules/@base-ui/react/use-render/useRender.mjs
9287 function useRender(params) {
9288 return useRenderElement(params.defaultTagName ?? "div", params, params);
9289 }
9290
9291 // packages/ui/build-module/text/text.mjs
9292 var import_element11 = __toESM(require_element(), 1);
9293 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9294 function getRuntime() {
9295 const globalScope = globalThis;
9296 if (globalScope.__wpStyleRuntime) {
9297 return globalScope.__wpStyleRuntime;
9298 }
9299 globalScope.__wpStyleRuntime = {
9300 documents: /* @__PURE__ */ new Map(),
9301 styles: /* @__PURE__ */ new Map(),
9302 injectedStyles: /* @__PURE__ */ new WeakMap()
9303 };
9304 if (typeof document !== "undefined") {
9305 registerDocument(document);
9306 }
9307 return globalScope.__wpStyleRuntime;
9308 }
9309 function documentContainsStyleHash(targetDocument, hash) {
9310 if (!targetDocument.head) {
9311 return false;
9312 }
9313 for (const style of targetDocument.head.querySelectorAll(
9314 `style[${STYLE_HASH_ATTRIBUTE}]`
9315 )) {
9316 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9317 return true;
9318 }
9319 }
9320 return false;
9321 }
9322 function injectStyle(targetDocument, hash, css) {
9323 if (!targetDocument.head) {
9324 return;
9325 }
9326 const runtime = getRuntime();
9327 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9328 if (!injectedStyles) {
9329 injectedStyles = /* @__PURE__ */ new Set();
9330 runtime.injectedStyles.set(targetDocument, injectedStyles);
9331 }
9332 if (injectedStyles.has(hash)) {
9333 return;
9334 }
9335 if (documentContainsStyleHash(targetDocument, hash)) {
9336 injectedStyles.add(hash);
9337 return;
9338 }
9339 const style = targetDocument.createElement("style");
9340 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9341 style.appendChild(targetDocument.createTextNode(css));
9342 targetDocument.head.appendChild(style);
9343 injectedStyles.add(hash);
9344 }
9345 function registerDocument(targetDocument) {
9346 const runtime = getRuntime();
9347 runtime.documents.set(
9348 targetDocument,
9349 (runtime.documents.get(targetDocument) ?? 0) + 1
9350 );
9351 for (const [hash, css] of runtime.styles) {
9352 injectStyle(targetDocument, hash, css);
9353 }
9354 return () => {
9355 const count = runtime.documents.get(targetDocument);
9356 if (count === void 0) {
9357 return;
9358 }
9359 if (count <= 1) {
9360 runtime.documents.delete(targetDocument);
9361 return;
9362 }
9363 runtime.documents.set(targetDocument, count - 1);
9364 };
9365 }
9366 function registerStyle(hash, css) {
9367 const runtime = getRuntime();
9368 runtime.styles.set(hash, css);
9369 for (const targetDocument of runtime.documents.keys()) {
9370 injectStyle(targetDocument, hash, css);
9371 }
9372 }
9373 if (typeof process === "undefined" || true) {
9374 registerStyle("a495f9d138", '@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-emphasis,600);--_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-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_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-emphasis,600);--_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-emphasis,600);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-emphasis,600);--_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-emphasis,600);--_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-emphasis,600);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-default,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-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,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-default,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-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,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)}}}');
9375 }
9376 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" };
9377 if (typeof process === "undefined" || true) {
9378 registerStyle("af6d9984a6", "._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-emphasis,600));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)}");
9379 }
9380 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" };
9381 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9382 const element = useRender({
9383 render: render4,
9384 defaultTagName: "span",
9385 ref,
9386 props: mergeProps(props, {
9387 className: clsx_default(
9388 style_default.text,
9389 global_css_defense_default.heading,
9390 global_css_defense_default.p,
9391 style_default[variant],
9392 className
9393 )
9394 })
9395 });
9396 return element;
9397 });
9398
9399 // packages/icons/build-module/library/arrow-down.mjs
9400 var import_primitives = __toESM(require_primitives(), 1);
9401 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9402 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" }) });
9403
9404 // packages/icons/build-module/library/arrow-left.mjs
9405 var import_primitives2 = __toESM(require_primitives(), 1);
9406 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9407 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" }) });
9408
9409 // packages/icons/build-module/library/arrow-right.mjs
9410 var import_primitives3 = __toESM(require_primitives(), 1);
9411 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9412 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" }) });
9413
9414 // packages/icons/build-module/library/arrow-up.mjs
9415 var import_primitives4 = __toESM(require_primitives(), 1);
9416 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9417 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" }) });
9418
9419 // packages/icons/build-module/library/block-table.mjs
9420 var import_primitives5 = __toESM(require_primitives(), 1);
9421 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9422 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" }) });
9423
9424 // packages/icons/build-module/library/category.mjs
9425 var import_primitives6 = __toESM(require_primitives(), 1);
9426 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9427 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" }) });
9428
9429 // packages/icons/build-module/library/check.mjs
9430 var import_primitives7 = __toESM(require_primitives(), 1);
9431 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9432 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" }) });
9433
9434 // packages/icons/build-module/library/close-small.mjs
9435 var import_primitives8 = __toESM(require_primitives(), 1);
9436 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9437 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" }) });
9438
9439 // packages/icons/build-module/library/cog.mjs
9440 var import_primitives9 = __toESM(require_primitives(), 1);
9441 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9442 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" }) });
9443
9444 // packages/icons/build-module/library/envelope.mjs
9445 var import_primitives10 = __toESM(require_primitives(), 1);
9446 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9447 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" }) });
9448
9449 // packages/icons/build-module/library/error.mjs
9450 var import_primitives11 = __toESM(require_primitives(), 1);
9451 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9452 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" }) });
9453
9454 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9455 var import_primitives12 = __toESM(require_primitives(), 1);
9456 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9457 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" }) });
9458
9459 // packages/icons/build-module/library/format-list-bullets.mjs
9460 var import_primitives13 = __toESM(require_primitives(), 1);
9461 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9462 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" }) });
9463
9464 // packages/icons/build-module/library/funnel.mjs
9465 var import_primitives14 = __toESM(require_primitives(), 1);
9466 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9467 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" }) });
9468
9469 // packages/icons/build-module/library/link.mjs
9470 var import_primitives15 = __toESM(require_primitives(), 1);
9471 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9472 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" }) });
9473
9474 // packages/icons/build-module/library/mobile.mjs
9475 var import_primitives16 = __toESM(require_primitives(), 1);
9476 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9477 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" }) });
9478
9479 // packages/icons/build-module/library/more-vertical.mjs
9480 var import_primitives17 = __toESM(require_primitives(), 1);
9481 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9482 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" }) });
9483
9484 // packages/icons/build-module/library/next.mjs
9485 var import_primitives18 = __toESM(require_primitives(), 1);
9486 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9487 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" }) });
9488
9489 // packages/icons/build-module/library/previous.mjs
9490 var import_primitives19 = __toESM(require_primitives(), 1);
9491 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9492 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" }) });
9493
9494 // packages/icons/build-module/library/scheduled.mjs
9495 var import_primitives20 = __toESM(require_primitives(), 1);
9496 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9497 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" }) });
9498
9499 // packages/icons/build-module/library/search.mjs
9500 var import_primitives21 = __toESM(require_primitives(), 1);
9501 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9502 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" }) });
9503
9504 // packages/icons/build-module/library/seen.mjs
9505 var import_primitives22 = __toESM(require_primitives(), 1);
9506 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9507 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" }) });
9508
9509 // packages/icons/build-module/library/unseen.mjs
9510 var import_primitives23 = __toESM(require_primitives(), 1);
9511 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9512 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" }) });
9513
9514 // packages/ui/build-module/utils/render-slot-with-children.mjs
9515 var import_element12 = __toESM(require_element(), 1);
9516 function renderSlotWithChildren(slot, defaultSlot, children) {
9517 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9518 }
9519
9520 // packages/ui/build-module/utils/theme-provider.mjs
9521 var theme = __toESM(require_theme(), 1);
9522
9523 // packages/ui/build-module/lock-unlock.mjs
9524 var import_private_apis2 = __toESM(require_private_apis(), 1);
9525 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9526 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9527 "@wordpress/ui"
9528 );
9529
9530 // packages/ui/build-module/utils/theme-provider.mjs
9531 function getThemeProvider() {
9532 const themePackage = theme;
9533 if (themePackage.ThemeProvider) {
9534 return themePackage.ThemeProvider;
9535 }
9536 if (!themePackage.privateApis) {
9537 throw new Error(
9538 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9539 );
9540 }
9541 return unlock2(
9542 themePackage.privateApis
9543 ).ThemeProvider;
9544 }
9545 var ThemeProvider = getThemeProvider();
9546
9547 // packages/ui/build-module/stack/stack.mjs
9548 var import_element13 = __toESM(require_element(), 1);
9549 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9550 function getRuntime2() {
9551 const globalScope = globalThis;
9552 if (globalScope.__wpStyleRuntime) {
9553 return globalScope.__wpStyleRuntime;
9554 }
9555 globalScope.__wpStyleRuntime = {
9556 documents: /* @__PURE__ */ new Map(),
9557 styles: /* @__PURE__ */ new Map(),
9558 injectedStyles: /* @__PURE__ */ new WeakMap()
9559 };
9560 if (typeof document !== "undefined") {
9561 registerDocument2(document);
9562 }
9563 return globalScope.__wpStyleRuntime;
9564 }
9565 function documentContainsStyleHash2(targetDocument, hash) {
9566 if (!targetDocument.head) {
9567 return false;
9568 }
9569 for (const style of targetDocument.head.querySelectorAll(
9570 `style[${STYLE_HASH_ATTRIBUTE2}]`
9571 )) {
9572 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9573 return true;
9574 }
9575 }
9576 return false;
9577 }
9578 function injectStyle2(targetDocument, hash, css) {
9579 if (!targetDocument.head) {
9580 return;
9581 }
9582 const runtime = getRuntime2();
9583 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9584 if (!injectedStyles) {
9585 injectedStyles = /* @__PURE__ */ new Set();
9586 runtime.injectedStyles.set(targetDocument, injectedStyles);
9587 }
9588 if (injectedStyles.has(hash)) {
9589 return;
9590 }
9591 if (documentContainsStyleHash2(targetDocument, hash)) {
9592 injectedStyles.add(hash);
9593 return;
9594 }
9595 const style = targetDocument.createElement("style");
9596 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9597 style.appendChild(targetDocument.createTextNode(css));
9598 targetDocument.head.appendChild(style);
9599 injectedStyles.add(hash);
9600 }
9601 function registerDocument2(targetDocument) {
9602 const runtime = getRuntime2();
9603 runtime.documents.set(
9604 targetDocument,
9605 (runtime.documents.get(targetDocument) ?? 0) + 1
9606 );
9607 for (const [hash, css] of runtime.styles) {
9608 injectStyle2(targetDocument, hash, css);
9609 }
9610 return () => {
9611 const count = runtime.documents.get(targetDocument);
9612 if (count === void 0) {
9613 return;
9614 }
9615 if (count <= 1) {
9616 runtime.documents.delete(targetDocument);
9617 return;
9618 }
9619 runtime.documents.set(targetDocument, count - 1);
9620 };
9621 }
9622 function registerStyle2(hash, css) {
9623 const runtime = getRuntime2();
9624 runtime.styles.set(hash, css);
9625 for (const targetDocument of runtime.documents.keys()) {
9626 injectStyle2(targetDocument, hash, css);
9627 }
9628 }
9629 if (typeof process === "undefined" || true) {
9630 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9631 }
9632 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9633 var gapTokens = {
9634 xs: "var(--wpds-dimension-gap-xs, 4px)",
9635 sm: "var(--wpds-dimension-gap-sm, 8px)",
9636 md: "var(--wpds-dimension-gap-md, 12px)",
9637 lg: "var(--wpds-dimension-gap-lg, 16px)",
9638 xl: "var(--wpds-dimension-gap-xl, 24px)",
9639 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9640 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9641 };
9642 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9643 const style = {
9644 gap: gap && gapTokens[gap],
9645 alignItems: align,
9646 justifyContent: justify,
9647 flexDirection: direction,
9648 flexWrap: wrap
9649 };
9650 const element = useRender({
9651 render: render4,
9652 ref,
9653 props: mergeProps(props, { style, className: style_default2.stack })
9654 });
9655 return element;
9656 });
9657
9658 // packages/ui/build-module/tooltip/index.mjs
9659 var tooltip_exports = {};
9660 __export(tooltip_exports, {
9661 Popup: () => Popup,
9662 Portal: () => Portal,
9663 Positioner: () => Positioner,
9664 Provider: () => Provider,
9665 Root: () => Root,
9666 Trigger: () => Trigger
9667 });
9668
9669 // packages/ui/build-module/tooltip/popup.mjs
9670 var import_element16 = __toESM(require_element(), 1);
9671
9672 // packages/ui/build-module/tooltip/portal.mjs
9673 var import_element14 = __toESM(require_element(), 1);
9674
9675 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9676 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9677 function getRuntime3() {
9678 const globalScope = globalThis;
9679 if (globalScope.__wpStyleRuntime) {
9680 return globalScope.__wpStyleRuntime;
9681 }
9682 globalScope.__wpStyleRuntime = {
9683 documents: /* @__PURE__ */ new Map(),
9684 styles: /* @__PURE__ */ new Map(),
9685 injectedStyles: /* @__PURE__ */ new WeakMap()
9686 };
9687 if (typeof document !== "undefined") {
9688 registerDocument3(document);
9689 }
9690 return globalScope.__wpStyleRuntime;
9691 }
9692 function documentContainsStyleHash3(targetDocument, hash) {
9693 if (!targetDocument.head) {
9694 return false;
9695 }
9696 for (const style of targetDocument.head.querySelectorAll(
9697 `style[${STYLE_HASH_ATTRIBUTE3}]`
9698 )) {
9699 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9700 return true;
9701 }
9702 }
9703 return false;
9704 }
9705 function injectStyle3(targetDocument, hash, css) {
9706 if (!targetDocument.head) {
9707 return;
9708 }
9709 const runtime = getRuntime3();
9710 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9711 if (!injectedStyles) {
9712 injectedStyles = /* @__PURE__ */ new Set();
9713 runtime.injectedStyles.set(targetDocument, injectedStyles);
9714 }
9715 if (injectedStyles.has(hash)) {
9716 return;
9717 }
9718 if (documentContainsStyleHash3(targetDocument, hash)) {
9719 injectedStyles.add(hash);
9720 return;
9721 }
9722 const style = targetDocument.createElement("style");
9723 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9724 style.appendChild(targetDocument.createTextNode(css));
9725 targetDocument.head.appendChild(style);
9726 injectedStyles.add(hash);
9727 }
9728 function registerDocument3(targetDocument) {
9729 const runtime = getRuntime3();
9730 runtime.documents.set(
9731 targetDocument,
9732 (runtime.documents.get(targetDocument) ?? 0) + 1
9733 );
9734 for (const [hash, css] of runtime.styles) {
9735 injectStyle3(targetDocument, hash, css);
9736 }
9737 return () => {
9738 const count = runtime.documents.get(targetDocument);
9739 if (count === void 0) {
9740 return;
9741 }
9742 if (count <= 1) {
9743 runtime.documents.delete(targetDocument);
9744 return;
9745 }
9746 runtime.documents.set(targetDocument, count - 1);
9747 };
9748 }
9749 function registerStyle3(hash, css) {
9750 const runtime = getRuntime3();
9751 runtime.styles.set(hash, css);
9752 for (const targetDocument of runtime.documents.keys()) {
9753 injectStyle3(targetDocument, hash, css);
9754 }
9755 }
9756 if (typeof process === "undefined" || true) {
9757 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}}}");
9758 }
9759 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9760 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9761 function resolveOwnerDocument() {
9762 return typeof document === "undefined" ? null : document;
9763 }
9764 function isInWordPressEnvironment() {
9765 let topWp;
9766 try {
9767 topWp = window.top?.wp;
9768 } catch {
9769 }
9770 const wp = topWp ?? window.wp;
9771 return typeof wp?.components === "object" && wp.components !== null;
9772 }
9773 var cachedSlot = null;
9774 function ensureSlotIsAccessible(element) {
9775 element.setAttribute("aria-hidden", "false");
9776 return element;
9777 }
9778 function createSlot(ownerDocument2) {
9779 const element = ownerDocument2.createElement("div");
9780 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9781 if (wp_compat_overlay_slot_default.slot) {
9782 element.classList.add(wp_compat_overlay_slot_default.slot);
9783 }
9784 ownerDocument2.body.appendChild(element);
9785 return element;
9786 }
9787 function getWpCompatOverlaySlot() {
9788 if (typeof window === "undefined") {
9789 return void 0;
9790 }
9791 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9792 return void 0;
9793 }
9794 const ownerDocument2 = resolveOwnerDocument();
9795 if (!ownerDocument2 || !ownerDocument2.body) {
9796 return void 0;
9797 }
9798 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9799 return ensureSlotIsAccessible(cachedSlot);
9800 }
9801 const existing = ownerDocument2.querySelector(
9802 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9803 );
9804 if (existing instanceof HTMLDivElement) {
9805 cachedSlot = ensureSlotIsAccessible(existing);
9806 return cachedSlot;
9807 }
9808 if (cachedSlot?.isConnected) {
9809 cachedSlot.remove();
9810 }
9811 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
9812 return cachedSlot;
9813 }
9814
9815 // packages/ui/build-module/tooltip/portal.mjs
9816 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9817 var Portal = (0, import_element14.forwardRef)(
9818 function TooltipPortal3({ container, ...restProps }, ref) {
9819 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9820 index_parts_exports.Portal,
9821 {
9822 container: container ?? getWpCompatOverlaySlot(),
9823 ...restProps,
9824 ref
9825 }
9826 );
9827 }
9828 );
9829
9830 // packages/ui/build-module/tooltip/positioner.mjs
9831 var import_element15 = __toESM(require_element(), 1);
9832 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9833 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9834 function getRuntime4() {
9835 const globalScope = globalThis;
9836 if (globalScope.__wpStyleRuntime) {
9837 return globalScope.__wpStyleRuntime;
9838 }
9839 globalScope.__wpStyleRuntime = {
9840 documents: /* @__PURE__ */ new Map(),
9841 styles: /* @__PURE__ */ new Map(),
9842 injectedStyles: /* @__PURE__ */ new WeakMap()
9843 };
9844 if (typeof document !== "undefined") {
9845 registerDocument4(document);
9846 }
9847 return globalScope.__wpStyleRuntime;
9848 }
9849 function documentContainsStyleHash4(targetDocument, hash) {
9850 if (!targetDocument.head) {
9851 return false;
9852 }
9853 for (const style of targetDocument.head.querySelectorAll(
9854 `style[${STYLE_HASH_ATTRIBUTE4}]`
9855 )) {
9856 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9857 return true;
9858 }
9859 }
9860 return false;
9861 }
9862 function injectStyle4(targetDocument, hash, css) {
9863 if (!targetDocument.head) {
9864 return;
9865 }
9866 const runtime = getRuntime4();
9867 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9868 if (!injectedStyles) {
9869 injectedStyles = /* @__PURE__ */ new Set();
9870 runtime.injectedStyles.set(targetDocument, injectedStyles);
9871 }
9872 if (injectedStyles.has(hash)) {
9873 return;
9874 }
9875 if (documentContainsStyleHash4(targetDocument, hash)) {
9876 injectedStyles.add(hash);
9877 return;
9878 }
9879 const style = targetDocument.createElement("style");
9880 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9881 style.appendChild(targetDocument.createTextNode(css));
9882 targetDocument.head.appendChild(style);
9883 injectedStyles.add(hash);
9884 }
9885 function registerDocument4(targetDocument) {
9886 const runtime = getRuntime4();
9887 runtime.documents.set(
9888 targetDocument,
9889 (runtime.documents.get(targetDocument) ?? 0) + 1
9890 );
9891 for (const [hash, css] of runtime.styles) {
9892 injectStyle4(targetDocument, hash, css);
9893 }
9894 return () => {
9895 const count = runtime.documents.get(targetDocument);
9896 if (count === void 0) {
9897 return;
9898 }
9899 if (count <= 1) {
9900 runtime.documents.delete(targetDocument);
9901 return;
9902 }
9903 runtime.documents.set(targetDocument, count - 1);
9904 };
9905 }
9906 function registerStyle4(hash, css) {
9907 const runtime = getRuntime4();
9908 runtime.styles.set(hash, css);
9909 for (const targetDocument of runtime.documents.keys()) {
9910 injectStyle4(targetDocument, hash, css);
9911 }
9912 }
9913 if (typeof process === "undefined" || true) {
9914 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9915 }
9916 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9917 if (typeof process === "undefined" || true) {
9918 registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);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}}}}');
9919 }
9920 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9921 var Positioner = (0, import_element15.forwardRef)(
9922 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9923 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9924 index_parts_exports.Positioner,
9925 {
9926 ref,
9927 align,
9928 side,
9929 sideOffset,
9930 ...props,
9931 className: clsx_default(
9932 resets_default["box-sizing"],
9933 style_default3.positioner,
9934 className
9935 )
9936 }
9937 );
9938 }
9939 );
9940
9941 // packages/ui/build-module/tooltip/popup.mjs
9942 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9943 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9944 function getRuntime5() {
9945 const globalScope = globalThis;
9946 if (globalScope.__wpStyleRuntime) {
9947 return globalScope.__wpStyleRuntime;
9948 }
9949 globalScope.__wpStyleRuntime = {
9950 documents: /* @__PURE__ */ new Map(),
9951 styles: /* @__PURE__ */ new Map(),
9952 injectedStyles: /* @__PURE__ */ new WeakMap()
9953 };
9954 if (typeof document !== "undefined") {
9955 registerDocument5(document);
9956 }
9957 return globalScope.__wpStyleRuntime;
9958 }
9959 function documentContainsStyleHash5(targetDocument, hash) {
9960 if (!targetDocument.head) {
9961 return false;
9962 }
9963 for (const style of targetDocument.head.querySelectorAll(
9964 `style[${STYLE_HASH_ATTRIBUTE5}]`
9965 )) {
9966 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9967 return true;
9968 }
9969 }
9970 return false;
9971 }
9972 function injectStyle5(targetDocument, hash, css) {
9973 if (!targetDocument.head) {
9974 return;
9975 }
9976 const runtime = getRuntime5();
9977 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9978 if (!injectedStyles) {
9979 injectedStyles = /* @__PURE__ */ new Set();
9980 runtime.injectedStyles.set(targetDocument, injectedStyles);
9981 }
9982 if (injectedStyles.has(hash)) {
9983 return;
9984 }
9985 if (documentContainsStyleHash5(targetDocument, hash)) {
9986 injectedStyles.add(hash);
9987 return;
9988 }
9989 const style = targetDocument.createElement("style");
9990 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9991 style.appendChild(targetDocument.createTextNode(css));
9992 targetDocument.head.appendChild(style);
9993 injectedStyles.add(hash);
9994 }
9995 function registerDocument5(targetDocument) {
9996 const runtime = getRuntime5();
9997 runtime.documents.set(
9998 targetDocument,
9999 (runtime.documents.get(targetDocument) ?? 0) + 1
10000 );
10001 for (const [hash, css] of runtime.styles) {
10002 injectStyle5(targetDocument, hash, css);
10003 }
10004 return () => {
10005 const count = runtime.documents.get(targetDocument);
10006 if (count === void 0) {
10007 return;
10008 }
10009 if (count <= 1) {
10010 runtime.documents.delete(targetDocument);
10011 return;
10012 }
10013 runtime.documents.set(targetDocument, count - 1);
10014 };
10015 }
10016 function registerStyle5(hash, css) {
10017 const runtime = getRuntime5();
10018 runtime.styles.set(hash, css);
10019 for (const targetDocument of runtime.documents.keys()) {
10020 injectStyle5(targetDocument, hash, css);
10021 }
10022 }
10023 if (typeof process === "undefined" || true) {
10024 registerStyle5("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);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}}}}');
10025 }
10026 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10027 var POPUP_COLOR = { background: "#1e1e1e" };
10028 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10029 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
10030 index_parts_exports.Popup,
10031 {
10032 ref,
10033 className: clsx_default(style_default4.popup, className),
10034 ...props,
10035 children
10036 }
10037 ) });
10038 const positionedPopup = renderSlotWithChildren(
10039 positioner,
10040 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
10041 popupContent
10042 );
10043 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
10044 });
10045
10046 // packages/ui/build-module/tooltip/trigger.mjs
10047 var import_element17 = __toESM(require_element(), 1);
10048 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10049 var Trigger = (0, import_element17.forwardRef)(
10050 function TooltipTrigger3(props, ref) {
10051 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
10052 }
10053 );
10054
10055 // packages/ui/build-module/tooltip/root.mjs
10056 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10057 function Root(props) {
10058 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
10059 }
10060
10061 // packages/ui/build-module/tooltip/provider.mjs
10062 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10063 function Provider({ ...props }) {
10064 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
10065 }
10066
10067 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10068 var import_element18 = __toESM(require_element(), 1);
10069 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10070 function getRuntime6() {
10071 const globalScope = globalThis;
10072 if (globalScope.__wpStyleRuntime) {
10073 return globalScope.__wpStyleRuntime;
10074 }
10075 globalScope.__wpStyleRuntime = {
10076 documents: /* @__PURE__ */ new Map(),
10077 styles: /* @__PURE__ */ new Map(),
10078 injectedStyles: /* @__PURE__ */ new WeakMap()
10079 };
10080 if (typeof document !== "undefined") {
10081 registerDocument6(document);
10082 }
10083 return globalScope.__wpStyleRuntime;
10084 }
10085 function documentContainsStyleHash6(targetDocument, hash) {
10086 if (!targetDocument.head) {
10087 return false;
10088 }
10089 for (const style of targetDocument.head.querySelectorAll(
10090 `style[${STYLE_HASH_ATTRIBUTE6}]`
10091 )) {
10092 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10093 return true;
10094 }
10095 }
10096 return false;
10097 }
10098 function injectStyle6(targetDocument, hash, css) {
10099 if (!targetDocument.head) {
10100 return;
10101 }
10102 const runtime = getRuntime6();
10103 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10104 if (!injectedStyles) {
10105 injectedStyles = /* @__PURE__ */ new Set();
10106 runtime.injectedStyles.set(targetDocument, injectedStyles);
10107 }
10108 if (injectedStyles.has(hash)) {
10109 return;
10110 }
10111 if (documentContainsStyleHash6(targetDocument, hash)) {
10112 injectedStyles.add(hash);
10113 return;
10114 }
10115 const style = targetDocument.createElement("style");
10116 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10117 style.appendChild(targetDocument.createTextNode(css));
10118 targetDocument.head.appendChild(style);
10119 injectedStyles.add(hash);
10120 }
10121 function registerDocument6(targetDocument) {
10122 const runtime = getRuntime6();
10123 runtime.documents.set(
10124 targetDocument,
10125 (runtime.documents.get(targetDocument) ?? 0) + 1
10126 );
10127 for (const [hash, css] of runtime.styles) {
10128 injectStyle6(targetDocument, hash, css);
10129 }
10130 return () => {
10131 const count = runtime.documents.get(targetDocument);
10132 if (count === void 0) {
10133 return;
10134 }
10135 if (count <= 1) {
10136 runtime.documents.delete(targetDocument);
10137 return;
10138 }
10139 runtime.documents.set(targetDocument, count - 1);
10140 };
10141 }
10142 function registerStyle6(hash, css) {
10143 const runtime = getRuntime6();
10144 runtime.styles.set(hash, css);
10145 for (const targetDocument of runtime.documents.keys()) {
10146 injectStyle6(targetDocument, hash, css);
10147 }
10148 }
10149 if (typeof process === "undefined" || true) {
10150 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}}}");
10151 }
10152 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10153 var VisuallyHidden = (0, import_element18.forwardRef)(
10154 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10155 const element = useRender({
10156 render: render4,
10157 ref,
10158 props: mergeProps(
10159 { className: style_default5["visually-hidden"] },
10160 restProps,
10161 {
10162 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10163 "data-visually-hidden": ""
10164 }
10165 )
10166 });
10167 return element;
10168 }
10169 );
10170
10171 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10172 var import_element19 = __toESM(require_element(), 1);
10173
10174 // packages/dataviews/build-module/constants.mjs
10175 var import_i18n = __toESM(require_i18n(), 1);
10176 var OPERATOR_IS_ANY = "isAny";
10177 var OPERATOR_IS_NONE = "isNone";
10178 var OPERATOR_IS_ALL = "isAll";
10179 var OPERATOR_IS_NOT_ALL = "isNotAll";
10180 var OPERATOR_BETWEEN = "between";
10181 var OPERATOR_IN_THE_PAST = "inThePast";
10182 var OPERATOR_OVER = "over";
10183 var OPERATOR_IS = "is";
10184 var OPERATOR_IS_NOT = "isNot";
10185 var OPERATOR_LESS_THAN = "lessThan";
10186 var OPERATOR_GREATER_THAN = "greaterThan";
10187 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10188 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10189 var OPERATOR_BEFORE = "before";
10190 var OPERATOR_AFTER = "after";
10191 var OPERATOR_BEFORE_INC = "beforeInc";
10192 var OPERATOR_AFTER_INC = "afterInc";
10193 var OPERATOR_CONTAINS = "contains";
10194 var OPERATOR_NOT_CONTAINS = "notContains";
10195 var OPERATOR_STARTS_WITH = "startsWith";
10196 var OPERATOR_ON = "on";
10197 var OPERATOR_NOT_ON = "notOn";
10198 var SORTING_DIRECTIONS = ["asc", "desc"];
10199 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10200 var sortValues = { asc: "ascending", desc: "descending" };
10201 var sortLabels = {
10202 asc: (0, import_i18n.__)("Sort ascending"),
10203 desc: (0, import_i18n.__)("Sort descending")
10204 };
10205 var sortIcons = {
10206 asc: arrow_up_default,
10207 desc: arrow_down_default
10208 };
10209 var LAYOUT_TABLE = "table";
10210 var LAYOUT_GRID = "grid";
10211 var LAYOUT_LIST = "list";
10212 var LAYOUT_ACTIVITY = "activity";
10213 var LAYOUT_PICKER_GRID = "pickerGrid";
10214 var LAYOUT_PICKER_TABLE = "pickerTable";
10215 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10216
10217 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10218 var DataViewsContext = (0, import_element19.createContext)({
10219 view: { type: LAYOUT_TABLE },
10220 onChangeView: () => {
10221 },
10222 fields: [],
10223 data: [],
10224 paginationInfo: {
10225 totalItems: 0,
10226 totalPages: 0
10227 },
10228 selection: [],
10229 onChangeSelection: () => {
10230 },
10231 setOpenedFilter: () => {
10232 },
10233 openedFilter: null,
10234 getItemId: (item) => item.id,
10235 isItemClickable: () => true,
10236 renderItemLink: void 0,
10237 containerWidth: 0,
10238 containerRef: (0, import_element19.createRef)(),
10239 resizeObserverRef: () => {
10240 },
10241 defaultLayouts: { list: {}, grid: {}, table: {} },
10242 filters: [],
10243 isShowingFilter: false,
10244 setIsShowingFilter: () => {
10245 },
10246 hasInitiallyLoaded: false,
10247 config: {
10248 perPageSizes: []
10249 },
10250 intersectionObserver: null
10251 });
10252 DataViewsContext.displayName = "DataViewsContext";
10253 var dataviews_context_default = DataViewsContext;
10254
10255 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10256 var import_i18n22 = __toESM(require_i18n(), 1);
10257
10258 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10259 var import_i18n9 = __toESM(require_i18n(), 1);
10260 var import_components6 = __toESM(require_components(), 1);
10261 var import_element28 = __toESM(require_element(), 1);
10262 var import_keycodes2 = __toESM(require_keycodes(), 1);
10263
10264 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10265 var import_components = __toESM(require_components(), 1);
10266 var import_i18n2 = __toESM(require_i18n(), 1);
10267 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10268 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10269 function DataViewsSelectionCheckbox({
10270 selection,
10271 onChangeSelection,
10272 item,
10273 getItemId,
10274 titleField,
10275 disabled: disabled2,
10276 ...extraProps
10277 }) {
10278 const id = getItemId(item);
10279 const isInSelectionArray = selection.includes(id);
10280 const checked = !disabled2 && isInSelectionArray;
10281 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10282 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10283 import_components.CheckboxControl,
10284 {
10285 className: SELECTION_CHECKBOX_CLASS,
10286 "aria-label": selectionLabel,
10287 "aria-disabled": disabled2,
10288 checked,
10289 onChange: () => {
10290 if (disabled2) {
10291 return;
10292 }
10293 onChangeSelection(
10294 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10295 );
10296 },
10297 ...extraProps
10298 }
10299 );
10300 }
10301
10302 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10303 var import_components2 = __toESM(require_components(), 1);
10304 var import_i18n3 = __toESM(require_i18n(), 1);
10305 var import_element20 = __toESM(require_element(), 1);
10306 var import_data4 = __toESM(require_data(), 1);
10307 var import_compose = __toESM(require_compose(), 1);
10308
10309 // packages/dataviews/build-module/lock-unlock.mjs
10310 var import_private_apis3 = __toESM(require_private_apis(), 1);
10311 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10312 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10313 "@wordpress/dataviews"
10314 );
10315
10316 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10317 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10318 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10319 function ButtonTrigger({
10320 action,
10321 onClick,
10322 items,
10323 variant
10324 }) {
10325 const label = typeof action.label === "string" ? action.label : action.label(items);
10326 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10327 import_components2.Button,
10328 {
10329 disabled: !!action.disabled,
10330 accessibleWhenDisabled: true,
10331 size: "compact",
10332 variant,
10333 onClick,
10334 children: label
10335 }
10336 );
10337 }
10338 function MenuItemTrigger({
10339 action,
10340 onClick,
10341 items
10342 }) {
10343 const label = typeof action.label === "string" ? action.label : action.label(items);
10344 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10345 }
10346 function ActionModal({
10347 action,
10348 items,
10349 closeModal
10350 }) {
10351 const label = typeof action.label === "string" ? action.label : action.label(items);
10352 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10353 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10354 import_components2.Modal,
10355 {
10356 title: modalHeader || label,
10357 __experimentalHideHeader: !!action.hideModalHeader,
10358 onRequestClose: closeModal,
10359 focusOnMount: action.modalFocusOnMount ?? true,
10360 size: action.modalSize || "medium",
10361 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10362 action.id
10363 )}`,
10364 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10365 }
10366 );
10367 }
10368 function ActionsMenuGroup({
10369 actions,
10370 item,
10371 registry,
10372 setActiveModalAction
10373 }) {
10374 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10375 return actions.reduce(
10376 (acc, action) => {
10377 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10378 return acc;
10379 },
10380 {
10381 primaryActions: [],
10382 regularActions: []
10383 }
10384 );
10385 }, [actions]);
10386 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10387 MenuItemTrigger,
10388 {
10389 action,
10390 onClick: () => {
10391 if ("RenderModal" in action) {
10392 setActiveModalAction(action);
10393 return;
10394 }
10395 action.callback([item], { registry });
10396 },
10397 items: [item]
10398 },
10399 action.id
10400 ));
10401 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10402 renderActionGroup(primaryActions),
10403 renderActionGroup(regularActions)
10404 ] });
10405 }
10406 function ItemActions({
10407 item,
10408 actions,
10409 isCompact
10410 }) {
10411 const registry = (0, import_data4.useRegistry)();
10412 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10413 const _eligibleActions = actions.filter(
10414 (action) => !action.isEligible || action.isEligible(item)
10415 );
10416 const _primaryActions = _eligibleActions.filter(
10417 (action) => action.isPrimary
10418 );
10419 return {
10420 primaryActions: _primaryActions,
10421 eligibleActions: _eligibleActions
10422 };
10423 }, [actions, item]);
10424 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10425 if (isCompact) {
10426 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10427 CompactItemActions,
10428 {
10429 item,
10430 actions: eligibleActions,
10431 isSmall: true,
10432 registry
10433 }
10434 );
10435 }
10436 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10437 Stack,
10438 {
10439 direction: "row",
10440 justify: "flex-end",
10441 className: "dataviews-item-actions",
10442 style: {
10443 flexShrink: 0,
10444 width: "auto"
10445 },
10446 children: [
10447 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10448 PrimaryActions,
10449 {
10450 item,
10451 actions: primaryActions,
10452 registry
10453 }
10454 ),
10455 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10456 // there if there are any actions at all.
10457 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10458 CompactItemActions,
10459 {
10460 item,
10461 actions: eligibleActions,
10462 registry
10463 }
10464 )
10465 ]
10466 }
10467 );
10468 }
10469 function CompactItemActions({
10470 item,
10471 actions,
10472 isSmall,
10473 registry
10474 }) {
10475 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
10476 null
10477 );
10478 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10479 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10480 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10481 Menu.TriggerButton,
10482 {
10483 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10484 import_components2.Button,
10485 {
10486 size: isSmall ? "small" : "compact",
10487 icon: more_vertical_default,
10488 label: (0, import_i18n3.__)("Actions"),
10489 accessibleWhenDisabled: true,
10490 disabled: !actions.length,
10491 className: "dataviews-all-actions-button"
10492 }
10493 )
10494 }
10495 ),
10496 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10497 ActionsMenuGroup,
10498 {
10499 actions,
10500 item,
10501 registry,
10502 setActiveModalAction
10503 }
10504 ) })
10505 ] }),
10506 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10507 ActionModal,
10508 {
10509 action: activeModalAction,
10510 items: [item],
10511 closeModal: () => setActiveModalAction(null)
10512 }
10513 )
10514 ] });
10515 }
10516 function PrimaryActions({
10517 item,
10518 actions,
10519 registry,
10520 buttonVariant
10521 }) {
10522 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
10523 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10524 if (isMobileViewport) {
10525 return null;
10526 }
10527 if (!Array.isArray(actions) || actions.length === 0) {
10528 return null;
10529 }
10530 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10531 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10532 ButtonTrigger,
10533 {
10534 action,
10535 onClick: () => {
10536 if ("RenderModal" in action) {
10537 setActiveModalAction(action);
10538 return;
10539 }
10540 action.callback([item], { registry });
10541 },
10542 items: [item],
10543 variant: buttonVariant
10544 },
10545 action.id
10546 )),
10547 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10548 ActionModal,
10549 {
10550 action: activeModalAction,
10551 items: [item],
10552 closeModal: () => setActiveModalAction(null)
10553 }
10554 )
10555 ] });
10556 }
10557
10558 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10559 var import_components3 = __toESM(require_components(), 1);
10560 var import_i18n5 = __toESM(require_i18n(), 1);
10561 var import_element21 = __toESM(require_element(), 1);
10562 var import_data5 = __toESM(require_data(), 1);
10563 var import_compose2 = __toESM(require_compose(), 1);
10564
10565 // packages/dataviews/build-module/utils/get-footer-message.mjs
10566 var import_i18n4 = __toESM(require_i18n(), 1);
10567 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10568 if (selectionCount > 0) {
10569 return (0, import_i18n4.sprintf)(
10570 /* translators: %d: number of items. */
10571 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10572 selectionCount
10573 );
10574 }
10575 if (onlyTotalCount || totalItems <= itemsCount) {
10576 return (0, import_i18n4.sprintf)(
10577 /* translators: %d: number of items. */
10578 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10579 totalItems
10580 );
10581 }
10582 return (0, import_i18n4.sprintf)(
10583 /* translators: %1$d: number of items. %2$d: total number of items. */
10584 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10585 itemsCount,
10586 totalItems
10587 );
10588 }
10589
10590 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10591 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10592 function ActionWithModal({
10593 action,
10594 items,
10595 ActionTriggerComponent
10596 }) {
10597 const [isModalOpen, setIsModalOpen] = (0, import_element21.useState)(false);
10598 const actionTriggerProps = {
10599 action,
10600 onClick: () => {
10601 setIsModalOpen(true);
10602 },
10603 items
10604 };
10605 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10606 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10607 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10608 ActionModal,
10609 {
10610 action,
10611 items,
10612 closeModal: () => setIsModalOpen(false)
10613 }
10614 )
10615 ] });
10616 }
10617 function hasAPossibleBulkAction(actions, item) {
10618 return actions.some(
10619 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10620 );
10621 }
10622 function useHasAPossibleBulkAction(actions, item) {
10623 return (0, import_element21.useMemo)(
10624 () => hasAPossibleBulkAction(actions, item),
10625 [actions, item]
10626 );
10627 }
10628 function useSomeItemHasAPossibleBulkAction(actions, data) {
10629 return (0, import_element21.useMemo)(
10630 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
10631 [actions, data]
10632 );
10633 }
10634 function BulkSelectionCheckbox({
10635 selection,
10636 onChangeSelection,
10637 data,
10638 actions,
10639 getItemId,
10640 disableSelectAll = false
10641 }) {
10642 const selectableItems = (0, import_element21.useMemo)(() => {
10643 return data.filter((item) => {
10644 return actions.some(
10645 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10646 );
10647 });
10648 }, [data, actions]);
10649 const selectedItems = data.filter(
10650 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10651 );
10652 const hasSelection = selection.length > 0;
10653 const areAllSelected = selectedItems.length === selectableItems.length;
10654 if (disableSelectAll) {
10655 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10656 import_components3.CheckboxControl,
10657 {
10658 className: "dataviews-view-table-selection-checkbox",
10659 checked: hasSelection,
10660 disabled: !hasSelection,
10661 onChange: () => {
10662 onChangeSelection([]);
10663 },
10664 "aria-label": (0, import_i18n5.__)("Deselect all")
10665 }
10666 );
10667 }
10668 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10669 import_components3.CheckboxControl,
10670 {
10671 className: "dataviews-view-table-selection-checkbox",
10672 checked: areAllSelected,
10673 indeterminate: !areAllSelected && !!selectedItems.length,
10674 onChange: () => {
10675 if (areAllSelected) {
10676 onChangeSelection([]);
10677 } else {
10678 onChangeSelection(
10679 selectableItems.map((item) => getItemId(item))
10680 );
10681 }
10682 },
10683 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10684 }
10685 );
10686 }
10687 function ActionTrigger({
10688 action,
10689 onClick,
10690 isBusy,
10691 items
10692 }) {
10693 const label = typeof action.label === "string" ? action.label : action.label(items);
10694 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10695 if (isMobile) {
10696 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10697 import_components3.Button,
10698 {
10699 disabled: isBusy,
10700 accessibleWhenDisabled: true,
10701 label,
10702 icon: action.icon,
10703 size: "compact",
10704 onClick,
10705 isBusy
10706 }
10707 );
10708 }
10709 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10710 import_components3.Button,
10711 {
10712 disabled: isBusy,
10713 accessibleWhenDisabled: true,
10714 size: "compact",
10715 onClick,
10716 isBusy,
10717 children: label
10718 }
10719 );
10720 }
10721 var EMPTY_ARRAY2 = [];
10722 function ActionButton({
10723 action,
10724 selectedItems,
10725 actionInProgress,
10726 setActionInProgress
10727 }) {
10728 const registry = (0, import_data5.useRegistry)();
10729 const selectedEligibleItems = (0, import_element21.useMemo)(() => {
10730 return selectedItems.filter((item) => {
10731 return !action.isEligible || action.isEligible(item);
10732 });
10733 }, [action, selectedItems]);
10734 if ("RenderModal" in action) {
10735 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10736 ActionWithModal,
10737 {
10738 action,
10739 items: selectedEligibleItems,
10740 ActionTriggerComponent: ActionTrigger
10741 },
10742 action.id
10743 );
10744 }
10745 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10746 ActionTrigger,
10747 {
10748 action,
10749 onClick: async () => {
10750 setActionInProgress(action.id);
10751 await action.callback(selectedItems, {
10752 registry
10753 });
10754 setActionInProgress(null);
10755 },
10756 items: selectedEligibleItems,
10757 isBusy: actionInProgress === action.id
10758 },
10759 action.id
10760 );
10761 }
10762 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10763 const message2 = getFooterMessage(
10764 selection.length,
10765 data.length,
10766 paginationInfo.totalItems,
10767 isInfiniteScroll
10768 );
10769 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10770 Stack,
10771 {
10772 direction: "row",
10773 className: "dataviews-bulk-actions-footer__container",
10774 gap: "md",
10775 align: "center",
10776 children: [
10777 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10778 BulkSelectionCheckbox,
10779 {
10780 selection,
10781 onChangeSelection,
10782 data,
10783 actions,
10784 getItemId,
10785 disableSelectAll: isInfiniteScroll
10786 }
10787 ),
10788 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10789 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10790 Stack,
10791 {
10792 direction: "row",
10793 className: "dataviews-bulk-actions-footer__action-buttons",
10794 gap: "xs",
10795 children: [
10796 actionsToShow.map((action) => {
10797 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10798 ActionButton,
10799 {
10800 action,
10801 selectedItems,
10802 actionInProgress,
10803 setActionInProgress
10804 },
10805 action.id
10806 );
10807 }),
10808 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10809 import_components3.Button,
10810 {
10811 icon: close_small_default,
10812 showTooltip: true,
10813 tooltipPosition: "top",
10814 size: "compact",
10815 label: (0, import_i18n5.__)("Cancel"),
10816 disabled: !!actionInProgress,
10817 accessibleWhenDisabled: false,
10818 onClick: () => {
10819 onChangeSelection(EMPTY_ARRAY2);
10820 }
10821 }
10822 )
10823 ]
10824 }
10825 )
10826 ]
10827 }
10828 );
10829 }
10830 function FooterContent({
10831 selection,
10832 actions,
10833 onChangeSelection,
10834 data,
10835 getItemId,
10836 isInfiniteScroll,
10837 paginationInfo
10838 }) {
10839 const [actionInProgress, setActionInProgress] = (0, import_element21.useState)(
10840 null
10841 );
10842 const footerContentRef = (0, import_element21.useRef)(void 0);
10843 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10844 const bulkActions = (0, import_element21.useMemo)(
10845 () => actions.filter((action) => action.supportsBulk),
10846 [actions]
10847 );
10848 const selectableItems = (0, import_element21.useMemo)(() => {
10849 return data.filter((item) => {
10850 return bulkActions.some(
10851 (action) => !action.isEligible || action.isEligible(item)
10852 );
10853 });
10854 }, [data, bulkActions]);
10855 const selectedItems = (0, import_element21.useMemo)(() => {
10856 return data.filter(
10857 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10858 );
10859 }, [selection, data, getItemId, selectableItems]);
10860 const actionsToShow = (0, import_element21.useMemo)(
10861 () => actions.filter((action) => {
10862 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10863 (item) => !action.isEligible || action.isEligible(item)
10864 );
10865 }),
10866 [actions, selectedItems, isMobile]
10867 );
10868 if (!actionInProgress) {
10869 if (footerContentRef.current) {
10870 footerContentRef.current = void 0;
10871 }
10872 return renderFooterContent(
10873 data,
10874 actions,
10875 getItemId,
10876 isInfiniteScroll,
10877 selection,
10878 actionsToShow,
10879 selectedItems,
10880 actionInProgress,
10881 setActionInProgress,
10882 onChangeSelection,
10883 paginationInfo
10884 );
10885 } else if (!footerContentRef.current) {
10886 footerContentRef.current = renderFooterContent(
10887 data,
10888 actions,
10889 getItemId,
10890 isInfiniteScroll,
10891 selection,
10892 actionsToShow,
10893 selectedItems,
10894 actionInProgress,
10895 setActionInProgress,
10896 onChangeSelection,
10897 paginationInfo
10898 );
10899 }
10900 return footerContentRef.current;
10901 }
10902 function BulkActionsFooter() {
10903 const {
10904 data,
10905 selection,
10906 actions = EMPTY_ARRAY2,
10907 onChangeSelection,
10908 getItemId,
10909 paginationInfo,
10910 view
10911 } = (0, import_element21.useContext)(dataviews_context_default);
10912 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10913 FooterContent,
10914 {
10915 selection,
10916 onChangeSelection,
10917 data,
10918 actions,
10919 getItemId,
10920 isInfiniteScroll: !!view.infiniteScrollEnabled,
10921 paginationInfo
10922 }
10923 );
10924 }
10925
10926 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10927 var import_i18n6 = __toESM(require_i18n(), 1);
10928 var import_components4 = __toESM(require_components(), 1);
10929 var import_element22 = __toESM(require_element(), 1);
10930
10931 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10932 function getHideableFields(view, fields) {
10933 const togglableFields = [
10934 view?.titleField,
10935 view?.mediaField,
10936 view?.descriptionField
10937 ].filter(Boolean);
10938 return fields.filter(
10939 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10940 );
10941 }
10942
10943 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10944 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10945 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10946 function WithMenuSeparators({ children }) {
10947 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element22.Fragment, { children: [
10948 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10949 child
10950 ] }, i2));
10951 }
10952 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
10953 fieldId,
10954 view,
10955 fields,
10956 onChangeView,
10957 onHide,
10958 setOpenedFilter,
10959 canMove = true,
10960 canInsertLeft = true,
10961 canInsertRight = true
10962 }, ref) {
10963 const visibleFieldIds = view.fields ?? [];
10964 const index2 = visibleFieldIds?.indexOf(fieldId);
10965 const isSorted = view.sort?.field === fieldId;
10966 let isHidable = false;
10967 let isSortable = false;
10968 let canAddFilter = false;
10969 let operators = [];
10970 const field = fields.find((f2) => f2.id === fieldId);
10971 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
10972 if (!field) {
10973 return null;
10974 }
10975 isHidable = field.enableHiding !== false;
10976 isSortable = field.enableSorting !== false;
10977 const header = field.header;
10978 operators = !!field.filterBy && field.filterBy?.operators || [];
10979 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10980 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10981 return header;
10982 }
10983 const hiddenFields = getHideableFields(view, fields).filter(
10984 (f2) => !visibleFieldIds.includes(f2.id)
10985 );
10986 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10987 const isRtl = (0, import_i18n6.isRTL)();
10988 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10989 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10990 Menu2.TriggerButton,
10991 {
10992 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10993 import_components4.Button,
10994 {
10995 size: "compact",
10996 className: "dataviews-view-table-header-button",
10997 ref,
10998 variant: "tertiary"
10999 }
11000 ),
11001 children: [
11002 header,
11003 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11004 ]
11005 }
11006 ),
11007 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
11008 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11009 (direction) => {
11010 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11011 const value = `${fieldId}-${direction}`;
11012 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11013 Menu2.RadioItem,
11014 {
11015 name: "view-table-sorting",
11016 value,
11017 checked: isChecked,
11018 onChange: () => {
11019 onChangeView({
11020 ...view,
11021 sort: {
11022 field: fieldId,
11023 direction
11024 },
11025 showLevels: false
11026 });
11027 },
11028 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11029 },
11030 value
11031 );
11032 }
11033 ) }),
11034 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11035 Menu2.Item,
11036 {
11037 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
11038 onClick: () => {
11039 setOpenedFilter(fieldId);
11040 setIsShowingFilter(true);
11041 onChangeView({
11042 ...view,
11043 page: 1,
11044 filters: [
11045 ...view.filters || [],
11046 {
11047 field: fieldId,
11048 value: void 0,
11049 operator: operators[0]
11050 }
11051 ]
11052 });
11053 },
11054 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
11055 }
11056 ) }),
11057 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
11058 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11059 Menu2.Item,
11060 {
11061 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11062 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11063 onClick: () => {
11064 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11065 const newFields = [
11066 ...visibleFieldIds
11067 ];
11068 newFields.splice(index2, 1);
11069 newFields.splice(
11070 targetIndex,
11071 0,
11072 fieldId
11073 );
11074 onChangeView({
11075 ...view,
11076 fields: newFields
11077 });
11078 },
11079 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
11080 }
11081 ),
11082 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11083 Menu2.Item,
11084 {
11085 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11086 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11087 onClick: () => {
11088 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11089 const newFields = [
11090 ...visibleFieldIds
11091 ];
11092 newFields.splice(index2, 1);
11093 newFields.splice(
11094 targetIndex,
11095 0,
11096 fieldId
11097 );
11098 onChangeView({
11099 ...view,
11100 fields: newFields
11101 });
11102 },
11103 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
11104 }
11105 ),
11106 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11107 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
11108 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11109 const insertIndex = isRtl ? index2 + 1 : index2;
11110 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11111 Menu2.Item,
11112 {
11113 onClick: () => {
11114 onChangeView({
11115 ...view,
11116 fields: [
11117 ...visibleFieldIds.slice(
11118 0,
11119 insertIndex
11120 ),
11121 hiddenField.id,
11122 ...visibleFieldIds.slice(
11123 insertIndex
11124 )
11125 ]
11126 });
11127 },
11128 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11129 },
11130 hiddenField.id
11131 );
11132 }) })
11133 ] }),
11134 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11135 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
11136 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11137 const insertIndex = isRtl ? index2 : index2 + 1;
11138 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11139 Menu2.Item,
11140 {
11141 onClick: () => {
11142 onChangeView({
11143 ...view,
11144 fields: [
11145 ...visibleFieldIds.slice(
11146 0,
11147 insertIndex
11148 ),
11149 hiddenField.id,
11150 ...visibleFieldIds.slice(
11151 insertIndex
11152 )
11153 ]
11154 });
11155 },
11156 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11157 },
11158 hiddenField.id
11159 );
11160 }) })
11161 ] }),
11162 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11163 Menu2.Item,
11164 {
11165 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
11166 onClick: () => {
11167 onHide(field);
11168 onChangeView({
11169 ...view,
11170 fields: visibleFieldIds.filter(
11171 (id) => id !== fieldId
11172 )
11173 });
11174 },
11175 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
11176 }
11177 )
11178 ] })
11179 ] }) })
11180 ] });
11181 });
11182 var ColumnHeaderMenu = _HeaderMenu;
11183 var column_header_menu_default = ColumnHeaderMenu;
11184
11185 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11186 var import_element23 = __toESM(require_element(), 1);
11187 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11188 function getClickableItemProps({
11189 item,
11190 isItemClickable,
11191 onClickItem,
11192 className
11193 }) {
11194 if (!isItemClickable(item) || !onClickItem) {
11195 return { className };
11196 }
11197 return {
11198 className: className ? `${className} ${className}--clickable` : void 0,
11199 role: "button",
11200 tabIndex: 0,
11201 onClick: (event) => {
11202 event.stopPropagation();
11203 onClickItem(item);
11204 },
11205 onKeyDown: (event) => {
11206 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11207 event.stopPropagation();
11208 onClickItem(item);
11209 }
11210 }
11211 };
11212 }
11213 function ItemClickWrapper({
11214 item,
11215 isItemClickable,
11216 onClickItem,
11217 renderItemLink,
11218 className,
11219 children,
11220 ...extraProps
11221 }) {
11222 if (!isItemClickable(item)) {
11223 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
11224 }
11225 if (renderItemLink) {
11226 const renderedElement = renderItemLink({
11227 item,
11228 className: `${className} ${className}--clickable`,
11229 ...extraProps,
11230 children
11231 });
11232 return (0, import_element23.cloneElement)(renderedElement, {
11233 onClick: (event) => {
11234 event.stopPropagation();
11235 if (renderedElement.props.onClick) {
11236 renderedElement.props.onClick(event);
11237 }
11238 },
11239 onKeyDown: (event) => {
11240 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11241 event.stopPropagation();
11242 if (renderedElement.props.onKeyDown) {
11243 renderedElement.props.onKeyDown(event);
11244 }
11245 }
11246 }
11247 });
11248 }
11249 const clickProps = getClickableItemProps({
11250 item,
11251 isItemClickable,
11252 onClickItem,
11253 className
11254 });
11255 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
11256 }
11257
11258 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11259 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11260 function ColumnPrimary({
11261 item,
11262 level,
11263 titleField,
11264 mediaField,
11265 descriptionField,
11266 onClickItem,
11267 renderItemLink,
11268 isItemClickable
11269 }) {
11270 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11271 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11272 ItemClickWrapper,
11273 {
11274 item,
11275 isItemClickable,
11276 onClickItem,
11277 renderItemLink,
11278 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11279 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11280 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11281 mediaField.render,
11282 {
11283 item,
11284 field: mediaField,
11285 config: { sizes: "32px" }
11286 }
11287 )
11288 }
11289 ),
11290 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11291 Stack,
11292 {
11293 direction: "column",
11294 align: "flex-start",
11295 className: "dataviews-view-table__primary-column-content",
11296 children: [
11297 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11298 ItemClickWrapper,
11299 {
11300 item,
11301 isItemClickable,
11302 onClickItem,
11303 renderItemLink,
11304 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11305 children: [
11306 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11307 Array(level).fill("\u2014").join(" "),
11308 "\xA0"
11309 ] }),
11310 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11311 ]
11312 }
11313 ),
11314 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11315 descriptionField.render,
11316 {
11317 item,
11318 field: descriptionField
11319 }
11320 )
11321 ]
11322 }
11323 )
11324 ] });
11325 }
11326 var column_primary_default = ColumnPrimary;
11327
11328 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11329 var import_element24 = __toESM(require_element(), 1);
11330 var import_i18n7 = __toESM(require_i18n(), 1);
11331 var isScrolledToEnd = (element) => {
11332 if ((0, import_i18n7.isRTL)()) {
11333 const scrollLeft = Math.abs(element.scrollLeft);
11334 return scrollLeft <= 1;
11335 }
11336 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11337 };
11338 function useScrollState({
11339 scrollContainerRef,
11340 enabledHorizontal = false
11341 }) {
11342 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11343 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11344 const handleScroll = (0, import_element24.useCallback)(() => {
11345 const scrollContainer = scrollContainerRef.current;
11346 if (!scrollContainer) {
11347 return;
11348 }
11349 if (enabledHorizontal) {
11350 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11351 }
11352 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11353 }, [scrollContainerRef, enabledHorizontal]);
11354 (0, import_element24.useEffect)(() => {
11355 if (typeof window === "undefined" || !scrollContainerRef.current) {
11356 return () => {
11357 };
11358 }
11359 const scrollContainer = scrollContainerRef.current;
11360 handleScroll();
11361 scrollContainer.addEventListener("scroll", handleScroll);
11362 window.addEventListener("resize", handleScroll);
11363 return () => {
11364 scrollContainer.removeEventListener("scroll", handleScroll);
11365 window.removeEventListener("resize", handleScroll);
11366 };
11367 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11368 return { isHorizontalScrollEnd, isVerticallyScrolled };
11369 }
11370
11371 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11372 function getDataByGroup(data, groupByField) {
11373 return data.reduce((groups, item) => {
11374 const groupName = groupByField.getValue({ item });
11375 if (!groups.has(groupName)) {
11376 groups.set(groupName, []);
11377 }
11378 groups.get(groupName)?.push(item);
11379 return groups;
11380 }, /* @__PURE__ */ new Map());
11381 }
11382
11383 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11384 var import_element25 = __toESM(require_element(), 1);
11385 var import_keycodes = __toESM(require_keycodes(), 1);
11386 function getRange(orderedIds, fromIndex, toIndex) {
11387 return orderedIds.slice(
11388 Math.min(fromIndex, toIndex),
11389 Math.max(fromIndex, toIndex) + 1
11390 );
11391 }
11392 function getRangeSelection({
11393 anchorId,
11394 targetId,
11395 lastTargetId,
11396 orderedIds,
11397 selection
11398 }) {
11399 const targetIndex = orderedIds.indexOf(targetId);
11400 if (targetIndex === -1) {
11401 return selection;
11402 }
11403 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11404 const hasAnchor = anchorIndex !== -1;
11405 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11406 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11407 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11408 const base = selection.filter((id) => !lastRange.includes(id));
11409 return [
11410 .../* @__PURE__ */ new Set([
11411 ...base,
11412 ...getRange(orderedIds, rangeStart, targetIndex)
11413 ])
11414 ];
11415 }
11416 function getClosestSelectedId({
11417 targetId,
11418 orderedIds,
11419 selection
11420 }) {
11421 const targetIndex = orderedIds.indexOf(targetId);
11422 if (targetIndex === -1) {
11423 return null;
11424 }
11425 const selectedIds = new Set(selection);
11426 let closestId = null;
11427 let closestDistance = Infinity;
11428 orderedIds.forEach((id, index2) => {
11429 if (!selectedIds.has(id)) {
11430 return;
11431 }
11432 const distance = Math.abs(index2 - targetIndex);
11433 if (distance < closestDistance) {
11434 closestDistance = distance;
11435 closestId = id;
11436 }
11437 });
11438 return closestId;
11439 }
11440 function useSelectionProps({
11441 data,
11442 actions,
11443 getItemId,
11444 selection,
11445 onChangeSelection
11446 }) {
11447 const gestureRef = (0, import_element25.useRef)(null);
11448 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11449 (0, import_element25.useEffect)(() => {
11450 const markTouchDevice = () => {
11451 isTouchDeviceRef.current = true;
11452 };
11453 document.addEventListener("touchstart", markTouchDevice, {
11454 once: true
11455 });
11456 return () => document.removeEventListener("touchstart", markTouchDevice);
11457 }, []);
11458 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
11459 const selectableIdSet = new Set(selectableIds);
11460 const hasSelectableItems = selectableIds.length > 0;
11461 const getSelectionProps = (id) => {
11462 const isSelectable = selectableIdSet.has(id);
11463 return {
11464 onMouseDown: (event) => {
11465 if (event.button === 0 && event.shiftKey && hasSelectableItems) {
11466 event.preventDefault();
11467 }
11468 },
11469 onClickCapture: (event) => {
11470 if (!hasSelectableItems) {
11471 return;
11472 }
11473 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11474 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
11475 if (!isModifierKeyPressed && !event.shiftKey) {
11476 if (isSelectable && isSelectionCheckboxClick) {
11477 gestureRef.current = {
11478 anchorId: id,
11479 lastTargetId: null
11480 };
11481 }
11482 return;
11483 }
11484 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11485 return;
11486 }
11487 event.stopPropagation();
11488 if (!isSelectionCheckboxClick) {
11489 event.preventDefault();
11490 }
11491 if (!isSelectable) {
11492 return;
11493 }
11494 if (event.shiftKey) {
11495 let gesture = gestureRef.current;
11496 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11497 gesture = {
11498 anchorId: getClosestSelectedId({
11499 targetId: id,
11500 orderedIds: selectableIds,
11501 selection
11502 }) ?? id,
11503 lastTargetId: null
11504 };
11505 }
11506 onChangeSelection(
11507 getRangeSelection({
11508 anchorId: gesture.anchorId,
11509 targetId: id,
11510 lastTargetId: gesture.lastTargetId,
11511 orderedIds: selectableIds,
11512 selection
11513 })
11514 );
11515 gestureRef.current = {
11516 anchorId: gesture.anchorId,
11517 lastTargetId: id
11518 };
11519 } else {
11520 onChangeSelection(
11521 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11522 );
11523 gestureRef.current = { anchorId: id, lastTargetId: null };
11524 }
11525 }
11526 };
11527 };
11528 return { getSelectionProps };
11529 }
11530
11531 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11532 var import_components5 = __toESM(require_components(), 1);
11533 var import_i18n8 = __toESM(require_i18n(), 1);
11534 var import_element26 = __toESM(require_element(), 1);
11535 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11536 function FieldItem({
11537 field,
11538 isVisible: isVisible2,
11539 onToggleVisibility
11540 }) {
11541 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: [
11542 /* @__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 }) }),
11543 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11544 ] }) });
11545 }
11546 function isDefined(item) {
11547 return !!item;
11548 }
11549 function PropertiesSection({
11550 showLabel = true
11551 }) {
11552 const { view, fields, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
11553 const regularFields = getHideableFields(view, fields);
11554 if (!regularFields?.length) {
11555 return null;
11556 }
11557 const titleField = fields.find((f2) => f2.id === view.titleField);
11558 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11559 const descriptionField = fields.find(
11560 (f2) => f2.id === view.descriptionField
11561 );
11562 const lockedFields = [
11563 {
11564 field: titleField,
11565 isVisibleFlag: "showTitle"
11566 },
11567 {
11568 field: previewField2,
11569 isVisibleFlag: "showMedia"
11570 },
11571 {
11572 field: descriptionField,
11573 isVisibleFlag: "showDescription"
11574 }
11575 ].filter(({ field }) => isDefined(field));
11576 const visibleFieldIds = view.fields ?? [];
11577 const visibleRegularFieldsCount = regularFields.filter(
11578 (f2) => visibleFieldIds.includes(f2.id)
11579 ).length;
11580 const visibleLockedFields = lockedFields.filter(
11581 ({ isVisibleFlag }) => (
11582 // @ts-expect-error
11583 view[isVisibleFlag] ?? true
11584 )
11585 );
11586 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11587 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11588 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11589 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11590 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11591 Stack,
11592 {
11593 direction: "column",
11594 className: "dataviews-view-config__properties",
11595 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11596 lockedFields.map(({ field, isVisibleFlag }) => {
11597 const isVisible2 = view[isVisibleFlag] ?? true;
11598 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11599 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11600 FieldItem,
11601 {
11602 field: fieldToRender,
11603 isVisible: isVisible2,
11604 onToggleVisibility: () => {
11605 onChangeView({
11606 ...view,
11607 [isVisibleFlag]: !isVisible2
11608 });
11609 }
11610 },
11611 field.id
11612 );
11613 }),
11614 regularFields.map((field) => {
11615 const isVisible2 = visibleFieldIds.includes(field.id);
11616 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11617 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11618 FieldItem,
11619 {
11620 field: fieldToRender,
11621 isVisible: isVisible2,
11622 onToggleVisibility: () => {
11623 onChangeView({
11624 ...view,
11625 fields: isVisible2 ? visibleFieldIds.filter(
11626 (fieldId) => fieldId !== field.id
11627 ) : [...visibleFieldIds, field.id]
11628 });
11629 }
11630 },
11631 field.id
11632 );
11633 })
11634 ] })
11635 }
11636 )
11637 ] });
11638 }
11639
11640 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11641 var import_element27 = __toESM(require_element(), 1);
11642 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11643 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
11644 (0, import_element27.useEffect)(() => {
11645 if (!isLoading) {
11646 return;
11647 }
11648 const timeout = setTimeout(() => {
11649 setShowLoader(true);
11650 }, options.delay);
11651 return () => {
11652 clearTimeout(timeout);
11653 setShowLoader(false);
11654 };
11655 }, [isLoading, options.delay]);
11656 return showLoader;
11657 }
11658
11659 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11660 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11661 function getEffectiveAlign(explicitAlign, fieldType) {
11662 if (explicitAlign) {
11663 return explicitAlign;
11664 }
11665 if (fieldType === "integer" || fieldType === "number") {
11666 return "end";
11667 }
11668 return void 0;
11669 }
11670 function TableColumnField({
11671 item,
11672 fields,
11673 column,
11674 align
11675 }) {
11676 const field = fields.find((f2) => f2.id === column);
11677 if (!field) {
11678 return null;
11679 }
11680 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11681 "dataviews-view-table__cell-align-end": align === "end",
11682 "dataviews-view-table__cell-align-center": align === "center"
11683 });
11684 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11685 }
11686 function TableRow({
11687 hasBulkActions,
11688 item,
11689 level,
11690 actions,
11691 fields,
11692 id,
11693 view,
11694 titleField,
11695 mediaField,
11696 descriptionField,
11697 selection,
11698 getItemId,
11699 isItemClickable,
11700 onClickItem,
11701 renderItemLink,
11702 onChangeSelection,
11703 onMouseDown,
11704 onClickCapture,
11705 isActionsColumnSticky,
11706 posinset
11707 }) {
11708 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
11709 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11710 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11711 const {
11712 showTitle = true,
11713 showMedia = true,
11714 showDescription = true,
11715 infiniteScrollEnabled
11716 } = view;
11717 const columns = view.fields ?? [];
11718 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11719 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11720 "tr",
11721 {
11722 className: clsx_default("dataviews-view-table__row", {
11723 "is-selected": hasPossibleBulkAction && isSelected2,
11724 "has-bulk-actions": hasPossibleBulkAction
11725 }),
11726 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11727 "aria-posinset": posinset,
11728 role: infiniteScrollEnabled ? "article" : void 0,
11729 onClickCapture,
11730 onMouseDown: (event) => {
11731 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
11732 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11733 event.preventDefault();
11734 }
11735 onMouseDown(event);
11736 },
11737 children: [
11738 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)(
11739 DataViewsSelectionCheckbox,
11740 {
11741 item,
11742 selection,
11743 onChangeSelection,
11744 getItemId,
11745 titleField,
11746 disabled: !hasPossibleBulkAction
11747 }
11748 ) }) }),
11749 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11750 column_primary_default,
11751 {
11752 item,
11753 level,
11754 titleField: showTitle ? titleField : void 0,
11755 mediaField: showMedia ? mediaField : void 0,
11756 descriptionField: showDescription ? descriptionField : void 0,
11757 isItemClickable,
11758 onClickItem,
11759 renderItemLink
11760 }
11761 ) }),
11762 columns.map((column) => {
11763 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11764 const field = fields.find((f2) => f2.id === column);
11765 const effectiveAlign = getEffectiveAlign(align, field?.type);
11766 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11767 "td",
11768 {
11769 style: {
11770 width,
11771 maxWidth,
11772 minWidth
11773 },
11774 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11775 TableColumnField,
11776 {
11777 fields,
11778 item,
11779 column,
11780 align: effectiveAlign
11781 }
11782 )
11783 },
11784 column
11785 );
11786 }),
11787 !!actions?.length && // Disable reason: we are not making the element interactive,
11788 // but preventing any click events from bubbling up to the
11789 // table row. This allows us to add a click handler to the row
11790 // itself (to toggle row selection) without erroneously
11791 // intercepting click events from ItemActions.
11792 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11793 "td",
11794 {
11795 className: clsx_default("dataviews-view-table__actions-column", {
11796 "dataviews-view-table__actions-column--sticky": true,
11797 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11798 }),
11799 onClick: (e2) => e2.stopPropagation(),
11800 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11801 }
11802 )
11803 ]
11804 }
11805 );
11806 }
11807 function ViewTable({
11808 actions,
11809 data,
11810 fields,
11811 getItemId,
11812 getItemLevel,
11813 isLoading = false,
11814 onChangeView,
11815 onChangeSelection,
11816 selection,
11817 setOpenedFilter,
11818 onClickItem,
11819 isItemClickable,
11820 renderItemLink,
11821 view,
11822 className,
11823 empty
11824 }) {
11825 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
11826 const isDelayedLoading = useDelayedLoading(isLoading);
11827 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11828 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11829 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
11830 const { getSelectionProps } = useSelectionProps({
11831 data: orderedData,
11832 actions,
11833 getItemId,
11834 selection,
11835 onChangeSelection
11836 });
11837 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
11838 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
11839 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
11840 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
11841 (0, import_element28.useEffect)(() => {
11842 if (headerMenuToFocusRef.current) {
11843 headerMenuToFocusRef.current.focus();
11844 headerMenuToFocusRef.current = void 0;
11845 }
11846 });
11847 const tableNoticeId = (0, import_element28.useId)();
11848 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11849 scrollContainerRef: containerRef,
11850 enabledHorizontal: !!actions?.length
11851 });
11852 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11853 if (nextHeaderMenuToFocus) {
11854 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11855 setNextHeaderMenuToFocus(void 0);
11856 return;
11857 }
11858 const onHide = (field) => {
11859 const hidden = headerMenuRefs.current.get(field.id);
11860 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11861 setNextHeaderMenuToFocus(fallback?.node);
11862 };
11863 const handleHeaderContextMenu = (event) => {
11864 event.preventDefault();
11865 event.stopPropagation();
11866 const virtualAnchor = {
11867 getBoundingClientRect: () => ({
11868 x: event.clientX,
11869 y: event.clientY,
11870 top: event.clientY,
11871 left: event.clientX,
11872 right: event.clientX,
11873 bottom: event.clientY,
11874 width: 0,
11875 height: 0,
11876 toJSON: () => ({})
11877 })
11878 };
11879 window.requestAnimationFrame(() => {
11880 setContextMenuAnchor(virtualAnchor);
11881 });
11882 };
11883 const hasData = !!data?.length;
11884 const titleField = fields.find((field) => field.id === view.titleField);
11885 const mediaField = fields.find((field) => field.id === view.mediaField);
11886 const descriptionField = fields.find(
11887 (field) => field.id === view.descriptionField
11888 );
11889 const { showTitle = true, showMedia = true, showDescription = true } = view;
11890 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11891 const columns = view.fields ?? [];
11892 const headerMenuRef = (column, index2) => (node) => {
11893 if (node) {
11894 headerMenuRefs.current.set(column, {
11895 node,
11896 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11897 });
11898 } else {
11899 headerMenuRefs.current.delete(column);
11900 }
11901 };
11902 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11903 const isRtl = (0, import_i18n9.isRTL)();
11904 if (!hasData) {
11905 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11906 "div",
11907 {
11908 className: clsx_default("dataviews-no-results", {
11909 "is-refreshing": isDelayedLoading
11910 }),
11911 id: tableNoticeId,
11912 children: empty
11913 }
11914 );
11915 }
11916 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11917 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11918 "table",
11919 {
11920 className: clsx_default("dataviews-view-table", className, {
11921 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11922 view.layout.density
11923 ),
11924 "has-bulk-actions": hasBulkActions,
11925 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11926 }),
11927 "aria-busy": isLoading,
11928 "aria-describedby": tableNoticeId,
11929 role: isInfiniteScroll ? "feed" : void 0,
11930 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11931 children: [
11932 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11933 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11934 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11935 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11936 "col",
11937 {
11938 className: clsx_default(
11939 `dataviews-view-table__col-${column}`,
11940 {
11941 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11942 }
11943 )
11944 },
11945 `col-${column}`
11946 )),
11947 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11948 ] }),
11949 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11950 import_components6.Popover,
11951 {
11952 anchor: contextMenuAnchor,
11953 onClose: () => setContextMenuAnchor(null),
11954 placement: "bottom-start",
11955 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11956 }
11957 ),
11958 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11959 "thead",
11960 {
11961 className: clsx_default({
11962 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11963 }),
11964 onContextMenu: handleHeaderContextMenu,
11965 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11966 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11967 "th",
11968 {
11969 className: "dataviews-view-table__checkbox-column",
11970 scope: "col",
11971 onContextMenu: handleHeaderContextMenu,
11972 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11973 BulkSelectionCheckbox,
11974 {
11975 selection,
11976 onChangeSelection,
11977 data,
11978 actions,
11979 getItemId
11980 }
11981 )
11982 }
11983 ),
11984 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11985 column_header_menu_default,
11986 {
11987 ref: headerMenuRef(
11988 titleField.id,
11989 0
11990 ),
11991 fieldId: titleField.id,
11992 view,
11993 fields,
11994 onChangeView,
11995 onHide,
11996 setOpenedFilter,
11997 canMove: false,
11998 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11999 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12000 }
12001 ) }),
12002 columns.map((column, index2) => {
12003 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12004 const field = fields.find(
12005 (f2) => f2.id === column
12006 );
12007 const effectiveAlign = getEffectiveAlign(
12008 align,
12009 field?.type
12010 );
12011 const canInsertOrMove = view.layout?.enableMoving ?? true;
12012 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12013 "th",
12014 {
12015 style: {
12016 width,
12017 maxWidth,
12018 minWidth,
12019 textAlign: effectiveAlign
12020 },
12021 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12022 scope: "col",
12023 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12024 column_header_menu_default,
12025 {
12026 ref: headerMenuRef(column, index2),
12027 fieldId: column,
12028 view,
12029 fields,
12030 onChangeView,
12031 onHide,
12032 setOpenedFilter,
12033 canMove: canInsertOrMove,
12034 canInsertLeft: canInsertOrMove,
12035 canInsertRight: canInsertOrMove
12036 }
12037 )
12038 },
12039 column
12040 );
12041 }),
12042 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12043 "th",
12044 {
12045 className: clsx_default(
12046 "dataviews-view-table__actions-column",
12047 {
12048 "dataviews-view-table__actions-column--sticky": true,
12049 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12050 }
12051 ),
12052 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
12053 }
12054 )
12055 ] })
12056 }
12057 ),
12058 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12059 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
12060 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12061 "td",
12062 {
12063 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12064 className: "dataviews-view-table__group-header-cell",
12065 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
12066 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12067 (0, import_i18n9.__)("%1$s: %2$s"),
12068 groupField.label,
12069 groupName
12070 )
12071 }
12072 ) }),
12073 groupItems.map((item, index2) => {
12074 const id = getItemId(item) || index2.toString();
12075 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12076 TableRow,
12077 {
12078 item,
12079 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12080 hasBulkActions,
12081 actions,
12082 fields,
12083 id,
12084 view,
12085 titleField,
12086 mediaField,
12087 descriptionField,
12088 selection,
12089 getItemId,
12090 onChangeSelection,
12091 ...getSelectionProps(id),
12092 onClickItem,
12093 renderItemLink,
12094 isItemClickable,
12095 isActionsColumnSticky: !isHorizontalScrollEnd
12096 },
12097 getItemId(item)
12098 );
12099 })
12100 ] }, `group-${groupName}`)
12101 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12102 const id = getItemId(item) || index2.toString();
12103 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12104 TableRow,
12105 {
12106 item,
12107 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12108 hasBulkActions,
12109 actions,
12110 fields,
12111 id,
12112 view,
12113 titleField,
12114 mediaField,
12115 descriptionField,
12116 selection,
12117 getItemId,
12118 onChangeSelection,
12119 ...getSelectionProps(id),
12120 onClickItem,
12121 renderItemLink,
12122 isItemClickable,
12123 isActionsColumnSticky: !isHorizontalScrollEnd,
12124 posinset: isInfiniteScroll ? index2 + 1 : void 0
12125 },
12126 getItemId(item)
12127 );
12128 }) })
12129 ]
12130 }
12131 ),
12132 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, {}) }) })
12133 ] });
12134 }
12135 var table_default = ViewTable;
12136
12137 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12138 var import_components9 = __toESM(require_components(), 1);
12139 var import_i18n12 = __toESM(require_i18n(), 1);
12140
12141 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12142 var import_components8 = __toESM(require_components(), 1);
12143 var import_i18n11 = __toESM(require_i18n(), 1);
12144 var import_compose3 = __toESM(require_compose(), 1);
12145 var import_element32 = __toESM(require_element(), 1);
12146
12147 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12148 var import_components7 = __toESM(require_components(), 1);
12149 var import_i18n10 = __toESM(require_i18n(), 1);
12150 var import_element29 = __toESM(require_element(), 1);
12151 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
12152 var imageSizes = [
12153 {
12154 value: 120,
12155 breakpoint: 1
12156 },
12157 {
12158 value: 170,
12159 breakpoint: 1
12160 },
12161 {
12162 value: 230,
12163 breakpoint: 1
12164 },
12165 {
12166 value: 290,
12167 breakpoint: 1112
12168 // at minimum image width, 4 images display at this container size
12169 },
12170 {
12171 value: 350,
12172 breakpoint: 1636
12173 // at minimum image width, 6 images display at this container size
12174 },
12175 {
12176 value: 430,
12177 breakpoint: 588
12178 // at minimum image width, 2 images display at this container size
12179 }
12180 ];
12181 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12182 function useGridColumns() {
12183 const context = (0, import_element29.useContext)(dataviews_context_default);
12184 const view = context.view;
12185 return (0, import_element29.useMemo)(() => {
12186 const containerWidth = context.containerWidth;
12187 const gap = 32;
12188 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12189 const columns = Math.floor(
12190 (containerWidth + gap) / (previewSize + gap)
12191 );
12192 return Math.max(1, columns);
12193 }, [context.containerWidth, view.layout?.previewSize]);
12194 }
12195
12196 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12197 var import_element30 = __toESM(require_element(), 1);
12198 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
12199 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
12200 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
12201 "div",
12202 {
12203 ref,
12204 className: clsx_default("dataviews-view-grid-items", className),
12205 style: {
12206 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12207 },
12208 ...props
12209 }
12210 );
12211 });
12212
12213 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12214 var import_element31 = __toESM(require_element(), 1);
12215 function useIntersectionObserver(elementRef, posinset) {
12216 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
12217 (0, import_element31.useEffect)(() => {
12218 const element = elementRef.current;
12219 if (!element || posinset === void 0 || !intersectionObserver) {
12220 return;
12221 }
12222 intersectionObserver.observe(element);
12223 return () => {
12224 intersectionObserver.unobserve(element);
12225 };
12226 }, [elementRef, intersectionObserver, posinset]);
12227 }
12228 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12229 const hasData = !!data?.length;
12230 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12231 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12232 }
12233
12234 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12235 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
12236 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
12237 function chunk(array, size4) {
12238 const chunks = [];
12239 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12240 chunks.push(array.slice(i2, i2 + size4));
12241 }
12242 return chunks;
12243 }
12244 var GridItem = (0, import_element32.forwardRef)(
12245 function GridItem2({
12246 view,
12247 selection,
12248 onChangeSelection,
12249 onClickItem,
12250 isItemClickable,
12251 renderItemLink,
12252 getItemId,
12253 item,
12254 actions,
12255 mediaField,
12256 titleField,
12257 descriptionField,
12258 regularFields,
12259 badgeFields,
12260 hasBulkActions,
12261 config,
12262 posinset,
12263 setsize,
12264 ...props
12265 }, forwardedRef) {
12266 const {
12267 showTitle = true,
12268 showMedia = true,
12269 showDescription = true
12270 } = view;
12271 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12272 const id = getItemId(item);
12273 const elementRef = (0, import_element32.useRef)(null);
12274 const setRefs = (0, import_element32.useCallback)(
12275 (node) => {
12276 elementRef.current = node;
12277 if (typeof forwardedRef === "function") {
12278 forwardedRef(node);
12279 } else if (forwardedRef) {
12280 forwardedRef.current = node;
12281 }
12282 },
12283 [forwardedRef]
12284 );
12285 useIntersectionObserver(elementRef, posinset);
12286 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12287 const isSelected2 = selection.includes(id);
12288 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12289 const rendersMediaField = showMedia && mediaField?.render;
12290 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12291 mediaField.render,
12292 {
12293 item,
12294 field: mediaField,
12295 config
12296 }
12297 ) : mediaPlaceholder;
12298 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
12299 let mediaA11yProps;
12300 let titleA11yProps;
12301 if (isItemClickable(item) && onClickItem) {
12302 if (renderedTitleField) {
12303 mediaA11yProps = {
12304 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12305 };
12306 titleA11yProps = {
12307 id: `dataviews-view-grid__title-field-${instanceId}`
12308 };
12309 } else {
12310 mediaA11yProps = {
12311 "aria-label": (0, import_i18n11.__)("Navigate to item")
12312 };
12313 }
12314 }
12315 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12316 Stack,
12317 {
12318 direction: "column",
12319 ...props,
12320 ref: setRefs,
12321 "aria-setsize": setsize,
12322 "aria-posinset": posinset,
12323 className: clsx_default(
12324 props.className,
12325 "dataviews-view-grid__row__gridcell",
12326 "dataviews-view-grid__card",
12327 {
12328 "is-selected": hasBulkAction && isSelected2
12329 }
12330 ),
12331 children: [
12332 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12333 ItemClickWrapper,
12334 {
12335 item,
12336 isItemClickable,
12337 onClickItem,
12338 renderItemLink,
12339 className: clsx_default("dataviews-view-grid__media", {
12340 "dataviews-view-grid__media--placeholder": !rendersMediaField
12341 }),
12342 ...mediaA11yProps,
12343 children: renderedMediaField
12344 }
12345 ),
12346 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12347 DataViewsSelectionCheckbox,
12348 {
12349 item,
12350 selection,
12351 onChangeSelection,
12352 getItemId,
12353 titleField,
12354 disabled: !hasBulkAction
12355 }
12356 ),
12357 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12358 ItemActions,
12359 {
12360 item,
12361 actions,
12362 isCompact: true
12363 }
12364 ) }),
12365 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12366 ItemClickWrapper,
12367 {
12368 item,
12369 isItemClickable,
12370 onClickItem,
12371 renderItemLink,
12372 className: "dataviews-view-grid__title-field dataviews-title-field",
12373 ...titleA11yProps,
12374 title: titleField?.getValueFormatted({
12375 item,
12376 field: titleField
12377 }) || void 0,
12378 children: renderedTitleField
12379 }
12380 ) }),
12381 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12382 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12383 descriptionField.render,
12384 {
12385 item,
12386 field: descriptionField
12387 }
12388 ),
12389 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12390 Stack,
12391 {
12392 direction: "row",
12393 className: "dataviews-view-grid__badge-fields",
12394 gap: "sm",
12395 wrap: "wrap",
12396 align: "top",
12397 justify: "flex-start",
12398 children: badgeFields.map((field) => {
12399 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12400 WCBadge,
12401 {
12402 className: "dataviews-view-grid__field-value",
12403 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12404 field.render,
12405 {
12406 item,
12407 field
12408 }
12409 )
12410 },
12411 field.id
12412 );
12413 })
12414 }
12415 ),
12416 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12417 Stack,
12418 {
12419 direction: "column",
12420 className: "dataviews-view-grid__fields",
12421 gap: "xs",
12422 children: regularFields.map((field) => {
12423 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12424 import_components8.Flex,
12425 {
12426 className: "dataviews-view-grid__field",
12427 gap: 1,
12428 justify: "flex-start",
12429 expanded: true,
12430 style: { height: "auto" },
12431 direction: "row",
12432 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12433 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12434 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12435 tooltip_exports.Trigger,
12436 {
12437 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12438 }
12439 ),
12440 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12441 ] }),
12442 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12443 import_components8.FlexItem,
12444 {
12445 className: "dataviews-view-grid__field-value",
12446 style: { maxHeight: "none" },
12447 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12448 field.render,
12449 {
12450 item,
12451 field
12452 }
12453 )
12454 }
12455 )
12456 ] })
12457 },
12458 field.id
12459 );
12460 })
12461 }
12462 )
12463 ] })
12464 ]
12465 }
12466 );
12467 }
12468 );
12469 function CompositeGrid({
12470 data,
12471 isInfiniteScroll,
12472 className,
12473 inert,
12474 isLoading,
12475 view,
12476 fields,
12477 selection,
12478 onChangeSelection,
12479 onClickItem,
12480 isItemClickable,
12481 renderItemLink,
12482 getItemId,
12483 actions,
12484 getSelectionProps
12485 }) {
12486 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
12487 const gridColumns = useGridColumns();
12488 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12489 const titleField = fields.find(
12490 (field) => field.id === view?.titleField
12491 );
12492 const mediaField = fields.find(
12493 (field) => field.id === view?.mediaField
12494 );
12495 const descriptionField = fields.find(
12496 (field) => field.id === view?.descriptionField
12497 );
12498 const otherFields = view.fields ?? [];
12499 const { regularFields, badgeFields } = otherFields.reduce(
12500 (accumulator, fieldId) => {
12501 const field = fields.find((f2) => f2.id === fieldId);
12502 if (!field) {
12503 return accumulator;
12504 }
12505 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12506 accumulator[key].push(field);
12507 return accumulator;
12508 },
12509 { regularFields: [], badgeFields: [] }
12510 );
12511 const size4 = "900px";
12512 const totalRows = Math.ceil(data.length / gridColumns);
12513 const placeholdersNeeded = usePlaceholdersNeeded(
12514 data,
12515 isInfiniteScroll,
12516 gridColumns
12517 );
12518 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12519 // Render infinite scroll layout (no rows, feed semantics)
12520 children: [
12521 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12522 import_components8.Composite,
12523 {
12524 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12525 GridItems,
12526 {
12527 className: clsx_default(
12528 "dataviews-view-grid-infinite-scroll",
12529 className,
12530 {
12531 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12532 "compact",
12533 "comfortable"
12534 ].includes(view.layout.density)
12535 }
12536 ),
12537 previewSize: view.layout?.previewSize,
12538 "aria-busy": isLoading,
12539 ref: resizeObserverRef
12540 }
12541 ),
12542 role: "feed",
12543 focusWrap: true,
12544 inert,
12545 children: [
12546 Array.from({ length: placeholdersNeeded }).map(
12547 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12548 import_components8.Composite.Item,
12549 {
12550 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12551 Stack,
12552 {
12553 ...props,
12554 direction: "column",
12555 role: "article",
12556 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12557 }
12558 ),
12559 "aria-hidden": true,
12560 tabIndex: -1
12561 },
12562 `placeholder-${index2}`
12563 )
12564 ),
12565 data.map((item) => {
12566 const itemId = getItemId(item);
12567 const selectionProps = getSelectionProps(itemId);
12568 const stablePosition = item.position;
12569 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12570 import_components8.Composite.Item,
12571 {
12572 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12573 GridItem,
12574 {
12575 ...props,
12576 id: itemId,
12577 role: "article",
12578 view,
12579 selection,
12580 onChangeSelection,
12581 onClickItem,
12582 isItemClickable,
12583 renderItemLink,
12584 getItemId,
12585 item,
12586 actions,
12587 onMouseDown: (event) => {
12588 props.onMouseDown?.(event);
12589 selectionProps.onMouseDown(
12590 event
12591 );
12592 },
12593 onClickCapture: (event) => {
12594 props.onClickCapture?.(event);
12595 selectionProps.onClickCapture(
12596 event
12597 );
12598 },
12599 mediaField,
12600 titleField,
12601 descriptionField,
12602 regularFields,
12603 badgeFields,
12604 hasBulkActions,
12605 posinset: stablePosition,
12606 setsize: paginationInfo.totalItems,
12607 config: {
12608 sizes: size4
12609 }
12610 }
12611 )
12612 },
12613 itemId
12614 );
12615 })
12616 ]
12617 }
12618 ),
12619 // Render standard grid layout (with rows, grid semantics)
12620 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12621 import_components8.Composite,
12622 {
12623 role: "grid",
12624 className: clsx_default("dataviews-view-grid", className, {
12625 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12626 view.layout.density
12627 )
12628 }),
12629 focusWrap: true,
12630 "aria-busy": isLoading,
12631 "aria-rowcount": totalRows,
12632 ref: resizeObserverRef,
12633 inert,
12634 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12635 import_components8.Composite.Row,
12636 {
12637 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12638 "div",
12639 {
12640 role: "row",
12641 "aria-rowindex": i2 + 1,
12642 "aria-label": (0, import_i18n11.sprintf)(
12643 /* translators: %d: The row number in the grid */
12644 (0, import_i18n11.__)("Row %d"),
12645 i2 + 1
12646 ),
12647 className: "dataviews-view-grid__row",
12648 style: {
12649 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12650 }
12651 }
12652 ),
12653 children: row.map((item) => {
12654 const itemId = getItemId(item);
12655 const selectionProps = getSelectionProps(itemId);
12656 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12657 import_components8.Composite.Item,
12658 {
12659 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12660 GridItem,
12661 {
12662 ...props,
12663 id: itemId,
12664 role: "gridcell",
12665 view,
12666 selection,
12667 onChangeSelection,
12668 onClickItem,
12669 isItemClickable,
12670 renderItemLink,
12671 getItemId,
12672 item,
12673 actions,
12674 onMouseDown: (event) => {
12675 props.onMouseDown?.(
12676 event
12677 );
12678 selectionProps.onMouseDown(
12679 event
12680 );
12681 },
12682 onClickCapture: (event) => {
12683 props.onClickCapture?.(
12684 event
12685 );
12686 selectionProps.onClickCapture(
12687 event
12688 );
12689 },
12690 mediaField,
12691 titleField,
12692 descriptionField,
12693 regularFields,
12694 badgeFields,
12695 hasBulkActions,
12696 config: {
12697 sizes: size4
12698 }
12699 }
12700 )
12701 },
12702 itemId
12703 );
12704 })
12705 },
12706 i2
12707 ))
12708 }
12709 )
12710 ]
12711 });
12712 }
12713
12714 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12715 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12716 function ViewGrid({
12717 actions,
12718 data,
12719 fields,
12720 getItemId,
12721 isLoading,
12722 onChangeSelection,
12723 onClickItem,
12724 isItemClickable,
12725 renderItemLink,
12726 selection,
12727 view,
12728 className,
12729 empty
12730 }) {
12731 const isDelayedLoading = useDelayedLoading(!!isLoading);
12732 const hasData = !!data?.length;
12733 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12734 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12735 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12736 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12737 const { getSelectionProps } = useSelectionProps({
12738 data: orderedData,
12739 actions,
12740 getItemId,
12741 selection,
12742 onChangeSelection
12743 });
12744 if (!hasData) {
12745 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12746 "div",
12747 {
12748 className: clsx_default("dataviews-no-results", {
12749 "is-refreshing": isDelayedLoading
12750 }),
12751 children: empty
12752 }
12753 );
12754 }
12755 const gridProps = {
12756 className: clsx_default(className, {
12757 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12758 }),
12759 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12760 isLoading,
12761 view,
12762 fields,
12763 selection,
12764 onChangeSelection,
12765 onClickItem,
12766 isItemClickable,
12767 renderItemLink,
12768 getItemId,
12769 actions,
12770 getSelectionProps
12771 };
12772 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12773 // Render multiple groups.
12774 children: [
12775 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12776 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12777 Stack,
12778 {
12779 direction: "column",
12780 gap: "sm",
12781 children: [
12782 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12783 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12784 (0, import_i18n12.__)("%1$s: %2$s"),
12785 groupField.label,
12786 groupName
12787 ) }),
12788 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12789 CompositeGrid,
12790 {
12791 ...gridProps,
12792 data: groupItems,
12793 isInfiniteScroll: false
12794 }
12795 )
12796 ]
12797 },
12798 groupName
12799 )
12800 ) }),
12801 // Render a single grid with all data.
12802 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12803 CompositeGrid,
12804 {
12805 ...gridProps,
12806 data,
12807 isInfiniteScroll: !!isInfiniteScroll
12808 }
12809 ),
12810 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12811 ]
12812 });
12813 }
12814 var grid_default = ViewGrid;
12815
12816 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12817 var import_compose4 = __toESM(require_compose(), 1);
12818 var import_components10 = __toESM(require_components(), 1);
12819 var import_element33 = __toESM(require_element(), 1);
12820 var import_i18n13 = __toESM(require_i18n(), 1);
12821 var import_data6 = __toESM(require_data(), 1);
12822 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12823 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12824 function generateItemWrapperCompositeId(idPrefix) {
12825 return `${idPrefix}-item-wrapper`;
12826 }
12827 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12828 return `${idPrefix}-primary-action-${primaryActionId}`;
12829 }
12830 function generateDropdownTriggerCompositeId(idPrefix) {
12831 return `${idPrefix}-dropdown`;
12832 }
12833 function PrimaryActionGridCell({
12834 idPrefix,
12835 primaryAction,
12836 item
12837 }) {
12838 const registry = (0, import_data6.useRegistry)();
12839 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
12840 const compositeItemId = generatePrimaryActionCompositeId(
12841 idPrefix,
12842 primaryAction.id
12843 );
12844 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12845 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12846 import_components10.Composite.Item,
12847 {
12848 id: compositeItemId,
12849 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12850 import_components10.Button,
12851 {
12852 disabled: !!primaryAction.disabled,
12853 accessibleWhenDisabled: true,
12854 text: label,
12855 size: "small",
12856 onClick: () => setIsModalOpen(true)
12857 }
12858 ),
12859 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12860 ActionModal,
12861 {
12862 action: primaryAction,
12863 items: [item],
12864 closeModal: () => setIsModalOpen(false)
12865 }
12866 )
12867 }
12868 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12869 import_components10.Composite.Item,
12870 {
12871 id: compositeItemId,
12872 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12873 import_components10.Button,
12874 {
12875 disabled: !!primaryAction.disabled,
12876 accessibleWhenDisabled: true,
12877 size: "small",
12878 onClick: () => {
12879 primaryAction.callback([item], { registry });
12880 },
12881 children: label
12882 }
12883 )
12884 }
12885 ) }, primaryAction.id);
12886 }
12887 function ListItem({
12888 view,
12889 actions,
12890 idPrefix,
12891 isSelected: isSelected2,
12892 item,
12893 titleField,
12894 mediaField,
12895 descriptionField,
12896 onSelect,
12897 otherFields,
12898 onDropdownTriggerKeyDown,
12899 posinset
12900 }) {
12901 const {
12902 showTitle = true,
12903 showMedia = true,
12904 showDescription = true,
12905 infiniteScrollEnabled
12906 } = view;
12907 const itemRef = (0, import_element33.useRef)(null);
12908 const labelId = `${idPrefix}-label`;
12909 const descriptionId = `${idPrefix}-description`;
12910 const registry = (0, import_data6.useRegistry)();
12911 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
12912 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
12913 null
12914 );
12915 const handleHover = ({ type }) => {
12916 const isHover = type === "mouseenter";
12917 setIsHovered(isHover);
12918 };
12919 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
12920 (0, import_element33.useEffect)(() => {
12921 if (isSelected2) {
12922 itemRef.current?.scrollIntoView({
12923 behavior: "auto",
12924 block: "nearest",
12925 inline: "nearest"
12926 });
12927 }
12928 }, [isSelected2]);
12929 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
12930 const _eligibleActions = actions.filter(
12931 (action) => !action.isEligible || action.isEligible(item)
12932 );
12933 const _primaryActions = _eligibleActions.filter(
12934 (action) => action.isPrimary
12935 );
12936 return {
12937 primaryAction: _primaryActions[0],
12938 eligibleActions: _eligibleActions
12939 };
12940 }, [actions, item]);
12941 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12942 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)(
12943 mediaField.render,
12944 {
12945 item,
12946 field: mediaField,
12947 config: { sizes: "52px" }
12948 }
12949 ) }) : null;
12950 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12951 const renderDescription = showDescription && descriptionField?.render;
12952 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12953 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12954 Stack,
12955 {
12956 direction: "row",
12957 gap: "md",
12958 className: "dataviews-view-list__item-actions",
12959 children: [
12960 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12961 PrimaryActionGridCell,
12962 {
12963 idPrefix,
12964 primaryAction,
12965 item
12966 }
12967 ),
12968 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12969 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12970 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12971 Menu3.TriggerButton,
12972 {
12973 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12974 import_components10.Composite.Item,
12975 {
12976 id: generateDropdownTriggerCompositeId(
12977 idPrefix
12978 ),
12979 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12980 import_components10.Button,
12981 {
12982 size: "small",
12983 icon: more_vertical_default,
12984 label: (0, import_i18n13.__)("Actions"),
12985 accessibleWhenDisabled: true,
12986 disabled: !actions.length,
12987 onKeyDown: onDropdownTriggerKeyDown
12988 }
12989 )
12990 }
12991 )
12992 }
12993 ),
12994 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12995 ActionsMenuGroup,
12996 {
12997 actions: eligibleActions,
12998 item,
12999 registry,
13000 setActiveModalAction
13001 }
13002 ) })
13003 ] }),
13004 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13005 ActionModal,
13006 {
13007 action: activeModalAction,
13008 items: [item],
13009 closeModal: () => setActiveModalAction(null)
13010 }
13011 )
13012 ] })
13013 ]
13014 }
13015 );
13016 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13017 import_components10.Composite.Row,
13018 {
13019 ref: itemRef,
13020 render: (
13021 /* aria-posinset breaks Composite.Row if passed to it directly. */
13022 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13023 "div",
13024 {
13025 "aria-posinset": posinset,
13026 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13027 }
13028 )
13029 ),
13030 role: infiniteScrollEnabled ? "article" : "row",
13031 className: clsx_default({
13032 "is-selected": isSelected2,
13033 "is-hovered": isHovered
13034 }),
13035 onMouseEnter: handleHover,
13036 onMouseLeave: handleHover,
13037 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13038 Stack,
13039 {
13040 direction: "row",
13041 className: "dataviews-view-list__item-wrapper",
13042 children: [
13043 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13044 import_components10.Composite.Item,
13045 {
13046 id: generateItemWrapperCompositeId(idPrefix),
13047 "aria-pressed": isSelected2,
13048 "aria-labelledby": labelId,
13049 "aria-describedby": descriptionId,
13050 className: "dataviews-view-list__item",
13051 onClick: () => onSelect(item)
13052 }
13053 ) }),
13054 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13055 Stack,
13056 {
13057 direction: "row",
13058 gap: "md",
13059 justify: "start",
13060 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13061 style: { flex: 1, minWidth: 0 },
13062 children: [
13063 renderedMediaField,
13064 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13065 Stack,
13066 {
13067 direction: "column",
13068 gap: "xs",
13069 className: "dataviews-view-list__field-wrapper",
13070 children: [
13071 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
13072 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13073 "div",
13074 {
13075 className: "dataviews-title-field dataviews-view-list__title-field",
13076 id: labelId,
13077 children: renderedTitleField
13078 }
13079 ),
13080 usedActions
13081 ] }),
13082 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13083 descriptionField.render,
13084 {
13085 item,
13086 field: descriptionField
13087 }
13088 ) }),
13089 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13090 "div",
13091 {
13092 className: "dataviews-view-list__fields",
13093 id: descriptionId,
13094 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13095 "div",
13096 {
13097 className: "dataviews-view-list__field",
13098 children: [
13099 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13100 VisuallyHidden,
13101 {
13102 className: "dataviews-view-list__field-label",
13103 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
13104 children: field.label
13105 }
13106 ),
13107 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13108 field.render,
13109 {
13110 item,
13111 field
13112 }
13113 ) })
13114 ]
13115 },
13116 field.id
13117 ))
13118 }
13119 )
13120 ]
13121 }
13122 )
13123 ]
13124 }
13125 )
13126 ]
13127 }
13128 )
13129 }
13130 );
13131 }
13132 function isDefined2(item) {
13133 return !!item;
13134 }
13135 function ViewList(props) {
13136 const {
13137 actions,
13138 data,
13139 fields,
13140 getItemId,
13141 isLoading,
13142 onChangeSelection,
13143 selection,
13144 view,
13145 className,
13146 empty
13147 } = props;
13148 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13149 const isDelayedLoading = useDelayedLoading(!!isLoading);
13150 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13151 const selectedItem = data?.findLast(
13152 (item) => selection.includes(getItemId(item))
13153 );
13154 const titleField = fields.find((field) => field.id === view.titleField);
13155 const mediaField = fields.find((field) => field.id === view.mediaField);
13156 const descriptionField = fields.find(
13157 (field) => field.id === view.descriptionField
13158 );
13159 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13160 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13161 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
13162 (item) => `${baseId}-${getItemId(item)}`,
13163 [baseId, getItemId]
13164 );
13165 const isActiveCompositeItem = (0, import_element33.useCallback)(
13166 (item, idToCheck) => {
13167 return idToCheck.startsWith(
13168 generateCompositeItemIdPrefix(item)
13169 );
13170 },
13171 [generateCompositeItemIdPrefix]
13172 );
13173 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
13174 const compositeRef = (0, import_element33.useRef)(null);
13175 (0, import_element33.useEffect)(() => {
13176 if (selectedItem) {
13177 setActiveCompositeId(
13178 generateItemWrapperCompositeId(
13179 generateCompositeItemIdPrefix(selectedItem)
13180 )
13181 );
13182 }
13183 }, [selectedItem, generateCompositeItemIdPrefix]);
13184 const activeItemIndex = data.findIndex(
13185 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13186 );
13187 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13188 const isActiveIdInList = activeItemIndex !== -1;
13189 const selectCompositeItem = (0, import_element33.useCallback)(
13190 (targetIndex, generateCompositeId) => {
13191 const clampedIndex = Math.min(
13192 data.length - 1,
13193 Math.max(0, targetIndex)
13194 );
13195 if (!data[clampedIndex]) {
13196 return;
13197 }
13198 const itemIdPrefix = generateCompositeItemIdPrefix(
13199 data[clampedIndex]
13200 );
13201 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13202 setActiveCompositeId(targetCompositeItemId);
13203 if (compositeRef.current?.contains(
13204 compositeRef.current.ownerDocument.activeElement
13205 )) {
13206 document.getElementById(targetCompositeItemId)?.focus();
13207 }
13208 },
13209 [data, generateCompositeItemIdPrefix]
13210 );
13211 (0, import_element33.useEffect)(() => {
13212 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13213 if (!isActiveIdInList && wasActiveIdInList) {
13214 selectCompositeItem(
13215 previousActiveItemIndex,
13216 generateItemWrapperCompositeId
13217 );
13218 }
13219 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13220 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
13221 (event) => {
13222 if (event.key === "ArrowDown") {
13223 event.preventDefault();
13224 selectCompositeItem(
13225 activeItemIndex + 1,
13226 generateDropdownTriggerCompositeId
13227 );
13228 }
13229 if (event.key === "ArrowUp") {
13230 event.preventDefault();
13231 selectCompositeItem(
13232 activeItemIndex - 1,
13233 generateDropdownTriggerCompositeId
13234 );
13235 }
13236 },
13237 [selectCompositeItem, activeItemIndex]
13238 );
13239 const hasData = !!data?.length;
13240 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13241 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13242 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13243 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13244 const listClassName = clsx_default("dataviews-view-list", className, {
13245 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13246 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13247 });
13248 const compositeProps = {
13249 ref: compositeRef,
13250 id: baseId,
13251 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
13252 activeId: activeCompositeId,
13253 setActiveId: setActiveCompositeId,
13254 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13255 };
13256 if (!hasData) {
13257 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13258 "div",
13259 {
13260 className: clsx_default("dataviews-no-results", {
13261 "is-refreshing": isDelayedLoading
13262 }),
13263 children: empty
13264 }
13265 );
13266 }
13267 if (hasData && groupField && dataByGroup) {
13268 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13269 import_components10.Composite,
13270 {
13271 ...compositeProps,
13272 className: "dataviews-view-list__group",
13273 role: "grid",
13274 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13275 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "column", children: [
13276 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
13277 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13278 (0, import_i18n13.__)("%1$s: %2$s"),
13279 groupField.label,
13280 groupName
13281 ) }),
13282 groupItems.map((item) => {
13283 const id = generateCompositeItemIdPrefix(item);
13284 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13285 ListItem,
13286 {
13287 view,
13288 idPrefix: id,
13289 actions,
13290 item,
13291 isSelected: item === selectedItem,
13292 onSelect,
13293 mediaField,
13294 titleField,
13295 descriptionField,
13296 otherFields,
13297 onDropdownTriggerKeyDown
13298 },
13299 id
13300 );
13301 })
13302 ] }, groupName)
13303 ) })
13304 }
13305 );
13306 }
13307 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
13308 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13309 import_components10.Composite,
13310 {
13311 ...compositeProps,
13312 className: listClassName,
13313 role: view.infiniteScrollEnabled ? "feed" : "grid",
13314 children: data.map((item, index2) => {
13315 const id = generateCompositeItemIdPrefix(item);
13316 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13317 ListItem,
13318 {
13319 view,
13320 idPrefix: id,
13321 actions,
13322 item,
13323 isSelected: item === selectedItem,
13324 onSelect,
13325 mediaField,
13326 titleField,
13327 descriptionField,
13328 otherFields,
13329 onDropdownTriggerKeyDown,
13330 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13331 },
13332 id
13333 );
13334 })
13335 }
13336 ),
13337 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13338 // scroll position doesn't bounce. Hidden, and silent to a11y,
13339 // while idle.
13340 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13341 "p",
13342 {
13343 className: "dataviews-loading-more",
13344 "aria-hidden": !isLoading,
13345 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {})
13346 }
13347 )
13348 ] });
13349 }
13350
13351 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13352 var import_components11 = __toESM(require_components(), 1);
13353
13354 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13355 var import_i18n14 = __toESM(require_i18n(), 1);
13356 var import_element34 = __toESM(require_element(), 1);
13357 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13358 function ActivityGroup({
13359 groupName,
13360 groupData,
13361 groupField,
13362 showLabel = true,
13363 children
13364 }) {
13365 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
13366 // translators: %s: The label of the field e.g. "Status".
13367 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
13368 {
13369 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
13370 groupField.render,
13371 {
13372 item: groupData[0],
13373 field: groupField
13374 }
13375 )
13376 }
13377 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
13378 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
13379 Stack,
13380 {
13381 direction: "column",
13382 className: "dataviews-view-activity__group",
13383 children: [
13384 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13385 children
13386 ]
13387 },
13388 groupName
13389 );
13390 }
13391
13392 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13393 var import_element35 = __toESM(require_element(), 1);
13394 var import_data7 = __toESM(require_data(), 1);
13395 var import_compose5 = __toESM(require_compose(), 1);
13396 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13397 function ActivityItem(props) {
13398 const {
13399 view,
13400 actions,
13401 item,
13402 titleField,
13403 mediaField,
13404 descriptionField,
13405 otherFields,
13406 posinset,
13407 onClickItem,
13408 renderItemLink,
13409 isItemClickable
13410 } = props;
13411 const {
13412 showTitle = true,
13413 showMedia = true,
13414 showDescription = true,
13415 infiniteScrollEnabled
13416 } = view;
13417 const itemRef = (0, import_element35.useRef)(null);
13418 const registry = (0, import_data7.useRegistry)();
13419 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
13420 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
13421 const _eligibleActions = actions.filter(
13422 (action) => !action.isEligible || action.isEligible(item)
13423 );
13424 const _primaryActions = _eligibleActions.filter(
13425 (action) => action.isPrimary
13426 );
13427 return {
13428 primaryActions: _primaryActions,
13429 eligibleActions: _eligibleActions
13430 };
13431 }, [actions, item]);
13432 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13433 const density = view.layout?.density ?? "balanced";
13434 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13435 mediaField.render,
13436 {
13437 item,
13438 field: mediaField,
13439 config: {
13440 sizes: density === "comfortable" ? "32px" : "24px"
13441 }
13442 }
13443 ) : null;
13444 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13445 "span",
13446 {
13447 className: "dataviews-view-activity__item-bullet",
13448 "aria-hidden": "true"
13449 }
13450 ) });
13451 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13452 const verticalGap = (0, import_element35.useMemo)(() => {
13453 switch (density) {
13454 case "comfortable":
13455 return "md";
13456 default:
13457 return "sm";
13458 }
13459 }, [density]);
13460 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13461 "div",
13462 {
13463 ref: itemRef,
13464 role: infiniteScrollEnabled ? "article" : void 0,
13465 "aria-posinset": posinset,
13466 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13467 className: clsx_default(
13468 "dataviews-view-activity__item",
13469 density === "compact" && "is-compact",
13470 density === "balanced" && "is-balanced",
13471 density === "comfortable" && "is-comfortable"
13472 ),
13473 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13474 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13475 Stack,
13476 {
13477 direction: "column",
13478 gap: "xs",
13479 align: "center",
13480 className: "dataviews-view-activity__item-type",
13481 children: renderedMediaField
13482 }
13483 ),
13484 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13485 Stack,
13486 {
13487 direction: "column",
13488 gap: verticalGap,
13489 align: "flex-start",
13490 className: "dataviews-view-activity__item-content",
13491 children: [
13492 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13493 ItemClickWrapper,
13494 {
13495 item,
13496 isItemClickable,
13497 onClickItem,
13498 renderItemLink,
13499 className: "dataviews-view-activity__item-title",
13500 children: renderedTitleField
13501 }
13502 ),
13503 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13504 descriptionField.render,
13505 {
13506 item,
13507 field: descriptionField
13508 }
13509 ) }),
13510 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13511 "div",
13512 {
13513 className: "dataviews-view-activity__item-field",
13514 children: [
13515 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13516 VisuallyHidden,
13517 {
13518 className: "dataviews-view-activity__item-field-label",
13519 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13520 children: field.label
13521 }
13522 ),
13523 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13524 field.render,
13525 {
13526 item,
13527 field
13528 }
13529 ) })
13530 ]
13531 },
13532 field.id
13533 )) }),
13534 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13535 PrimaryActions,
13536 {
13537 item,
13538 actions: primaryActions,
13539 registry,
13540 buttonVariant: "secondary"
13541 }
13542 )
13543 ]
13544 }
13545 ),
13546 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13547 // there if there are any actions at all.
13548 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13549 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13550 ItemActions,
13551 {
13552 item,
13553 actions: eligibleActions,
13554 isCompact: true
13555 }
13556 ) })
13557 ] })
13558 }
13559 );
13560 }
13561 var activity_item_default = ActivityItem;
13562
13563 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13564 var import_react6 = __toESM(require_react(), 1);
13565 function isDefined3(item) {
13566 return !!item;
13567 }
13568 function ActivityItems(props) {
13569 const { data, fields, getItemId, view } = props;
13570 const titleField = fields.find((field) => field.id === view.titleField);
13571 const mediaField = fields.find((field) => field.id === view.mediaField);
13572 const descriptionField = fields.find(
13573 (field) => field.id === view.descriptionField
13574 );
13575 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13576 return data.map((item, index2) => {
13577 return /* @__PURE__ */ (0, import_react6.createElement)(
13578 activity_item_default,
13579 {
13580 ...props,
13581 key: getItemId(item),
13582 item,
13583 mediaField,
13584 titleField,
13585 descriptionField,
13586 otherFields,
13587 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13588 }
13589 );
13590 });
13591 }
13592
13593 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13594 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13595 function ViewActivity(props) {
13596 const { empty, data, fields, isLoading, view, className } = props;
13597 const isDelayedLoading = useDelayedLoading(!!isLoading);
13598 const hasData = !!data?.length;
13599 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13600 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13601 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13602 if (!hasData) {
13603 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13604 "div",
13605 {
13606 className: clsx_default("dataviews-no-results", {
13607 "is-refreshing": isDelayedLoading
13608 }),
13609 children: empty
13610 }
13611 );
13612 }
13613 const isInert = !isInfiniteScroll && !!isLoading;
13614 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13615 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13616 });
13617 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13618 if (hasData && groupField && dataByGroup) {
13619 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13620 Stack,
13621 {
13622 direction: "column",
13623 gap: "sm",
13624 className: wrapperClassName,
13625 inert: isInert ? "true" : void 0,
13626 children: groupedEntries.map(
13627 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13628 ActivityGroup,
13629 {
13630 groupName,
13631 groupData,
13632 groupField,
13633 showLabel: view.groupBy?.showLabel !== false,
13634 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13635 ActivityItems,
13636 {
13637 ...props,
13638 data: groupData
13639 }
13640 )
13641 },
13642 groupName
13643 )
13644 )
13645 }
13646 );
13647 }
13648 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13649 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13650 "div",
13651 {
13652 className: wrapperClassName,
13653 role: view.infiniteScrollEnabled ? "feed" : void 0,
13654 inert: isInert ? "true" : void 0,
13655 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13656 }
13657 ),
13658 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13659 ] });
13660 }
13661
13662 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13663 var import_components14 = __toESM(require_components(), 1);
13664 var import_i18n17 = __toESM(require_i18n(), 1);
13665 var import_compose6 = __toESM(require_compose(), 1);
13666 var import_element38 = __toESM(require_element(), 1);
13667
13668 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13669 var import_components13 = __toESM(require_components(), 1);
13670 var import_data8 = __toESM(require_data(), 1);
13671 var import_element37 = __toESM(require_element(), 1);
13672 var import_i18n16 = __toESM(require_i18n(), 1);
13673
13674 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13675 var import_components12 = __toESM(require_components(), 1);
13676 var import_element36 = __toESM(require_element(), 1);
13677 var import_i18n15 = __toESM(require_i18n(), 1);
13678 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13679 function hasPaginationControls(view, paginationInfo) {
13680 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
13681 }
13682 function DataViewsPagination() {
13683 const { view, onChangeView, paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13684 if (!hasPaginationControls(view, paginationInfo)) {
13685 return null;
13686 }
13687 const { totalPages } = paginationInfo;
13688 const currentPage = view.page ?? 1;
13689 const pageSelectOptions = Array.from(Array(totalPages)).map(
13690 (_, i2) => {
13691 const page = i2 + 1;
13692 return {
13693 value: page.toString(),
13694 label: page.toString(),
13695 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13696 // translators: 1: current page number. 2: total number of pages.
13697 (0, import_i18n15.__)("Page %1$d of %2$d"),
13698 currentPage,
13699 totalPages
13700 ) : page.toString()
13701 };
13702 }
13703 );
13704 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13705 Stack,
13706 {
13707 direction: "row",
13708 className: "dataviews-pagination",
13709 justify: "end",
13710 align: "center",
13711 gap: "xl",
13712 children: [
13713 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13714 Stack,
13715 {
13716 direction: "row",
13717 justify: "flex-start",
13718 align: "center",
13719 gap: "xs",
13720 className: "dataviews-pagination__page-select",
13721 children: (0, import_element36.createInterpolateElement)(
13722 (0, import_i18n15.sprintf)(
13723 // translators: 1: Current page number, 2: Total number of pages.
13724 (0, import_i18n15._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
13725 "<CurrentPage />",
13726 totalPages
13727 ),
13728 {
13729 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13730 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13731 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13732 import_components12.SelectControl,
13733 {
13734 "aria-label": (0, import_i18n15.__)("Current page"),
13735 value: currentPage.toString(),
13736 options: pageSelectOptions,
13737 onChange: (newValue) => {
13738 onChangeView({
13739 ...view,
13740 page: +newValue
13741 });
13742 },
13743 size: "small",
13744 variant: "minimal"
13745 }
13746 )
13747 }
13748 )
13749 }
13750 ),
13751 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13752 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13753 import_components12.Button,
13754 {
13755 onClick: () => onChangeView({
13756 ...view,
13757 page: currentPage - 1
13758 }),
13759 disabled: currentPage === 1,
13760 accessibleWhenDisabled: true,
13761 label: (0, import_i18n15.__)("Previous page"),
13762 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13763 showTooltip: true,
13764 size: "compact",
13765 tooltipPosition: "top"
13766 }
13767 ),
13768 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13769 import_components12.Button,
13770 {
13771 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13772 disabled: currentPage >= totalPages,
13773 accessibleWhenDisabled: true,
13774 label: (0, import_i18n15.__)("Next page"),
13775 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13776 showTooltip: true,
13777 size: "compact",
13778 tooltipPosition: "top"
13779 }
13780 )
13781 ] })
13782 ]
13783 }
13784 );
13785 }
13786 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
13787
13788 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13789 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13790 function useIsMultiselectPicker(actions) {
13791 return (0, import_element37.useMemo)(() => {
13792 return !!actions?.length && actions?.every((action) => action.supportsBulk);
13793 }, [actions]);
13794 }
13795
13796 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13797 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13798 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13799 function GridItem3({
13800 view,
13801 multiselect,
13802 selection,
13803 onChangeSelection,
13804 getItemId,
13805 item,
13806 mediaField,
13807 titleField,
13808 descriptionField,
13809 regularFields,
13810 badgeFields,
13811 config,
13812 posinset,
13813 setsize
13814 }) {
13815 const { showTitle = true, showMedia = true, showDescription = true } = view;
13816 const id = getItemId(item);
13817 const elementRef = (0, import_element38.useRef)(null);
13818 const isSelected2 = selection.includes(id);
13819 useIntersectionObserver(elementRef, posinset);
13820 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13821 mediaField.render,
13822 {
13823 item,
13824 field: mediaField,
13825 config
13826 }
13827 ) : null;
13828 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13829 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13830 import_components14.Composite.Item,
13831 {
13832 ref: elementRef,
13833 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13834 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13835 role: "option",
13836 "aria-posinset": posinset,
13837 "aria-setsize": setsize,
13838 className: clsx_default("dataviews-view-picker-grid__card", {
13839 "is-selected": isSelected2
13840 }),
13841 "aria-selected": isSelected2,
13842 onClick: () => {
13843 if (isSelected2) {
13844 onChangeSelection(
13845 selection.filter((itemId) => id !== itemId)
13846 );
13847 } else {
13848 const newSelection = multiselect ? [...selection, id] : [id];
13849 onChangeSelection(newSelection);
13850 }
13851 },
13852 children: [
13853 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13854 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13855 DataViewsSelectionCheckbox,
13856 {
13857 item,
13858 selection,
13859 onChangeSelection,
13860 getItemId,
13861 titleField,
13862 disabled: false,
13863 "aria-hidden": true,
13864 tabIndex: -1
13865 }
13866 ),
13867 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13868 Stack,
13869 {
13870 direction: "row",
13871 justify: "space-between",
13872 className: "dataviews-view-picker-grid__title-actions",
13873 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13874 }
13875 ),
13876 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13877 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13878 descriptionField.render,
13879 {
13880 item,
13881 field: descriptionField
13882 }
13883 ),
13884 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13885 Stack,
13886 {
13887 direction: "row",
13888 className: "dataviews-view-picker-grid__badge-fields",
13889 gap: "sm",
13890 wrap: "wrap",
13891 align: "top",
13892 justify: "flex-start",
13893 children: badgeFields.map((field) => {
13894 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13895 WCBadge2,
13896 {
13897 className: "dataviews-view-picker-grid__field-value",
13898 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13899 field.render,
13900 {
13901 item,
13902 field
13903 }
13904 )
13905 },
13906 field.id
13907 );
13908 })
13909 }
13910 ),
13911 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13912 Stack,
13913 {
13914 direction: "column",
13915 className: "dataviews-view-picker-grid__fields",
13916 gap: "xs",
13917 children: regularFields.map((field) => {
13918 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13919 import_components14.Flex,
13920 {
13921 className: "dataviews-view-picker-grid__field",
13922 gap: 1,
13923 justify: "flex-start",
13924 expanded: true,
13925 style: { height: "auto" },
13926 direction: "row",
13927 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13928 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13929 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13930 import_components14.FlexItem,
13931 {
13932 className: "dataviews-view-picker-grid__field-value",
13933 style: { maxHeight: "none" },
13934 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13935 field.render,
13936 {
13937 item,
13938 field
13939 }
13940 )
13941 }
13942 )
13943 ] })
13944 },
13945 field.id
13946 );
13947 })
13948 }
13949 )
13950 ] })
13951 ]
13952 },
13953 id
13954 );
13955 }
13956 function GridGroup({
13957 groupName,
13958 groupField,
13959 showLabel = true,
13960 children
13961 }) {
13962 const headerId = (0, import_compose6.useInstanceId)(
13963 GridGroup,
13964 "dataviews-view-picker-grid-group__header"
13965 );
13966 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13967 Stack,
13968 {
13969 direction: "column",
13970 gap: "sm",
13971 role: "group",
13972 "aria-labelledby": headerId,
13973 children: [
13974 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13975 "h3",
13976 {
13977 className: "dataviews-view-picker-grid-group__header",
13978 id: headerId,
13979 children: showLabel ? (0, import_i18n17.sprintf)(
13980 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13981 (0, import_i18n17.__)("%1$s: %2$s"),
13982 groupField.label,
13983 groupName
13984 ) : groupName
13985 }
13986 ),
13987 children
13988 ]
13989 },
13990 groupName
13991 );
13992 }
13993 function ViewPickerGrid({
13994 actions,
13995 data,
13996 fields,
13997 getItemId,
13998 isLoading,
13999 onChangeSelection,
14000 selection,
14001 view,
14002 className,
14003 empty
14004 }) {
14005 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
14006 const titleField = fields.find(
14007 (field) => field.id === view?.titleField
14008 );
14009 const mediaField = fields.find(
14010 (field) => field.id === view?.mediaField
14011 );
14012 const descriptionField = fields.find(
14013 (field) => field.id === view?.descriptionField
14014 );
14015 const otherFields = view.fields ?? [];
14016 const { regularFields, badgeFields } = otherFields.reduce(
14017 (accumulator, fieldId) => {
14018 const field = fields.find((f2) => f2.id === fieldId);
14019 if (!field) {
14020 return accumulator;
14021 }
14022 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14023 accumulator[key].push(field);
14024 return accumulator;
14025 },
14026 { regularFields: [], badgeFields: [] }
14027 );
14028 const hasData = !!data?.length;
14029 const usedPreviewSize = view.layout?.previewSize;
14030 const isMultiselect = useIsMultiselectPicker(actions);
14031 const size4 = "900px";
14032 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14033 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14034 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14035 const currentPage = view?.page ?? 1;
14036 const perPage = view?.perPage ?? 0;
14037 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14038 const gridColumns = useGridColumns();
14039 const placeholdersNeeded = usePlaceholdersNeeded(
14040 data,
14041 isInfiniteScroll,
14042 gridColumns
14043 );
14044 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
14045 // Render multiple groups.
14046 children: [
14047 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14048 import_components14.Composite,
14049 {
14050 virtualFocus: true,
14051 orientation: "horizontal",
14052 role: "listbox",
14053 "aria-multiselectable": isMultiselect,
14054 className: clsx_default(
14055 "dataviews-view-picker-grid",
14056 className,
14057 {
14058 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14059 view.layout.density
14060 )
14061 }
14062 ),
14063 "aria-label": itemListLabel,
14064 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14065 Stack,
14066 {
14067 direction: "column",
14068 gap: "lg",
14069 children,
14070 ...props
14071 }
14072 ),
14073 children: Array.from(dataByGroup.entries()).map(
14074 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14075 GridGroup,
14076 {
14077 groupName,
14078 groupField,
14079 showLabel: view.groupBy?.showLabel !== false,
14080 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14081 GridItems,
14082 {
14083 previewSize: usedPreviewSize,
14084 style: {
14085 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14086 },
14087 "aria-busy": isLoading,
14088 ref: resizeObserverRef,
14089 children: groupItems.map((item) => {
14090 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14091 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14092 GridItem3,
14093 {
14094 view,
14095 multiselect: isMultiselect,
14096 selection,
14097 onChangeSelection,
14098 getItemId,
14099 item,
14100 mediaField,
14101 titleField,
14102 descriptionField,
14103 regularFields,
14104 badgeFields,
14105 config: {
14106 sizes: size4
14107 },
14108 posinset: posInSet,
14109 setsize: setSize
14110 },
14111 getItemId(item)
14112 );
14113 })
14114 }
14115 )
14116 },
14117 groupName
14118 )
14119 )
14120 }
14121 ),
14122 // Render a single grid with all data.
14123 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
14124 import_components14.Composite,
14125 {
14126 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14127 GridItems,
14128 {
14129 className: clsx_default(
14130 "dataviews-view-picker-grid",
14131 className,
14132 {
14133 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14134 "compact",
14135 "comfortable"
14136 ].includes(view.layout.density)
14137 }
14138 ),
14139 previewSize: usedPreviewSize,
14140 "aria-busy": isLoading,
14141 ref: resizeObserverRef
14142 }
14143 ),
14144 virtualFocus: true,
14145 orientation: "horizontal",
14146 role: "listbox",
14147 "aria-multiselectable": isMultiselect,
14148 "aria-label": itemListLabel,
14149 children: [
14150 Array.from({ length: placeholdersNeeded }).map(
14151 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14152 import_components14.Composite.Item,
14153 {
14154 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14155 Stack,
14156 {
14157 direction: "column",
14158 children,
14159 ...props
14160 }
14161 ),
14162 role: "option",
14163 "aria-hidden": true,
14164 tabIndex: -1,
14165 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14166 },
14167 `placeholder-${index2}`
14168 )
14169 ),
14170 data.map((item) => {
14171 const posinset = item.position;
14172 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14173 GridItem3,
14174 {
14175 view,
14176 multiselect: isMultiselect,
14177 selection,
14178 onChangeSelection,
14179 getItemId,
14180 item,
14181 mediaField,
14182 titleField,
14183 descriptionField,
14184 regularFields,
14185 badgeFields,
14186 config: {
14187 sizes: size4
14188 },
14189 posinset,
14190 setsize: setSize
14191 },
14192 getItemId(item)
14193 );
14194 })
14195 ]
14196 }
14197 ),
14198 // Render empty state.
14199 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14200 "div",
14201 {
14202 className: clsx_default({
14203 "dataviews-loading": isLoading,
14204 "dataviews-no-results": !isLoading
14205 }),
14206 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
14207 }
14208 ),
14209 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
14210 ]
14211 });
14212 }
14213 var picker_grid_default = ViewPickerGrid;
14214
14215 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14216 var import_i18n18 = __toESM(require_i18n(), 1);
14217 var import_components15 = __toESM(require_components(), 1);
14218 var import_element39 = __toESM(require_element(), 1);
14219 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
14220 function TableColumnField2({
14221 item,
14222 fields,
14223 column,
14224 align
14225 }) {
14226 const field = fields.find((f2) => f2.id === column);
14227 if (!field) {
14228 return null;
14229 }
14230 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14231 "dataviews-view-table__cell-align-end": align === "end",
14232 "dataviews-view-table__cell-align-center": align === "center"
14233 });
14234 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
14235 }
14236 function TableRow2({
14237 item,
14238 fields,
14239 id,
14240 view,
14241 titleField,
14242 mediaField,
14243 descriptionField,
14244 selection,
14245 getItemId,
14246 onChangeSelection,
14247 multiselect,
14248 posinset
14249 }) {
14250 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14251 const isSelected2 = selection.includes(id);
14252 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
14253 const elementRef = (0, import_element39.useRef)(null);
14254 useIntersectionObserver(elementRef, posinset);
14255 const {
14256 showTitle = true,
14257 showMedia = true,
14258 showDescription = true,
14259 infiniteScrollEnabled
14260 } = view;
14261 const handleMouseEnter = () => {
14262 setIsHovered(true);
14263 };
14264 const handleMouseLeave = () => {
14265 setIsHovered(false);
14266 };
14267 const columns = view.fields ?? [];
14268 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14269 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14270 import_components15.Composite.Item,
14271 {
14272 ref: elementRef,
14273 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14274 "tr",
14275 {
14276 className: clsx_default("dataviews-view-table__row", {
14277 "is-selected": isSelected2,
14278 "is-hovered": isHovered
14279 }),
14280 onMouseEnter: handleMouseEnter,
14281 onMouseLeave: handleMouseLeave,
14282 children,
14283 ...props
14284 }
14285 ),
14286 "aria-selected": isSelected2,
14287 "aria-setsize": paginationInfo.totalItems || void 0,
14288 "aria-posinset": posinset,
14289 role: infiniteScrollEnabled ? "article" : "option",
14290 onMouseDown: (event) => {
14291 if (event.button !== 0) {
14292 return;
14293 }
14294 event.currentTarget.parentElement?.focus({
14295 preventScroll: true
14296 });
14297 },
14298 onClick: () => {
14299 if (isSelected2) {
14300 onChangeSelection(
14301 selection.filter((itemId) => id !== itemId)
14302 );
14303 } else {
14304 const newSelection = multiselect ? [...selection, id] : [id];
14305 onChangeSelection(newSelection);
14306 }
14307 },
14308 children: [
14309 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14310 "td",
14311 {
14312 className: "dataviews-view-table__checkbox-column",
14313 role: "presentation",
14314 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14315 DataViewsSelectionCheckbox,
14316 {
14317 item,
14318 selection,
14319 onChangeSelection,
14320 getItemId,
14321 titleField,
14322 disabled: false,
14323 "aria-hidden": true,
14324 tabIndex: -1
14325 }
14326 ) })
14327 }
14328 ),
14329 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14330 "td",
14331 {
14332 role: "presentation",
14333 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14334 column_primary_default,
14335 {
14336 item,
14337 titleField: showTitle ? titleField : void 0,
14338 mediaField: showMedia ? mediaField : void 0,
14339 descriptionField: showDescription ? descriptionField : void 0,
14340 isItemClickable: () => false
14341 }
14342 )
14343 }
14344 ),
14345 columns.map((column) => {
14346 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14347 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14348 "td",
14349 {
14350 style: {
14351 width,
14352 maxWidth,
14353 minWidth
14354 },
14355 role: "presentation",
14356 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14357 TableColumnField2,
14358 {
14359 fields,
14360 item,
14361 column,
14362 align
14363 }
14364 )
14365 },
14366 column
14367 );
14368 })
14369 ]
14370 },
14371 id
14372 );
14373 }
14374 function ViewPickerTable({
14375 actions,
14376 data,
14377 fields,
14378 getItemId,
14379 isLoading = false,
14380 onChangeView,
14381 onChangeSelection,
14382 selection,
14383 setOpenedFilter,
14384 view,
14385 className,
14386 empty
14387 }) {
14388 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
14389 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
14390 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
14391 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14392 (0, import_element39.useEffect)(() => {
14393 if (headerMenuToFocusRef.current) {
14394 headerMenuToFocusRef.current.focus();
14395 headerMenuToFocusRef.current = void 0;
14396 }
14397 });
14398 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14399 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14400 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14401 const tableNoticeId = (0, import_element39.useId)();
14402 if (nextHeaderMenuToFocus) {
14403 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14404 setNextHeaderMenuToFocus(void 0);
14405 return;
14406 }
14407 const onHide = (field) => {
14408 const hidden = headerMenuRefs.current.get(field.id);
14409 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14410 setNextHeaderMenuToFocus(fallback?.node);
14411 };
14412 const hasData = !!data?.length;
14413 const titleField = fields.find((field) => field.id === view.titleField);
14414 const mediaField = fields.find((field) => field.id === view.mediaField);
14415 const descriptionField = fields.find(
14416 (field) => field.id === view.descriptionField
14417 );
14418 const { showTitle = true, showMedia = true, showDescription = true } = view;
14419 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14420 const columns = view.fields ?? [];
14421 const headerMenuRef = (column, index2) => (node) => {
14422 if (node) {
14423 headerMenuRefs.current.set(column, {
14424 node,
14425 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14426 });
14427 } else {
14428 headerMenuRefs.current.delete(column);
14429 }
14430 };
14431 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
14432 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14433 "table",
14434 {
14435 className: clsx_default(
14436 "dataviews-view-table",
14437 "dataviews-view-picker-table",
14438 className,
14439 {
14440 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14441 view.layout.density
14442 )
14443 }
14444 ),
14445 "aria-busy": isLoading,
14446 "aria-describedby": tableNoticeId,
14447 role: isInfiniteScroll ? "feed" : "listbox",
14448 children: [
14449 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14450 "tr",
14451 {
14452 className: "dataviews-view-table__row",
14453 role: "presentation",
14454 children: [
14455 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14456 BulkSelectionCheckbox,
14457 {
14458 selection,
14459 onChangeSelection,
14460 data,
14461 actions,
14462 getItemId,
14463 disableSelectAll: isInfiniteScroll
14464 }
14465 ) }),
14466 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14467 column_header_menu_default,
14468 {
14469 ref: headerMenuRef(
14470 titleField.id,
14471 0
14472 ),
14473 fieldId: titleField.id,
14474 view,
14475 fields,
14476 onChangeView,
14477 onHide,
14478 setOpenedFilter,
14479 canMove: false
14480 }
14481 ) }),
14482 columns.map((column, index2) => {
14483 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14484 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14485 "th",
14486 {
14487 style: {
14488 width,
14489 maxWidth,
14490 minWidth,
14491 textAlign: align
14492 },
14493 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14494 scope: "col",
14495 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14496 column_header_menu_default,
14497 {
14498 ref: headerMenuRef(column, index2),
14499 fieldId: column,
14500 view,
14501 fields,
14502 onChangeView,
14503 onHide,
14504 setOpenedFilter,
14505 canMove: view.layout?.enableMoving ?? true
14506 }
14507 )
14508 },
14509 column
14510 );
14511 })
14512 ]
14513 }
14514 ) }),
14515 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14516 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14517 import_components15.Composite,
14518 {
14519 virtualFocus: true,
14520 orientation: "vertical",
14521 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14522 children: [
14523 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14524 "tr",
14525 {
14526 className: "dataviews-view-table__group-header-row",
14527 role: "presentation",
14528 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14529 "td",
14530 {
14531 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14532 className: "dataviews-view-table__group-header-cell",
14533 role: "presentation",
14534 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14535 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14536 (0, import_i18n18.__)("%1$s: %2$s"),
14537 groupField.label,
14538 groupName
14539 )
14540 }
14541 )
14542 }
14543 ),
14544 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14545 TableRow2,
14546 {
14547 item,
14548 fields,
14549 id: getItemId(item) || index2.toString(),
14550 view,
14551 titleField,
14552 mediaField,
14553 descriptionField,
14554 selection,
14555 getItemId,
14556 onChangeSelection,
14557 multiselect: isMultiselect
14558 },
14559 getItemId(item)
14560 ))
14561 ]
14562 },
14563 `group-${groupName}`
14564 )
14565 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14566 import_components15.Composite,
14567 {
14568 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14569 virtualFocus: true,
14570 orientation: "vertical",
14571 children: hasData && data.map((item, index2) => {
14572 const itemId = getItemId(item);
14573 const posinset = item.position;
14574 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14575 TableRow2,
14576 {
14577 item,
14578 fields,
14579 id: itemId || index2.toString(),
14580 view,
14581 titleField,
14582 mediaField,
14583 descriptionField,
14584 selection,
14585 getItemId,
14586 onChangeSelection,
14587 multiselect: isMultiselect,
14588 posinset
14589 },
14590 itemId
14591 );
14592 })
14593 }
14594 )
14595 ]
14596 }
14597 ),
14598 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14599 "div",
14600 {
14601 className: clsx_default({
14602 "dataviews-loading": isLoading,
14603 "dataviews-no-results": !hasData && !isLoading
14604 }),
14605 id: tableNoticeId,
14606 children: [
14607 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14608 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14609 ]
14610 }
14611 )
14612 ] });
14613 }
14614 var picker_table_default = ViewPickerTable;
14615
14616 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14617 var import_components16 = __toESM(require_components(), 1);
14618 var import_element40 = __toESM(require_element(), 1);
14619 var import_compose7 = __toESM(require_compose(), 1);
14620 var import_i18n19 = __toESM(require_i18n(), 1);
14621 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14622 function isDefined4(item) {
14623 return !!item;
14624 }
14625 function PickerActivityItem({
14626 view,
14627 multiselect,
14628 selection,
14629 onChangeSelection,
14630 getItemId,
14631 item,
14632 titleField,
14633 mediaField,
14634 descriptionField,
14635 otherFields,
14636 posinset,
14637 setsize
14638 }) {
14639 const elementRef = (0, import_element40.useRef)(null);
14640 useIntersectionObserver(elementRef, posinset);
14641 const { showTitle = true, showMedia = true, showDescription = true } = view;
14642 const id = getItemId(item);
14643 const isSelected2 = selection.includes(id);
14644 const density = view.layout?.density ?? "balanced";
14645 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14646 mediaField.render,
14647 {
14648 item,
14649 field: mediaField,
14650 config: {
14651 sizes: density === "comfortable" ? "32px" : "24px"
14652 }
14653 }
14654 ) : null;
14655 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)(
14656 "span",
14657 {
14658 className: "dataviews-view-picker-activity__item-bullet",
14659 "aria-hidden": "true"
14660 }
14661 ) });
14662 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
14663 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14664 const verticalGap = (0, import_element40.useMemo)(() => {
14665 switch (density) {
14666 case "comfortable":
14667 return "md";
14668 default:
14669 return "sm";
14670 }
14671 }, [density]);
14672 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14673 import_components16.Composite.Item,
14674 {
14675 ref: elementRef,
14676 role: "option",
14677 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14678 "aria-posinset": posinset,
14679 "aria-setsize": setsize,
14680 "aria-selected": isSelected2,
14681 className: clsx_default(
14682 "dataviews-view-picker-activity__item",
14683 density === "compact" && "is-compact",
14684 density === "balanced" && "is-balanced",
14685 density === "comfortable" && "is-comfortable",
14686 isSelected2 && "is-selected"
14687 ),
14688 onClick: () => {
14689 if (isSelected2) {
14690 onChangeSelection(
14691 selection.filter((itemId) => id !== itemId)
14692 );
14693 } else {
14694 const newSelection = multiselect ? [...selection, id] : [id];
14695 onChangeSelection(newSelection);
14696 }
14697 },
14698 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
14699 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14700 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14701 Stack,
14702 {
14703 direction: "column",
14704 gap: "xs",
14705 align: "center",
14706 className: "dataviews-view-picker-activity__item-type",
14707 children: renderedMediaField
14708 }
14709 ),
14710 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14711 Stack,
14712 {
14713 direction: "column",
14714 gap: verticalGap,
14715 align: "flex-start",
14716 className: "dataviews-view-picker-activity__item-content",
14717 children: [
14718 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14719 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14720 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14721 "div",
14722 {
14723 className: "dataviews-view-picker-activity__item-field",
14724 children: [
14725 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14726 VisuallyHidden,
14727 {
14728 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
14729 className: "dataviews-view-picker-activity__item-field-label",
14730 children: field.label
14731 }
14732 ),
14733 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14734 field.render,
14735 {
14736 item,
14737 field
14738 }
14739 ) })
14740 ]
14741 },
14742 field.id
14743 )) })
14744 ]
14745 }
14746 )
14747 ] })
14748 }
14749 );
14750 }
14751 function PickerActivityGroup({
14752 groupName,
14753 groupField,
14754 showLabel = true,
14755 children
14756 }) {
14757 const headerId = (0, import_compose7.useInstanceId)(
14758 PickerActivityGroup,
14759 "dataviews-view-picker-activity-group__header"
14760 );
14761 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14762 Stack,
14763 {
14764 direction: "column",
14765 role: "group",
14766 "aria-labelledby": headerId,
14767 className: "dataviews-view-picker-activity-group",
14768 children: [
14769 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14770 "h3",
14771 {
14772 className: "dataviews-view-picker-activity-group__header",
14773 id: headerId,
14774 children: showLabel ? (0, import_i18n19.sprintf)(
14775 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14776 (0, import_i18n19.__)("%1$s: %2$s"),
14777 groupField.label,
14778 groupName
14779 ) : groupName
14780 }
14781 ),
14782 children
14783 ]
14784 }
14785 );
14786 }
14787 function ViewPickerActivity({
14788 data,
14789 fields,
14790 getItemId,
14791 isLoading,
14792 onChangeSelection,
14793 selection,
14794 view,
14795 actions,
14796 className,
14797 empty
14798 }) {
14799 const { itemListLabel, paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
14800 const isMultiselect = useIsMultiselectPicker(actions);
14801 const titleField = fields.find(
14802 (field) => field.id === view?.titleField
14803 );
14804 const mediaField = fields.find(
14805 (field) => field.id === view?.mediaField
14806 );
14807 const descriptionField = fields.find(
14808 (field) => field.id === view?.descriptionField
14809 );
14810 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14811 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14812 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14813 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14814 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14815 const hasData = !!data?.length;
14816 const isGrouped = !!(groupField && dataByGroup);
14817 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14818 PickerActivityItem,
14819 {
14820 view,
14821 multiselect: isMultiselect,
14822 selection,
14823 onChangeSelection,
14824 getItemId,
14825 item,
14826 titleField,
14827 mediaField,
14828 descriptionField,
14829 otherFields,
14830 posinset: item.position,
14831 setsize
14832 },
14833 getItemId(item)
14834 );
14835 if (!hasData) {
14836 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14837 "div",
14838 {
14839 className: clsx_default({
14840 "dataviews-loading": isLoading,
14841 "dataviews-no-results": !isLoading
14842 }),
14843 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) }) : empty
14844 }
14845 );
14846 }
14847 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
14848 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14849 import_components16.Composite,
14850 {
14851 virtualFocus: true,
14852 orientation: "vertical",
14853 role: "listbox",
14854 "aria-multiselectable": isMultiselect,
14855 "aria-label": itemListLabel,
14856 "aria-busy": isLoading,
14857 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
14858 className: clsx_default(
14859 "dataviews-view-picker-activity",
14860 className
14861 ),
14862 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
14863 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14864 PickerActivityGroup,
14865 {
14866 groupName,
14867 groupField,
14868 showLabel: view.groupBy?.showLabel !== false,
14869 children: groupItems.map(renderItem)
14870 },
14871 groupName
14872 )
14873 ) : data.map(renderItem)
14874 }
14875 ),
14876 isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) })
14877 ] });
14878 }
14879
14880 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14881 var import_components17 = __toESM(require_components(), 1);
14882 var import_i18n20 = __toESM(require_i18n(), 1);
14883 var import_element41 = __toESM(require_element(), 1);
14884 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14885 function DensityPicker() {
14886 const context = (0, import_element41.useContext)(dataviews_context_default);
14887 const view = context.view;
14888 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
14889 import_components17.__experimentalToggleGroupControl,
14890 {
14891 label: (0, import_i18n20.__)("Density"),
14892 value: view.layout?.density || "balanced",
14893 onChange: (value) => {
14894 context.onChangeView({
14895 ...view,
14896 layout: {
14897 ...view.layout,
14898 density: value
14899 }
14900 });
14901 },
14902 isBlock: true,
14903 children: [
14904 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14905 import_components17.__experimentalToggleGroupControlOption,
14906 {
14907 value: "comfortable",
14908 label: (0, import_i18n20._x)(
14909 "Comfortable",
14910 "Density option for DataView layout"
14911 )
14912 },
14913 "comfortable"
14914 ),
14915 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14916 import_components17.__experimentalToggleGroupControlOption,
14917 {
14918 value: "balanced",
14919 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14920 },
14921 "balanced"
14922 ),
14923 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14924 import_components17.__experimentalToggleGroupControlOption,
14925 {
14926 value: "compact",
14927 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14928 },
14929 "compact"
14930 )
14931 ]
14932 }
14933 );
14934 }
14935
14936 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14937 var import_components18 = __toESM(require_components(), 1);
14938 var import_i18n21 = __toESM(require_i18n(), 1);
14939 var import_element42 = __toESM(require_element(), 1);
14940 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14941 var imageSizes2 = [
14942 {
14943 value: 120,
14944 breakpoint: 1
14945 },
14946 {
14947 value: 170,
14948 breakpoint: 1
14949 },
14950 {
14951 value: 230,
14952 breakpoint: 1
14953 },
14954 {
14955 value: 290,
14956 breakpoint: 1112
14957 // at minimum image width, 4 images display at this container size
14958 },
14959 {
14960 value: 350,
14961 breakpoint: 1636
14962 // at minimum image width, 6 images display at this container size
14963 },
14964 {
14965 value: 430,
14966 breakpoint: 588
14967 // at minimum image width, 2 images display at this container size
14968 }
14969 ];
14970 function PreviewSizePicker() {
14971 const context = (0, import_element42.useContext)(dataviews_context_default);
14972 const view = context.view;
14973 const breakValues = imageSizes2.filter((size4) => {
14974 return context.containerWidth >= size4.breakpoint;
14975 });
14976 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14977 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14978 const marks = breakValues.map((size4, index2) => {
14979 return {
14980 value: index2
14981 };
14982 });
14983 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
14984 import_components18.RangeControl,
14985 {
14986 showTooltip: false,
14987 label: (0, import_i18n21.__)("Preview size"),
14988 value: previewSizeToUse,
14989 min: 0,
14990 max: breakValues.length - 1,
14991 withInputField: false,
14992 onChange: (value = 0) => {
14993 context.onChangeView({
14994 ...view,
14995 layout: {
14996 ...view.layout,
14997 previewSize: breakValues[value].value
14998 }
14999 });
15000 },
15001 step: 1,
15002 marks
15003 }
15004 );
15005 }
15006
15007 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15008 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
15009 function GridConfigOptions() {
15010 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
15011 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DensityPicker, {}),
15012 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(PreviewSizePicker, {})
15013 ] });
15014 }
15015
15016 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15017 var VIEW_LAYOUTS = [
15018 {
15019 type: LAYOUT_TABLE,
15020 label: (0, import_i18n22.__)("Table"),
15021 component: table_default,
15022 icon: block_table_default,
15023 viewConfigOptions: DensityPicker
15024 },
15025 {
15026 type: LAYOUT_GRID,
15027 label: (0, import_i18n22.__)("Grid"),
15028 component: grid_default,
15029 icon: category_default,
15030 viewConfigOptions: GridConfigOptions
15031 },
15032 {
15033 type: LAYOUT_LIST,
15034 label: (0, import_i18n22.__)("List"),
15035 component: ViewList,
15036 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15037 viewConfigOptions: DensityPicker
15038 },
15039 {
15040 type: LAYOUT_ACTIVITY,
15041 label: (0, import_i18n22.__)("Activity"),
15042 component: ViewActivity,
15043 icon: scheduled_default,
15044 viewConfigOptions: DensityPicker
15045 },
15046 {
15047 type: LAYOUT_PICKER_GRID,
15048 label: (0, import_i18n22.__)("Grid"),
15049 component: picker_grid_default,
15050 icon: category_default,
15051 viewConfigOptions: GridConfigOptions,
15052 isPicker: true
15053 },
15054 {
15055 type: LAYOUT_PICKER_TABLE,
15056 label: (0, import_i18n22.__)("Table"),
15057 component: picker_table_default,
15058 icon: block_table_default,
15059 viewConfigOptions: DensityPicker,
15060 isPicker: true
15061 },
15062 {
15063 type: LAYOUT_PICKER_ACTIVITY,
15064 label: (0, import_i18n22.__)("Activity"),
15065 component: ViewPickerActivity,
15066 icon: scheduled_default,
15067 viewConfigOptions: DensityPicker,
15068 isPicker: true
15069 }
15070 ];
15071
15072 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15073 var import_element50 = __toESM(require_element(), 1);
15074
15075 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15076 var import_components21 = __toESM(require_components(), 1);
15077 var import_i18n25 = __toESM(require_i18n(), 1);
15078 var import_element47 = __toESM(require_element(), 1);
15079
15080 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15081 var import_react7 = __toESM(require_react(), 1);
15082 var FocusableContext = (0, import_react7.createContext)(true);
15083
15084 // node_modules/@ariakit/utils/dist/index.js
15085 function toArray(arg) {
15086 if (Array.isArray(arg)) return arg;
15087 return typeof arg !== "undefined" ? [arg] : [];
15088 }
15089 function flatten2DArray(array) {
15090 const flattened = [];
15091 for (const row of array) flattened.push(...row);
15092 return flattened;
15093 }
15094 function reverseArray(array) {
15095 return array.slice().reverse();
15096 }
15097 function noop4(..._) {
15098 }
15099 function hasOwnProperty(object, prop) {
15100 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15101 return Object.prototype.hasOwnProperty.call(object, prop);
15102 }
15103 function chain(...fns) {
15104 return (...args) => {
15105 for (const fn of fns) if (typeof fn === "function") fn(...args);
15106 };
15107 }
15108 function normalizeString(str) {
15109 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15110 }
15111 function omit2(object, keys) {
15112 const result = { ...object };
15113 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15114 return result;
15115 }
15116 function pick(object, paths) {
15117 const result = {};
15118 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15119 return result;
15120 }
15121 function identity(value) {
15122 return value;
15123 }
15124 function afterPaint(cb = noop4) {
15125 let raf = requestAnimationFrame(() => {
15126 raf = requestAnimationFrame(cb);
15127 });
15128 return () => cancelAnimationFrame(raf);
15129 }
15130 function invariant(condition, message2) {
15131 if (condition) return;
15132 if (typeof message2 !== "string") throw new Error("Invariant failed");
15133 throw new Error(message2);
15134 }
15135 function getKeys(obj) {
15136 return Object.keys(obj);
15137 }
15138 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15139 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15140 if (result == null) return false;
15141 return !result;
15142 }
15143 function disabledFromProps(props) {
15144 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15145 }
15146 function removeUndefinedValues(obj) {
15147 const result = {};
15148 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15149 return result;
15150 }
15151 function defaultValue(...values) {
15152 for (const value of values) if (value !== void 0) return value;
15153 }
15154 var canUseDOM = checkIsBrowser();
15155 function checkIsBrowser() {
15156 return typeof window !== "undefined" && !!window.document?.createElement;
15157 }
15158 function getDocument(node) {
15159 if (!node) return document;
15160 if ("self" in node) return node.document;
15161 return node.ownerDocument || document;
15162 }
15163 function getActiveElement(node, activeDescendant = false) {
15164 const { activeElement: activeElement2 } = getDocument(node);
15165 if (!activeElement2?.nodeName) return null;
15166 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15167 if (activeDescendant) {
15168 const id = activeElement2.getAttribute("aria-activedescendant");
15169 if (id) {
15170 const element = getDocument(activeElement2).getElementById(id);
15171 if (element) return element;
15172 }
15173 }
15174 return activeElement2;
15175 }
15176 function contains2(parent, child) {
15177 return parent === child || parent.contains(child);
15178 }
15179 function isElement2(target) {
15180 return target?.nodeType === 1;
15181 }
15182 function isNode2(target) {
15183 return typeof target?.nodeType === "number";
15184 }
15185 function isFrame(element) {
15186 return element.tagName === "IFRAME";
15187 }
15188 function isButton(element) {
15189 const tagName = element.tagName.toLowerCase();
15190 if (tagName === "button") return true;
15191 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15192 return false;
15193 }
15194 var buttonInputTypes = [
15195 "button",
15196 "color",
15197 "file",
15198 "image",
15199 "reset",
15200 "submit"
15201 ];
15202 function isVisible(element) {
15203 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15204 const htmlElement = element;
15205 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15206 }
15207 function isTextField(element) {
15208 try {
15209 if (element.tagName === "TEXTAREA") return true;
15210 if (element.tagName !== "INPUT") return false;
15211 return element.selectionStart !== null;
15212 } catch (_error) {
15213 return false;
15214 }
15215 }
15216 function isTextbox(element) {
15217 return element.isContentEditable || isTextField(element);
15218 }
15219 function getTextboxValue(element) {
15220 if (isTextField(element)) return element.value;
15221 if (element.isContentEditable) {
15222 const range = getDocument(element).createRange();
15223 range.selectNodeContents(element);
15224 return range.toString();
15225 }
15226 return "";
15227 }
15228 function getTextboxSelection(element) {
15229 let start = 0;
15230 let end = 0;
15231 if (isTextField(element)) {
15232 start = element.selectionStart || 0;
15233 end = element.selectionEnd || 0;
15234 } else if (element.isContentEditable) {
15235 const selection = getDocument(element).getSelection();
15236 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15237 const range = selection.getRangeAt(0);
15238 const nextRange = range.cloneRange();
15239 nextRange.selectNodeContents(element);
15240 nextRange.setEnd(range.startContainer, range.startOffset);
15241 start = nextRange.toString().length;
15242 nextRange.setEnd(range.endContainer, range.endOffset);
15243 end = nextRange.toString().length;
15244 }
15245 }
15246 return {
15247 start,
15248 end
15249 };
15250 }
15251 var allowedPopupRoles = [
15252 "dialog",
15253 "menu",
15254 "listbox",
15255 "tree",
15256 "grid"
15257 ];
15258 var itemRoleByPopupRole = {
15259 menu: "menuitem",
15260 listbox: "option",
15261 tree: "treeitem"
15262 };
15263 function getPopupRole(element, fallback) {
15264 const role = element?.getAttribute("role");
15265 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15266 return fallback;
15267 }
15268 function getItemRoleByPopupRole(popupRole) {
15269 if (popupRole == null) return;
15270 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15271 return itemRoleByPopupRole[popupRole];
15272 }
15273 function getScrollingElement(element) {
15274 if (!element) return null;
15275 const isScrollableOverflow = (overflow) => {
15276 if (overflow === "auto") return true;
15277 if (overflow === "scroll") return true;
15278 return false;
15279 };
15280 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15281 const { overflowY } = getComputedStyle(element);
15282 if (isScrollableOverflow(overflowY)) return element;
15283 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15284 const { overflowX } = getComputedStyle(element);
15285 if (isScrollableOverflow(overflowX)) return element;
15286 }
15287 const doc = getDocument(element);
15288 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15289 }
15290 function setSelectionRange(element, ...args) {
15291 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15292 }
15293 function sortBasedOnDOMPosition(items, getElement) {
15294 const pairs = items.map((item, index2) => [index2, item]);
15295 let isOrderDifferent = false;
15296 pairs.sort(([indexA, a2], [indexB, b2]) => {
15297 const elementA = getElement(a2);
15298 const elementB = getElement(b2);
15299 if (elementA === elementB) return 0;
15300 if (!elementA || !elementB) return 0;
15301 if (isElementPreceding(elementA, elementB)) {
15302 if (indexA > indexB) isOrderDifferent = true;
15303 return -1;
15304 }
15305 if (indexA < indexB) isOrderDifferent = true;
15306 return 1;
15307 });
15308 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15309 return items;
15310 }
15311 function isElementPreceding(a2, b2) {
15312 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15313 }
15314 function isTouchDevice() {
15315 return canUseDOM && !!navigator.maxTouchPoints;
15316 }
15317 function isApple() {
15318 if (!canUseDOM) return false;
15319 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15320 }
15321 function isSafari() {
15322 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15323 }
15324 function isFirefox() {
15325 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15326 }
15327 function isPortalEvent(event) {
15328 const { currentTarget, target } = event;
15329 if (!currentTarget) return false;
15330 if (!isNode2(target)) return true;
15331 return !contains2(currentTarget, target);
15332 }
15333 function isSelfTarget(event) {
15334 return event.target === event.currentTarget;
15335 }
15336 function isActivatableNavigationTarget(element) {
15337 if (!isElement2(element)) return false;
15338 const target = element;
15339 const tagName = target.tagName.toLowerCase();
15340 if (tagName === "a") return true;
15341 if (tagName === "button" && target.type === "submit") return true;
15342 if (tagName === "input" && target.type === "submit") return true;
15343 return false;
15344 }
15345 function isOpeningInNewTab(event) {
15346 const isAppleDevice = isApple();
15347 if (isAppleDevice && !event.metaKey) return false;
15348 if (!isAppleDevice && !event.ctrlKey) return false;
15349 return isActivatableNavigationTarget(event.currentTarget);
15350 }
15351 function isDownloading(event) {
15352 if (!event.altKey) return false;
15353 return isActivatableNavigationTarget(event.currentTarget);
15354 }
15355 function fireBlurEvent(element, eventInit) {
15356 const event = new FocusEvent("blur", eventInit);
15357 const defaultAllowed = element.dispatchEvent(event);
15358 const bubbleInit = {
15359 ...eventInit,
15360 bubbles: true
15361 };
15362 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15363 return defaultAllowed;
15364 }
15365 function fireKeyboardEvent(element, type, eventInit) {
15366 const event = new KeyboardEvent(type, eventInit);
15367 return element.dispatchEvent(event);
15368 }
15369 function fireClickEvent(element, eventInit) {
15370 const event = new MouseEvent("click", eventInit);
15371 return element.dispatchEvent(event);
15372 }
15373 function isFocusEventOutside(event, container) {
15374 const containerElement = container || event.currentTarget;
15375 const relatedTarget = event.relatedTarget;
15376 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15377 }
15378 function isInputEvent(event) {
15379 return event.type === "input";
15380 }
15381 function queueBeforeEvent(element, type, callback, timeout) {
15382 const createTimer = (callback2) => {
15383 if (timeout) {
15384 const timerId2 = setTimeout(callback2, timeout);
15385 return () => clearTimeout(timerId2);
15386 }
15387 const timerId = requestAnimationFrame(callback2);
15388 return () => cancelAnimationFrame(timerId);
15389 };
15390 const cancelTimer = createTimer(() => {
15391 element.removeEventListener(type, callSync, true);
15392 callback();
15393 });
15394 const callSync = () => {
15395 cancelTimer();
15396 callback();
15397 };
15398 element.addEventListener(type, callSync, {
15399 once: true,
15400 capture: true
15401 });
15402 return () => {
15403 cancelTimer();
15404 element.removeEventListener(type, callSync, true);
15405 };
15406 }
15407 function addGlobalEventListener(type, listener, options, scope = window) {
15408 const children = [];
15409 try {
15410 scope.document.addEventListener(type, listener, options);
15411 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15412 } catch {
15413 }
15414 const removeEventListener = () => {
15415 try {
15416 scope.document.removeEventListener(type, listener, options);
15417 } catch {
15418 }
15419 for (const remove of children) remove();
15420 };
15421 return removeEventListener;
15422 }
15423 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'])";
15424 function isFocusable(element) {
15425 if (!element.matches(selector)) return false;
15426 if (!isVisible(element)) return false;
15427 if (element.closest("[inert]")) return false;
15428 return true;
15429 }
15430 function hasFocus(element) {
15431 const activeElement2 = getActiveElement(element);
15432 if (!activeElement2) return false;
15433 if (activeElement2 === element) return true;
15434 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15435 if (!activeDescendant) return false;
15436 return activeDescendant === element.id;
15437 }
15438 function hasFocusWithin(element) {
15439 const activeElement2 = getActiveElement(element);
15440 if (!activeElement2) return false;
15441 if (contains2(element, activeElement2)) return true;
15442 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15443 if (!activeDescendant) return false;
15444 if (!("id" in element)) return false;
15445 if (activeDescendant === element.id) return true;
15446 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15447 }
15448 function focusIntoView(element, options) {
15449 if (!("scrollIntoView" in element)) element.focus();
15450 else {
15451 element.focus({ preventScroll: true });
15452 element.scrollIntoView({
15453 block: "nearest",
15454 inline: "nearest",
15455 ...options
15456 });
15457 }
15458 }
15459 function createUndoCallback(callback) {
15460 return async () => {
15461 const redo = await callback?.();
15462 return createUndoCallback(async () => {
15463 await redo?.();
15464 return callback;
15465 });
15466 };
15467 }
15468 var UndoManager = createUndoManager();
15469 function createUndoManager({ limit = 100 } = {}) {
15470 const undoStack = [];
15471 let redoStack = [];
15472 let currentGroup = null;
15473 const canUndo = () => undoStack.length > 0;
15474 const canRedo = () => redoStack.length > 0;
15475 const undo = async () => {
15476 if (!canUndo()) return;
15477 currentGroup = null;
15478 redoStack.push(await undoStack.pop()?.());
15479 };
15480 const redo = async () => {
15481 if (!canRedo()) return;
15482 currentGroup = null;
15483 undoStack.push(await redoStack.pop()?.());
15484 };
15485 const execute = async (callback, group) => {
15486 if (!callback) return;
15487 const sameGroup = group === currentGroup;
15488 currentGroup = group ?? null;
15489 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15490 const undoCallback = await callback();
15491 if (!undoCallback) return;
15492 redoStack = [];
15493 const currentUndo = undoStack[nextIndex];
15494 undoStack[nextIndex] = createUndoCallback(async () => {
15495 await undoCallback?.();
15496 const currentRedo = await currentUndo?.();
15497 return async () => {
15498 await currentRedo?.();
15499 await callback?.();
15500 };
15501 });
15502 while (undoStack.length > limit) undoStack.shift();
15503 };
15504 return {
15505 canUndo,
15506 canRedo,
15507 undo,
15508 redo,
15509 execute
15510 };
15511 }
15512
15513 // node_modules/@ariakit/react-utils/dist/index.js
15514 var React48 = __toESM(require_react(), 1);
15515 var import_react8 = __toESM(require_react(), 1);
15516 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15517 function setRef(ref, value) {
15518 if (typeof ref === "function") {
15519 const cleanup = ref(value);
15520 if (typeof cleanup === "function") return cleanup;
15521 } else if (ref) ref.current = value;
15522 }
15523 function isValidElementWithRef(element) {
15524 if (!element) return false;
15525 if (!(0, import_react8.isValidElement)(element)) return false;
15526 if ("ref" in element.props) return true;
15527 if ("ref" in element) return true;
15528 return false;
15529 }
15530 function getRefProperty(element) {
15531 if (!isValidElementWithRef(element)) return null;
15532 return { ...element.props }.ref || element.ref;
15533 }
15534 function mergeProps2(base, overrides) {
15535 const props = { ...base };
15536 for (const key in overrides) {
15537 if (!hasOwnProperty(overrides, key)) continue;
15538 if (key === "className") {
15539 const prop = "className";
15540 const baseClass = base[prop];
15541 const overrideClass = overrides[prop];
15542 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15543 else props[prop] = overrideClass || baseClass;
15544 continue;
15545 }
15546 if (key === "style") {
15547 const prop = "style";
15548 props[prop] = base[prop] ? {
15549 ...base[prop],
15550 ...overrides[prop]
15551 } : overrides[prop];
15552 continue;
15553 }
15554 const overrideValue = overrides[key];
15555 if (key.startsWith("on")) {
15556 if (typeof overrideValue !== "function") continue;
15557 const baseValue = base[key];
15558 if (typeof baseValue === "function") {
15559 props[key] = (...args) => {
15560 overrideValue(...args);
15561 baseValue(...args);
15562 };
15563 continue;
15564 }
15565 }
15566 props[key] = overrideValue;
15567 }
15568 return props;
15569 }
15570 var _React = { ...React48 };
15571 var useReactId = _React.useId;
15572 var useReactDeferredValue = _React.useDeferredValue;
15573 var useReactInsertionEffect = _React.useInsertionEffect;
15574 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
15575 function useInitialValue(value) {
15576 const [initialValue] = (0, import_react8.useState)(value);
15577 return initialValue;
15578 }
15579 function useLiveRef(value) {
15580 const ref = (0, import_react8.useRef)(value);
15581 useSafeLayoutEffect(() => {
15582 ref.current = value;
15583 });
15584 return ref;
15585 }
15586 function useEvent(callback) {
15587 const ref = (0, import_react8.useRef)(() => {
15588 throw new Error("Cannot call an event handler while rendering.");
15589 });
15590 if (useReactInsertionEffect) useReactInsertionEffect(() => {
15591 ref.current = callback;
15592 });
15593 else ref.current = callback;
15594 return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
15595 }
15596 function useTransactionState(callback) {
15597 const [state, setState] = (0, import_react8.useState)(null);
15598 useSafeLayoutEffect(() => {
15599 if (state == null) return;
15600 if (!callback) return;
15601 let prevState = null;
15602 callback((prev) => {
15603 prevState = prev;
15604 return state;
15605 });
15606 return () => {
15607 callback(prevState);
15608 };
15609 }, [state, callback]);
15610 return [state, setState];
15611 }
15612 function useMergeRefs(...refs) {
15613 return (0, import_react8.useMemo)(() => {
15614 if (!refs.some(Boolean)) return;
15615 return (value) => {
15616 const refEffects = [];
15617 for (const ref of refs) {
15618 if (!ref) continue;
15619 const cleanup = setRef(ref, value);
15620 refEffects.push({
15621 ref,
15622 cleanup: typeof cleanup === "function" ? cleanup : void 0
15623 });
15624 }
15625 if (!refEffects.some((effect) => effect.cleanup)) return;
15626 return () => {
15627 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
15628 else setRef(ref, null);
15629 };
15630 };
15631 }, refs);
15632 }
15633 function useId4(defaultId) {
15634 if (useReactId) {
15635 const reactId = useReactId();
15636 if (defaultId) return defaultId;
15637 return reactId;
15638 }
15639 const [id, setId] = (0, import_react8.useState)(defaultId);
15640 useSafeLayoutEffect(() => {
15641 if (defaultId || id) return;
15642 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
15643 }, [defaultId, id]);
15644 return defaultId || id;
15645 }
15646 function useTagName(refOrElement, type) {
15647 const stringOrUndefined = (type2) => {
15648 if (typeof type2 !== "string") return;
15649 return type2;
15650 };
15651 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
15652 useSafeLayoutEffect(() => {
15653 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
15654 }, [refOrElement, type]);
15655 return tagName;
15656 }
15657 function useAttribute(refOrElement, attributeName, defaultValue2) {
15658 const initialValue = useInitialValue(defaultValue2);
15659 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
15660 (0, import_react8.useEffect)(() => {
15661 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15662 if (!element) return;
15663 const callback = () => {
15664 const value = element.getAttribute(attributeName);
15665 setAttribute(value == null ? initialValue : value);
15666 };
15667 const observer = new MutationObserver(callback);
15668 observer.observe(element, { attributeFilter: [attributeName] });
15669 callback();
15670 return () => observer.disconnect();
15671 }, [
15672 refOrElement,
15673 attributeName,
15674 initialValue
15675 ]);
15676 return attribute;
15677 }
15678 function useUpdateEffect(effect, deps) {
15679 const mounted = (0, import_react8.useRef)(false);
15680 (0, import_react8.useEffect)(() => {
15681 if (mounted.current) return effect();
15682 mounted.current = true;
15683 }, deps);
15684 (0, import_react8.useEffect)(() => () => {
15685 mounted.current = false;
15686 }, []);
15687 }
15688 function useUpdateLayoutEffect(effect, deps) {
15689 const mounted = (0, import_react8.useRef)(false);
15690 useSafeLayoutEffect(() => {
15691 if (mounted.current) return effect();
15692 mounted.current = true;
15693 }, deps);
15694 useSafeLayoutEffect(() => () => {
15695 mounted.current = false;
15696 }, []);
15697 }
15698 function useForceUpdate() {
15699 return (0, import_react8.useReducer)(() => [], []);
15700 }
15701 function useBooleanEvent(booleanOrCallback) {
15702 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
15703 }
15704 function useWrapElement(props, callback, deps = []) {
15705 const wrapElement = (0, import_react8.useCallback)((element) => {
15706 if (props.wrapElement) element = props.wrapElement(element);
15707 return callback(element);
15708 }, [...deps, props.wrapElement]);
15709 return {
15710 ...props,
15711 wrapElement
15712 };
15713 }
15714 function useMetadataProps(props, key, value) {
15715 const parent = props.onLoadedMetadataCapture;
15716 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
15717 return Object.assign(() => {
15718 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
15719 }, [
15720 parent,
15721 key,
15722 value
15723 ]);
15724 return [parent?.[key], { onLoadedMetadataCapture }];
15725 }
15726 var hasInstalledGlobalEventListeners = false;
15727 function useIsMouseMoving() {
15728 (0, import_react8.useEffect)(() => {
15729 if (hasInstalledGlobalEventListeners) return;
15730 addGlobalEventListener("mousemove", setMouseMoving, true);
15731 addGlobalEventListener("mousedown", resetMouseMoving, true);
15732 addGlobalEventListener("mouseup", resetMouseMoving, true);
15733 addGlobalEventListener("keydown", resetMouseMoving, true);
15734 addGlobalEventListener("scroll", resetMouseMoving, true);
15735 hasInstalledGlobalEventListeners = true;
15736 }, []);
15737 return useEvent(() => mouseMoving);
15738 }
15739 var mouseMoving = false;
15740 var previousScreenX = 0;
15741 var previousScreenY = 0;
15742 function hasMouseMovement(event) {
15743 const movementX = event.movementX || event.screenX - previousScreenX;
15744 const movementY = event.movementY || event.screenY - previousScreenY;
15745 previousScreenX = event.screenX;
15746 previousScreenY = event.screenY;
15747 return movementX || movementY || false;
15748 }
15749 function setMouseMoving(event) {
15750 if (!hasMouseMovement(event)) return;
15751 mouseMoving = true;
15752 }
15753 function resetMouseMoving() {
15754 mouseMoving = false;
15755 }
15756 function forwardRef21(render4) {
15757 const Role = React48.forwardRef((props, ref) => render4({
15758 ...props,
15759 ref
15760 }));
15761 Role.displayName = render4.displayName || render4.name;
15762 return Role;
15763 }
15764 function memo3(Component, propsAreEqual) {
15765 return React48.memo(Component, propsAreEqual);
15766 }
15767 function createElement3(Type, props) {
15768 const { wrapElement, render: render4, ...rest } = props;
15769 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15770 let element;
15771 if (React48.isValidElement(render4)) {
15772 const renderProps = {
15773 ...render4.props,
15774 ref: mergedRef
15775 };
15776 element = React48.cloneElement(render4, mergeProps2(rest, renderProps));
15777 } else if (render4) element = render4(rest);
15778 else element = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Type, { ...rest });
15779 if (wrapElement) return wrapElement(element);
15780 return element;
15781 }
15782 function createHook(useProps) {
15783 const useRole = (props = {}) => {
15784 return useProps(props);
15785 };
15786 useRole.displayName = useProps.name;
15787 return useRole;
15788 }
15789 function createStoreContext(providers = [], scopedProviders = []) {
15790 const context = React48.createContext(void 0);
15791 const scopedContext = React48.createContext(void 0);
15792 const useContext38 = () => React48.useContext(context);
15793 const useScopedContext = (onlyScoped = false) => {
15794 const scoped = React48.useContext(scopedContext);
15795 const store = useContext38();
15796 if (onlyScoped) return scoped;
15797 return scoped || store;
15798 };
15799 const useProviderContext = () => {
15800 const scoped = React48.useContext(scopedContext);
15801 const store = useContext38();
15802 if (scoped && scoped === store) return;
15803 return store;
15804 };
15805 const ContextProvider = (props) => {
15806 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15807 ...props,
15808 children
15809 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(context.Provider, { ...props }));
15810 };
15811 const ScopedContextProvider = (props) => {
15812 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ContextProvider, {
15813 ...props,
15814 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15815 ...props,
15816 children
15817 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(scopedContext.Provider, { ...props }))
15818 });
15819 };
15820 return {
15821 context,
15822 scopedContext,
15823 useContext: useContext38,
15824 useScopedContext,
15825 useProviderContext,
15826 ContextProvider,
15827 ScopedContextProvider
15828 };
15829 }
15830
15831 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
15832 var import_react9 = __toESM(require_react(), 1);
15833 var TagName = "div";
15834 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
15835 var isSafariBrowser = isSafari();
15836 var alwaysFocusVisibleInputTypes = [
15837 "text",
15838 "search",
15839 "url",
15840 "tel",
15841 "email",
15842 "password",
15843 "number",
15844 "date",
15845 "month",
15846 "week",
15847 "time",
15848 "datetime",
15849 "datetime-local"
15850 ];
15851 function isAlwaysFocusVisible(element) {
15852 const { tagName, readOnly, type } = element;
15853 if (tagName === "TEXTAREA" && !readOnly) return true;
15854 if (tagName === "SELECT" && !readOnly) return true;
15855 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
15856 if (element.isContentEditable) return true;
15857 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
15858 return false;
15859 }
15860 function isNativeTabbable(tagName) {
15861 if (!tagName) return true;
15862 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15863 }
15864 function supportsDisabledAttribute(tagName) {
15865 if (!tagName) return true;
15866 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15867 }
15868 function isNativeSubmitControl(element) {
15869 if (element.tagName === "BUTTON") {
15870 const { type } = element;
15871 return type === "submit";
15872 }
15873 if (element.tagName === "INPUT") {
15874 const { type } = element;
15875 return type === "submit" || type === "image";
15876 }
15877 return false;
15878 }
15879 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
15880 if (!focusable2) return tabIndexProp;
15881 if (trulyDisabled) {
15882 if (nativeTabbable && !supportsDisabled) return -1;
15883 return;
15884 }
15885 if (nativeTabbable) {
15886 if (safariTabIndex && tabIndexProp == null) return 0;
15887 return tabIndexProp;
15888 }
15889 return tabIndexProp ?? 0;
15890 }
15891 function useDisableEvent(onEvent, disabled2) {
15892 return useEvent((event) => {
15893 onEvent?.(event);
15894 if (event.defaultPrevented) return;
15895 if (disabled2) {
15896 event.stopPropagation();
15897 event.preventDefault();
15898 }
15899 });
15900 }
15901 var hasInstalledGlobalEventListeners2 = false;
15902 var isKeyboardModality = true;
15903 function onGlobalMouseDown(event) {
15904 const target = event.target;
15905 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
15906 }
15907 function onGlobalKeyDown(event) {
15908 if (event.metaKey) return;
15909 if (event.ctrlKey) return;
15910 if (event.altKey) return;
15911 isKeyboardModality = true;
15912 }
15913 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
15914 const ref = (0, import_react9.useRef)(null);
15915 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
15916 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
15917 (0, import_react9.useEffect)(() => {
15918 if (!focusable2) return;
15919 if (hasInstalledGlobalEventListeners2) return;
15920 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15921 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15922 hasInstalledGlobalEventListeners2 = true;
15923 }, [focusable2]);
15924 const disabled2 = focusable2 && disabledFromProps(props);
15925 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
15926 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
15927 const focusVisibleRef = (0, import_react9.useRef)(false);
15928 const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
15929 const cleanupFocusVisible = useEvent((element) => {
15930 nativeSubmitObserverCleanupRef.current?.();
15931 nativeSubmitObserverCleanupRef.current = null;
15932 focusVisibleRef.current = false;
15933 element?.removeAttribute("data-focus-visible");
15934 });
15935 (0, import_react9.useEffect)(() => {
15936 if (!focusable2) return;
15937 if (!trulyDisabled) return;
15938 cleanupFocusVisible(ref.current);
15939 if (focusVisible) setFocusVisible(false);
15940 }, [
15941 focusable2,
15942 trulyDisabled,
15943 focusVisible,
15944 cleanupFocusVisible
15945 ]);
15946 (0, import_react9.useEffect)(() => {
15947 if (!focusable2) return;
15948 if (!focusVisible) return;
15949 const element = ref.current;
15950 if (!element) return;
15951 if (typeof IntersectionObserver === "undefined") return;
15952 const observer = new IntersectionObserver(() => {
15953 if (!isFocusable(element)) {
15954 focusVisibleRef.current = false;
15955 setFocusVisible(false);
15956 }
15957 });
15958 observer.observe(element);
15959 return () => observer.disconnect();
15960 }, [focusable2, focusVisible]);
15961 (0, import_react9.useEffect)(() => {
15962 return () => nativeSubmitObserverCleanupRef.current?.();
15963 }, []);
15964 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
15965 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
15966 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15967 const handleFocusVisible = (event, currentTarget) => {
15968 if (currentTarget) event.currentTarget = currentTarget;
15969 if (!focusable2) return;
15970 const element = event.currentTarget;
15971 if (!element) return;
15972 if (!hasFocus(element)) return;
15973 onFocusVisible?.(event);
15974 if (event.defaultPrevented) return;
15975 element.dataset.focusVisible = "true";
15976 focusVisibleRef.current = true;
15977 if (isNativeSubmitControl(element)) {
15978 nativeSubmitObserverCleanupRef.current?.();
15979 nativeSubmitObserverCleanupRef.current = null;
15980 if (typeof IntersectionObserver !== "undefined") {
15981 const observer = new IntersectionObserver(() => {
15982 if (isFocusable(element)) return;
15983 cleanupFocusVisible(element);
15984 });
15985 observer.observe(element);
15986 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
15987 }
15988 return;
15989 }
15990 setFocusVisible(true);
15991 };
15992 const onKeyDownCaptureProp = props.onKeyDownCapture;
15993 const onKeyDownCapture = useEvent((event) => {
15994 onKeyDownCaptureProp?.(event);
15995 if (event.defaultPrevented) return;
15996 if (!focusable2) return;
15997 if (focusVisible) return;
15998 if (focusVisibleRef.current) return;
15999 if (event.metaKey) return;
16000 if (event.altKey) return;
16001 if (event.ctrlKey) return;
16002 if (!isSelfTarget(event)) return;
16003 const element = event.currentTarget;
16004 const applyFocusVisible = () => handleFocusVisible(event, element);
16005 queueBeforeEvent(element, "focusout", applyFocusVisible);
16006 });
16007 const onFocusCaptureProp = props.onFocusCapture;
16008 const onFocusCapture = useEvent((event) => {
16009 onFocusCaptureProp?.(event);
16010 if (event.defaultPrevented) return;
16011 if (!focusable2) return;
16012 if (!isSelfTarget(event)) {
16013 setFocusVisible(false);
16014 return;
16015 }
16016 const element = event.currentTarget;
16017 const applyFocusVisible = () => handleFocusVisible(event, element);
16018 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16019 else setFocusVisible(false);
16020 });
16021 const onBlurProp = props.onBlur;
16022 const onBlur = useEvent((event) => {
16023 onBlurProp?.(event);
16024 if (!focusable2) return;
16025 if (!isFocusEventOutside(event)) return;
16026 cleanupFocusVisible(event.currentTarget);
16027 setFocusVisible(false);
16028 });
16029 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
16030 const autoFocusRef = useEvent((element) => {
16031 if (!focusable2) return;
16032 if (!autoFocus) return;
16033 if (!element) return;
16034 if (!autoFocusOnShow) return;
16035 queueMicrotask(() => {
16036 if (hasFocus(element)) return;
16037 if (!isFocusable(element)) return;
16038 element.focus();
16039 });
16040 });
16041 const tagName = useTagName(ref);
16042 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16043 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16044 const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
16045 if (isSafariBrowser) (0, import_react9.useEffect)(() => {
16046 if (!focusable2) return;
16047 const element = ref.current;
16048 if (!element) return;
16049 const { type } = element;
16050 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16051 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16052 }, [focusable2]);
16053 const styleProp = props.style;
16054 const style = (0, import_react9.useMemo)(() => {
16055 if (trulyDisabled) return {
16056 pointerEvents: "none",
16057 ...styleProp
16058 };
16059 return styleProp;
16060 }, [trulyDisabled, styleProp]);
16061 props = {
16062 "data-focus-visible": focusable2 && focusVisible || void 0,
16063 "data-autofocus": autoFocus || void 0,
16064 "aria-disabled": disabled2 || void 0,
16065 ...props,
16066 ...metadataProps,
16067 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16068 style,
16069 tabIndex: getTabIndex2({
16070 focusable: focusable2,
16071 trulyDisabled,
16072 nativeTabbable,
16073 supportsDisabled,
16074 safariTabIndex,
16075 tabIndexProp: props.tabIndex
16076 }),
16077 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16078 contentEditable: disabled2 ? void 0 : props.contentEditable,
16079 onKeyPressCapture,
16080 onClickCapture,
16081 onMouseDownCapture,
16082 onKeyDownCapture,
16083 onFocusCapture,
16084 onBlur
16085 };
16086 return removeUndefinedValues(props);
16087 });
16088 var Focusable = forwardRef21(function Focusable2(props) {
16089 return createElement3(TagName, useFocusable(props));
16090 });
16091
16092 // node_modules/@ariakit/react-components/dist/command/command.js
16093 var import_react10 = __toESM(require_react(), 1);
16094 var TagName2 = "button";
16095 function isNativeClick(event) {
16096 if (!event.isTrusted) return false;
16097 const element = event.currentTarget;
16098 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16099 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16100 return false;
16101 }
16102 var symbol = /* @__PURE__ */ Symbol("command");
16103 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16104 const ref = (0, import_react10.useRef)(null);
16105 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
16106 (0, import_react10.useEffect)(() => {
16107 if (!ref.current) return;
16108 setIsNativeButton(isButton(ref.current));
16109 }, []);
16110 const [active, setActive] = (0, import_react10.useState)(false);
16111 const activeRef = (0, import_react10.useRef)(false);
16112 const disabled2 = disabledFromProps(props);
16113 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16114 useSafeLayoutEffect(() => {
16115 if (!disabled2) return;
16116 activeRef.current = false;
16117 setActive(false);
16118 }, [disabled2]);
16119 const onKeyDownProp = props.onKeyDown;
16120 const onKeyDown = useEvent((event) => {
16121 onKeyDownProp?.(event);
16122 const element = event.currentTarget;
16123 if (event.defaultPrevented) return;
16124 if (isDuplicate) return;
16125 if (disabled2) return;
16126 if (!isSelfTarget(event)) return;
16127 if (isTextField(element)) return;
16128 if (element.isContentEditable) return;
16129 const isEnter = clickOnEnter && event.key === "Enter";
16130 const isSpace = clickOnSpace && event.key === " ";
16131 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16132 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16133 if (shouldPreventEnter || shouldPreventSpace) {
16134 event.preventDefault();
16135 return;
16136 }
16137 if (isEnter || isSpace) {
16138 const nativeClick = isNativeClick(event);
16139 if (isEnter) {
16140 if (!nativeClick) {
16141 event.preventDefault();
16142 const { view, ...eventInit } = event;
16143 const click = () => fireClickEvent(element, eventInit);
16144 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16145 else queueMicrotask(click);
16146 }
16147 } else if (isSpace) {
16148 activeRef.current = true;
16149 if (!nativeClick) {
16150 event.preventDefault();
16151 setActive(true);
16152 }
16153 }
16154 }
16155 });
16156 const onKeyUpProp = props.onKeyUp;
16157 const onKeyUp = useEvent((event) => {
16158 onKeyUpProp?.(event);
16159 if (isDuplicate) return;
16160 const isSpace = clickOnSpace && event.key === " ";
16161 if (!activeRef.current || !isSpace) return;
16162 const nativeClick = isNativeClick(event);
16163 activeRef.current = false;
16164 if (!nativeClick) setActive(false);
16165 if (event.defaultPrevented) return;
16166 if (!isSelfTarget(event)) return;
16167 if (disabled2) return;
16168 if (event.metaKey) return;
16169 if (nativeClick) return;
16170 event.preventDefault();
16171 const element = event.currentTarget;
16172 const { view, ...eventInit } = event;
16173 queueMicrotask(() => fireClickEvent(element, eventInit));
16174 });
16175 const onBlurProp = props.onBlur;
16176 const onBlur = useEvent((event) => {
16177 onBlurProp?.(event);
16178 if (!activeRef.current) return;
16179 activeRef.current = false;
16180 setActive(false);
16181 });
16182 props = {
16183 "data-active": active || void 0,
16184 type: isNativeButton ? "button" : void 0,
16185 ...metadataProps,
16186 ...props,
16187 ref: useMergeRefs(ref, props.ref),
16188 onKeyDown,
16189 onKeyUp,
16190 onBlur
16191 };
16192 props = useFocusable(props);
16193 return props;
16194 });
16195 var Command = forwardRef21(function Command2(props) {
16196 return createElement3(TagName2, useCommand(props));
16197 });
16198
16199 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16200 var ctx = createStoreContext();
16201 var useCollectionContext = ctx.useContext;
16202 var useCollectionScopedContext = ctx.useScopedContext;
16203 var useCollectionProviderContext = ctx.useProviderContext;
16204 var CollectionContextProvider = ctx.ContextProvider;
16205 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16206
16207 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16208 var import_react11 = __toESM(require_react(), 1);
16209 var TagName3 = "div";
16210 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16211 const context = useCollectionContext();
16212 store = store || context;
16213 const id = useId4(props.id);
16214 const ref = (0, import_react11.useRef)(element);
16215 (0, import_react11.useEffect)(() => {
16216 const element2 = ref.current;
16217 if (!id) return;
16218 if (!element2) return;
16219 if (!shouldRegisterItem) return;
16220 const item = getItem({
16221 id,
16222 element: element2
16223 });
16224 return store?.renderItem(item);
16225 }, [
16226 id,
16227 shouldRegisterItem,
16228 getItem,
16229 store
16230 ]);
16231 props = {
16232 ...props,
16233 ref: useMergeRefs(ref, props.ref)
16234 };
16235 return removeUndefinedValues(props);
16236 });
16237 var CollectionItem = forwardRef21(function CollectionItem2(props) {
16238 return createElement3(TagName3, useCollectionItem(props));
16239 });
16240
16241 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16242 var import_react12 = __toESM(require_react(), 1);
16243 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16244 var useCompositeContext = ctx2.useContext;
16245 var useCompositeScopedContext = ctx2.useScopedContext;
16246 var useCompositeProviderContext = ctx2.useProviderContext;
16247 var CompositeContextProvider = ctx2.ContextProvider;
16248 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16249 var CompositeItemContext = (0, import_react12.createContext)(void 0);
16250 var CompositeRowContext = (0, import_react12.createContext)(void 0);
16251
16252 // node_modules/@ariakit/store/dist/index.js
16253 function getInternal(store, key) {
16254 const internals = store.__unstableInternals;
16255 invariant(internals, "Invalid store");
16256 return internals[key];
16257 }
16258 function hasUpdatedKey(keys, updatedKey) {
16259 if (!keys) return true;
16260 for (const currentKey of keys) if (updatedKey instanceof Set) {
16261 if (updatedKey.has(currentKey)) return true;
16262 } else if (currentKey === updatedKey) return true;
16263 return false;
16264 }
16265 function isSameValue(value, other) {
16266 return value === other || value !== value && other !== other;
16267 }
16268 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16269 let cleanupPrevState;
16270 for (const key of getKeys(state)) {
16271 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16272 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16273 cleanupPrevState ??= { ...prevState };
16274 cleanupPrevState[key] = state[key];
16275 }
16276 return cleanupPrevState;
16277 }
16278 var MAX_REPAIR_PASSES = 100;
16279 function addKeyedListener(map, keys, listener) {
16280 if (!keys) return;
16281 for (const key of keys) {
16282 let listeners = map.get(key);
16283 if (!listeners) {
16284 listeners = /* @__PURE__ */ new Set();
16285 map.set(key, listeners);
16286 }
16287 listeners.add(listener);
16288 }
16289 }
16290 function deleteKeyedListener(map, keys, listener) {
16291 if (!map) return;
16292 if (!keys) return;
16293 for (const key of keys) {
16294 const listeners = map.get(key);
16295 if (!listeners) continue;
16296 listeners.delete(listener);
16297 if (!listeners.size) map.delete(key);
16298 }
16299 }
16300 function getFastPathNotifiedListeners(frame) {
16301 const notifiedListeners = /* @__PURE__ */ new Set();
16302 const currentListener = frame.currentListener;
16303 if (!currentListener) return notifiedListeners;
16304 for (const listener of frame.keyedListeners) {
16305 notifiedListeners.add(listener);
16306 if (listener === currentListener) return notifiedListeners;
16307 }
16308 notifiedListeners.clear();
16309 notifiedListeners.add(currentListener);
16310 return notifiedListeners;
16311 }
16312 function preserveFastPathNotifiedListeners(frame) {
16313 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16314 }
16315 function hasFastPathPassedListener(frame, listener) {
16316 if (!frame.currentListener) return false;
16317 let foundCurrentKeyedListener = false;
16318 for (const currentListener of frame.keyedListeners) {
16319 if (currentListener === frame.currentListener) {
16320 foundCurrentKeyedListener = true;
16321 continue;
16322 }
16323 if (!foundCurrentKeyedListener) continue;
16324 if (currentListener === listener) return false;
16325 }
16326 let foundListener = false;
16327 for (const currentListener of frame.group.listeners) {
16328 if (currentListener === frame.currentListener) return foundListener;
16329 if (currentListener === listener) foundListener = true;
16330 }
16331 return false;
16332 }
16333 function preserveFastPathFrames(fastPathFrames, group, listener) {
16334 for (const frame of fastPathFrames) {
16335 if (frame.group !== group) continue;
16336 if (frame.recovering) continue;
16337 if (listener && !frame.keyedListeners.has(listener)) continue;
16338 preserveFastPathNotifiedListeners(frame);
16339 for (const currentListener of frame.group.listeners) {
16340 if (currentListener === frame.currentListener) break;
16341 if (!hasFastPathPassedListener(frame, currentListener)) continue;
16342 frame.notifiedListeners?.add(currentListener);
16343 }
16344 }
16345 }
16346 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16347 for (const frame of fastPathFrames) {
16348 if (frame.group !== group) continue;
16349 if (frame.recovering) continue;
16350 if (!hasFastPathPassedListener(frame, listener)) continue;
16351 preserveFastPathNotifiedListeners(frame);
16352 frame.notifiedListeners?.add(listener);
16353 }
16354 }
16355 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16356 const wasRegistered = group.listeners.has(listener);
16357 for (const frame of fastPathFrames) {
16358 if (frame.group !== group) continue;
16359 if (frame.recovering) continue;
16360 if (!keys.includes(frame.updatedKey)) continue;
16361 if (hasFastPathPassedListener(frame, listener)) {
16362 preserveFastPathNotifiedListeners(frame);
16363 frame.notifiedListeners?.add(listener);
16364 } else if (wasRegistered) {
16365 preserveFastPathNotifiedListeners(frame);
16366 frame.recoverToLive = true;
16367 }
16368 }
16369 }
16370 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16371 for (const frame of fastPathFrames) {
16372 if (frame.group !== group) continue;
16373 frame.notifiedListeners?.delete(listener);
16374 }
16375 }
16376 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16377 for (const frame of fastPathFrames) {
16378 if (frame.group !== group) continue;
16379 if (frame.recovering) continue;
16380 if (!keys.includes(frame.updatedKey)) continue;
16381 frame.keyedListeners.add(listener);
16382 }
16383 }
16384 function runPendingCleanup(group, listener) {
16385 if (!group.disposables.size) return;
16386 const cleanup = group.disposables.get(listener);
16387 if (!cleanup) return;
16388 group.disposables.delete(listener);
16389 cleanup();
16390 }
16391 function setListenerCleanup(group, listener, cleanup) {
16392 const currentCleanup = group.disposables.get(listener);
16393 if (!currentCleanup) {
16394 group.disposables.set(listener, cleanup);
16395 return;
16396 }
16397 group.disposables.set(listener, () => {
16398 currentCleanup();
16399 cleanup();
16400 });
16401 }
16402 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16403 if (group.suspendCounts?.has(listener)) return;
16404 const { disposables } = group;
16405 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16406 if (cleanup) {
16407 disposables.delete(listener);
16408 const stateBeforeCleanup = state;
16409 cleanup();
16410 state = getState?.() ?? state;
16411 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16412 }
16413 const result = listener(state, prevState);
16414 if (result) setListenerCleanup(group, listener, result);
16415 }
16416 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16417 const allKeysListeners = group.allKeysListeners;
16418 for (const listener of group.listeners) {
16419 if (notifiedListeners?.has(listener)) continue;
16420 if (!allKeysListeners?.has(listener)) {
16421 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16422 }
16423 notifiedListeners?.add(listener);
16424 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16425 }
16426 }
16427 function createStore(initialState, ...stores) {
16428 let state = initialState;
16429 let prevStateBatch = state;
16430 let destroy = noop4;
16431 let batchPending = false;
16432 let inDispatch = false;
16433 let updatedKeys = /* @__PURE__ */ new Set();
16434 const instances = /* @__PURE__ */ new Set();
16435 const setups = /* @__PURE__ */ new Set();
16436 const syncListenerGroup = {
16437 listeners: /* @__PURE__ */ new Set(),
16438 disposables: /* @__PURE__ */ new Map(),
16439 listenerKeys: /* @__PURE__ */ new WeakMap()
16440 };
16441 const batchListenerGroup = {
16442 listeners: /* @__PURE__ */ new Set(),
16443 disposables: /* @__PURE__ */ new Map(),
16444 listenerKeys: /* @__PURE__ */ new WeakMap()
16445 };
16446 const storeSetup = (callback) => {
16447 setups.add(callback);
16448 return () => setups.delete(callback);
16449 };
16450 const storeInit = () => {
16451 const initializedInstances = instances.size;
16452 const instance = /* @__PURE__ */ Symbol();
16453 instances.add(instance);
16454 const maybeDestroy = () => {
16455 if (!instances.delete(instance)) return;
16456 if (instances.size) return;
16457 destroy();
16458 };
16459 if (initializedInstances) return maybeDestroy;
16460 const stateKeys = getKeys(state);
16461 const desyncs = [];
16462 for (const store of stores) {
16463 const storeState = store?.getState?.();
16464 if (!storeState) continue;
16465 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16466 if (!keys.length) continue;
16467 if (stores.length === 1 || keys.length === stateKeys.length) {
16468 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16469 setState(key, state2[key], true);
16470 }));
16471 continue;
16472 }
16473 desyncs.push(subscribe(store, keys, (state2, prevState) => {
16474 for (const key of keys) {
16475 if (state2[key] === prevState[key]) continue;
16476 setState(key, state2[key], true);
16477 }
16478 }));
16479 for (const key of keys) {
16480 const liveState = store?.getState?.();
16481 if (!liveState) continue;
16482 setState(key, liveState[key], true);
16483 }
16484 }
16485 const teardowns = [];
16486 for (const setup2 of setups) teardowns.push(setup2());
16487 const cleanups = stores.map(init);
16488 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16489 return maybeDestroy;
16490 };
16491 const deleteListenerIndexes = (group, listener, keys) => {
16492 if (keys === void 0) return;
16493 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16494 else group.allKeysListeners?.delete(listener);
16495 };
16496 const fastPathFrames = [];
16497 const registerListener = (keys, listener, group = syncListenerGroup) => {
16498 const listenerKeysValue = keys ? [...keys] : null;
16499 const wasRegistered = group.listeners.has(listener);
16500 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
16501 if (!listenerKeysValue) {
16502 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
16503 preserveFastPathPassedListeners(fastPathFrames, group, listener);
16504 } else preserveFastPathPassedKeyedListeners({
16505 fastPathFrames,
16506 group,
16507 keys: listenerKeysValue,
16508 listener
16509 });
16510 if (wasRegistered) {
16511 preserveFastPathFrames(fastPathFrames, group, listener);
16512 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16513 }
16514 group.listeners.add(listener);
16515 if (listenerKeysValue) {
16516 group.listenersByKey ??= /* @__PURE__ */ new Map();
16517 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16518 addFastPathKeyedListener({
16519 fastPathFrames,
16520 group,
16521 keys: listenerKeysValue,
16522 listener
16523 });
16524 } else {
16525 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16526 group.allKeysListeners.add(listener);
16527 }
16528 group.listenerKeys.set(listener, listenerKeysValue);
16529 return () => {
16530 const cleanup = group.disposables.get(listener);
16531 group.disposables.delete(listener);
16532 preserveFastPathFrames(fastPathFrames, group, listener);
16533 const currentKeys = group.listenerKeys.get(listener);
16534 deleteListenerIndexes(group, listener, listenerKeysValue);
16535 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16536 group.listenerKeys.delete(listener);
16537 group.listeners.delete(listener);
16538 cleanup?.();
16539 };
16540 };
16541 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16542 const runInitialListener = (group, listener, prevState) => {
16543 const shouldSuspend = group.listeners.has(listener);
16544 if (shouldSuspend) {
16545 group.suspendCounts ??= /* @__PURE__ */ new Map();
16546 const count = group.suspendCounts.get(listener) ?? 0;
16547 group.suspendCounts.set(listener, count + 1);
16548 }
16549 let cleanupPrevState;
16550 try {
16551 const stateBeforeCleanups = state;
16552 runPendingCleanup(group, listener);
16553 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
16554 const cleanup = listener(state, cleanupPrevState ?? prevState);
16555 if (cleanup) setListenerCleanup(group, listener, cleanup);
16556 } finally {
16557 if (shouldSuspend) {
16558 const suspendCounts = group.suspendCounts;
16559 const count = suspendCounts?.get(listener);
16560 if (count && count > 1) suspendCounts?.set(listener, count - 1);
16561 else suspendCounts?.delete(listener);
16562 if (!suspendCounts?.size) delete group.suspendCounts;
16563 }
16564 }
16565 };
16566 const storeSync = (keys, listener) => {
16567 runInitialListener(syncListenerGroup, listener, state);
16568 return registerListener(keys, listener);
16569 };
16570 const storeBatch = (keys, listener) => {
16571 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
16572 runInitialListener(batchListenerGroup, listener, prevStateBatch);
16573 return registerListener(keys, listener, batchListenerGroup);
16574 };
16575 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16576 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
16577 const getState = () => state;
16578 const runListeners = (group, prevState, updatedKey) => {
16579 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
16580 const keyedListeners = group.listenersByKey?.get(updatedKey);
16581 if (!keyedListeners) return;
16582 const frame = {
16583 group,
16584 keyedListeners,
16585 updatedKey,
16586 currentListener: null
16587 };
16588 fastPathFrames.push(frame);
16589 try {
16590 for (const listener of keyedListeners) {
16591 if (frame.notifiedListeners?.has(listener)) continue;
16592 frame.currentListener = listener;
16593 frame.notifiedListeners?.add(listener);
16594 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
16595 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
16596 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
16597 frame.notifiedListeners = notifiedListeners;
16598 frame.recovering = true;
16599 runLiveListeners({
16600 group,
16601 getState,
16602 prevState,
16603 updatedKey,
16604 notifiedListeners
16605 });
16606 return;
16607 }
16608 } finally {
16609 fastPathFrames.pop();
16610 }
16611 return;
16612 }
16613 runLiveListeners({
16614 group,
16615 getState,
16616 prevState,
16617 updatedKey
16618 });
16619 };
16620 const setState = (key, value, fromStores = false) => {
16621 if (!hasOwnProperty(state, key)) return;
16622 const currentValue = state[key];
16623 const nextValue = typeof value === "function" ? value(currentValue) : value;
16624 if (isSameValue(nextValue, currentValue)) return;
16625 const wasInDispatch = inDispatch;
16626 inDispatch = true;
16627 const prevState = state;
16628 const nextState = {
16629 ...state,
16630 [key]: nextValue
16631 };
16632 state = nextState;
16633 let superseded = false;
16634 try {
16635 if (!fromStores && stores.length) {
16636 for (const store of stores) {
16637 store?.setState?.(key, nextValue);
16638 if (isSameValue(state[key], nextValue)) continue;
16639 superseded = true;
16640 break;
16641 }
16642 if (superseded) {
16643 let pass = 0;
16644 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
16645 let changed = false;
16646 for (const store of stores) {
16647 const previousValue = state[key];
16648 store?.setState?.(key, previousValue);
16649 if (!isSameValue(state[key], previousValue)) changed = true;
16650 }
16651 if (!changed) break;
16652 }
16653 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
16654 }
16655 }
16656 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
16657 ...state,
16658 [key]: prevState[key]
16659 }, key);
16660 } finally {
16661 inDispatch = wasInDispatch;
16662 }
16663 if (!batchListenerGroup.listeners.size) {
16664 if (!inDispatch) prevStateBatch = state;
16665 return;
16666 }
16667 updatedKeys.add(key);
16668 if (batchPending) return;
16669 batchPending = true;
16670 queueMicrotask(() => {
16671 batchPending = false;
16672 const snapshot = state;
16673 const updatedKeysSnapshot = updatedKeys;
16674 updatedKeys = /* @__PURE__ */ new Set();
16675 const prevStateBatchBefore = prevStateBatch;
16676 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
16677 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
16678 });
16679 };
16680 const finalStore = {
16681 getState,
16682 setState,
16683 __unstableInternals: {
16684 setup: storeSetup,
16685 init: storeInit,
16686 subscribe: storeSubscribe,
16687 sync: storeSync,
16688 batch: storeBatch,
16689 pick: storePick,
16690 omit: storeOmit
16691 }
16692 };
16693 return finalStore;
16694 }
16695 function setup(store, ...args) {
16696 if (!store) return;
16697 return getInternal(store, "setup")(...args);
16698 }
16699 function init(store, ...args) {
16700 if (!store) return;
16701 return getInternal(store, "init")(...args);
16702 }
16703 function subscribe(store, ...args) {
16704 if (!store) return;
16705 return getInternal(store, "subscribe")(...args);
16706 }
16707 function sync(store, ...args) {
16708 if (!store) return;
16709 return getInternal(store, "sync")(...args);
16710 }
16711 function batch(store, ...args) {
16712 if (!store) return;
16713 return getInternal(store, "batch")(...args);
16714 }
16715 function omit3(store, ...args) {
16716 if (!store) return;
16717 return getInternal(store, "omit")(...args);
16718 }
16719 function pick2(store, ...args) {
16720 if (!store) return;
16721 return getInternal(store, "pick")(...args);
16722 }
16723 function mergeStore(...stores) {
16724 const initialState = {};
16725 for (const store2 of stores) {
16726 const nextState = store2?.getState?.();
16727 if (nextState) Object.assign(initialState, nextState);
16728 }
16729 const store = createStore(initialState, ...stores);
16730 return Object.assign({}, ...stores, store);
16731 }
16732 function throwOnConflictingProps(props, store) {
16733 if (false) return;
16734 if (!store) return;
16735 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16736 const stateKey = key.replace("default", "");
16737 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
16738 });
16739 if (!defaultKeys.length) return;
16740 const storeState = store.getState();
16741 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
16742 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
16743
16744 const store = useSelectStore();
16745 <SelectProvider store={store} defaultValue="Apple" />
16746 ^ ^
16747
16748 Instead, pass the default state to the topmost store:
16749
16750 const store = useSelectStore({ defaultValue: "Apple" });
16751 <SelectProvider store={store} />
16752
16753 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16754
16755 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16756 `);
16757 }
16758
16759 // node_modules/@ariakit/components/dist/collection/collection-store.js
16760 function getCommonParent(items) {
16761 const firstItem = items.find((item) => !!item.element);
16762 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
16763 let parentElement = firstItem?.element?.parentElement;
16764 if (!lastElement) return getDocument(parentElement).body;
16765 while (parentElement) {
16766 if (parentElement.contains(lastElement)) return parentElement;
16767 parentElement = parentElement.parentElement;
16768 }
16769 return getDocument(parentElement).body;
16770 }
16771 function getPrivateStore(store) {
16772 return store?.__unstablePrivateStore;
16773 }
16774 function createCollectionStore(props = {}) {
16775 throwOnConflictingProps(props, props.store);
16776 const syncState = props.store?.getState();
16777 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
16778 const itemsMap = new Map(items.map((item) => [item.id, item]));
16779 const initialState = {
16780 items,
16781 renderedItems: defaultValue(syncState?.renderedItems, [])
16782 };
16783 const syncPrivateStore = getPrivateStore(props.store);
16784 const privateStore = createStore({
16785 items,
16786 renderedItems: initialState.renderedItems
16787 }, syncPrivateStore);
16788 const collection = createStore(initialState, props.store);
16789 const sortItems = (renderedItems) => {
16790 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
16791 privateStore.setState("renderedItems", sortedItems);
16792 collection.setState("renderedItems", sortedItems);
16793 };
16794 setup(collection, () => init(privateStore));
16795 setup(privateStore, () => {
16796 return batch(privateStore, ["items"], (state) => {
16797 collection.setState("items", state.items);
16798 });
16799 });
16800 setup(privateStore, () => {
16801 return batch(privateStore, ["renderedItems"], (state) => {
16802 let firstRun = true;
16803 let raf = requestAnimationFrame(() => {
16804 const { renderedItems } = collection.getState();
16805 if (state.renderedItems === renderedItems) return;
16806 sortItems(state.renderedItems);
16807 });
16808 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
16809 const ioCallback = () => {
16810 if (firstRun) {
16811 firstRun = false;
16812 return;
16813 }
16814 cancelAnimationFrame(raf);
16815 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
16816 };
16817 const root = getCommonParent(state.renderedItems);
16818 const observer = new IntersectionObserver(ioCallback, { root });
16819 for (const item of state.renderedItems) {
16820 if (!item.element) continue;
16821 observer.observe(item.element);
16822 }
16823 return () => {
16824 cancelAnimationFrame(raf);
16825 observer.disconnect();
16826 };
16827 });
16828 });
16829 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
16830 let prevItem;
16831 setItems((items2) => {
16832 const index2 = items2.findIndex(({ id }) => id === item.id);
16833 const nextItems = items2.slice();
16834 if (index2 !== -1) {
16835 prevItem = items2[index2];
16836 const nextItem = {
16837 ...prevItem,
16838 ...item
16839 };
16840 nextItems[index2] = nextItem;
16841 itemsMap.set(item.id, nextItem);
16842 } else {
16843 nextItems.push(item);
16844 itemsMap.set(item.id, item);
16845 }
16846 return nextItems;
16847 });
16848 const unmergeItem = () => {
16849 setItems((items2) => {
16850 if (!prevItem) {
16851 if (canDeleteFromMap) itemsMap.delete(item.id);
16852 return items2.filter(({ id }) => id !== item.id);
16853 }
16854 const index2 = items2.findIndex(({ id }) => id === item.id);
16855 if (index2 === -1) return items2;
16856 const nextItems = items2.slice();
16857 nextItems[index2] = prevItem;
16858 itemsMap.set(item.id, prevItem);
16859 return nextItems;
16860 });
16861 };
16862 return unmergeItem;
16863 };
16864 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
16865 return {
16866 ...collection,
16867 registerItem,
16868 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
16869 item: (id) => {
16870 if (!id) return null;
16871 let item = itemsMap.get(id);
16872 if (!item) {
16873 const { items: items2 } = privateStore.getState();
16874 item = items2.find((item2) => item2.id === id);
16875 if (item) itemsMap.set(id, item);
16876 }
16877 return item || null;
16878 },
16879 __unstablePrivateStore: privateStore
16880 };
16881 }
16882
16883 // node_modules/@ariakit/components/dist/composite/composite-store.js
16884 var NULL_ITEM = { id: null };
16885 function findFirstEnabledItem(items, excludeId) {
16886 return items.find((item) => {
16887 if (excludeId) return !item.disabled && item.id !== excludeId;
16888 return !item.disabled;
16889 });
16890 }
16891 function getEnabledItems(items, excludeId) {
16892 return items.filter((item) => {
16893 if (excludeId) return !item.disabled && item.id !== excludeId;
16894 return !item.disabled;
16895 });
16896 }
16897 function getItemsInRow(items, rowId) {
16898 return items.filter((item) => item.rowId === rowId);
16899 }
16900 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
16901 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
16902 const item = items[i2];
16903 if (!item) continue;
16904 if (item.rowId !== rowId) continue;
16905 if (item.disabled) continue;
16906 if (excludeId != null && item.id === excludeId) continue;
16907 return item.id;
16908 }
16909 }
16910 function flipItems(items, activeId, shouldInsertNullItem = false) {
16911 const index2 = items.findIndex((item) => item.id === activeId);
16912 return [
16913 ...items.slice(index2 + 1),
16914 ...shouldInsertNullItem ? [NULL_ITEM] : [],
16915 ...items.slice(0, index2)
16916 ];
16917 }
16918 function groupItemsByRows(items) {
16919 const rows = [];
16920 for (const item of items) {
16921 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
16922 if (row) row.push(item);
16923 else rows.push([item]);
16924 }
16925 return rows;
16926 }
16927 function getMaxRowLength(array) {
16928 let maxLength = 0;
16929 for (const { length } of array) if (length > maxLength) maxLength = length;
16930 return maxLength;
16931 }
16932 function createEmptyItem(rowId) {
16933 return {
16934 id: "__EMPTY_ITEM__",
16935 disabled: true,
16936 rowId
16937 };
16938 }
16939 function normalizeRows(rows, activeId, focusShift) {
16940 const maxLength = getMaxRowLength(rows);
16941 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
16942 const item = row[i2];
16943 if (!item || focusShift && item.disabled) {
16944 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
16945 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
16946 }
16947 }
16948 return rows;
16949 }
16950 function verticalizeItems(items) {
16951 const rows = groupItemsByRows(items);
16952 const maxLength = getMaxRowLength(rows);
16953 const verticalized = [];
16954 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
16955 const item = row[i2];
16956 if (item) verticalized.push({
16957 ...item,
16958 rowId: item.rowId ? `${i2}` : void 0
16959 });
16960 }
16961 return verticalized;
16962 }
16963 function createCompositeStore(props = {}) {
16964 const syncState = props.store?.getState();
16965 const collection = createCollectionStore(props);
16966 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
16967 const composite = createStore({
16968 ...collection.getState(),
16969 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
16970 activeId,
16971 baseElement: defaultValue(syncState?.baseElement, null),
16972 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
16973 moves: defaultValue(syncState?.moves, 0),
16974 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
16975 rtl: defaultValue(props.rtl, syncState?.rtl, false),
16976 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
16977 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
16978 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
16979 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
16980 }, collection, props.store);
16981 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
16982 composite.setState("activeId", (activeId2) => {
16983 if (activeId2 !== void 0) return activeId2;
16984 return findFirstEnabledItem(state.renderedItems)?.id;
16985 });
16986 }));
16987 const getNextId = (direction = "next", options = {}) => {
16988 const defaultState = composite.getState();
16989 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;
16990 const isVerticalDirection = direction === "up" || direction === "down";
16991 const isNextDirection = direction === "next" || direction === "down";
16992 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
16993 const canShift = focusShift && !skip;
16994 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
16995 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
16996 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
16997 const activeItem2 = renderedItems[activeIndex2];
16998 if (activeItem2) {
16999 const step = canReverse ? -1 : 1;
17000 const nextId = findEnabledItemId({
17001 items: renderedItems,
17002 fromIndex: activeIndex2 + step,
17003 step,
17004 rowId: activeItem2.rowId,
17005 excludeId: activeId2
17006 });
17007 if (nextId !== void 0) return nextId;
17008 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17009 return findEnabledItemId({
17010 items: renderedItems,
17011 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17012 step,
17013 rowId: activeItem2.rowId,
17014 excludeId: activeId2
17015 });
17016 }
17017 }
17018 }
17019 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17020 items = canReverse ? reverseArray(items) : items;
17021 items = isVerticalDirection ? verticalizeItems(items) : items;
17022 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17023 const activeItem = items.find((item) => item.id === activeId2);
17024 if (!activeItem) return findFirstEnabledItem(items)?.id;
17025 const isGrid2 = items.some((item) => item.rowId);
17026 const activeIndex = items.indexOf(activeItem);
17027 const nextItems = items.slice(activeIndex + 1);
17028 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17029 if (skip) {
17030 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17031 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17032 }
17033 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17034 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17035 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17036 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17037 if (canWrap) {
17038 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17039 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17040 }
17041 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17042 if (!nextItem && hasNullItem) return null;
17043 return nextItem?.id;
17044 };
17045 const getNextIdFromOptions = (direction, options) => {
17046 if (typeof options === "number") return getNextId(direction, { skip: options });
17047 return getNextId(direction, options);
17048 };
17049 return {
17050 ...collection,
17051 ...composite,
17052 setBaseElement: (element) => composite.setState("baseElement", element),
17053 setActiveId: (id) => composite.setState("activeId", id),
17054 move: (id) => {
17055 if (id === void 0) return;
17056 composite.setState("activeId", id);
17057 composite.setState("moves", (moves) => moves + 1);
17058 },
17059 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17060 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17061 next: (options) => getNextIdFromOptions("next", options),
17062 previous: (options) => getNextIdFromOptions("previous", options),
17063 down: (options) => getNextIdFromOptions("down", options),
17064 up: (options) => getNextIdFromOptions("up", options)
17065 };
17066 }
17067
17068 // node_modules/@ariakit/react-components/dist/composite/utils.js
17069 var findFirstEnabledItem2 = findFirstEnabledItem;
17070 var groupItemsByRows2 = groupItemsByRows;
17071 function getEnabledItem(store, id) {
17072 if (!id) return null;
17073 return store.item(id) || null;
17074 }
17075 function selectTextField(element, collapseToEnd = false) {
17076 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17077 else if (element.isContentEditable) {
17078 const selection = getDocument(element).getSelection();
17079 selection?.selectAllChildren(element);
17080 if (collapseToEnd) selection?.collapseToEnd();
17081 }
17082 }
17083 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17084 function focusSilently(element) {
17085 element[FOCUS_SILENTLY] = true;
17086 element.focus({ preventScroll: true });
17087 }
17088 function silentlyFocused(element) {
17089 const isSilentlyFocused = element[FOCUS_SILENTLY];
17090 delete element[FOCUS_SILENTLY];
17091 return isSilentlyFocused;
17092 }
17093 function isItem(store, element, exclude) {
17094 if (!element) return false;
17095 if (element === exclude) return false;
17096 const item = store.item(element.id);
17097 if (!item) return false;
17098 if (exclude && item.element === exclude) return false;
17099 return true;
17100 }
17101
17102 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17103 var import_react13 = __toESM(require_react(), 1);
17104 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
17105
17106 // node_modules/@ariakit/react-store/dist/index.js
17107 var React49 = __toESM(require_react(), 1);
17108 var import_shim2 = __toESM(require_shim(), 1);
17109 var noopSubscribe = () => () => {
17110 };
17111 function useStoreState(store, keyOrSelector = identity) {
17112 const storeSubscribe = React49.useCallback((callback) => {
17113 if (!store) return noopSubscribe();
17114 return subscribe(store, null, callback);
17115 }, [store]);
17116 const getSnapshot = () => {
17117 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17118 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17119 const state = store?.getState();
17120 if (selector2) return selector2(state);
17121 if (!state) return;
17122 if (!key) return;
17123 if (!hasOwnProperty(state, key)) return;
17124 return state[key];
17125 };
17126 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17127 }
17128 function useStoreStateObject(store, object) {
17129 const objRef = React49.useRef({});
17130 const storeSubscribe = React49.useCallback((callback) => {
17131 if (!store) return noopSubscribe();
17132 return subscribe(store, null, callback);
17133 }, [store]);
17134 const getSnapshot = () => {
17135 const state = store?.getState();
17136 let updated = false;
17137 const obj = objRef.current;
17138 for (const prop in object) {
17139 const keyOrSelector = object[prop];
17140 if (typeof keyOrSelector === "function") {
17141 const value = keyOrSelector(state);
17142 if (!Object.is(value, obj[prop])) {
17143 obj[prop] = value;
17144 updated = true;
17145 }
17146 }
17147 if (typeof keyOrSelector === "string") {
17148 if (!state) continue;
17149 if (!hasOwnProperty(state, keyOrSelector)) continue;
17150 const value = state[keyOrSelector];
17151 if (!Object.is(value, obj[prop])) {
17152 obj[prop] = value;
17153 updated = true;
17154 }
17155 }
17156 }
17157 if (updated) objRef.current = { ...obj };
17158 return objRef.current;
17159 };
17160 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17161 }
17162 function useStoreProps(store, props, key, setKey) {
17163 const value = hasOwnProperty(props, key) ? props[key] : void 0;
17164 const propsRef = useLiveRef({
17165 value,
17166 setValue: setKey ? props[setKey] : void 0
17167 });
17168 useSafeLayoutEffect(() => {
17169 return sync(store, [key], (state, prev) => {
17170 const { value: value2, setValue } = propsRef.current;
17171 if (!setValue) return;
17172 if (state[key] === prev[key]) return;
17173 if (state[key] === value2) return;
17174 setValue(state[key]);
17175 });
17176 }, [store, key]);
17177 useSafeLayoutEffect(() => {
17178 if (value === void 0) return;
17179 store.setState(key, value);
17180 return batch(store, [key], () => {
17181 if (value === void 0) return;
17182 store.setState(key, value);
17183 });
17184 });
17185 }
17186 function useStore2(createStore2, props) {
17187 const [store, setStore] = React49.useState(() => createStore2(props));
17188 useSafeLayoutEffect(() => init(store), [store]);
17189 const useState37 = React49.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17190 return [React49.useMemo(() => ({
17191 ...store,
17192 useState: useState37
17193 }), [store, useState37]), useEvent(() => {
17194 setStore((store2) => createStore2({
17195 ...props,
17196 ...store2.getState()
17197 }));
17198 })];
17199 }
17200
17201 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17202 var TagName4 = "button";
17203 function isEditableElement(element) {
17204 if (isTextbox(element)) return true;
17205 return element.tagName === "INPUT" && !isButton(element);
17206 }
17207 function getNextPageOffset(scrollingElement, pageUp = false) {
17208 const height = scrollingElement.clientHeight;
17209 const { top } = scrollingElement.getBoundingClientRect();
17210 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17211 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17212 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17213 return pageOffset;
17214 }
17215 function getItemOffset(itemElement, pageUp = false) {
17216 const { top } = itemElement.getBoundingClientRect();
17217 if (pageUp) return top + itemElement.clientHeight;
17218 return top;
17219 }
17220 function findNextPageItemId(element, store, next, pageUp = false) {
17221 if (!store) return;
17222 if (!next) return;
17223 const { renderedItems } = store.getState();
17224 const scrollingElement = getScrollingElement(element);
17225 if (!scrollingElement) return;
17226 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17227 let id;
17228 let prevDifference;
17229 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17230 const previousId = id;
17231 id = next(i2);
17232 if (!id) break;
17233 if (id === previousId) continue;
17234 const itemElement = getEnabledItem(store, id)?.element;
17235 if (!itemElement) continue;
17236 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17237 const absDifference = Math.abs(difference);
17238 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17239 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17240 break;
17241 }
17242 prevDifference = absDifference;
17243 }
17244 return id;
17245 }
17246 function targetIsAnotherItem(event, store) {
17247 if (isSelfTarget(event)) return false;
17248 return isItem(store, event.target);
17249 }
17250 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17251 const context = useCompositeScopedContext();
17252 store = store || context;
17253 const id = useId4(props.id);
17254 const ref = (0, import_react13.useRef)(null);
17255 const row = (0, import_react13.useContext)(CompositeRowContext);
17256 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17257 const shouldRegisterItem = props.shouldRegisterItem;
17258 const getRowId = (state) => {
17259 if (rowIdProp) return rowIdProp;
17260 if (!state) return;
17261 if (!row?.baseElement) return;
17262 if (row.baseElement !== state.baseElement) return;
17263 return row.id;
17264 };
17265 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17266 rowId: getRowId,
17267 baseElement(state) {
17268 return state?.baseElement || void 0;
17269 },
17270 isActiveItem(state) {
17271 return !!state && state.activeId === id;
17272 },
17273 ariaSetSize(state) {
17274 if (ariaSetSizeProp != null) return ariaSetSizeProp;
17275 if (!state) return;
17276 if (!row?.ariaSetSize) return;
17277 if (row.baseElement !== state.baseElement) return;
17278 return row.ariaSetSize;
17279 },
17280 ariaPosInSet(state) {
17281 if (ariaPosInSetProp != null) return ariaPosInSetProp;
17282 if (!state) return;
17283 if (!row?.ariaPosInSet) return;
17284 if (row.baseElement !== state.baseElement) return;
17285 const rowId2 = getRowId(state);
17286 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17287 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17288 },
17289 isTabbable(state) {
17290 if (!state?.renderedItems.length) return true;
17291 if (state.virtualFocus) return false;
17292 if (tabbable2) return true;
17293 if (state.activeId === null) return false;
17294 const item = store?.item(state.activeId);
17295 if (item?.disabled) return true;
17296 if (!item?.element) return true;
17297 return state.activeId === id;
17298 }
17299 });
17300 const getItem = (0, import_react13.useCallback)((item) => {
17301 const nextItem = {
17302 ...item,
17303 id: id || item.id,
17304 rowId,
17305 disabled: trulyDisabled,
17306 children: item.element?.textContent
17307 };
17308 if (getItemProp) return getItemProp(nextItem);
17309 return nextItem;
17310 }, [
17311 id,
17312 rowId,
17313 trulyDisabled,
17314 getItemProp
17315 ]);
17316 const onFocusProp = props.onFocus;
17317 const hasFocusedComposite = (0, import_react13.useRef)(false);
17318 const cancelScheduledFocusRedirectRef = (0, import_react13.useRef)(null);
17319 const onFocus = useEvent((event) => {
17320 onFocusProp?.(event);
17321 if (event.defaultPrevented) return;
17322 if (isPortalEvent(event)) return;
17323 if (!id) return;
17324 if (!store) return;
17325 if (targetIsAnotherItem(event, store)) return;
17326 const { virtualFocus, baseElement: baseElement2 } = store.getState();
17327 store.setActiveId(id);
17328 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17329 if (!virtualFocus) return;
17330 if (!isSelfTarget(event)) return;
17331 if (isEditableElement(event.currentTarget)) return;
17332 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17333 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17334 block: "nearest",
17335 inline: "nearest"
17336 });
17337 hasFocusedComposite.current = true;
17338 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17339 else baseElement3.focus();
17340 };
17341 if (baseElement2?.isConnected) {
17342 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17343 return;
17344 }
17345 if (shouldRegisterItem === false) return;
17346 const { currentTarget, relatedTarget } = event;
17347 const cancelScheduledFocusRedirect = () => {
17348 cancelScheduledFocusRedirectRef.current?.();
17349 cancelScheduledFocusRedirectRef.current = null;
17350 };
17351 cancelScheduledFocusRedirect();
17352 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17353 if (getActiveElement(currentTarget) !== currentTarget) {
17354 cancelScheduledFocusRedirect();
17355 return;
17356 }
17357 const state = store.getState();
17358 const nextBaseElement = state.baseElement;
17359 if (!nextBaseElement?.isConnected) return;
17360 cancelScheduledFocusRedirect();
17361 if (!state.virtualFocus) return;
17362 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17363 });
17364 });
17365 const onBlurCaptureProp = props.onBlurCapture;
17366 const onBlurCapture = useEvent((event) => {
17367 onBlurCaptureProp?.(event);
17368 if (event.defaultPrevented) return;
17369 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17370 hasFocusedComposite.current = false;
17371 event.preventDefault();
17372 event.stopPropagation();
17373 }
17374 });
17375 const onKeyDownProp = props.onKeyDown;
17376 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17377 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17378 const onKeyDown = useEvent((event) => {
17379 onKeyDownProp?.(event);
17380 if (event.defaultPrevented) return;
17381 if (!isSelfTarget(event)) return;
17382 if (!store) return;
17383 const { currentTarget } = event;
17384 const state = store.getState();
17385 const isGrid2 = !!store.item(id)?.rowId;
17386 const isVertical = state.orientation !== "horizontal";
17387 const isHorizontal = state.orientation !== "vertical";
17388 const canHomeEnd = () => {
17389 if (isGrid2) return true;
17390 if (isHorizontal) return true;
17391 if (!state.baseElement) return true;
17392 if (!isTextField(state.baseElement)) return true;
17393 return false;
17394 };
17395 const action = {
17396 ArrowUp: (isGrid2 || isVertical) && store.up,
17397 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17398 ArrowDown: (isGrid2 || isVertical) && store.down,
17399 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17400 Home: () => {
17401 if (!canHomeEnd()) return;
17402 if (!isGrid2 || event.ctrlKey) return store?.first();
17403 return store?.previous(-1);
17404 },
17405 End: () => {
17406 if (!canHomeEnd()) return;
17407 if (!isGrid2 || event.ctrlKey) return store?.last();
17408 return store?.next(-1);
17409 },
17410 PageUp: () => {
17411 return findNextPageItemId(currentTarget, store, store?.up, true);
17412 },
17413 PageDown: () => {
17414 return findNextPageItemId(currentTarget, store, store?.down);
17415 }
17416 }[event.key];
17417 if (action) {
17418 if (isTextbox(currentTarget)) {
17419 const selection = getTextboxSelection(currentTarget);
17420 const isLeft = isHorizontal && event.key === "ArrowLeft";
17421 const isRight = isHorizontal && event.key === "ArrowRight";
17422 const isUp = isVertical && event.key === "ArrowUp";
17423 const isDown = isVertical && event.key === "ArrowDown";
17424 if (isRight || isDown) {
17425 const { length: valueLength } = getTextboxValue(currentTarget);
17426 if (selection.end !== valueLength) return;
17427 } else if ((isLeft || isUp) && selection.start !== 0) return;
17428 }
17429 const nextId = action();
17430 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17431 if (!moveOnKeyPressProp(event)) return;
17432 event.preventDefault();
17433 store.move(nextId);
17434 }
17435 }
17436 });
17437 const providerValue = (0, import_react13.useMemo)(() => ({
17438 id,
17439 baseElement
17440 }), [id, baseElement]);
17441 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeItemContext.Provider, {
17442 value: providerValue,
17443 children: element
17444 }), [providerValue]);
17445 props = {
17446 "data-active-item": isActiveItem || void 0,
17447 ...props,
17448 id,
17449 ref: useMergeRefs(ref, props.ref),
17450 tabIndex: isTabbable ? props.tabIndex : -1,
17451 onFocus,
17452 onBlurCapture,
17453 onKeyDown
17454 };
17455 props = useCommand(props);
17456 props = useCollectionItem({
17457 store,
17458 ...props,
17459 getItem,
17460 shouldRegisterItem: id ? shouldRegisterItem : false
17461 });
17462 return removeUndefinedValues({
17463 ...props,
17464 "aria-setsize": ariaSetSize,
17465 "aria-posinset": ariaPosInSet
17466 });
17467 });
17468 var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
17469 return createElement3(TagName4, useCompositeItem(props));
17470 }));
17471
17472 // node_modules/@ariakit/react-components/dist/composite/composite.js
17473 var import_react14 = __toESM(require_react(), 1);
17474 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
17475 var TagName5 = "div";
17476 function isGrid(items) {
17477 return items.some((item) => !!item.rowId);
17478 }
17479 function isPrintableKey(event) {
17480 const target = event.target;
17481 if (target && !isTextField(target)) return false;
17482 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17483 }
17484 function isModifierKey(event) {
17485 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17486 }
17487 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17488 return useEvent((event) => {
17489 onKeyboardEvent?.(event);
17490 if (event.defaultPrevented) return;
17491 if (event.isPropagationStopped()) return;
17492 if (!isSelfTarget(event)) return;
17493 if (isModifierKey(event)) return;
17494 if (isPrintableKey(event)) return;
17495 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17496 if (!activeElement2) return;
17497 const { view, ...eventInit } = event;
17498 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17499 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17500 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17501 });
17502 }
17503 function findFirstEnabledItemInTheLastRow(items) {
17504 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
17505 }
17506 function withBaseScrollPreserved(store, callback) {
17507 const { virtualFocus, baseElement } = store.getState();
17508 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17509 callback();
17510 return;
17511 }
17512 const savedScrollLeft = baseElement.scrollLeft;
17513 const savedScrollTop = baseElement.scrollTop;
17514 callback();
17515 baseElement.scrollLeft = savedScrollLeft;
17516 baseElement.scrollTop = savedScrollTop;
17517 }
17518 function useScheduleFocus(store) {
17519 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
17520 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
17521 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
17522 (0, import_react14.useEffect)(() => {
17523 const activeElement2 = activeItem?.element;
17524 if (!scheduled) return;
17525 if (!activeElement2) return;
17526 setScheduled(false);
17527 withBaseScrollPreserved(store, () => {
17528 activeElement2.focus({ preventScroll: true });
17529 });
17530 }, [
17531 store,
17532 activeItem,
17533 scheduled
17534 ]);
17535 return schedule;
17536 }
17537 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
17538 const moves = useStoreState(store, "moves");
17539 const baseElement = useStoreState(store, "baseElement");
17540 (0, import_react14.useEffect)(() => {
17541 if (!moves) return;
17542 if (!focusOnMove) return;
17543 const { activeId } = store.getState();
17544 const itemElement = getEnabledItem(store, activeId)?.element;
17545 if (!itemElement) return;
17546 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
17547 }, [
17548 store,
17549 moves,
17550 focusOnMove
17551 ]);
17552 useSafeLayoutEffect(() => {
17553 if (!moves) return;
17554 if (!baseElement) return;
17555 const { activeId } = store.getState();
17556 if (!(activeId === null)) return;
17557 const previousElement = previousElementRef.current;
17558 previousElementRef.current = null;
17559 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
17560 if (!hasFocus(baseElement)) baseElement.focus();
17561 }, [
17562 store,
17563 moves,
17564 baseElement
17565 ]);
17566 return null;
17567 });
17568 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
17569 const context = useCompositeProviderContext();
17570 store = store || context;
17571 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
17572 const ref = (0, import_react14.useRef)(null);
17573 const previousElementRef = (0, import_react14.useRef)(null);
17574 const scheduleFocus = useScheduleFocus(store);
17575 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
17576 const virtualFocus = useStoreState(store, "virtualFocus");
17577 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
17578 useSafeLayoutEffect(() => {
17579 if (!store) return;
17580 if (!composite) return;
17581 if (!virtualFocus) return;
17582 const previousElement = previousElementRef.current;
17583 previousElementRef.current = null;
17584 if (!previousElement) return;
17585 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
17586 if (relatedTarget === previousElement) return;
17587 fireBlurEvent(previousElement, { relatedTarget });
17588 }, [
17589 store,
17590 activeId,
17591 virtualFocus,
17592 composite
17593 ]);
17594 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
17595 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
17596 const onFocusCaptureProp = props.onFocusCapture;
17597 const onFocusCapture = useEvent((event) => {
17598 onFocusCaptureProp?.(event);
17599 if (event.defaultPrevented) return;
17600 if (!store) return;
17601 const { virtualFocus: virtualFocus2 } = store.getState();
17602 if (!virtualFocus2) return;
17603 const previousActiveElement = event.relatedTarget;
17604 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17605 if (isSelfTarget(event) && isSilentlyFocused) {
17606 event.stopPropagation();
17607 previousElementRef.current = previousActiveElement;
17608 }
17609 });
17610 const onFocusProp = props.onFocus;
17611 const onFocus = useEvent((event) => {
17612 onFocusProp?.(event);
17613 if (event.defaultPrevented) return;
17614 if (!composite) return;
17615 if (!store) return;
17616 const { relatedTarget } = event;
17617 const { virtualFocus: virtualFocus2 } = store.getState();
17618 if (virtualFocus2) {
17619 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
17620 } else if (isSelfTarget(event)) store.setActiveId(null);
17621 });
17622 const onBlurCaptureProp = props.onBlurCapture;
17623 const onBlurCapture = useEvent((event) => {
17624 onBlurCaptureProp?.(event);
17625 if (event.defaultPrevented) return;
17626 if (!store) return;
17627 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17628 if (!virtualFocus2) return;
17629 const activeElement2 = getEnabledItem(store, activeId2)?.element;
17630 const nextActiveElement = event.relatedTarget;
17631 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17632 const previousElement = previousElementRef.current;
17633 previousElementRef.current = null;
17634 if (isSelfTarget(event) && nextActiveElementIsItem) {
17635 if (nextActiveElement === activeElement2) {
17636 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
17637 } else if (activeElement2) fireBlurEvent(activeElement2, event);
17638 else if (previousElement) fireBlurEvent(previousElement, event);
17639 event.stopPropagation();
17640 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
17641 });
17642 const onKeyDownProp = props.onKeyDown;
17643 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17644 const onKeyDown = useEvent((event) => {
17645 onKeyDownProp?.(event);
17646 if (event.nativeEvent.isComposing) return;
17647 if (event.defaultPrevented) return;
17648 if (!store) return;
17649 if (!isSelfTarget(event)) return;
17650 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
17651 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
17652 const isVertical = orientation !== "horizontal";
17653 const isHorizontal = orientation !== "vertical";
17654 const grid = isGrid(renderedItems);
17655 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
17656 const up = () => {
17657 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
17658 return store?.last();
17659 };
17660 const action = {
17661 ArrowUp: (grid || isVertical) && up,
17662 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
17663 ArrowDown: (grid || isVertical) && store.first,
17664 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
17665 Home: store.first,
17666 End: store.last,
17667 PageUp: store.first,
17668 PageDown: store.last
17669 }[event.key];
17670 if (action) {
17671 const id = action();
17672 if (id !== void 0) {
17673 if (!moveOnKeyPressProp(event)) return;
17674 event.preventDefault();
17675 store.move(id);
17676 }
17677 }
17678 });
17679 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(CompositeScopedContextProvider, {
17680 value: store,
17681 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(CompositeFocusOnMove, {
17682 store,
17683 focusOnMove,
17684 previousElementRef
17685 })]
17686 }), [
17687 store,
17688 composite,
17689 focusOnMove
17690 ]);
17691 props = {
17692 "aria-activedescendant": useStoreState(store, (state) => {
17693 if (!store) return;
17694 if (!composite) return;
17695 if (!state.virtualFocus) return;
17696 return getEnabledItem(store, state.activeId)?.id;
17697 }),
17698 ...props,
17699 ref: useMergeRefs(ref, setBaseElement, props.ref),
17700 onKeyDownCapture,
17701 onKeyUpCapture,
17702 onFocusCapture,
17703 onFocus,
17704 onBlurCapture,
17705 onKeyDown
17706 };
17707 props = useFocusable({
17708 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
17709 ...props
17710 });
17711 return props;
17712 });
17713 var Composite6 = forwardRef21(function Composite7(props) {
17714 return createElement3(TagName5, useComposite(props));
17715 });
17716
17717 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
17718 var ctx3 = createStoreContext();
17719 var useDisclosureContext = ctx3.useContext;
17720 var useDisclosureScopedContext = ctx3.useScopedContext;
17721 var useDisclosureProviderContext = ctx3.useProviderContext;
17722 var DisclosureContextProvider = ctx3.ContextProvider;
17723 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17724
17725 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
17726 var import_react15 = __toESM(require_react(), 1);
17727 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
17728 var useDialogContext = ctx4.useContext;
17729 var useDialogScopedContext = ctx4.useScopedContext;
17730 var useDialogProviderContext = ctx4.useProviderContext;
17731 var DialogContextProvider = ctx4.ContextProvider;
17732 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17733 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
17734 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
17735
17736 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
17737 var import_react16 = __toESM(require_react(), 1);
17738 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
17739 var import_react_dom4 = __toESM(require_react_dom(), 1);
17740 var TagName6 = "div";
17741 function afterTimeout(timeoutMs, cb) {
17742 const timeoutId = setTimeout(cb, timeoutMs);
17743 return () => clearTimeout(timeoutId);
17744 }
17745 function parseCSSTime(time) {
17746 const value = time?.trim() || "0s";
17747 const multiplier = value.endsWith("ms") ? 1 : 1e3;
17748 const parsed = Number.parseFloat(value) * multiplier;
17749 return Number.isNaN(parsed) ? 0 : parsed;
17750 }
17751 function getEndTime(names, delays, durations) {
17752 const nameList = names.split(",");
17753 const delayList = delays.split(",");
17754 const durationList = durations.split(",");
17755 let endTime = 0;
17756 for (const [index2, name] of nameList.entries()) {
17757 if (name.trim() === "none") continue;
17758 const delay = parseCSSTime(delayList[index2 % delayList.length]);
17759 const duration = parseCSSTime(durationList[index2 % durationList.length]);
17760 endTime = Math.max(endTime, delay + duration);
17761 }
17762 return endTime;
17763 }
17764 function getElementEndTime(element) {
17765 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
17766 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
17767 }
17768 function isHidden(mounted, hidden, alwaysVisible) {
17769 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17770 }
17771 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
17772 const context = useDisclosureProviderContext();
17773 store = store || context;
17774 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
17775 const ref = (0, import_react16.useRef)(null);
17776 const id = useId4(props.id);
17777 const [transition, setTransition] = (0, import_react16.useState)(null);
17778 const open = useStoreState(store, "open");
17779 const mounted = useStoreState(store, "mounted");
17780 const animated = useStoreState(store, "animated");
17781 const contentElement = useStoreState(store, "contentElement");
17782 const otherElement = useStoreState(store.disclosure, "contentElement");
17783 const hasClosedRef = (0, import_react16.useRef)(false);
17784 useSafeLayoutEffect(() => {
17785 if (!ref.current) return;
17786 store?.setContentElement(ref.current);
17787 }, [store]);
17788 useSafeLayoutEffect(() => {
17789 let previousAnimated;
17790 store?.setState("animated", (animated2) => {
17791 previousAnimated = animated2;
17792 return true;
17793 });
17794 return () => {
17795 if (previousAnimated === void 0) return;
17796 store?.setState("animated", previousAnimated);
17797 };
17798 }, [store]);
17799 useSafeLayoutEffect(() => {
17800 if (!animated) {
17801 if (!open) {
17802 hasClosedRef.current = true;
17803 setTransition(null);
17804 } else if (hasClosedRef.current) {
17805 hasClosedRef.current = false;
17806 setTransition("enter");
17807 }
17808 return;
17809 }
17810 if (!contentElement?.isConnected) {
17811 setTransition(null);
17812 return;
17813 }
17814 return afterPaint(() => {
17815 setTransition(open ? "enter" : mounted ? "leave" : null);
17816 });
17817 }, [
17818 animated,
17819 contentElement,
17820 open,
17821 mounted
17822 ]);
17823 useSafeLayoutEffect(() => {
17824 if (!store) return;
17825 if (!animated) return;
17826 if (!transition) return;
17827 if (!contentElement) return;
17828 const stopAnimation = () => store?.setState("animating", false);
17829 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17830 if (transition === "leave" && open) return;
17831 if (transition === "enter" && !open) return;
17832 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
17833 const elements = [contentElement];
17834 if (otherElement) elements.push(otherElement);
17835 const relatedElement = otherElementRef?.current;
17836 if (relatedElement) elements.push(relatedElement);
17837 const timeout = Math.max(...elements.map(getElementEndTime));
17838 if (!timeout) {
17839 if (transition === "enter") store.setState("animated", false);
17840 stopAnimation();
17841 return;
17842 }
17843 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
17844 }, [
17845 store,
17846 animated,
17847 contentElement,
17848 otherElement,
17849 otherElementRef,
17850 open,
17851 transition
17852 ]);
17853 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DialogScopedContextProvider, {
17854 value: store,
17855 children: element
17856 }), [store]);
17857 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17858 const styleProp = props.style;
17859 const style = (0, import_react16.useMemo)(() => {
17860 if (hidden) return {
17861 ...styleProp,
17862 display: "none"
17863 };
17864 return styleProp;
17865 }, [hidden, styleProp]);
17866 props = {
17867 "data-open": open || void 0,
17868 "data-enter": transition === "enter" || void 0,
17869 "data-leave": transition === "leave" || void 0,
17870 hidden,
17871 ...props,
17872 id,
17873 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17874 style
17875 };
17876 return removeUndefinedValues(props);
17877 });
17878 var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
17879 return createElement3(TagName6, useDisclosureContent(props));
17880 });
17881 var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
17882 const context = useDisclosureProviderContext();
17883 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
17884 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DisclosureContentImpl, { ...props });
17885 });
17886
17887 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
17888 function createDisclosureStore(props = {}) {
17889 const store = mergeStore(props.store, omit3(props.disclosure, ["contentElement", "disclosureElement"]));
17890 throwOnConflictingProps(props, store);
17891 const syncState = store?.getState();
17892 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
17893 const animated = defaultValue(props.animated, syncState?.animated, false);
17894 const disclosure = createStore({
17895 open,
17896 animated,
17897 animating: !!animated && open,
17898 mounted: open,
17899 contentElement: defaultValue(syncState?.contentElement, null),
17900 disclosureElement: defaultValue(syncState?.disclosureElement, null)
17901 }, store);
17902 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
17903 if (state.animated) return;
17904 disclosure.setState("animating", false);
17905 }));
17906 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
17907 if (!disclosure.getState().animated) return;
17908 disclosure.setState("animating", true);
17909 }));
17910 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
17911 disclosure.setState("mounted", state.open || state.animating);
17912 }));
17913 return {
17914 ...disclosure,
17915 disclosure: props.disclosure,
17916 setOpen: (value) => disclosure.setState("open", value),
17917 show: () => disclosure.setState("open", true),
17918 hide: () => disclosure.setState("open", false),
17919 toggle: () => disclosure.setState("open", (open2) => !open2),
17920 stopAnimation: () => disclosure.setState("animating", false),
17921 setContentElement: (value) => disclosure.setState("contentElement", value),
17922 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17923 };
17924 }
17925
17926 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
17927 function useDisclosureStoreProps(store, update2, props) {
17928 useUpdateEffect(update2, [props.store, props.disclosure]);
17929 useStoreProps(store, props, "open", "setOpen");
17930 useStoreProps(store, props, "mounted", "setMounted");
17931 useStoreProps(store, props, "animated");
17932 return Object.assign(store, { disclosure: props.disclosure });
17933 }
17934
17935 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
17936 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
17937 var usePopoverContext = ctx5.useContext;
17938 var usePopoverScopedContext = ctx5.useScopedContext;
17939 var usePopoverProviderContext = ctx5.useProviderContext;
17940 var PopoverContextProvider = ctx5.ContextProvider;
17941 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17942
17943 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
17944 var import_react17 = __toESM(require_react(), 1);
17945 var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
17946 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
17947 var useComboboxContext = ctx6.useContext;
17948 var useComboboxScopedContext = ctx6.useScopedContext;
17949 var useComboboxProviderContext = ctx6.useProviderContext;
17950 var ComboboxContextProvider = ctx6.ContextProvider;
17951 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17952 var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
17953 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
17954
17955 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
17956 function useCollectionStoreProps(store, update2, props) {
17957 useUpdateEffect(update2, [props.store]);
17958 useStoreProps(store, props, "items", "setItems");
17959 return store;
17960 }
17961
17962 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
17963 function useCompositeStoreOptions(props) {
17964 return {
17965 id: useId4(props.id),
17966 ...props
17967 };
17968 }
17969 function useCompositeStoreProps(store, update2, props) {
17970 store = useCollectionStoreProps(store, update2, props);
17971 useStoreProps(store, props, "activeId", "setActiveId");
17972 useStoreProps(store, props, "includesBaseElement");
17973 useStoreProps(store, props, "virtualFocus");
17974 useStoreProps(store, props, "orientation");
17975 useStoreProps(store, props, "rtl");
17976 useStoreProps(store, props, "focusLoop");
17977 useStoreProps(store, props, "focusWrap");
17978 useStoreProps(store, props, "focusShift");
17979 return store;
17980 }
17981
17982 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
17983 function createDialogStore(props = {}) {
17984 return createDisclosureStore(props);
17985 }
17986
17987 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
17988 function useDialogStoreProps(store, update2, props) {
17989 return useDisclosureStoreProps(store, update2, props);
17990 }
17991
17992 // node_modules/@ariakit/components/dist/popover/popover-store.js
17993 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
17994 const store = mergeStore(props.store, omit3(otherPopover, [
17995 "arrowElement",
17996 "anchorElement",
17997 "contentElement",
17998 "popoverElement",
17999 "disclosureElement"
18000 ]));
18001 throwOnConflictingProps(props, store);
18002 const syncState = store?.getState();
18003 const dialog = createDialogStore({
18004 ...props,
18005 store
18006 });
18007 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18008 const popover = createStore({
18009 ...dialog.getState(),
18010 placement,
18011 currentPlacement: placement,
18012 anchorElement: defaultValue(syncState?.anchorElement, null),
18013 popoverElement: defaultValue(syncState?.popoverElement, null),
18014 arrowElement: defaultValue(syncState?.arrowElement, null),
18015 rendered: /* @__PURE__ */ Symbol("rendered")
18016 }, dialog, store);
18017 return {
18018 ...dialog,
18019 ...popover,
18020 setAnchorElement: (element) => popover.setState("anchorElement", element),
18021 setPopoverElement: (element) => popover.setState("popoverElement", element),
18022 setArrowElement: (element) => popover.setState("arrowElement", element),
18023 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18024 };
18025 }
18026
18027 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18028 function usePopoverStoreProps(store, update2, props) {
18029 useUpdateEffect(update2, [props.popover]);
18030 useStoreProps(store, props, "placement");
18031 return useDialogStoreProps(store, update2, props);
18032 }
18033
18034 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18035 var TagName7 = "div";
18036 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18037 const context = usePopoverProviderContext();
18038 store = store || context;
18039 props = {
18040 ...props,
18041 ref: useMergeRefs(store?.setAnchorElement, props.ref)
18042 };
18043 return props;
18044 });
18045 var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
18046 return createElement3(TagName7, usePopoverAnchor(props));
18047 });
18048
18049 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18050 var import_react18 = __toESM(require_react(), 1);
18051 var TagName8 = "div";
18052 function hoveringInside(event) {
18053 const nextElement = event.relatedTarget;
18054 if (!isElement2(nextElement)) return false;
18055 return contains2(event.currentTarget, nextElement);
18056 }
18057 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18058 function movingToAnotherItem(event) {
18059 const { relatedTarget } = event;
18060 if (!isElement2(relatedTarget)) return false;
18061 let dest = relatedTarget;
18062 do {
18063 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18064 dest = dest.parentElement;
18065 } while (dest);
18066 return false;
18067 }
18068 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18069 const context = useCompositeScopedContext();
18070 store = store || context;
18071 invariant(store, "CompositeHover must be wrapped in a Composite component.");
18072 const isMouseMoving = useIsMouseMoving();
18073 const onMouseMoveProp = props.onMouseMove;
18074 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18075 const onMouseMove = useEvent((event) => {
18076 onMouseMoveProp?.(event);
18077 if (event.defaultPrevented) return;
18078 if (!isMouseMoving()) return;
18079 if (!focusOnHoverProp(event)) return;
18080 if (!hasFocusWithin(event.currentTarget)) {
18081 const baseElement = store?.getState().baseElement;
18082 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18083 }
18084 store?.setActiveId(event.currentTarget.id);
18085 });
18086 const onMouseLeaveProp = props.onMouseLeave;
18087 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18088 const onMouseLeave = useEvent((event) => {
18089 onMouseLeaveProp?.(event);
18090 if (event.defaultPrevented) return;
18091 if (!isMouseMoving()) return;
18092 if (hoveringInside(event)) return;
18093 if (movingToAnotherItem(event)) return;
18094 if (!focusOnHoverProp(event)) return;
18095 if (!blurOnHoverEndProp(event)) return;
18096 store?.setActiveId(null);
18097 store?.getState().baseElement?.focus();
18098 });
18099 const ref = (0, import_react18.useCallback)((element) => {
18100 if (!element) return;
18101 element[symbol2] = true;
18102 }, []);
18103 props = {
18104 ...props,
18105 ref: useMergeRefs(ref, props.ref),
18106 onMouseMove,
18107 onMouseLeave
18108 };
18109 return removeUndefinedValues(props);
18110 });
18111 var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
18112 return createElement3(TagName8, useCompositeHover(props));
18113 }));
18114
18115 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18116 var import_react19 = __toESM(require_react(), 1);
18117 var TagName9 = "input";
18118 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18119 if (!autoSelect) return false;
18120 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18121 }
18122 function hasCompletionString(value, activeValue) {
18123 if (!activeValue) return false;
18124 if (value == null) return false;
18125 const normalizedValue = normalizeString(value);
18126 const normalizedActiveValue = normalizeString(activeValue);
18127 if (normalizedValue.length !== value.length) return false;
18128 if (normalizedActiveValue.length !== activeValue.length) return false;
18129 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18130 }
18131 function isAriaAutoCompleteValue(value) {
18132 return value === "inline" || value === "list" || value === "both" || value === "none";
18133 }
18134 function getDefaultAutoSelectId(items) {
18135 return items.find((item) => {
18136 if (item.disabled) return false;
18137 return item.element?.getAttribute("role") !== "tab";
18138 })?.id;
18139 }
18140 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 }) {
18141 const context = useComboboxProviderContext();
18142 store = store || context;
18143 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18144 const ref = (0, import_react19.useRef)(null);
18145 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18146 const canAutoSelectRef = (0, import_react19.useRef)(false);
18147 const composingRef = (0, import_react19.useRef)(false);
18148 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18149 const inline4 = autoComplete === "inline" || autoComplete === "both";
18150 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
18151 useUpdateLayoutEffect(() => {
18152 if (!inline4) return;
18153 setCanInline(true);
18154 }, [inline4]);
18155 const storeValue = useStoreState(store, "value");
18156 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
18157 (0, import_react19.useEffect)(() => {
18158 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18159 prevSelectedValueRef.current = prev.selectedValue;
18160 });
18161 }, [store]);
18162 const inlineActiveValue = useStoreState(store, (state) => {
18163 if (!inline4) return;
18164 if (!canInline) return;
18165 if (state.activeValue && Array.isArray(state.selectedValue)) {
18166 if (state.selectedValue.includes(state.activeValue)) return;
18167 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18168 }
18169 return state.activeValue;
18170 });
18171 const items = useStoreState(store, "renderedItems");
18172 const open = useStoreState(store, "open");
18173 const contentElement = useStoreState(store, "contentElement");
18174 const value = (0, import_react19.useMemo)(() => {
18175 if (!inline4) return storeValue;
18176 if (!canInline) return storeValue;
18177 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18178 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18179 return storeValue;
18180 }
18181 return inlineActiveValue || storeValue;
18182 }, [
18183 inline4,
18184 canInline,
18185 items,
18186 inlineActiveValue,
18187 autoSelect,
18188 storeValue
18189 ]);
18190 (0, import_react19.useEffect)(() => {
18191 const element = ref.current;
18192 if (!element) return;
18193 const onCompositeItemMove = () => setCanInline(true);
18194 element.addEventListener("combobox-item-move", onCompositeItemMove);
18195 return () => {
18196 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18197 };
18198 }, []);
18199 (0, import_react19.useEffect)(() => {
18200 if (!inline4) return;
18201 if (!canInline) return;
18202 if (!inlineActiveValue) return;
18203 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18204 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18205 let cleanup = noop4;
18206 queueMicrotask(() => {
18207 const element = ref.current;
18208 if (!element) return;
18209 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18210 const nextStart = storeValue.length;
18211 const nextEnd = inlineActiveValue.length;
18212 setSelectionRange(element, nextStart, nextEnd);
18213 cleanup = () => {
18214 if (!hasFocus(element)) return;
18215 const { start, end } = getTextboxSelection(element);
18216 if (start !== nextStart) return;
18217 if (end !== nextEnd) return;
18218 setSelectionRange(element, prevStart, prevEnd);
18219 };
18220 });
18221 return () => cleanup();
18222 }, [
18223 valueUpdated,
18224 inline4,
18225 canInline,
18226 inlineActiveValue,
18227 items,
18228 autoSelect,
18229 storeValue
18230 ]);
18231 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18232 const autoSelectIdRef = (0, import_react19.useRef)(null);
18233 const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
18234 const userScrolledRef = (0, import_react19.useRef)(false);
18235 const isAutoScrollingRef = (0, import_react19.useRef)(false);
18236 (0, import_react19.useEffect)(() => {
18237 if (!open) return;
18238 if (!contentElement) return;
18239 const scrollingElement = getScrollingElement(contentElement);
18240 if (!scrollingElement) return;
18241 const onUserScroll = () => {
18242 canAutoSelectRef.current = false;
18243 userScrolledRef.current = true;
18244 };
18245 const onScroll = () => {
18246 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18247 if (!store) return;
18248 if (!canAutoSelectRef.current) return;
18249 const { activeId } = store.getState();
18250 if (activeId === null) return;
18251 if (activeId === autoSelectIdRef.current) return;
18252 canAutoSelectRef.current = false;
18253 };
18254 const options = {
18255 passive: true,
18256 capture: true
18257 };
18258 scrollingElement.addEventListener("wheel", onUserScroll, options);
18259 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18260 scrollingElement.addEventListener("scroll", onScroll, options);
18261 return () => {
18262 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18263 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18264 scrollingElement.removeEventListener("scroll", onScroll, true);
18265 };
18266 }, [
18267 open,
18268 contentElement,
18269 store
18270 ]);
18271 useSafeLayoutEffect(() => {
18272 userScrolledRef.current = false;
18273 if (!storeValue) return;
18274 if (composingRef.current) return;
18275 canAutoSelectRef.current = true;
18276 }, [storeValue]);
18277 useSafeLayoutEffect(() => {
18278 if (autoSelect !== "always" && open) return;
18279 canAutoSelectRef.current = open;
18280 }, [autoSelect, open]);
18281 useSafeLayoutEffect(() => {
18282 if (open) return;
18283 autoSelectMovedRef.current = void 0;
18284 }, [open]);
18285 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18286 useUpdateEffect(() => {
18287 const canAutoSelect = canAutoSelectRef.current;
18288 if (!store) return;
18289 if (!open) return;
18290 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18291 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18292 if (baseElement && !hasFocus(baseElement)) return;
18293 if (contentElement2?.hasAttribute("data-placing")) {
18294 const observer = new MutationObserver(forceValueUpdate);
18295 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18296 return () => observer.disconnect();
18297 }
18298 if (autoSelect && canAutoSelect) {
18299 const userAutoSelectId = getAutoSelectIdProp(items);
18300 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18301 autoSelectIdRef.current = autoSelectId;
18302 const nextActiveId = autoSelectId ?? null;
18303 const nextActiveValue = store.item(nextActiveId)?.value;
18304 const moved = autoSelectMovedRef.current;
18305 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18306 autoSelectMovedRef.current = {
18307 id: nextActiveId,
18308 value: nextActiveValue
18309 };
18310 store.move(nextActiveId);
18311 } else store.setState("activeValue", nextActiveValue);
18312 } else {
18313 const element = store.item(activeId || store.first())?.element;
18314 if (element && "scrollIntoView" in element) {
18315 isAutoScrollingRef.current = true;
18316 element.scrollIntoView({
18317 block: "nearest",
18318 inline: "nearest"
18319 });
18320 requestAnimationFrame(() => {
18321 isAutoScrollingRef.current = false;
18322 });
18323 }
18324 }
18325 }, [
18326 store,
18327 open,
18328 valueUpdated,
18329 storeValue,
18330 autoSelect,
18331 resetValueOnSelect,
18332 getAutoSelectIdProp,
18333 items
18334 ]);
18335 (0, import_react19.useEffect)(() => {
18336 if (!inline4) return;
18337 const combobox = ref.current;
18338 if (!combobox) return;
18339 const elements = [combobox, contentElement].filter((value2) => !!value2);
18340 const onBlur2 = (event) => {
18341 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18342 };
18343 for (const element of elements) element.addEventListener("focusout", onBlur2);
18344 return () => {
18345 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18346 };
18347 }, [
18348 inline4,
18349 contentElement,
18350 store,
18351 value
18352 ]);
18353 const canShow = (event) => {
18354 return event.currentTarget.value.length >= showMinLength;
18355 };
18356 const onChangeProp = props.onChange;
18357 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18358 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18359 const onChange = useEvent((event) => {
18360 onChangeProp?.(event);
18361 if (event.defaultPrevented) return;
18362 if (!store) return;
18363 const currentTarget = event.currentTarget;
18364 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18365 const nativeEvent = event.nativeEvent;
18366 canAutoSelectRef.current = true;
18367 if (isInputEvent(nativeEvent)) {
18368 if (nativeEvent.isComposing) {
18369 canAutoSelectRef.current = false;
18370 composingRef.current = true;
18371 }
18372 if (inline4) {
18373 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18374 const caretAtEnd = selectionStart === value2.length;
18375 setCanInline(textInserted && caretAtEnd);
18376 }
18377 }
18378 if (setValueOnChangeProp(event)) {
18379 const isSameValue2 = value2 === store.getState().value;
18380 store.setValue(value2);
18381 queueMicrotask(() => {
18382 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18383 });
18384 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18385 }
18386 if (showOnChangeProp(event)) store.show();
18387 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18388 });
18389 const onCompositionEndProp = props.onCompositionEnd;
18390 const onCompositionEnd = useEvent((event) => {
18391 canAutoSelectRef.current = true;
18392 composingRef.current = false;
18393 onCompositionEndProp?.(event);
18394 if (event.defaultPrevented) return;
18395 if (!autoSelect) return;
18396 forceValueUpdate();
18397 });
18398 const onMouseDownProp = props.onMouseDown;
18399 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18400 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18401 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18402 const onMouseDown = useEvent((event) => {
18403 onMouseDownProp?.(event);
18404 if (event.defaultPrevented) return;
18405 if (event.button) return;
18406 if (event.ctrlKey) return;
18407 if (!store) return;
18408 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18409 if (setValueOnClickProp(event)) store.setValue(value);
18410 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18411 });
18412 const onKeyDownProp = props.onKeyDown;
18413 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18414 const onKeyDown = useEvent((event) => {
18415 onKeyDownProp?.(event);
18416 if (!event.repeat) canAutoSelectRef.current = false;
18417 if (event.defaultPrevented) return;
18418 if (!store) return;
18419 const { open: open2 } = store.getState();
18420 if (open2 && event.key === "Enter") {
18421 event.preventDefault();
18422 return;
18423 }
18424 if (event.ctrlKey) return;
18425 if (event.altKey) return;
18426 if (event.shiftKey) return;
18427 if (event.metaKey) return;
18428 if (open2) return;
18429 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18430 if (showOnKeyPressProp(event)) {
18431 event.preventDefault();
18432 store.show();
18433 }
18434 }
18435 });
18436 const onBlurProp = props.onBlur;
18437 const onBlur = useEvent((event) => {
18438 canAutoSelectRef.current = false;
18439 onBlurProp?.(event);
18440 });
18441 const id = useId4(props.id);
18442 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18443 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18444 props = {
18445 role: "combobox",
18446 "aria-autocomplete": ariaAutoComplete,
18447 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18448 "aria-expanded": open,
18449 "aria-controls": contentElement?.id,
18450 "data-active-item": isActiveItem || void 0,
18451 value,
18452 ...props,
18453 id,
18454 ref: useMergeRefs(ref, props.ref),
18455 onChange,
18456 onCompositionEnd,
18457 onMouseDown,
18458 onKeyDown,
18459 onBlur
18460 };
18461 props = useComposite({
18462 store,
18463 focusable: focusable2,
18464 ...props,
18465 moveOnKeyPress: (event) => {
18466 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18467 if (inline4) setCanInline(true);
18468 return true;
18469 }
18470 });
18471 props = usePopoverAnchor({
18472 store,
18473 ...props
18474 });
18475 return {
18476 autoComplete: "off",
18477 ...props
18478 };
18479 });
18480 var Combobox = forwardRef21(function Combobox2(props) {
18481 return createElement3(TagName9, useCombobox(props));
18482 });
18483
18484 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18485 var import_react20 = __toESM(require_react(), 1);
18486 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
18487 var TagName10 = "div";
18488 function isSelected(storeValue, itemValue) {
18489 if (itemValue == null) return;
18490 if (storeValue == null) return false;
18491 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18492 return storeValue === itemValue;
18493 }
18494 function getItemRole(popupRole) {
18495 return getItemRoleByPopupRole(popupRole) ?? "option";
18496 }
18497 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18498 const context = useComboboxScopedContext();
18499 store = store || context;
18500 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18501 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18502 resetValueOnSelectState: "resetValueOnSelect",
18503 multiSelectable(state) {
18504 return Array.isArray(state.selectedValue);
18505 },
18506 selected(state) {
18507 return isSelected(state.selectedValue, value);
18508 }
18509 });
18510 const getItem = (0, import_react20.useCallback)((item) => {
18511 const nextItem = {
18512 ...item,
18513 value
18514 };
18515 if (getItemProp) return getItemProp(nextItem);
18516 return nextItem;
18517 }, [value, getItemProp]);
18518 setValueOnClick = setValueOnClick ?? !multiSelectable;
18519 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18520 const onClickProp = props.onClick;
18521 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18522 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18523 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18524 const hideOnClickProp = useBooleanEvent(hideOnClick);
18525 const onClick = useEvent((event) => {
18526 onClickProp?.(event);
18527 if (event.defaultPrevented) return;
18528 if (isDownloading(event)) return;
18529 if (isOpeningInNewTab(event)) return;
18530 if (value != null) {
18531 if (selectValueOnClickProp(event)) {
18532 if (resetValueOnSelectProp(event)) store?.resetValue();
18533 store?.setSelectedValue((prevValue) => {
18534 if (!Array.isArray(prevValue)) return value;
18535 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18536 return [...prevValue, value];
18537 });
18538 }
18539 if (setValueOnClickProp(event)) store?.setValue(value);
18540 }
18541 if (hideOnClickProp(event)) store?.hide();
18542 });
18543 const onKeyDownProp = props.onKeyDown;
18544 const onKeyDown = useEvent((event) => {
18545 onKeyDownProp?.(event);
18546 if (event.defaultPrevented) return;
18547 const baseElement = store?.getState().baseElement;
18548 if (!baseElement) return;
18549 if (hasFocus(baseElement)) return;
18550 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
18551 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
18552 const deleteKey = event.key === "Backspace" || event.key === "Delete";
18553 if (printable || paste || deleteKey) {
18554 queueMicrotask(() => baseElement.focus());
18555 if (isTextField(baseElement)) store?.setValue(baseElement.value);
18556 }
18557 });
18558 if (multiSelectable && selected != null) props = {
18559 "aria-selected": selected,
18560 ...props
18561 };
18562 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemValueContext.Provider, {
18563 value,
18564 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemCheckedContext.Provider, {
18565 value: selected ?? false,
18566 children: element
18567 })
18568 }), [value, selected]);
18569 props = {
18570 role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
18571 children: value,
18572 ...props,
18573 onClick,
18574 onKeyDown
18575 };
18576 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18577 props = useCompositeItem({
18578 store,
18579 ...props,
18580 getItem,
18581 moveOnKeyPress: (event) => {
18582 if (!moveOnKeyPressProp(event)) return false;
18583 const moveEvent = new Event("combobox-item-move");
18584 store?.getState().baseElement?.dispatchEvent(moveEvent);
18585 return true;
18586 }
18587 });
18588 props = useCompositeHover({
18589 store,
18590 focusOnHover,
18591 ...props
18592 });
18593 return props;
18594 });
18595 var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
18596 return createElement3(TagName10, useComboboxItem(props));
18597 }));
18598
18599 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
18600 var import_react21 = __toESM(require_react(), 1);
18601 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18602 var TagName11 = "span";
18603 function normalizeValue(value) {
18604 return normalizeString(value).toLowerCase();
18605 }
18606 function getOffsets(string, values) {
18607 const offsets = [];
18608 for (const value of values) {
18609 if (!value) continue;
18610 let pos = 0;
18611 const length = value.length;
18612 let index2 = string.indexOf(value, pos);
18613 while (index2 !== -1) {
18614 offsets.push([index2, length]);
18615 pos = index2 + 1;
18616 index2 = string.indexOf(value, pos);
18617 }
18618 }
18619 return offsets;
18620 }
18621 function mergeOverlappingOffsets(offsets) {
18622 offsets.sort(([a2], [b2]) => a2 - b2);
18623 const merged = [];
18624 for (const [offset4, length] of offsets) {
18625 const last = merged[merged.length - 1];
18626 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
18627 else merged.push([offset4, length]);
18628 }
18629 return merged;
18630 }
18631 function getNormalizedIndexes(itemValue) {
18632 const starts = [];
18633 const ends = [];
18634 let index2 = 0;
18635 for (const char of itemValue) {
18636 const normalizedLength = normalizeValue(char).length;
18637 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
18638 starts.push(i2 === 0 ? index2 : -1);
18639 ends.push(index2);
18640 }
18641 index2 += char.length;
18642 }
18643 starts.push(itemValue.length);
18644 ends.push(itemValue.length);
18645 let nextBoundary = itemValue.length;
18646 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
18647 const start = starts[i2];
18648 if (start == null) continue;
18649 if (start === -1) starts[i2] = nextBoundary;
18650 else nextBoundary = start;
18651 }
18652 return {
18653 starts,
18654 ends
18655 };
18656 }
18657 function toOriginalOffsets(itemValue, normalizedOffsets) {
18658 if (!normalizedOffsets.length) return normalizedOffsets;
18659 const { starts, ends } = getNormalizedIndexes(itemValue);
18660 const offsets = [];
18661 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
18662 const start = starts[normalizedOffset];
18663 const end = ends[normalizedOffset + normalizedLength];
18664 if (start == null || end == null) continue;
18665 if (end <= start) continue;
18666 offsets.push([start, end - start]);
18667 }
18668 return offsets;
18669 }
18670 function splitValue(itemValue, userValue) {
18671 if (!itemValue) return itemValue;
18672 if (!userValue) return itemValue;
18673 const userValues = toArray(userValue).map(normalizeValue);
18674 const parts = [];
18675 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", {
18676 "data-autocomplete-value": autocomplete ? "" : void 0,
18677 "data-user-value": autocomplete ? void 0 : "",
18678 children: value
18679 }, parts.length);
18680 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
18681 const firstEntry = offsets[0];
18682 if (!firstEntry) {
18683 parts.push(span(itemValue, true));
18684 return parts;
18685 }
18686 const [firstOffset] = firstEntry;
18687 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
18688 const value = itemValue.slice(offset4, offset4 + length);
18689 const nextOffset = offsets[i2 + 1]?.[0];
18690 return [value, itemValue.slice(offset4 + length, nextOffset)];
18691 })].forEach((value, i2) => {
18692 if (!value) return;
18693 parts.push(span(value, i2 % 2 === 0));
18694 });
18695 return parts;
18696 }
18697 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18698 const context = useComboboxScopedContext();
18699 store = store || context;
18700 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
18701 const itemValue = value ?? itemContext;
18702 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
18703 props = {
18704 children: (0, import_react21.useMemo)(() => {
18705 if (!itemValue) return;
18706 if (!inputValue) return itemValue;
18707 return splitValue(itemValue, inputValue);
18708 }, [itemValue, inputValue]),
18709 ...props
18710 };
18711 return removeUndefinedValues(props);
18712 });
18713 var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
18714 return createElement3(TagName11, useComboboxItemValue(props));
18715 });
18716
18717 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
18718 var TagName12 = "label";
18719 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
18720 const context = useComboboxProviderContext();
18721 store = store || context;
18722 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18723 props = {
18724 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
18725 ...props
18726 };
18727 return removeUndefinedValues(props);
18728 });
18729 var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
18730 return createElement3(TagName12, useComboboxLabel(props));
18731 }));
18732
18733 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
18734 var import_react22 = __toESM(require_react(), 1);
18735 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18736 var TagName13 = "div";
18737 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
18738 const scopedContext = useComboboxScopedContext(true);
18739 const context = useComboboxContext();
18740 store = store || context;
18741 const scopedContextSameStore = !!store && store === scopedContext;
18742 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18743 const ref = (0, import_react22.useRef)(null);
18744 const id = useId4(props.id);
18745 const mounted = useStoreState(store, "mounted");
18746 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18747 const style = hidden ? {
18748 ...props.style,
18749 display: "none"
18750 } : props.style;
18751 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
18752 const role = useAttribute(ref, "role", props.role);
18753 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
18754 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
18755 const contentElement = useStoreState(store, "contentElement");
18756 useSafeLayoutEffect(() => {
18757 if (!mounted) return;
18758 const element = ref.current;
18759 if (!element) return;
18760 if (contentElement !== element) return;
18761 const callback = () => {
18762 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18763 };
18764 const observer = new MutationObserver(callback);
18765 observer.observe(element, {
18766 subtree: true,
18767 childList: true,
18768 attributeFilter: ["role"]
18769 });
18770 callback();
18771 return () => observer.disconnect();
18772 }, [mounted, contentElement]);
18773 if (!hasListboxInside) props = {
18774 role: "listbox",
18775 "aria-multiselectable": ariaMultiSelectable,
18776 ...props
18777 };
18778 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxScopedContextProvider, {
18779 value: store,
18780 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxListRoleContext.Provider, {
18781 value: role,
18782 children: element
18783 })
18784 }), [store, role]);
18785 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18786 props = {
18787 hidden,
18788 ...props,
18789 id,
18790 ref: useMergeRefs(setContentElement, ref, props.ref),
18791 style
18792 };
18793 return removeUndefinedValues(props);
18794 });
18795 var ComboboxList = forwardRef21(function ComboboxList2(props) {
18796 return createElement3(TagName13, useComboboxList(props));
18797 });
18798
18799 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
18800 var import_react23 = __toESM(require_react(), 1);
18801 var TagValueContext = (0, import_react23.createContext)(null);
18802 var TagRemoveIdContext = (0, import_react23.createContext)(null);
18803 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
18804 var useTagContext = ctx7.useContext;
18805 var useTagScopedContext = ctx7.useScopedContext;
18806 var useTagProviderContext = ctx7.useProviderContext;
18807 var TagContextProvider = ctx7.ContextProvider;
18808 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18809
18810 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
18811 var isTouchSafari = isSafari() && isTouchDevice();
18812 function createComboboxStore({ tag, ...props } = {}) {
18813 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18814 throwOnConflictingProps(props, store);
18815 const tagState = tag?.getState();
18816 const syncState = store?.getState();
18817 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
18818 const composite = createCompositeStore({
18819 ...props,
18820 activeId,
18821 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
18822 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
18823 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
18824 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
18825 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
18826 });
18827 const popover = createPopoverStore({
18828 ...props,
18829 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
18830 });
18831 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
18832 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
18833 const multiSelectable = Array.isArray(selectedValue);
18834 const initialState = {
18835 ...composite.getState(),
18836 ...popover.getState(),
18837 value,
18838 selectedValue,
18839 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
18840 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
18841 activeValue: syncState?.activeValue
18842 };
18843 const combobox = createStore(initialState, composite, popover, store);
18844 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
18845 combobox.setState("virtualFocus", false);
18846 }));
18847 setup(combobox, () => {
18848 if (!tag) return;
18849 return chain(sync(combobox, ["selectedValue"], (state) => {
18850 if (!Array.isArray(state.selectedValue)) return;
18851 tag.setValues(state.selectedValue);
18852 }), sync(tag, ["values"], (state) => {
18853 combobox.setState("selectedValue", state.values);
18854 }));
18855 });
18856 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18857 if (!state.resetValueOnHide) return;
18858 if (state.mounted) return;
18859 combobox.setState("value", value);
18860 }));
18861 setup(combobox, () => sync(combobox, ["open"], (state) => {
18862 if (state.open) return;
18863 combobox.setState("activeId", activeId);
18864 combobox.setState("moves", 0);
18865 }));
18866 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18867 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
18868 }));
18869 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18870 if (state.moves === prev.moves) return;
18871 const { activeId: activeId2 } = combobox.getState();
18872 const activeItem = composite.item(activeId2);
18873 combobox.setState("activeValue", activeItem?.value);
18874 }));
18875 return {
18876 ...popover,
18877 ...composite,
18878 ...combobox,
18879 tag,
18880 setValue: (value2) => combobox.setState("value", value2),
18881 resetValue: () => combobox.setState("value", initialState.value),
18882 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18883 };
18884 }
18885
18886 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
18887 function useComboboxStoreOptions(props) {
18888 const tag = useTagContext();
18889 props = {
18890 ...props,
18891 tag: props.tag !== void 0 ? props.tag : tag
18892 };
18893 return useCompositeStoreOptions(props);
18894 }
18895 function useComboboxStoreProps(store, update2, props) {
18896 useUpdateEffect(update2, [props.tag]);
18897 useStoreProps(store, props, "value", "setValue");
18898 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18899 useStoreProps(store, props, "resetValueOnHide");
18900 useStoreProps(store, props, "resetValueOnSelect");
18901 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
18902 }
18903 function useComboboxStore(props = {}) {
18904 props = useComboboxStoreOptions(props);
18905 const [store, update2] = useStore2(createComboboxStore, props);
18906 return useComboboxStoreProps(store, update2, props);
18907 }
18908
18909 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
18910 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18911 function ComboboxProvider(props = {}) {
18912 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxContextProvider, {
18913 value: useComboboxStore(props),
18914 children: props.children
18915 });
18916 }
18917
18918 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18919 var import_remove_accents = __toESM(require_remove_accents(), 1);
18920 var import_compose8 = __toESM(require_compose(), 1);
18921 var import_i18n23 = __toESM(require_i18n(), 1);
18922 var import_element44 = __toESM(require_element(), 1);
18923 var import_components19 = __toESM(require_components(), 1);
18924
18925 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18926 var EMPTY_ARRAY3 = [];
18927 var getCurrentValue = (filterDefinition, currentFilter) => {
18928 if (filterDefinition.singleSelection) {
18929 return currentFilter?.value;
18930 }
18931 if (Array.isArray(currentFilter?.value)) {
18932 return currentFilter.value;
18933 }
18934 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18935 return [currentFilter.value];
18936 }
18937 return EMPTY_ARRAY3;
18938 };
18939
18940 // packages/dataviews/build-module/hooks/use-elements.mjs
18941 var import_element43 = __toESM(require_element(), 1);
18942 var EMPTY_ARRAY4 = [];
18943 function useElements({
18944 elements,
18945 getElements
18946 }) {
18947 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18948 const [records, setRecords] = (0, import_element43.useState)(staticElements);
18949 const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
18950 (0, import_element43.useEffect)(() => {
18951 if (!getElements) {
18952 setRecords(staticElements);
18953 return;
18954 }
18955 let cancelled = false;
18956 setIsLoading(true);
18957 getElements().then((fetchedElements) => {
18958 if (!cancelled) {
18959 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18960 setRecords(dynamicElements);
18961 }
18962 }).catch(() => {
18963 if (!cancelled) {
18964 setRecords(staticElements);
18965 }
18966 }).finally(() => {
18967 if (!cancelled) {
18968 setIsLoading(false);
18969 }
18970 });
18971 return () => {
18972 cancelled = true;
18973 };
18974 }, [getElements, staticElements]);
18975 return {
18976 elements: records,
18977 isLoading
18978 };
18979 }
18980
18981 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18982 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
18983 function normalizeSearchInput(input = "") {
18984 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18985 }
18986 var getNewValue = (filterDefinition, currentFilter, value) => {
18987 if (filterDefinition.singleSelection) {
18988 return value;
18989 }
18990 if (Array.isArray(currentFilter?.value)) {
18991 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18992 }
18993 return [value];
18994 };
18995 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18996 return `${prefix}-${filterElementValue}`;
18997 }
18998 var MultiSelectionOption = ({ selected }) => {
18999 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19000 "span",
19001 {
19002 className: clsx_default(
19003 "dataviews-filters__search-widget-listitem-multi-selection",
19004 { "is-selected": selected }
19005 ),
19006 children: selected && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: check_default })
19007 }
19008 );
19009 };
19010 var SingleSelectionOption = ({ selected }) => {
19011 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19012 "span",
19013 {
19014 className: clsx_default(
19015 "dataviews-filters__search-widget-listitem-single-selection",
19016 { "is-selected": selected }
19017 )
19018 }
19019 );
19020 };
19021 function ListBox({ view, filter, onChangeView }) {
19022 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19023 const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
19024 // When there are one or less operators, the first item is set as active
19025 // (by setting the initial `activeId` to `undefined`).
19026 // With 2 or more operators, the focus is moved on the operators control
19027 // (by setting the initial `activeId` to `null`), meaning that there won't
19028 // be an active item initially. Focus is then managed via the
19029 // `onFocusVisible` callback.
19030 filter.operators?.length === 1 ? void 0 : null
19031 );
19032 const currentFilter = view.filters?.find(
19033 (f2) => f2.field === filter.field
19034 );
19035 const currentValue = getCurrentValue(filter, currentFilter);
19036 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19037 import_components19.Composite,
19038 {
19039 virtualFocus: true,
19040 focusLoop: true,
19041 activeId: activeCompositeId,
19042 setActiveId: setActiveCompositeId,
19043 role: "listbox",
19044 className: "dataviews-filters__search-widget-listbox",
19045 "aria-label": (0, import_i18n23.sprintf)(
19046 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19047 (0, import_i18n23.__)("List of: %1$s"),
19048 filter.name
19049 ),
19050 onFocusVisible: () => {
19051 if (!activeCompositeId && filter.elements.length) {
19052 setActiveCompositeId(
19053 generateFilterElementCompositeItemId(
19054 baseId,
19055 filter.elements[0].value
19056 )
19057 );
19058 }
19059 },
19060 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Composite.Typeahead, {}),
19061 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19062 import_components19.Composite.Hover,
19063 {
19064 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19065 import_components19.Composite.Item,
19066 {
19067 id: generateFilterElementCompositeItemId(
19068 baseId,
19069 element.value
19070 ),
19071 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19072 "div",
19073 {
19074 "aria-label": element.label,
19075 role: "option",
19076 className: "dataviews-filters__search-widget-listitem"
19077 }
19078 ),
19079 onClick: () => {
19080 const newFilters = currentFilter ? [
19081 ...(view.filters ?? []).map(
19082 (_filter) => {
19083 if (_filter.field === filter.field) {
19084 return {
19085 ..._filter,
19086 operator: currentFilter.operator || filter.operators[0],
19087 value: getNewValue(
19088 filter,
19089 currentFilter,
19090 element.value
19091 )
19092 };
19093 }
19094 return _filter;
19095 }
19096 )
19097 ] : [
19098 ...view.filters ?? [],
19099 {
19100 field: filter.field,
19101 operator: filter.operators[0],
19102 value: getNewValue(
19103 filter,
19104 currentFilter,
19105 element.value
19106 )
19107 }
19108 ];
19109 onChangeView({
19110 ...view,
19111 page: 1,
19112 filters: newFilters
19113 });
19114 }
19115 }
19116 ),
19117 children: [
19118 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19119 SingleSelectionOption,
19120 {
19121 selected: currentValue === element.value
19122 }
19123 ),
19124 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19125 MultiSelectionOption,
19126 {
19127 selected: currentValue.includes(element.value)
19128 }
19129 ),
19130 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19131 "span",
19132 {
19133 className: "dataviews-filters__search-widget-listitem-value",
19134 title: element.label,
19135 children: element.label
19136 }
19137 )
19138 ]
19139 },
19140 element.value
19141 ))
19142 }
19143 );
19144 }
19145 function ComboboxList22({ view, filter, onChangeView }) {
19146 const [searchValue, setSearchValue] = (0, import_element44.useState)("");
19147 const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
19148 const currentFilter = view.filters?.find(
19149 (_filter) => _filter.field === filter.field
19150 );
19151 const currentValue = getCurrentValue(filter, currentFilter);
19152 const matches = (0, import_element44.useMemo)(() => {
19153 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19154 return filter.elements.filter(
19155 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19156 );
19157 }, [filter.elements, deferredSearchValue]);
19158 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19159 ComboboxProvider,
19160 {
19161 selectedValue: currentValue,
19162 setSelectedValue: (value) => {
19163 const newFilters = currentFilter ? [
19164 ...(view.filters ?? []).map((_filter) => {
19165 if (_filter.field === filter.field) {
19166 return {
19167 ..._filter,
19168 operator: currentFilter.operator || filter.operators[0],
19169 value
19170 };
19171 }
19172 return _filter;
19173 })
19174 ] : [
19175 ...view.filters ?? [],
19176 {
19177 field: filter.field,
19178 operator: filter.operators[0],
19179 value
19180 }
19181 ];
19182 onChangeView({
19183 ...view,
19184 page: 1,
19185 filters: newFilters
19186 });
19187 },
19188 setValue: setSearchValue,
19189 children: [
19190 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19191 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19192 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19193 Combobox,
19194 {
19195 autoSelect: "always",
19196 placeholder: (0, import_i18n23.__)("Search"),
19197 className: "dataviews-filters__search-widget-filter-combobox__input"
19198 }
19199 ),
19200 /* @__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 }) })
19201 ] }),
19202 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19203 ComboboxList,
19204 {
19205 className: "dataviews-filters__search-widget-filter-combobox-list",
19206 alwaysVisible: true,
19207 children: [
19208 matches.map((element) => {
19209 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19210 ComboboxItem,
19211 {
19212 resetValueOnSelect: false,
19213 value: element.value,
19214 className: "dataviews-filters__search-widget-listitem",
19215 hideOnClick: false,
19216 setValueOnClick: false,
19217 focusOnHover: true,
19218 children: [
19219 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19220 SingleSelectionOption,
19221 {
19222 selected: currentValue === element.value
19223 }
19224 ),
19225 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19226 MultiSelectionOption,
19227 {
19228 selected: currentValue.includes(
19229 element.value
19230 )
19231 }
19232 ),
19233 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19234 "span",
19235 {
19236 className: "dataviews-filters__search-widget-listitem-value",
19237 title: element.label,
19238 children: [
19239 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19240 ComboboxItemValue,
19241 {
19242 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19243 value: element.label
19244 }
19245 ),
19246 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19247 ]
19248 }
19249 )
19250 ]
19251 },
19252 element.value
19253 );
19254 }),
19255 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19256 ]
19257 }
19258 )
19259 ]
19260 }
19261 );
19262 }
19263 function SearchWidget(props) {
19264 const { elements, isLoading } = useElements({
19265 elements: props.filter.elements,
19266 getElements: props.filter.getElements
19267 });
19268 if (isLoading) {
19269 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, {}) });
19270 }
19271 if (elements.length === 0) {
19272 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19273 }
19274 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19275 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19276 }
19277
19278 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19279 var import_es6 = __toESM(require_es6(), 1);
19280 var import_compose9 = __toESM(require_compose(), 1);
19281 var import_element45 = __toESM(require_element(), 1);
19282 var import_components20 = __toESM(require_components(), 1);
19283 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
19284 function InputWidget({
19285 filter,
19286 view,
19287 onChangeView,
19288 fields
19289 }) {
19290 const currentFilter = view.filters?.find(
19291 (f2) => f2.field === filter.field
19292 );
19293 const currentValue = getCurrentValue(filter, currentFilter);
19294 const field = (0, import_element45.useMemo)(() => {
19295 const currentField = fields.find((f2) => f2.id === filter.field);
19296 if (currentField) {
19297 return {
19298 ...currentField,
19299 // Deactivate validation for filters.
19300 isValid: {},
19301 // Filter controls are always enabled.
19302 isDisabled: () => false,
19303 // Filter controls are always visible.
19304 isVisible: () => true,
19305 // Configure getValue/setValue as if Item was a plain object.
19306 getValue: ({ item }) => item[currentField.id],
19307 setValue: ({ value }) => ({
19308 [currentField.id]: value
19309 })
19310 };
19311 }
19312 return currentField;
19313 }, [fields, filter.field]);
19314 const data = (0, import_element45.useMemo)(() => {
19315 return (view.filters ?? []).reduce(
19316 (acc, activeFilter) => {
19317 acc[activeFilter.field] = activeFilter.value;
19318 return acc;
19319 },
19320 {}
19321 );
19322 }, [view.filters]);
19323 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19324 if (!field || !currentFilter) {
19325 return;
19326 }
19327 const nextValue = field.getValue({ item: updatedData });
19328 if ((0, import_es6.default)(nextValue, currentValue)) {
19329 return;
19330 }
19331 onChangeView({
19332 ...view,
19333 filters: (view.filters ?? []).map(
19334 (_filter) => _filter.field === filter.field ? {
19335 ..._filter,
19336 operator: currentFilter.operator || filter.operators[0],
19337 // Consider empty strings as undefined:
19338 //
19339 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19340 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19341 //
19342 // In practice, this means the filter will not be able to find an empty string as the value.
19343 value: nextValue === "" ? void 0 : nextValue
19344 } : _filter
19345 )
19346 });
19347 });
19348 if (!field || !field.Edit || !currentFilter) {
19349 return null;
19350 }
19351 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19352 import_components20.Flex,
19353 {
19354 className: "dataviews-filters__user-input-widget",
19355 gap: 2.5,
19356 direction: "column",
19357 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19358 field.Edit,
19359 {
19360 hideLabelFromVision: true,
19361 data,
19362 field,
19363 operator: currentFilter.operator,
19364 onChange: handleChange
19365 }
19366 )
19367 }
19368 );
19369 }
19370
19371 // node_modules/date-fns/constants.js
19372 var daysInYear = 365.2425;
19373 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19374 var minTime = -maxTime;
19375 var millisecondsInWeek = 6048e5;
19376 var millisecondsInDay = 864e5;
19377 var secondsInHour = 3600;
19378 var secondsInDay = secondsInHour * 24;
19379 var secondsInWeek = secondsInDay * 7;
19380 var secondsInYear = secondsInDay * daysInYear;
19381 var secondsInMonth = secondsInYear / 12;
19382 var secondsInQuarter = secondsInMonth * 3;
19383 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19384
19385 // node_modules/date-fns/constructFrom.js
19386 function constructFrom(date, value) {
19387 if (typeof date === "function") return date(value);
19388 if (date && typeof date === "object" && constructFromSymbol in date)
19389 return date[constructFromSymbol](value);
19390 if (date instanceof Date) return new date.constructor(value);
19391 return new Date(value);
19392 }
19393
19394 // node_modules/date-fns/toDate.js
19395 function toDate(argument, context) {
19396 return constructFrom(context || argument, argument);
19397 }
19398
19399 // node_modules/date-fns/addDays.js
19400 function addDays(date, amount, options) {
19401 const _date = toDate(date, options?.in);
19402 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19403 if (!amount) return _date;
19404 _date.setDate(_date.getDate() + amount);
19405 return _date;
19406 }
19407
19408 // node_modules/date-fns/addMonths.js
19409 function addMonths(date, amount, options) {
19410 const _date = toDate(date, options?.in);
19411 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19412 if (!amount) {
19413 return _date;
19414 }
19415 const dayOfMonth = _date.getDate();
19416 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19417 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19418 const daysInMonth = endOfDesiredMonth.getDate();
19419 if (dayOfMonth >= daysInMonth) {
19420 return endOfDesiredMonth;
19421 } else {
19422 _date.setFullYear(
19423 endOfDesiredMonth.getFullYear(),
19424 endOfDesiredMonth.getMonth(),
19425 dayOfMonth
19426 );
19427 return _date;
19428 }
19429 }
19430
19431 // node_modules/date-fns/_lib/defaultOptions.js
19432 var defaultOptions = {};
19433 function getDefaultOptions() {
19434 return defaultOptions;
19435 }
19436
19437 // node_modules/date-fns/startOfWeek.js
19438 function startOfWeek(date, options) {
19439 const defaultOptions2 = getDefaultOptions();
19440 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19441 const _date = toDate(date, options?.in);
19442 const day = _date.getDay();
19443 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19444 _date.setDate(_date.getDate() - diff);
19445 _date.setHours(0, 0, 0, 0);
19446 return _date;
19447 }
19448
19449 // node_modules/date-fns/startOfISOWeek.js
19450 function startOfISOWeek(date, options) {
19451 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19452 }
19453
19454 // node_modules/date-fns/getISOWeekYear.js
19455 function getISOWeekYear(date, options) {
19456 const _date = toDate(date, options?.in);
19457 const year = _date.getFullYear();
19458 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19459 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19460 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19461 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19462 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19463 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19464 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19465 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19466 if (_date.getTime() >= startOfNextYear.getTime()) {
19467 return year + 1;
19468 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19469 return year;
19470 } else {
19471 return year - 1;
19472 }
19473 }
19474
19475 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19476 function getTimezoneOffsetInMilliseconds(date) {
19477 const _date = toDate(date);
19478 const utcDate = new Date(
19479 Date.UTC(
19480 _date.getFullYear(),
19481 _date.getMonth(),
19482 _date.getDate(),
19483 _date.getHours(),
19484 _date.getMinutes(),
19485 _date.getSeconds(),
19486 _date.getMilliseconds()
19487 )
19488 );
19489 utcDate.setUTCFullYear(_date.getFullYear());
19490 return +date - +utcDate;
19491 }
19492
19493 // node_modules/date-fns/_lib/normalizeDates.js
19494 function normalizeDates(context, ...dates) {
19495 const normalize = constructFrom.bind(
19496 null,
19497 context || dates.find((date) => typeof date === "object")
19498 );
19499 return dates.map(normalize);
19500 }
19501
19502 // node_modules/date-fns/startOfDay.js
19503 function startOfDay(date, options) {
19504 const _date = toDate(date, options?.in);
19505 _date.setHours(0, 0, 0, 0);
19506 return _date;
19507 }
19508
19509 // node_modules/date-fns/differenceInCalendarDays.js
19510 function differenceInCalendarDays(laterDate, earlierDate, options) {
19511 const [laterDate_, earlierDate_] = normalizeDates(
19512 options?.in,
19513 laterDate,
19514 earlierDate
19515 );
19516 const laterStartOfDay = startOfDay(laterDate_);
19517 const earlierStartOfDay = startOfDay(earlierDate_);
19518 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19519 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19520 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19521 }
19522
19523 // node_modules/date-fns/startOfISOWeekYear.js
19524 function startOfISOWeekYear(date, options) {
19525 const year = getISOWeekYear(date, options);
19526 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19527 fourthOfJanuary.setFullYear(year, 0, 4);
19528 fourthOfJanuary.setHours(0, 0, 0, 0);
19529 return startOfISOWeek(fourthOfJanuary);
19530 }
19531
19532 // node_modules/date-fns/addWeeks.js
19533 function addWeeks(date, amount, options) {
19534 return addDays(date, amount * 7, options);
19535 }
19536
19537 // node_modules/date-fns/addYears.js
19538 function addYears(date, amount, options) {
19539 return addMonths(date, amount * 12, options);
19540 }
19541
19542 // node_modules/date-fns/isDate.js
19543 function isDate(value) {
19544 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19545 }
19546
19547 // node_modules/date-fns/isValid.js
19548 function isValid(date) {
19549 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19550 }
19551
19552 // node_modules/date-fns/startOfMonth.js
19553 function startOfMonth(date, options) {
19554 const _date = toDate(date, options?.in);
19555 _date.setDate(1);
19556 _date.setHours(0, 0, 0, 0);
19557 return _date;
19558 }
19559
19560 // node_modules/date-fns/startOfYear.js
19561 function startOfYear(date, options) {
19562 const date_ = toDate(date, options?.in);
19563 date_.setFullYear(date_.getFullYear(), 0, 1);
19564 date_.setHours(0, 0, 0, 0);
19565 return date_;
19566 }
19567
19568 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19569 var formatDistanceLocale = {
19570 lessThanXSeconds: {
19571 one: "less than a second",
19572 other: "less than {{count}} seconds"
19573 },
19574 xSeconds: {
19575 one: "1 second",
19576 other: "{{count}} seconds"
19577 },
19578 halfAMinute: "half a minute",
19579 lessThanXMinutes: {
19580 one: "less than a minute",
19581 other: "less than {{count}} minutes"
19582 },
19583 xMinutes: {
19584 one: "1 minute",
19585 other: "{{count}} minutes"
19586 },
19587 aboutXHours: {
19588 one: "about 1 hour",
19589 other: "about {{count}} hours"
19590 },
19591 xHours: {
19592 one: "1 hour",
19593 other: "{{count}} hours"
19594 },
19595 xDays: {
19596 one: "1 day",
19597 other: "{{count}} days"
19598 },
19599 aboutXWeeks: {
19600 one: "about 1 week",
19601 other: "about {{count}} weeks"
19602 },
19603 xWeeks: {
19604 one: "1 week",
19605 other: "{{count}} weeks"
19606 },
19607 aboutXMonths: {
19608 one: "about 1 month",
19609 other: "about {{count}} months"
19610 },
19611 xMonths: {
19612 one: "1 month",
19613 other: "{{count}} months"
19614 },
19615 aboutXYears: {
19616 one: "about 1 year",
19617 other: "about {{count}} years"
19618 },
19619 xYears: {
19620 one: "1 year",
19621 other: "{{count}} years"
19622 },
19623 overXYears: {
19624 one: "over 1 year",
19625 other: "over {{count}} years"
19626 },
19627 almostXYears: {
19628 one: "almost 1 year",
19629 other: "almost {{count}} years"
19630 }
19631 };
19632 var formatDistance = (token, count, options) => {
19633 let result;
19634 const tokenValue = formatDistanceLocale[token];
19635 if (typeof tokenValue === "string") {
19636 result = tokenValue;
19637 } else if (count === 1) {
19638 result = tokenValue.one;
19639 } else {
19640 result = tokenValue.other.replace("{{count}}", count.toString());
19641 }
19642 if (options?.addSuffix) {
19643 if (options.comparison && options.comparison > 0) {
19644 return "in " + result;
19645 } else {
19646 return result + " ago";
19647 }
19648 }
19649 return result;
19650 };
19651
19652 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19653 function buildFormatLongFn(args) {
19654 return (options = {}) => {
19655 const width = options.width ? String(options.width) : args.defaultWidth;
19656 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19657 return format6;
19658 };
19659 }
19660
19661 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19662 var dateFormats = {
19663 full: "EEEE, MMMM do, y",
19664 long: "MMMM do, y",
19665 medium: "MMM d, y",
19666 short: "MM/dd/yyyy"
19667 };
19668 var timeFormats = {
19669 full: "h:mm:ss a zzzz",
19670 long: "h:mm:ss a z",
19671 medium: "h:mm:ss a",
19672 short: "h:mm a"
19673 };
19674 var dateTimeFormats = {
19675 full: "{{date}} 'at' {{time}}",
19676 long: "{{date}} 'at' {{time}}",
19677 medium: "{{date}}, {{time}}",
19678 short: "{{date}}, {{time}}"
19679 };
19680 var formatLong = {
19681 date: buildFormatLongFn({
19682 formats: dateFormats,
19683 defaultWidth: "full"
19684 }),
19685 time: buildFormatLongFn({
19686 formats: timeFormats,
19687 defaultWidth: "full"
19688 }),
19689 dateTime: buildFormatLongFn({
19690 formats: dateTimeFormats,
19691 defaultWidth: "full"
19692 })
19693 };
19694
19695 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19696 var formatRelativeLocale = {
19697 lastWeek: "'last' eeee 'at' p",
19698 yesterday: "'yesterday at' p",
19699 today: "'today at' p",
19700 tomorrow: "'tomorrow at' p",
19701 nextWeek: "eeee 'at' p",
19702 other: "P"
19703 };
19704 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19705
19706 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19707 function buildLocalizeFn(args) {
19708 return (value, options) => {
19709 const context = options?.context ? String(options.context) : "standalone";
19710 let valuesArray;
19711 if (context === "formatting" && args.formattingValues) {
19712 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19713 const width = options?.width ? String(options.width) : defaultWidth;
19714 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19715 } else {
19716 const defaultWidth = args.defaultWidth;
19717 const width = options?.width ? String(options.width) : args.defaultWidth;
19718 valuesArray = args.values[width] || args.values[defaultWidth];
19719 }
19720 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19721 return valuesArray[index2];
19722 };
19723 }
19724
19725 // node_modules/date-fns/locale/en-US/_lib/localize.js
19726 var eraValues = {
19727 narrow: ["B", "A"],
19728 abbreviated: ["BC", "AD"],
19729 wide: ["Before Christ", "Anno Domini"]
19730 };
19731 var quarterValues = {
19732 narrow: ["1", "2", "3", "4"],
19733 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19734 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19735 };
19736 var monthValues = {
19737 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19738 abbreviated: [
19739 "Jan",
19740 "Feb",
19741 "Mar",
19742 "Apr",
19743 "May",
19744 "Jun",
19745 "Jul",
19746 "Aug",
19747 "Sep",
19748 "Oct",
19749 "Nov",
19750 "Dec"
19751 ],
19752 wide: [
19753 "January",
19754 "February",
19755 "March",
19756 "April",
19757 "May",
19758 "June",
19759 "July",
19760 "August",
19761 "September",
19762 "October",
19763 "November",
19764 "December"
19765 ]
19766 };
19767 var dayValues = {
19768 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19769 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19770 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19771 wide: [
19772 "Sunday",
19773 "Monday",
19774 "Tuesday",
19775 "Wednesday",
19776 "Thursday",
19777 "Friday",
19778 "Saturday"
19779 ]
19780 };
19781 var dayPeriodValues = {
19782 narrow: {
19783 am: "a",
19784 pm: "p",
19785 midnight: "mi",
19786 noon: "n",
19787 morning: "morning",
19788 afternoon: "afternoon",
19789 evening: "evening",
19790 night: "night"
19791 },
19792 abbreviated: {
19793 am: "AM",
19794 pm: "PM",
19795 midnight: "midnight",
19796 noon: "noon",
19797 morning: "morning",
19798 afternoon: "afternoon",
19799 evening: "evening",
19800 night: "night"
19801 },
19802 wide: {
19803 am: "a.m.",
19804 pm: "p.m.",
19805 midnight: "midnight",
19806 noon: "noon",
19807 morning: "morning",
19808 afternoon: "afternoon",
19809 evening: "evening",
19810 night: "night"
19811 }
19812 };
19813 var formattingDayPeriodValues = {
19814 narrow: {
19815 am: "a",
19816 pm: "p",
19817 midnight: "mi",
19818 noon: "n",
19819 morning: "in the morning",
19820 afternoon: "in the afternoon",
19821 evening: "in the evening",
19822 night: "at night"
19823 },
19824 abbreviated: {
19825 am: "AM",
19826 pm: "PM",
19827 midnight: "midnight",
19828 noon: "noon",
19829 morning: "in the morning",
19830 afternoon: "in the afternoon",
19831 evening: "in the evening",
19832 night: "at night"
19833 },
19834 wide: {
19835 am: "a.m.",
19836 pm: "p.m.",
19837 midnight: "midnight",
19838 noon: "noon",
19839 morning: "in the morning",
19840 afternoon: "in the afternoon",
19841 evening: "in the evening",
19842 night: "at night"
19843 }
19844 };
19845 var ordinalNumber = (dirtyNumber, _options) => {
19846 const number = Number(dirtyNumber);
19847 const rem100 = number % 100;
19848 if (rem100 > 20 || rem100 < 10) {
19849 switch (rem100 % 10) {
19850 case 1:
19851 return number + "st";
19852 case 2:
19853 return number + "nd";
19854 case 3:
19855 return number + "rd";
19856 }
19857 }
19858 return number + "th";
19859 };
19860 var localize = {
19861 ordinalNumber,
19862 era: buildLocalizeFn({
19863 values: eraValues,
19864 defaultWidth: "wide"
19865 }),
19866 quarter: buildLocalizeFn({
19867 values: quarterValues,
19868 defaultWidth: "wide",
19869 argumentCallback: (quarter) => quarter - 1
19870 }),
19871 month: buildLocalizeFn({
19872 values: monthValues,
19873 defaultWidth: "wide"
19874 }),
19875 day: buildLocalizeFn({
19876 values: dayValues,
19877 defaultWidth: "wide"
19878 }),
19879 dayPeriod: buildLocalizeFn({
19880 values: dayPeriodValues,
19881 defaultWidth: "wide",
19882 formattingValues: formattingDayPeriodValues,
19883 defaultFormattingWidth: "wide"
19884 })
19885 };
19886
19887 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19888 function buildMatchFn(args) {
19889 return (string, options = {}) => {
19890 const width = options.width;
19891 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19892 const matchResult = string.match(matchPattern);
19893 if (!matchResult) {
19894 return null;
19895 }
19896 const matchedString = matchResult[0];
19897 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19898 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19899 // [TODO] -- I challenge you to fix the type
19900 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19901 );
19902 let value;
19903 value = args.valueCallback ? args.valueCallback(key) : key;
19904 value = options.valueCallback ? (
19905 // [TODO] -- I challenge you to fix the type
19906 options.valueCallback(value)
19907 ) : value;
19908 const rest = string.slice(matchedString.length);
19909 return { value, rest };
19910 };
19911 }
19912 function findKey(object, predicate) {
19913 for (const key in object) {
19914 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19915 return key;
19916 }
19917 }
19918 return void 0;
19919 }
19920 function findIndex(array, predicate) {
19921 for (let key = 0; key < array.length; key++) {
19922 if (predicate(array[key])) {
19923 return key;
19924 }
19925 }
19926 return void 0;
19927 }
19928
19929 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19930 function buildMatchPatternFn(args) {
19931 return (string, options = {}) => {
19932 const matchResult = string.match(args.matchPattern);
19933 if (!matchResult) return null;
19934 const matchedString = matchResult[0];
19935 const parseResult = string.match(args.parsePattern);
19936 if (!parseResult) return null;
19937 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19938 value = options.valueCallback ? options.valueCallback(value) : value;
19939 const rest = string.slice(matchedString.length);
19940 return { value, rest };
19941 };
19942 }
19943
19944 // node_modules/date-fns/locale/en-US/_lib/match.js
19945 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19946 var parseOrdinalNumberPattern = /\d+/i;
19947 var matchEraPatterns = {
19948 narrow: /^(b|a)/i,
19949 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19950 wide: /^(before christ|before common era|anno domini|common era)/i
19951 };
19952 var parseEraPatterns = {
19953 any: [/^b/i, /^(a|c)/i]
19954 };
19955 var matchQuarterPatterns = {
19956 narrow: /^[1234]/i,
19957 abbreviated: /^q[1234]/i,
19958 wide: /^[1234](th|st|nd|rd)? quarter/i
19959 };
19960 var parseQuarterPatterns = {
19961 any: [/1/i, /2/i, /3/i, /4/i]
19962 };
19963 var matchMonthPatterns = {
19964 narrow: /^[jfmasond]/i,
19965 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19966 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19967 };
19968 var parseMonthPatterns = {
19969 narrow: [
19970 /^j/i,
19971 /^f/i,
19972 /^m/i,
19973 /^a/i,
19974 /^m/i,
19975 /^j/i,
19976 /^j/i,
19977 /^a/i,
19978 /^s/i,
19979 /^o/i,
19980 /^n/i,
19981 /^d/i
19982 ],
19983 any: [
19984 /^ja/i,
19985 /^f/i,
19986 /^mar/i,
19987 /^ap/i,
19988 /^may/i,
19989 /^jun/i,
19990 /^jul/i,
19991 /^au/i,
19992 /^s/i,
19993 /^o/i,
19994 /^n/i,
19995 /^d/i
19996 ]
19997 };
19998 var matchDayPatterns = {
19999 narrow: /^[smtwf]/i,
20000 short: /^(su|mo|tu|we|th|fr|sa)/i,
20001 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20002 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20003 };
20004 var parseDayPatterns = {
20005 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20006 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20007 };
20008 var matchDayPeriodPatterns = {
20009 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20010 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20011 };
20012 var parseDayPeriodPatterns = {
20013 any: {
20014 am: /^a/i,
20015 pm: /^p/i,
20016 midnight: /^mi/i,
20017 noon: /^no/i,
20018 morning: /morning/i,
20019 afternoon: /afternoon/i,
20020 evening: /evening/i,
20021 night: /night/i
20022 }
20023 };
20024 var match = {
20025 ordinalNumber: buildMatchPatternFn({
20026 matchPattern: matchOrdinalNumberPattern,
20027 parsePattern: parseOrdinalNumberPattern,
20028 valueCallback: (value) => parseInt(value, 10)
20029 }),
20030 era: buildMatchFn({
20031 matchPatterns: matchEraPatterns,
20032 defaultMatchWidth: "wide",
20033 parsePatterns: parseEraPatterns,
20034 defaultParseWidth: "any"
20035 }),
20036 quarter: buildMatchFn({
20037 matchPatterns: matchQuarterPatterns,
20038 defaultMatchWidth: "wide",
20039 parsePatterns: parseQuarterPatterns,
20040 defaultParseWidth: "any",
20041 valueCallback: (index2) => index2 + 1
20042 }),
20043 month: buildMatchFn({
20044 matchPatterns: matchMonthPatterns,
20045 defaultMatchWidth: "wide",
20046 parsePatterns: parseMonthPatterns,
20047 defaultParseWidth: "any"
20048 }),
20049 day: buildMatchFn({
20050 matchPatterns: matchDayPatterns,
20051 defaultMatchWidth: "wide",
20052 parsePatterns: parseDayPatterns,
20053 defaultParseWidth: "any"
20054 }),
20055 dayPeriod: buildMatchFn({
20056 matchPatterns: matchDayPeriodPatterns,
20057 defaultMatchWidth: "any",
20058 parsePatterns: parseDayPeriodPatterns,
20059 defaultParseWidth: "any"
20060 })
20061 };
20062
20063 // node_modules/date-fns/locale/en-US.js
20064 var enUS = {
20065 code: "en-US",
20066 formatDistance,
20067 formatLong,
20068 formatRelative,
20069 localize,
20070 match,
20071 options: {
20072 weekStartsOn: 0,
20073 firstWeekContainsDate: 1
20074 }
20075 };
20076
20077 // node_modules/date-fns/getDayOfYear.js
20078 function getDayOfYear(date, options) {
20079 const _date = toDate(date, options?.in);
20080 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20081 const dayOfYear = diff + 1;
20082 return dayOfYear;
20083 }
20084
20085 // node_modules/date-fns/getISOWeek.js
20086 function getISOWeek(date, options) {
20087 const _date = toDate(date, options?.in);
20088 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20089 return Math.round(diff / millisecondsInWeek) + 1;
20090 }
20091
20092 // node_modules/date-fns/getWeekYear.js
20093 function getWeekYear(date, options) {
20094 const _date = toDate(date, options?.in);
20095 const year = _date.getFullYear();
20096 const defaultOptions2 = getDefaultOptions();
20097 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20098 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20099 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20100 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20101 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20102 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20103 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20104 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20105 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20106 if (+_date >= +startOfNextYear) {
20107 return year + 1;
20108 } else if (+_date >= +startOfThisYear) {
20109 return year;
20110 } else {
20111 return year - 1;
20112 }
20113 }
20114
20115 // node_modules/date-fns/startOfWeekYear.js
20116 function startOfWeekYear(date, options) {
20117 const defaultOptions2 = getDefaultOptions();
20118 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20119 const year = getWeekYear(date, options);
20120 const firstWeek = constructFrom(options?.in || date, 0);
20121 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20122 firstWeek.setHours(0, 0, 0, 0);
20123 const _date = startOfWeek(firstWeek, options);
20124 return _date;
20125 }
20126
20127 // node_modules/date-fns/getWeek.js
20128 function getWeek(date, options) {
20129 const _date = toDate(date, options?.in);
20130 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20131 return Math.round(diff / millisecondsInWeek) + 1;
20132 }
20133
20134 // node_modules/date-fns/_lib/addLeadingZeros.js
20135 function addLeadingZeros(number, targetLength) {
20136 const sign = number < 0 ? "-" : "";
20137 const output = Math.abs(number).toString().padStart(targetLength, "0");
20138 return sign + output;
20139 }
20140
20141 // node_modules/date-fns/_lib/format/lightFormatters.js
20142 var lightFormatters = {
20143 // Year
20144 y(date, token) {
20145 const signedYear = date.getFullYear();
20146 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20147 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20148 },
20149 // Month
20150 M(date, token) {
20151 const month = date.getMonth();
20152 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20153 },
20154 // Day of the month
20155 d(date, token) {
20156 return addLeadingZeros(date.getDate(), token.length);
20157 },
20158 // AM or PM
20159 a(date, token) {
20160 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20161 switch (token) {
20162 case "a":
20163 case "aa":
20164 return dayPeriodEnumValue.toUpperCase();
20165 case "aaa":
20166 return dayPeriodEnumValue;
20167 case "aaaaa":
20168 return dayPeriodEnumValue[0];
20169 case "aaaa":
20170 default:
20171 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20172 }
20173 },
20174 // Hour [1-12]
20175 h(date, token) {
20176 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20177 },
20178 // Hour [0-23]
20179 H(date, token) {
20180 return addLeadingZeros(date.getHours(), token.length);
20181 },
20182 // Minute
20183 m(date, token) {
20184 return addLeadingZeros(date.getMinutes(), token.length);
20185 },
20186 // Second
20187 s(date, token) {
20188 return addLeadingZeros(date.getSeconds(), token.length);
20189 },
20190 // Fraction of second
20191 S(date, token) {
20192 const numberOfDigits = token.length;
20193 const milliseconds = date.getMilliseconds();
20194 const fractionalSeconds = Math.trunc(
20195 milliseconds * Math.pow(10, numberOfDigits - 3)
20196 );
20197 return addLeadingZeros(fractionalSeconds, token.length);
20198 }
20199 };
20200
20201 // node_modules/date-fns/_lib/format/formatters.js
20202 var dayPeriodEnum = {
20203 am: "am",
20204 pm: "pm",
20205 midnight: "midnight",
20206 noon: "noon",
20207 morning: "morning",
20208 afternoon: "afternoon",
20209 evening: "evening",
20210 night: "night"
20211 };
20212 var formatters = {
20213 // Era
20214 G: function(date, token, localize2) {
20215 const era = date.getFullYear() > 0 ? 1 : 0;
20216 switch (token) {
20217 // AD, BC
20218 case "G":
20219 case "GG":
20220 case "GGG":
20221 return localize2.era(era, { width: "abbreviated" });
20222 // A, B
20223 case "GGGGG":
20224 return localize2.era(era, { width: "narrow" });
20225 // Anno Domini, Before Christ
20226 case "GGGG":
20227 default:
20228 return localize2.era(era, { width: "wide" });
20229 }
20230 },
20231 // Year
20232 y: function(date, token, localize2) {
20233 if (token === "yo") {
20234 const signedYear = date.getFullYear();
20235 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20236 return localize2.ordinalNumber(year, { unit: "year" });
20237 }
20238 return lightFormatters.y(date, token);
20239 },
20240 // Local week-numbering year
20241 Y: function(date, token, localize2, options) {
20242 const signedWeekYear = getWeekYear(date, options);
20243 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20244 if (token === "YY") {
20245 const twoDigitYear = weekYear % 100;
20246 return addLeadingZeros(twoDigitYear, 2);
20247 }
20248 if (token === "Yo") {
20249 return localize2.ordinalNumber(weekYear, { unit: "year" });
20250 }
20251 return addLeadingZeros(weekYear, token.length);
20252 },
20253 // ISO week-numbering year
20254 R: function(date, token) {
20255 const isoWeekYear = getISOWeekYear(date);
20256 return addLeadingZeros(isoWeekYear, token.length);
20257 },
20258 // Extended year. This is a single number designating the year of this calendar system.
20259 // The main difference between `y` and `u` localizers are B.C. years:
20260 // | Year | `y` | `u` |
20261 // |------|-----|-----|
20262 // | AC 1 | 1 | 1 |
20263 // | BC 1 | 1 | 0 |
20264 // | BC 2 | 2 | -1 |
20265 // Also `yy` always returns the last two digits of a year,
20266 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20267 u: function(date, token) {
20268 const year = date.getFullYear();
20269 return addLeadingZeros(year, token.length);
20270 },
20271 // Quarter
20272 Q: function(date, token, localize2) {
20273 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20274 switch (token) {
20275 // 1, 2, 3, 4
20276 case "Q":
20277 return String(quarter);
20278 // 01, 02, 03, 04
20279 case "QQ":
20280 return addLeadingZeros(quarter, 2);
20281 // 1st, 2nd, 3rd, 4th
20282 case "Qo":
20283 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20284 // Q1, Q2, Q3, Q4
20285 case "QQQ":
20286 return localize2.quarter(quarter, {
20287 width: "abbreviated",
20288 context: "formatting"
20289 });
20290 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20291 case "QQQQQ":
20292 return localize2.quarter(quarter, {
20293 width: "narrow",
20294 context: "formatting"
20295 });
20296 // 1st quarter, 2nd quarter, ...
20297 case "QQQQ":
20298 default:
20299 return localize2.quarter(quarter, {
20300 width: "wide",
20301 context: "formatting"
20302 });
20303 }
20304 },
20305 // Stand-alone quarter
20306 q: function(date, token, localize2) {
20307 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20308 switch (token) {
20309 // 1, 2, 3, 4
20310 case "q":
20311 return String(quarter);
20312 // 01, 02, 03, 04
20313 case "qq":
20314 return addLeadingZeros(quarter, 2);
20315 // 1st, 2nd, 3rd, 4th
20316 case "qo":
20317 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20318 // Q1, Q2, Q3, Q4
20319 case "qqq":
20320 return localize2.quarter(quarter, {
20321 width: "abbreviated",
20322 context: "standalone"
20323 });
20324 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20325 case "qqqqq":
20326 return localize2.quarter(quarter, {
20327 width: "narrow",
20328 context: "standalone"
20329 });
20330 // 1st quarter, 2nd quarter, ...
20331 case "qqqq":
20332 default:
20333 return localize2.quarter(quarter, {
20334 width: "wide",
20335 context: "standalone"
20336 });
20337 }
20338 },
20339 // Month
20340 M: function(date, token, localize2) {
20341 const month = date.getMonth();
20342 switch (token) {
20343 case "M":
20344 case "MM":
20345 return lightFormatters.M(date, token);
20346 // 1st, 2nd, ..., 12th
20347 case "Mo":
20348 return localize2.ordinalNumber(month + 1, { unit: "month" });
20349 // Jan, Feb, ..., Dec
20350 case "MMM":
20351 return localize2.month(month, {
20352 width: "abbreviated",
20353 context: "formatting"
20354 });
20355 // J, F, ..., D
20356 case "MMMMM":
20357 return localize2.month(month, {
20358 width: "narrow",
20359 context: "formatting"
20360 });
20361 // January, February, ..., December
20362 case "MMMM":
20363 default:
20364 return localize2.month(month, { width: "wide", context: "formatting" });
20365 }
20366 },
20367 // Stand-alone month
20368 L: function(date, token, localize2) {
20369 const month = date.getMonth();
20370 switch (token) {
20371 // 1, 2, ..., 12
20372 case "L":
20373 return String(month + 1);
20374 // 01, 02, ..., 12
20375 case "LL":
20376 return addLeadingZeros(month + 1, 2);
20377 // 1st, 2nd, ..., 12th
20378 case "Lo":
20379 return localize2.ordinalNumber(month + 1, { unit: "month" });
20380 // Jan, Feb, ..., Dec
20381 case "LLL":
20382 return localize2.month(month, {
20383 width: "abbreviated",
20384 context: "standalone"
20385 });
20386 // J, F, ..., D
20387 case "LLLLL":
20388 return localize2.month(month, {
20389 width: "narrow",
20390 context: "standalone"
20391 });
20392 // January, February, ..., December
20393 case "LLLL":
20394 default:
20395 return localize2.month(month, { width: "wide", context: "standalone" });
20396 }
20397 },
20398 // Local week of year
20399 w: function(date, token, localize2, options) {
20400 const week = getWeek(date, options);
20401 if (token === "wo") {
20402 return localize2.ordinalNumber(week, { unit: "week" });
20403 }
20404 return addLeadingZeros(week, token.length);
20405 },
20406 // ISO week of year
20407 I: function(date, token, localize2) {
20408 const isoWeek = getISOWeek(date);
20409 if (token === "Io") {
20410 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20411 }
20412 return addLeadingZeros(isoWeek, token.length);
20413 },
20414 // Day of the month
20415 d: function(date, token, localize2) {
20416 if (token === "do") {
20417 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20418 }
20419 return lightFormatters.d(date, token);
20420 },
20421 // Day of year
20422 D: function(date, token, localize2) {
20423 const dayOfYear = getDayOfYear(date);
20424 if (token === "Do") {
20425 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20426 }
20427 return addLeadingZeros(dayOfYear, token.length);
20428 },
20429 // Day of week
20430 E: function(date, token, localize2) {
20431 const dayOfWeek = date.getDay();
20432 switch (token) {
20433 // Tue
20434 case "E":
20435 case "EE":
20436 case "EEE":
20437 return localize2.day(dayOfWeek, {
20438 width: "abbreviated",
20439 context: "formatting"
20440 });
20441 // T
20442 case "EEEEE":
20443 return localize2.day(dayOfWeek, {
20444 width: "narrow",
20445 context: "formatting"
20446 });
20447 // Tu
20448 case "EEEEEE":
20449 return localize2.day(dayOfWeek, {
20450 width: "short",
20451 context: "formatting"
20452 });
20453 // Tuesday
20454 case "EEEE":
20455 default:
20456 return localize2.day(dayOfWeek, {
20457 width: "wide",
20458 context: "formatting"
20459 });
20460 }
20461 },
20462 // Local day of week
20463 e: function(date, token, localize2, options) {
20464 const dayOfWeek = date.getDay();
20465 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20466 switch (token) {
20467 // Numerical value (Nth day of week with current locale or weekStartsOn)
20468 case "e":
20469 return String(localDayOfWeek);
20470 // Padded numerical value
20471 case "ee":
20472 return addLeadingZeros(localDayOfWeek, 2);
20473 // 1st, 2nd, ..., 7th
20474 case "eo":
20475 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20476 case "eee":
20477 return localize2.day(dayOfWeek, {
20478 width: "abbreviated",
20479 context: "formatting"
20480 });
20481 // T
20482 case "eeeee":
20483 return localize2.day(dayOfWeek, {
20484 width: "narrow",
20485 context: "formatting"
20486 });
20487 // Tu
20488 case "eeeeee":
20489 return localize2.day(dayOfWeek, {
20490 width: "short",
20491 context: "formatting"
20492 });
20493 // Tuesday
20494 case "eeee":
20495 default:
20496 return localize2.day(dayOfWeek, {
20497 width: "wide",
20498 context: "formatting"
20499 });
20500 }
20501 },
20502 // Stand-alone local day of week
20503 c: function(date, token, localize2, options) {
20504 const dayOfWeek = date.getDay();
20505 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20506 switch (token) {
20507 // Numerical value (same as in `e`)
20508 case "c":
20509 return String(localDayOfWeek);
20510 // Padded numerical value
20511 case "cc":
20512 return addLeadingZeros(localDayOfWeek, token.length);
20513 // 1st, 2nd, ..., 7th
20514 case "co":
20515 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20516 case "ccc":
20517 return localize2.day(dayOfWeek, {
20518 width: "abbreviated",
20519 context: "standalone"
20520 });
20521 // T
20522 case "ccccc":
20523 return localize2.day(dayOfWeek, {
20524 width: "narrow",
20525 context: "standalone"
20526 });
20527 // Tu
20528 case "cccccc":
20529 return localize2.day(dayOfWeek, {
20530 width: "short",
20531 context: "standalone"
20532 });
20533 // Tuesday
20534 case "cccc":
20535 default:
20536 return localize2.day(dayOfWeek, {
20537 width: "wide",
20538 context: "standalone"
20539 });
20540 }
20541 },
20542 // ISO day of week
20543 i: function(date, token, localize2) {
20544 const dayOfWeek = date.getDay();
20545 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20546 switch (token) {
20547 // 2
20548 case "i":
20549 return String(isoDayOfWeek);
20550 // 02
20551 case "ii":
20552 return addLeadingZeros(isoDayOfWeek, token.length);
20553 // 2nd
20554 case "io":
20555 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20556 // Tue
20557 case "iii":
20558 return localize2.day(dayOfWeek, {
20559 width: "abbreviated",
20560 context: "formatting"
20561 });
20562 // T
20563 case "iiiii":
20564 return localize2.day(dayOfWeek, {
20565 width: "narrow",
20566 context: "formatting"
20567 });
20568 // Tu
20569 case "iiiiii":
20570 return localize2.day(dayOfWeek, {
20571 width: "short",
20572 context: "formatting"
20573 });
20574 // Tuesday
20575 case "iiii":
20576 default:
20577 return localize2.day(dayOfWeek, {
20578 width: "wide",
20579 context: "formatting"
20580 });
20581 }
20582 },
20583 // AM or PM
20584 a: function(date, token, localize2) {
20585 const hours = date.getHours();
20586 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20587 switch (token) {
20588 case "a":
20589 case "aa":
20590 return localize2.dayPeriod(dayPeriodEnumValue, {
20591 width: "abbreviated",
20592 context: "formatting"
20593 });
20594 case "aaa":
20595 return localize2.dayPeriod(dayPeriodEnumValue, {
20596 width: "abbreviated",
20597 context: "formatting"
20598 }).toLowerCase();
20599 case "aaaaa":
20600 return localize2.dayPeriod(dayPeriodEnumValue, {
20601 width: "narrow",
20602 context: "formatting"
20603 });
20604 case "aaaa":
20605 default:
20606 return localize2.dayPeriod(dayPeriodEnumValue, {
20607 width: "wide",
20608 context: "formatting"
20609 });
20610 }
20611 },
20612 // AM, PM, midnight, noon
20613 b: function(date, token, localize2) {
20614 const hours = date.getHours();
20615 let dayPeriodEnumValue;
20616 if (hours === 12) {
20617 dayPeriodEnumValue = dayPeriodEnum.noon;
20618 } else if (hours === 0) {
20619 dayPeriodEnumValue = dayPeriodEnum.midnight;
20620 } else {
20621 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20622 }
20623 switch (token) {
20624 case "b":
20625 case "bb":
20626 return localize2.dayPeriod(dayPeriodEnumValue, {
20627 width: "abbreviated",
20628 context: "formatting"
20629 });
20630 case "bbb":
20631 return localize2.dayPeriod(dayPeriodEnumValue, {
20632 width: "abbreviated",
20633 context: "formatting"
20634 }).toLowerCase();
20635 case "bbbbb":
20636 return localize2.dayPeriod(dayPeriodEnumValue, {
20637 width: "narrow",
20638 context: "formatting"
20639 });
20640 case "bbbb":
20641 default:
20642 return localize2.dayPeriod(dayPeriodEnumValue, {
20643 width: "wide",
20644 context: "formatting"
20645 });
20646 }
20647 },
20648 // in the morning, in the afternoon, in the evening, at night
20649 B: function(date, token, localize2) {
20650 const hours = date.getHours();
20651 let dayPeriodEnumValue;
20652 if (hours >= 17) {
20653 dayPeriodEnumValue = dayPeriodEnum.evening;
20654 } else if (hours >= 12) {
20655 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20656 } else if (hours >= 4) {
20657 dayPeriodEnumValue = dayPeriodEnum.morning;
20658 } else {
20659 dayPeriodEnumValue = dayPeriodEnum.night;
20660 }
20661 switch (token) {
20662 case "B":
20663 case "BB":
20664 case "BBB":
20665 return localize2.dayPeriod(dayPeriodEnumValue, {
20666 width: "abbreviated",
20667 context: "formatting"
20668 });
20669 case "BBBBB":
20670 return localize2.dayPeriod(dayPeriodEnumValue, {
20671 width: "narrow",
20672 context: "formatting"
20673 });
20674 case "BBBB":
20675 default:
20676 return localize2.dayPeriod(dayPeriodEnumValue, {
20677 width: "wide",
20678 context: "formatting"
20679 });
20680 }
20681 },
20682 // Hour [1-12]
20683 h: function(date, token, localize2) {
20684 if (token === "ho") {
20685 let hours = date.getHours() % 12;
20686 if (hours === 0) hours = 12;
20687 return localize2.ordinalNumber(hours, { unit: "hour" });
20688 }
20689 return lightFormatters.h(date, token);
20690 },
20691 // Hour [0-23]
20692 H: function(date, token, localize2) {
20693 if (token === "Ho") {
20694 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20695 }
20696 return lightFormatters.H(date, token);
20697 },
20698 // Hour [0-11]
20699 K: function(date, token, localize2) {
20700 const hours = date.getHours() % 12;
20701 if (token === "Ko") {
20702 return localize2.ordinalNumber(hours, { unit: "hour" });
20703 }
20704 return addLeadingZeros(hours, token.length);
20705 },
20706 // Hour [1-24]
20707 k: function(date, token, localize2) {
20708 let hours = date.getHours();
20709 if (hours === 0) hours = 24;
20710 if (token === "ko") {
20711 return localize2.ordinalNumber(hours, { unit: "hour" });
20712 }
20713 return addLeadingZeros(hours, token.length);
20714 },
20715 // Minute
20716 m: function(date, token, localize2) {
20717 if (token === "mo") {
20718 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20719 }
20720 return lightFormatters.m(date, token);
20721 },
20722 // Second
20723 s: function(date, token, localize2) {
20724 if (token === "so") {
20725 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20726 }
20727 return lightFormatters.s(date, token);
20728 },
20729 // Fraction of second
20730 S: function(date, token) {
20731 return lightFormatters.S(date, token);
20732 },
20733 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20734 X: function(date, token, _localize) {
20735 const timezoneOffset = date.getTimezoneOffset();
20736 if (timezoneOffset === 0) {
20737 return "Z";
20738 }
20739 switch (token) {
20740 // Hours and optional minutes
20741 case "X":
20742 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20743 // Hours, minutes and optional seconds without `:` delimiter
20744 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20745 // so this token always has the same output as `XX`
20746 case "XXXX":
20747 case "XX":
20748 return formatTimezone(timezoneOffset);
20749 // Hours, minutes and optional seconds with `:` delimiter
20750 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20751 // so this token always has the same output as `XXX`
20752 case "XXXXX":
20753 case "XXX":
20754 // Hours and minutes with `:` delimiter
20755 default:
20756 return formatTimezone(timezoneOffset, ":");
20757 }
20758 },
20759 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20760 x: function(date, token, _localize) {
20761 const timezoneOffset = date.getTimezoneOffset();
20762 switch (token) {
20763 // Hours and optional minutes
20764 case "x":
20765 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20766 // Hours, minutes and optional seconds without `:` delimiter
20767 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20768 // so this token always has the same output as `xx`
20769 case "xxxx":
20770 case "xx":
20771 return formatTimezone(timezoneOffset);
20772 // Hours, minutes and optional seconds with `:` delimiter
20773 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20774 // so this token always has the same output as `xxx`
20775 case "xxxxx":
20776 case "xxx":
20777 // Hours and minutes with `:` delimiter
20778 default:
20779 return formatTimezone(timezoneOffset, ":");
20780 }
20781 },
20782 // Timezone (GMT)
20783 O: function(date, token, _localize) {
20784 const timezoneOffset = date.getTimezoneOffset();
20785 switch (token) {
20786 // Short
20787 case "O":
20788 case "OO":
20789 case "OOO":
20790 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20791 // Long
20792 case "OOOO":
20793 default:
20794 return "GMT" + formatTimezone(timezoneOffset, ":");
20795 }
20796 },
20797 // Timezone (specific non-location)
20798 z: function(date, token, _localize) {
20799 const timezoneOffset = date.getTimezoneOffset();
20800 switch (token) {
20801 // Short
20802 case "z":
20803 case "zz":
20804 case "zzz":
20805 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20806 // Long
20807 case "zzzz":
20808 default:
20809 return "GMT" + formatTimezone(timezoneOffset, ":");
20810 }
20811 },
20812 // Seconds timestamp
20813 t: function(date, token, _localize) {
20814 const timestamp = Math.trunc(+date / 1e3);
20815 return addLeadingZeros(timestamp, token.length);
20816 },
20817 // Milliseconds timestamp
20818 T: function(date, token, _localize) {
20819 return addLeadingZeros(+date, token.length);
20820 }
20821 };
20822 function formatTimezoneShort(offset4, delimiter = "") {
20823 const sign = offset4 > 0 ? "-" : "+";
20824 const absOffset = Math.abs(offset4);
20825 const hours = Math.trunc(absOffset / 60);
20826 const minutes = absOffset % 60;
20827 if (minutes === 0) {
20828 return sign + String(hours);
20829 }
20830 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20831 }
20832 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20833 if (offset4 % 60 === 0) {
20834 const sign = offset4 > 0 ? "-" : "+";
20835 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20836 }
20837 return formatTimezone(offset4, delimiter);
20838 }
20839 function formatTimezone(offset4, delimiter = "") {
20840 const sign = offset4 > 0 ? "-" : "+";
20841 const absOffset = Math.abs(offset4);
20842 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20843 const minutes = addLeadingZeros(absOffset % 60, 2);
20844 return sign + hours + delimiter + minutes;
20845 }
20846
20847 // node_modules/date-fns/_lib/format/longFormatters.js
20848 var dateLongFormatter = (pattern, formatLong2) => {
20849 switch (pattern) {
20850 case "P":
20851 return formatLong2.date({ width: "short" });
20852 case "PP":
20853 return formatLong2.date({ width: "medium" });
20854 case "PPP":
20855 return formatLong2.date({ width: "long" });
20856 case "PPPP":
20857 default:
20858 return formatLong2.date({ width: "full" });
20859 }
20860 };
20861 var timeLongFormatter = (pattern, formatLong2) => {
20862 switch (pattern) {
20863 case "p":
20864 return formatLong2.time({ width: "short" });
20865 case "pp":
20866 return formatLong2.time({ width: "medium" });
20867 case "ppp":
20868 return formatLong2.time({ width: "long" });
20869 case "pppp":
20870 default:
20871 return formatLong2.time({ width: "full" });
20872 }
20873 };
20874 var dateTimeLongFormatter = (pattern, formatLong2) => {
20875 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20876 const datePattern = matchResult[1];
20877 const timePattern = matchResult[2];
20878 if (!timePattern) {
20879 return dateLongFormatter(pattern, formatLong2);
20880 }
20881 let dateTimeFormat;
20882 switch (datePattern) {
20883 case "P":
20884 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20885 break;
20886 case "PP":
20887 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20888 break;
20889 case "PPP":
20890 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20891 break;
20892 case "PPPP":
20893 default:
20894 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20895 break;
20896 }
20897 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20898 };
20899 var longFormatters = {
20900 p: timeLongFormatter,
20901 P: dateTimeLongFormatter
20902 };
20903
20904 // node_modules/date-fns/_lib/protectedTokens.js
20905 var dayOfYearTokenRE = /^D+$/;
20906 var weekYearTokenRE = /^Y+$/;
20907 var throwTokens = ["D", "DD", "YY", "YYYY"];
20908 function isProtectedDayOfYearToken(token) {
20909 return dayOfYearTokenRE.test(token);
20910 }
20911 function isProtectedWeekYearToken(token) {
20912 return weekYearTokenRE.test(token);
20913 }
20914 function warnOrThrowProtectedError(token, format6, input) {
20915 const _message = message(token, format6, input);
20916 console.warn(_message);
20917 if (throwTokens.includes(token)) throw new RangeError(_message);
20918 }
20919 function message(token, format6, input) {
20920 const subject = token[0] === "Y" ? "years" : "days of the month";
20921 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`;
20922 }
20923
20924 // node_modules/date-fns/format.js
20925 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20926 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20927 var escapedStringRegExp = /^'([^]*?)'?$/;
20928 var doubleQuoteRegExp = /''/g;
20929 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20930 function format(date, formatStr, options) {
20931 const defaultOptions2 = getDefaultOptions();
20932 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20933 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20934 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20935 const originalDate = toDate(date, options?.in);
20936 if (!isValid(originalDate)) {
20937 throw new RangeError("Invalid time value");
20938 }
20939 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20940 const firstCharacter = substring[0];
20941 if (firstCharacter === "p" || firstCharacter === "P") {
20942 const longFormatter = longFormatters[firstCharacter];
20943 return longFormatter(substring, locale.formatLong);
20944 }
20945 return substring;
20946 }).join("").match(formattingTokensRegExp).map((substring) => {
20947 if (substring === "''") {
20948 return { isToken: false, value: "'" };
20949 }
20950 const firstCharacter = substring[0];
20951 if (firstCharacter === "'") {
20952 return { isToken: false, value: cleanEscapedString(substring) };
20953 }
20954 if (formatters[firstCharacter]) {
20955 return { isToken: true, value: substring };
20956 }
20957 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20958 throw new RangeError(
20959 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20960 );
20961 }
20962 return { isToken: false, value: substring };
20963 });
20964 if (locale.localize.preprocessor) {
20965 parts = locale.localize.preprocessor(originalDate, parts);
20966 }
20967 const formatterOptions = {
20968 firstWeekContainsDate,
20969 weekStartsOn,
20970 locale
20971 };
20972 return parts.map((part) => {
20973 if (!part.isToken) return part.value;
20974 const token = part.value;
20975 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20976 warnOrThrowProtectedError(token, formatStr, String(date));
20977 }
20978 const formatter = formatters[token[0]];
20979 return formatter(originalDate, token, locale.localize, formatterOptions);
20980 }).join("");
20981 }
20982 function cleanEscapedString(input) {
20983 const matched = input.match(escapedStringRegExp);
20984 if (!matched) {
20985 return input;
20986 }
20987 return matched[1].replace(doubleQuoteRegExp, "'");
20988 }
20989
20990 // node_modules/date-fns/subDays.js
20991 function subDays(date, amount, options) {
20992 return addDays(date, -amount, options);
20993 }
20994
20995 // node_modules/date-fns/subMonths.js
20996 function subMonths(date, amount, options) {
20997 return addMonths(date, -amount, options);
20998 }
20999
21000 // node_modules/date-fns/subWeeks.js
21001 function subWeeks(date, amount, options) {
21002 return addWeeks(date, -amount, options);
21003 }
21004
21005 // node_modules/date-fns/subYears.js
21006 function subYears(date, amount, options) {
21007 return addYears(date, -amount, options);
21008 }
21009
21010 // packages/dataviews/build-module/utils/operators.mjs
21011 var import_i18n24 = __toESM(require_i18n(), 1);
21012 var import_element46 = __toESM(require_element(), 1);
21013 var import_date = __toESM(require_date(), 1);
21014 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
21015 var filterTextWrappers = {
21016 Name: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21017 Value: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21018 };
21019 function getRelativeDate(value, unit) {
21020 switch (unit) {
21021 case "days":
21022 return subDays(/* @__PURE__ */ new Date(), value);
21023 case "weeks":
21024 return subWeeks(/* @__PURE__ */ new Date(), value);
21025 case "months":
21026 return subMonths(/* @__PURE__ */ new Date(), value);
21027 case "years":
21028 return subYears(/* @__PURE__ */ new Date(), value);
21029 default:
21030 return /* @__PURE__ */ new Date();
21031 }
21032 }
21033 var isNoneOperatorDefinition = {
21034 /* translators: DataViews operator name */
21035 label: (0, import_i18n24.__)("Is none of"),
21036 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21037 (0, import_i18n24.sprintf)(
21038 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21039 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21040 filter.name,
21041 activeElements.map((element) => element.label).join(", ")
21042 ),
21043 filterTextWrappers
21044 ),
21045 filter: ((item, field, filterValue) => {
21046 if (!filterValue?.length) {
21047 return true;
21048 }
21049 const fieldValue = field.getValue({ item });
21050 if (Array.isArray(fieldValue)) {
21051 return !filterValue.some(
21052 (fv) => fieldValue.includes(fv)
21053 );
21054 } else if (typeof fieldValue === "string") {
21055 return !filterValue.includes(fieldValue);
21056 }
21057 return false;
21058 }),
21059 selection: "multi"
21060 };
21061 var OPERATORS = [
21062 {
21063 name: OPERATOR_IS_ANY,
21064 /* translators: DataViews operator name */
21065 label: (0, import_i18n24.__)("Includes"),
21066 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21067 (0, import_i18n24.sprintf)(
21068 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21069 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21070 filter.name,
21071 activeElements.map((element) => element.label).join(", ")
21072 ),
21073 filterTextWrappers
21074 ),
21075 filter(item, field, filterValue) {
21076 if (!filterValue?.length) {
21077 return true;
21078 }
21079 const fieldValue = field.getValue({ item });
21080 if (Array.isArray(fieldValue)) {
21081 return filterValue.some(
21082 (fv) => fieldValue.includes(fv)
21083 );
21084 } else if (typeof fieldValue === "string") {
21085 return filterValue.includes(fieldValue);
21086 }
21087 return false;
21088 },
21089 selection: "multi"
21090 },
21091 {
21092 name: OPERATOR_IS_NONE,
21093 ...isNoneOperatorDefinition
21094 },
21095 {
21096 name: OPERATOR_IS_ALL,
21097 /* translators: DataViews operator name */
21098 label: (0, import_i18n24.__)("Includes all"),
21099 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21100 (0, import_i18n24.sprintf)(
21101 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21102 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21103 filter.name,
21104 activeElements.map((element) => element.label).join(", ")
21105 ),
21106 filterTextWrappers
21107 ),
21108 filter(item, field, filterValue) {
21109 if (!filterValue?.length) {
21110 return true;
21111 }
21112 return filterValue.every((value) => {
21113 return field.getValue({ item })?.includes(value);
21114 });
21115 },
21116 selection: "multi"
21117 },
21118 {
21119 name: OPERATOR_IS_NOT_ALL,
21120 ...isNoneOperatorDefinition
21121 },
21122 {
21123 name: OPERATOR_BETWEEN,
21124 /* translators: DataViews operator name */
21125 label: (0, import_i18n24.__)("Between (inc)"),
21126 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21127 (0, import_i18n24.sprintf)(
21128 /* 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". */
21129 (0, import_i18n24.__)(
21130 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21131 ),
21132 filter.name,
21133 activeElements[0].label[0],
21134 activeElements[0].label[1]
21135 ),
21136 filterTextWrappers
21137 ),
21138 filter(item, field, filterValue) {
21139 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21140 return true;
21141 }
21142 const fieldValue = field.getValue({ item });
21143 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21144 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21145 }
21146 return false;
21147 },
21148 selection: "custom"
21149 },
21150 {
21151 name: OPERATOR_IN_THE_PAST,
21152 /* translators: DataViews operator name */
21153 label: (0, import_i18n24.__)("In the past"),
21154 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21155 (0, import_i18n24.sprintf)(
21156 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21157 (0, import_i18n24.__)(
21158 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21159 ),
21160 filter.name,
21161 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21162 ),
21163 filterTextWrappers
21164 ),
21165 filter(item, field, filterValue) {
21166 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21167 return true;
21168 }
21169 const targetDate = getRelativeDate(
21170 filterValue.value,
21171 filterValue.unit
21172 );
21173 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21174 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21175 },
21176 selection: "custom"
21177 },
21178 {
21179 name: OPERATOR_OVER,
21180 /* translators: DataViews operator name */
21181 label: (0, import_i18n24.__)("Over"),
21182 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21183 (0, import_i18n24.sprintf)(
21184 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21185 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21186 filter.name,
21187 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21188 ),
21189 filterTextWrappers
21190 ),
21191 filter(item, field, filterValue) {
21192 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21193 return true;
21194 }
21195 const targetDate = getRelativeDate(
21196 filterValue.value,
21197 filterValue.unit
21198 );
21199 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21200 return fieldValue < targetDate;
21201 },
21202 selection: "custom"
21203 },
21204 {
21205 name: OPERATOR_IS,
21206 /* translators: DataViews operator name */
21207 label: (0, import_i18n24.__)("Is"),
21208 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21209 (0, import_i18n24.sprintf)(
21210 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21211 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21212 filter.name,
21213 activeElements[0].label
21214 ),
21215 filterTextWrappers
21216 ),
21217 filter(item, field, filterValue) {
21218 return filterValue === field.getValue({ item }) || filterValue === void 0;
21219 },
21220 selection: "single"
21221 },
21222 {
21223 name: OPERATOR_IS_NOT,
21224 /* translators: DataViews operator name */
21225 label: (0, import_i18n24.__)("Is not"),
21226 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21227 (0, import_i18n24.sprintf)(
21228 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21229 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21230 filter.name,
21231 activeElements[0].label
21232 ),
21233 filterTextWrappers
21234 ),
21235 filter(item, field, filterValue) {
21236 return filterValue !== field.getValue({ item });
21237 },
21238 selection: "single"
21239 },
21240 {
21241 name: OPERATOR_LESS_THAN,
21242 /* translators: DataViews operator name */
21243 label: (0, import_i18n24.__)("Less than"),
21244 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21245 (0, import_i18n24.sprintf)(
21246 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21247 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21248 filter.name,
21249 activeElements[0].label
21250 ),
21251 filterTextWrappers
21252 ),
21253 filter(item, field, filterValue) {
21254 if (filterValue === void 0) {
21255 return true;
21256 }
21257 const fieldValue = field.getValue({ item });
21258 return fieldValue < filterValue;
21259 },
21260 selection: "single"
21261 },
21262 {
21263 name: OPERATOR_GREATER_THAN,
21264 /* translators: DataViews operator name */
21265 label: (0, import_i18n24.__)("Greater than"),
21266 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21267 (0, import_i18n24.sprintf)(
21268 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21269 (0, import_i18n24.__)(
21270 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21271 ),
21272 filter.name,
21273 activeElements[0].label
21274 ),
21275 filterTextWrappers
21276 ),
21277 filter(item, field, filterValue) {
21278 if (filterValue === void 0) {
21279 return true;
21280 }
21281 const fieldValue = field.getValue({ item });
21282 return fieldValue > filterValue;
21283 },
21284 selection: "single"
21285 },
21286 {
21287 name: OPERATOR_LESS_THAN_OR_EQUAL,
21288 /* translators: DataViews operator name */
21289 label: (0, import_i18n24.__)("Less than or equal"),
21290 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21291 (0, import_i18n24.sprintf)(
21292 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21293 (0, import_i18n24.__)(
21294 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21295 ),
21296 filter.name,
21297 activeElements[0].label
21298 ),
21299 filterTextWrappers
21300 ),
21301 filter(item, field, filterValue) {
21302 if (filterValue === void 0) {
21303 return true;
21304 }
21305 const fieldValue = field.getValue({ item });
21306 return fieldValue <= filterValue;
21307 },
21308 selection: "single"
21309 },
21310 {
21311 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21312 /* translators: DataViews operator name */
21313 label: (0, import_i18n24.__)("Greater than or equal"),
21314 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21315 (0, import_i18n24.sprintf)(
21316 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21317 (0, import_i18n24.__)(
21318 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21319 ),
21320 filter.name,
21321 activeElements[0].label
21322 ),
21323 filterTextWrappers
21324 ),
21325 filter(item, field, filterValue) {
21326 if (filterValue === void 0) {
21327 return true;
21328 }
21329 const fieldValue = field.getValue({ item });
21330 return fieldValue >= filterValue;
21331 },
21332 selection: "single"
21333 },
21334 {
21335 name: OPERATOR_BEFORE,
21336 /* translators: DataViews operator name */
21337 label: (0, import_i18n24.__)("Before"),
21338 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21339 (0, import_i18n24.sprintf)(
21340 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21341 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21342 filter.name,
21343 activeElements[0].label
21344 ),
21345 filterTextWrappers
21346 ),
21347 filter(item, field, filterValue) {
21348 if (filterValue === void 0) {
21349 return true;
21350 }
21351 const filterDate = (0, import_date.getDate)(filterValue);
21352 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21353 return fieldDate < filterDate;
21354 },
21355 selection: "single"
21356 },
21357 {
21358 name: OPERATOR_AFTER,
21359 /* translators: DataViews operator name */
21360 label: (0, import_i18n24.__)("After"),
21361 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21362 (0, import_i18n24.sprintf)(
21363 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21364 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21365 filter.name,
21366 activeElements[0].label
21367 ),
21368 filterTextWrappers
21369 ),
21370 filter(item, field, filterValue) {
21371 if (filterValue === void 0) {
21372 return true;
21373 }
21374 const filterDate = (0, import_date.getDate)(filterValue);
21375 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21376 return fieldDate > filterDate;
21377 },
21378 selection: "single"
21379 },
21380 {
21381 name: OPERATOR_BEFORE_INC,
21382 /* translators: DataViews operator name */
21383 label: (0, import_i18n24.__)("Before (inc)"),
21384 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21385 (0, import_i18n24.sprintf)(
21386 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21387 (0, import_i18n24.__)(
21388 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21389 ),
21390 filter.name,
21391 activeElements[0].label
21392 ),
21393 filterTextWrappers
21394 ),
21395 filter(item, field, filterValue) {
21396 if (filterValue === void 0) {
21397 return true;
21398 }
21399 const filterDate = (0, import_date.getDate)(filterValue);
21400 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21401 return fieldDate <= filterDate;
21402 },
21403 selection: "single"
21404 },
21405 {
21406 name: OPERATOR_AFTER_INC,
21407 /* translators: DataViews operator name */
21408 label: (0, import_i18n24.__)("After (inc)"),
21409 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21410 (0, import_i18n24.sprintf)(
21411 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21412 (0, import_i18n24.__)(
21413 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21414 ),
21415 filter.name,
21416 activeElements[0].label
21417 ),
21418 filterTextWrappers
21419 ),
21420 filter(item, field, filterValue) {
21421 if (filterValue === void 0) {
21422 return true;
21423 }
21424 const filterDate = (0, import_date.getDate)(filterValue);
21425 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21426 return fieldDate >= filterDate;
21427 },
21428 selection: "single"
21429 },
21430 {
21431 name: OPERATOR_CONTAINS,
21432 /* translators: DataViews operator name */
21433 label: (0, import_i18n24.__)("Contains"),
21434 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21435 (0, import_i18n24.sprintf)(
21436 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21437 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21438 filter.name,
21439 activeElements[0].label
21440 ),
21441 filterTextWrappers
21442 ),
21443 filter(item, field, filterValue) {
21444 if (filterValue === void 0) {
21445 return true;
21446 }
21447 const fieldValue = field.getValue({ item });
21448 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21449 },
21450 selection: "single"
21451 },
21452 {
21453 name: OPERATOR_NOT_CONTAINS,
21454 /* translators: DataViews operator name */
21455 label: (0, import_i18n24.__)("Doesn't contain"),
21456 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21457 (0, import_i18n24.sprintf)(
21458 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21459 (0, import_i18n24.__)(
21460 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21461 ),
21462 filter.name,
21463 activeElements[0].label
21464 ),
21465 filterTextWrappers
21466 ),
21467 filter(item, field, filterValue) {
21468 if (filterValue === void 0) {
21469 return true;
21470 }
21471 const fieldValue = field.getValue({ item });
21472 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21473 },
21474 selection: "single"
21475 },
21476 {
21477 name: OPERATOR_STARTS_WITH,
21478 /* translators: DataViews operator name */
21479 label: (0, import_i18n24.__)("Starts with"),
21480 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21481 (0, import_i18n24.sprintf)(
21482 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21483 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21484 filter.name,
21485 activeElements[0].label
21486 ),
21487 filterTextWrappers
21488 ),
21489 filter(item, field, filterValue) {
21490 if (filterValue === void 0) {
21491 return true;
21492 }
21493 const fieldValue = field.getValue({ item });
21494 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21495 },
21496 selection: "single"
21497 },
21498 {
21499 name: OPERATOR_ON,
21500 /* translators: DataViews operator name */
21501 label: (0, import_i18n24.__)("On"),
21502 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21503 (0, import_i18n24.sprintf)(
21504 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21505 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21506 filter.name,
21507 activeElements[0].label
21508 ),
21509 filterTextWrappers
21510 ),
21511 filter(item, field, filterValue) {
21512 if (filterValue === void 0) {
21513 return true;
21514 }
21515 const filterDate = (0, import_date.getDate)(filterValue);
21516 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21517 return filterDate.getTime() === fieldDate.getTime();
21518 },
21519 selection: "single"
21520 },
21521 {
21522 name: OPERATOR_NOT_ON,
21523 /* translators: DataViews operator name */
21524 label: (0, import_i18n24.__)("Not on"),
21525 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21526 (0, import_i18n24.sprintf)(
21527 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21528 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21529 filter.name,
21530 activeElements[0].label
21531 ),
21532 filterTextWrappers
21533 ),
21534 filter(item, field, filterValue) {
21535 if (filterValue === void 0) {
21536 return true;
21537 }
21538 const filterDate = (0, import_date.getDate)(filterValue);
21539 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21540 return filterDate.getTime() !== fieldDate.getTime();
21541 },
21542 selection: "single"
21543 }
21544 ];
21545 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21546 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21547 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21548 (op) => op.name === name
21549 );
21550 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21551
21552 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21553 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
21554 var ENTER = "Enter";
21555 var SPACE = " ";
21556 var FilterText = ({
21557 activeElements,
21558 filterInView,
21559 filter
21560 }) => {
21561 if (activeElements === void 0 || activeElements.length === 0) {
21562 return filter.name;
21563 }
21564 const operator = getOperatorByName(filterInView?.operator);
21565 if (operator !== void 0) {
21566 return operator.filterText(filter, activeElements);
21567 }
21568 return (0, import_i18n25.sprintf)(
21569 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21570 (0, import_i18n25.__)("Unknown status for %1$s"),
21571 filter.name
21572 );
21573 };
21574 function OperatorSelector({
21575 filter,
21576 view,
21577 onChangeView
21578 }) {
21579 const operatorOptions = filter.operators?.map((operator) => ({
21580 value: operator,
21581 label: getOperatorByName(operator)?.label || operator
21582 }));
21583 const currentFilter = view.filters?.find(
21584 (_filter) => _filter.field === filter.field
21585 );
21586 const value = currentFilter?.operator || filter.operators[0];
21587 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
21588 Stack,
21589 {
21590 direction: "row",
21591 gap: "sm",
21592 justify: "flex-start",
21593 className: "dataviews-filters__summary-operators-container",
21594 align: "center",
21595 children: [
21596 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21597 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21598 import_components21.SelectControl,
21599 {
21600 className: "dataviews-filters__summary-operators-filter-select",
21601 label: (0, import_i18n25.__)("Conditions"),
21602 value,
21603 options: operatorOptions,
21604 onChange: (newValue) => {
21605 const newOperator = newValue;
21606 const currentOperator = currentFilter?.operator;
21607 const newFilters = currentFilter ? [
21608 ...(view.filters ?? []).map(
21609 (_filter) => {
21610 if (_filter.field === filter.field) {
21611 const currentOpSelectionModel = getOperatorByName(
21612 currentOperator
21613 )?.selection;
21614 const newOpSelectionModel = getOperatorByName(
21615 newOperator
21616 )?.selection;
21617 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21618 currentOpSelectionModel,
21619 newOpSelectionModel
21620 ].includes("custom");
21621 return {
21622 ..._filter,
21623 value: shouldResetValue ? void 0 : _filter.value,
21624 operator: newOperator
21625 };
21626 }
21627 return _filter;
21628 }
21629 )
21630 ] : [
21631 ...view.filters ?? [],
21632 {
21633 field: filter.field,
21634 operator: newOperator,
21635 value: void 0
21636 }
21637 ];
21638 onChangeView({
21639 ...view,
21640 page: 1,
21641 filters: newFilters
21642 });
21643 },
21644 size: "small",
21645 variant: "minimal",
21646 hideLabelFromVision: true
21647 }
21648 )
21649 ]
21650 }
21651 );
21652 }
21653 function Filter({
21654 addFilterRef,
21655 openedFilter,
21656 fields,
21657 ...commonProps
21658 }) {
21659 const toggleRef = (0, import_element47.useRef)(null);
21660 const { filter, view, onChangeView } = commonProps;
21661 const filterInView = view.filters?.find(
21662 (f2) => f2.field === filter.field
21663 );
21664 let activeElements = [];
21665 const field = (0, import_element47.useMemo)(() => {
21666 const currentField = fields.find((f2) => f2.id === filter.field);
21667 if (currentField) {
21668 return {
21669 ...currentField,
21670 // Configure getValue as if Item was a plain object.
21671 // See related input-widget.tsx
21672 getValue: ({ item }) => item[currentField.id]
21673 };
21674 }
21675 return currentField;
21676 }, [fields, filter.field]);
21677 const { elements } = useElements({
21678 elements: filter.elements,
21679 getElements: filter.getElements
21680 });
21681 if (elements.length > 0) {
21682 activeElements = elements.filter((element) => {
21683 if (filter.singleSelection) {
21684 return element.value === filterInView?.value;
21685 }
21686 return filterInView?.value?.includes(element.value);
21687 });
21688 } else if (Array.isArray(filterInView?.value)) {
21689 const label = filterInView.value.map((v2) => {
21690 const formattedValue = field?.getValueFormatted({
21691 item: { [field.id]: v2 },
21692 field
21693 });
21694 return formattedValue || String(v2);
21695 });
21696 activeElements = [
21697 {
21698 value: filterInView.value,
21699 // @ts-ignore
21700 label
21701 }
21702 ];
21703 } else if (typeof filterInView?.value === "object") {
21704 activeElements = [
21705 { value: filterInView.value, label: filterInView.value }
21706 ];
21707 } else if (filterInView?.value !== void 0) {
21708 const label = field !== void 0 ? field.getValueFormatted({
21709 item: { [field.id]: filterInView.value },
21710 field
21711 }) : String(filterInView.value);
21712 activeElements = [
21713 {
21714 value: filterInView.value,
21715 label
21716 }
21717 ];
21718 }
21719 const isPrimary = filter.isPrimary;
21720 const isLocked = filterInView?.isLocked;
21721 const hasValues = !isLocked && filterInView?.value !== void 0;
21722 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21723 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21724 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21725 import_components21.Dropdown,
21726 {
21727 defaultOpen: openedFilter === filter.field,
21728 contentClassName: "dataviews-filters__summary-popover",
21729 popoverProps: { placement: "bottom-start", role: "dialog" },
21730 onClose: () => {
21731 toggleRef.current?.focus();
21732 },
21733 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21734 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21735 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21736 tooltip_exports.Trigger,
21737 {
21738 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21739 "div",
21740 {
21741 className: clsx_default(
21742 "dataviews-filters__summary-chip",
21743 {
21744 "has-reset": canResetOrRemove,
21745 "has-values": hasValues,
21746 "is-not-clickable": isLocked
21747 }
21748 ),
21749 role: "button",
21750 tabIndex: isLocked ? -1 : 0,
21751 onClick: () => {
21752 if (!isLocked) {
21753 onToggle();
21754 }
21755 },
21756 onKeyDown: (event) => {
21757 if (!isLocked && [ENTER, SPACE].includes(
21758 event.key
21759 )) {
21760 onToggle();
21761 event.preventDefault();
21762 }
21763 },
21764 "aria-disabled": isLocked,
21765 "aria-pressed": isOpen,
21766 "aria-expanded": isOpen,
21767 ref: toggleRef,
21768 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21769 FilterText,
21770 {
21771 activeElements,
21772 filterInView,
21773 filter
21774 }
21775 )
21776 }
21777 )
21778 }
21779 ),
21780 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21781 /* translators: 1: Filter name. */
21782 (0, import_i18n25.__)("Filter by: %1$s"),
21783 filter.name.toLowerCase()
21784 ) })
21785 ] }),
21786 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21787 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21788 tooltip_exports.Trigger,
21789 {
21790 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21791 "button",
21792 {
21793 className: clsx_default(
21794 "dataviews-filters__summary-chip-remove",
21795 { "has-values": hasValues }
21796 ),
21797 "aria-label": resetOrRemoveLabel,
21798 onClick: () => {
21799 onChangeView({
21800 ...view,
21801 page: 1,
21802 filters: view.filters?.filter(
21803 (_filter) => _filter.field !== filter.field
21804 )
21805 });
21806 if (!isPrimary) {
21807 addFilterRef.current?.focus();
21808 } else {
21809 toggleRef.current?.focus();
21810 }
21811 },
21812 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.Icon, { icon: close_small_default })
21813 }
21814 )
21815 }
21816 ),
21817 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21818 ] })
21819 ] }),
21820 renderContent: () => {
21821 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21822 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(OperatorSelector, { ...commonProps }),
21823 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21824 SearchWidget,
21825 {
21826 ...commonProps,
21827 filter: {
21828 ...commonProps.filter,
21829 elements
21830 }
21831 }
21832 ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(InputWidget, { ...commonProps, fields })
21833 ] });
21834 }
21835 }
21836 );
21837 }
21838
21839 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21840 var import_components22 = __toESM(require_components(), 1);
21841 var import_i18n26 = __toESM(require_i18n(), 1);
21842 var import_element48 = __toESM(require_element(), 1);
21843 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21844 var { Menu: Menu4 } = unlock3(import_components22.privateApis);
21845 function AddFilterMenu({
21846 filters,
21847 view,
21848 onChangeView,
21849 setOpenedFilter,
21850 triggerProps
21851 }) {
21852 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21853 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Menu4, { children: [
21854 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21855 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21856 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21857 Menu4.Item,
21858 {
21859 onClick: () => {
21860 setOpenedFilter(filter.field);
21861 onChangeView({
21862 ...view,
21863 page: 1,
21864 filters: [
21865 ...view.filters || [],
21866 {
21867 field: filter.field,
21868 value: void 0,
21869 operator: filter.operators[0]
21870 }
21871 ]
21872 });
21873 },
21874 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.ItemLabel, { children: filter.name })
21875 },
21876 filter.field
21877 );
21878 }) })
21879 ] });
21880 }
21881 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21882 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21883 return null;
21884 }
21885 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21886 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21887 AddFilterMenu,
21888 {
21889 triggerProps: {
21890 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21891 import_components22.Button,
21892 {
21893 accessibleWhenDisabled: true,
21894 size: "compact",
21895 className: "dataviews-filters-button",
21896 variant: "tertiary",
21897 disabled: !inactiveFilters.length,
21898 ref
21899 }
21900 ),
21901 children: (0, import_i18n26.__)("Add filter")
21902 },
21903 ...{ filters, view, onChangeView, setOpenedFilter }
21904 }
21905 );
21906 }
21907 var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
21908
21909 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21910 var import_components23 = __toESM(require_components(), 1);
21911 var import_i18n27 = __toESM(require_i18n(), 1);
21912 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21913 function ResetFilter({
21914 filters,
21915 view,
21916 onChangeView
21917 }) {
21918 const isPrimary = (field) => filters.some(
21919 (_filter) => _filter.field === field && _filter.isPrimary
21920 );
21921 const isDisabled = !view.search && !view.filters?.some(
21922 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21923 );
21924 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21925 import_components23.Button,
21926 {
21927 disabled: isDisabled,
21928 accessibleWhenDisabled: true,
21929 size: "compact",
21930 variant: "tertiary",
21931 className: "dataviews-filters__reset-button",
21932 onClick: () => {
21933 onChangeView({
21934 ...view,
21935 page: 1,
21936 search: "",
21937 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21938 });
21939 },
21940 children: (0, import_i18n27.__)("Reset")
21941 }
21942 );
21943 }
21944
21945 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21946 var import_element49 = __toESM(require_element(), 1);
21947 function useFilters(fields, view) {
21948 return (0, import_element49.useMemo)(() => {
21949 const filters = [];
21950 fields.forEach((field) => {
21951 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21952 return;
21953 }
21954 const operators = field.filterBy.operators;
21955 const isPrimary = !!field.filterBy?.isPrimary;
21956 const isLocked = view.filters?.some(
21957 (f2) => f2.field === field.id && !!f2.isLocked
21958 ) ?? false;
21959 filters.push({
21960 field: field.id,
21961 name: field.label,
21962 elements: field.elements,
21963 getElements: field.getElements,
21964 hasElements: field.hasElements,
21965 singleSelection: operators.some(
21966 (op) => isSingleSelectionOperator(op)
21967 ),
21968 operators,
21969 isVisible: isLocked || isPrimary || !!view.filters?.some(
21970 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21971 ),
21972 isPrimary,
21973 isLocked
21974 });
21975 });
21976 filters.sort((a2, b2) => {
21977 if (a2.isLocked && !b2.isLocked) {
21978 return -1;
21979 }
21980 if (!a2.isLocked && b2.isLocked) {
21981 return 1;
21982 }
21983 if (a2.isPrimary && !b2.isPrimary) {
21984 return -1;
21985 }
21986 if (!a2.isPrimary && b2.isPrimary) {
21987 return 1;
21988 }
21989 return a2.name.localeCompare(b2.name);
21990 });
21991 return filters;
21992 }, [fields, view]);
21993 }
21994 var use_filters_default = useFilters;
21995
21996 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21997 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
21998 function Filters({ className }) {
21999 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
22000 const addFilterRef = (0, import_element50.useRef)(null);
22001 const filters = use_filters_default(fields, view);
22002 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22003 add_filter_default,
22004 {
22005 filters,
22006 view,
22007 onChangeView,
22008 ref: addFilterRef,
22009 setOpenedFilter
22010 },
22011 "add-filter"
22012 );
22013 const visibleFilters = filters.filter((filter) => filter.isVisible);
22014 if (visibleFilters.length === 0) {
22015 return null;
22016 }
22017 const filterComponents = [
22018 ...visibleFilters.map((filter) => {
22019 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22020 Filter,
22021 {
22022 filter,
22023 view,
22024 fields,
22025 onChangeView,
22026 addFilterRef,
22027 openedFilter
22028 },
22029 filter.field
22030 );
22031 }),
22032 addFilter
22033 ];
22034 filterComponents.push(
22035 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22036 ResetFilter,
22037 {
22038 filters,
22039 view,
22040 onChangeView
22041 },
22042 "reset-filters"
22043 )
22044 );
22045 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22046 Stack,
22047 {
22048 direction: "row",
22049 justify: "flex-start",
22050 gap: "sm",
22051 style: { width: "fit-content" },
22052 wrap: "wrap",
22053 className,
22054 children: filterComponents
22055 }
22056 );
22057 }
22058 var filters_default = (0, import_element50.memo)(Filters);
22059
22060 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22061 var import_element51 = __toESM(require_element(), 1);
22062 var import_components24 = __toESM(require_components(), 1);
22063 var import_i18n28 = __toESM(require_i18n(), 1);
22064 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
22065 function FiltersToggle() {
22066 const {
22067 filters,
22068 view,
22069 onChangeView,
22070 setOpenedFilter,
22071 isShowingFilter,
22072 setIsShowingFilter
22073 } = (0, import_element51.useContext)(dataviews_context_default);
22074 const buttonRef = (0, import_element51.useRef)(null);
22075 const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
22076 (_view) => {
22077 onChangeView(_view);
22078 setIsShowingFilter(true);
22079 },
22080 [onChangeView, setIsShowingFilter]
22081 );
22082 if (filters.length === 0) {
22083 return null;
22084 }
22085 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22086 const addFilterButtonProps = {
22087 label: (0, import_i18n28.__)("Add filter"),
22088 "aria-expanded": false,
22089 isPressed: false
22090 };
22091 const toggleFiltersButtonProps = {
22092 label: (0, import_i18n28._x)("Filter", "verb"),
22093 "aria-expanded": isShowingFilter,
22094 isPressed: isShowingFilter,
22095 onClick: () => {
22096 if (!isShowingFilter) {
22097 setOpenedFilter(null);
22098 }
22099 setIsShowingFilter(!isShowingFilter);
22100 }
22101 };
22102 const hasPrimaryOrLockedFilters = filters.some(
22103 (filter) => filter.isPrimary || filter.isLocked
22104 );
22105 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22106 import_components24.Button,
22107 {
22108 ref: buttonRef,
22109 className: "dataviews-filters__visibility-toggle",
22110 size: "compact",
22111 icon: funnel_default,
22112 disabled: hasPrimaryOrLockedFilters,
22113 accessibleWhenDisabled: true,
22114 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22115 }
22116 );
22117 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22118 AddFilterMenu,
22119 {
22120 filters,
22121 view,
22122 onChangeView: onChangeViewWithFilterVisibility,
22123 setOpenedFilter,
22124 triggerProps: { render: buttonComponent }
22125 }
22126 ) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22127 FilterVisibilityToggle,
22128 {
22129 buttonRef,
22130 filtersCount: view.filters?.length,
22131 children: buttonComponent
22132 }
22133 ) });
22134 }
22135 function FilterVisibilityToggle({
22136 buttonRef,
22137 filtersCount,
22138 children
22139 }) {
22140 (0, import_element51.useEffect)(
22141 () => () => {
22142 buttonRef.current?.focus();
22143 },
22144 [buttonRef]
22145 );
22146 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
22147 children,
22148 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22149 ] });
22150 }
22151 var toggle_default = FiltersToggle;
22152
22153 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22154 var import_element52 = __toESM(require_element(), 1);
22155 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
22156 function FiltersToggled(props) {
22157 const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
22158 if (!isShowingFilter) {
22159 return null;
22160 }
22161 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(filters_default, { ...props });
22162 }
22163 var filters_toggled_default = FiltersToggled;
22164
22165 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22166 var import_element53 = __toESM(require_element(), 1);
22167 var import_components25 = __toESM(require_components(), 1);
22168 var import_i18n29 = __toESM(require_i18n(), 1);
22169 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
22170 function DataViewsLayout({ className }) {
22171 const {
22172 actions = [],
22173 data,
22174 fields,
22175 getItemId,
22176 getItemLevel,
22177 hasInitiallyLoaded,
22178 isLoading,
22179 view,
22180 onChangeView,
22181 selection,
22182 onChangeSelection,
22183 setOpenedFilter,
22184 onClickItem,
22185 isItemClickable,
22186 renderItemLink,
22187 defaultLayouts,
22188 containerRef,
22189 empty = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22190 } = (0, import_element53.useContext)(dataviews_context_default);
22191 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22192 delay: 200
22193 });
22194 if (!hasInitiallyLoaded) {
22195 if (!isDelayedInitialLoading) {
22196 return null;
22197 }
22198 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, {}) }) });
22199 }
22200 const ViewComponent = VIEW_LAYOUTS.find(
22201 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22202 )?.component;
22203 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
22204 ViewComponent,
22205 {
22206 className,
22207 actions,
22208 data,
22209 fields,
22210 getItemId,
22211 getItemLevel,
22212 isLoading,
22213 onChangeView,
22214 onChangeSelection,
22215 selection,
22216 setOpenedFilter,
22217 onClickItem,
22218 renderItemLink,
22219 isItemClickable,
22220 view,
22221 empty
22222 }
22223 ) });
22224 }
22225
22226 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22227 var import_element54 = __toESM(require_element(), 1);
22228 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
22229 var EMPTY_ARRAY5 = [];
22230 function DataViewsFooter() {
22231 const {
22232 view,
22233 paginationInfo: { totalItems = 0, totalPages },
22234 data,
22235 actions = EMPTY_ARRAY5,
22236 isLoading,
22237 hasInitiallyLoaded
22238 } = (0, import_element54.useContext)(dataviews_context_default);
22239 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22240 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22241 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22242 const hasPagination = hasPaginationControls(view, {
22243 totalItems,
22244 totalPages
22245 });
22246 if (!totalItems || !hasBulkActions && !hasPagination) {
22247 return null;
22248 }
22249 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22250 "div",
22251 {
22252 className: "dataviews-footer",
22253 inert: isRefreshing ? "true" : void 0,
22254 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
22255 Stack,
22256 {
22257 direction: "row",
22258 justify: "end",
22259 align: "center",
22260 className: clsx_default("dataviews-footer__content", {
22261 "is-refreshing": isDelayedRefreshing
22262 }),
22263 gap: "sm",
22264 children: [
22265 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(BulkActionsFooter, {}),
22266 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(dataviews_pagination_default, {})
22267 ]
22268 }
22269 )
22270 }
22271 );
22272 }
22273
22274 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22275 var import_i18n30 = __toESM(require_i18n(), 1);
22276 var import_element55 = __toESM(require_element(), 1);
22277 var import_components26 = __toESM(require_components(), 1);
22278 var import_compose10 = __toESM(require_compose(), 1);
22279 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22280 var DataViewsSearch = (0, import_element55.memo)(function Search({ label }) {
22281 const { view, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22282 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22283 view.search
22284 );
22285 (0, import_element55.useEffect)(() => {
22286 if (view.search !== debouncedSearch) {
22287 setSearch(view.search ?? "");
22288 }
22289 }, [view.search, setSearch]);
22290 const onChangeViewRef = (0, import_element55.useRef)(onChangeView);
22291 const viewRef = (0, import_element55.useRef)(view);
22292 (0, import_element55.useEffect)(() => {
22293 onChangeViewRef.current = onChangeView;
22294 viewRef.current = view;
22295 }, [onChangeView, view]);
22296 (0, import_element55.useEffect)(() => {
22297 if (debouncedSearch !== viewRef.current?.search) {
22298 onChangeViewRef.current({
22299 ...viewRef.current,
22300 page: view.page ? 1 : void 0,
22301 startPosition: view.startPosition ? 1 : void 0,
22302 search: debouncedSearch
22303 });
22304 }
22305 }, [debouncedSearch]);
22306 const searchLabel = label || (0, import_i18n30.__)("Search");
22307 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22308 import_components26.SearchControl,
22309 {
22310 className: "dataviews-search",
22311 onChange: setSearch,
22312 value: search,
22313 label: searchLabel,
22314 placeholder: searchLabel,
22315 size: "compact"
22316 }
22317 );
22318 });
22319 var dataviews_search_default = DataViewsSearch;
22320
22321 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22322 var import_components27 = __toESM(require_components(), 1);
22323 var import_i18n31 = __toESM(require_i18n(), 1);
22324 var import_element56 = __toESM(require_element(), 1);
22325 var import_warning = __toESM(require_warning(), 1);
22326 var import_compose11 = __toESM(require_compose(), 1);
22327 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22328 var { Menu: Menu5 } = unlock3(import_components27.privateApis);
22329 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22330 className: "dataviews-config__popover",
22331 placement: "bottom-end",
22332 offset: 9
22333 };
22334 function ViewTypeMenu() {
22335 const { view, onChangeView, defaultLayouts } = (0, import_element56.useContext)(dataviews_context_default);
22336 const availableLayouts = Object.keys(defaultLayouts);
22337 if (availableLayouts.length <= 1) {
22338 return null;
22339 }
22340 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22341 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu5, { children: [
22342 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22343 Menu5.TriggerButton,
22344 {
22345 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22346 import_components27.Button,
22347 {
22348 size: "compact",
22349 icon: activeView?.icon,
22350 label: (0, import_i18n31.__)("Layout")
22351 }
22352 )
22353 }
22354 ),
22355 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22356 const config = VIEW_LAYOUTS.find(
22357 (v2) => v2.type === layout
22358 );
22359 if (!config) {
22360 return null;
22361 }
22362 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22363 Menu5.RadioItem,
22364 {
22365 value: layout,
22366 name: "view-actions-available-view",
22367 checked: layout === view.type,
22368 hideOnClick: true,
22369 onChange: (e2) => {
22370 switch (e2.target.value) {
22371 case "list":
22372 case "grid":
22373 case "table":
22374 case "pickerGrid":
22375 case "pickerTable":
22376 case "pickerActivity":
22377 case "activity":
22378 const viewWithoutLayout = { ...view };
22379 if ("layout" in viewWithoutLayout) {
22380 delete viewWithoutLayout.layout;
22381 }
22382 return onChangeView({
22383 ...viewWithoutLayout,
22384 type: e2.target.value,
22385 ...defaultLayouts[e2.target.value]
22386 });
22387 }
22388 (0, import_warning.default)("Invalid dataview");
22389 },
22390 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.ItemLabel, { children: config.label })
22391 },
22392 layout
22393 );
22394 }) })
22395 ] });
22396 }
22397 function SortFieldControl() {
22398 const { view, fields, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22399 const orderOptions = (0, import_element56.useMemo)(() => {
22400 const sortableFields = fields.filter(
22401 (field) => field.enableSorting !== false
22402 );
22403 return sortableFields.map((field) => {
22404 return {
22405 label: field.label,
22406 value: field.id
22407 };
22408 });
22409 }, [fields]);
22410 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22411 import_components27.SelectControl,
22412 {
22413 label: (0, import_i18n31.__)("Sort by"),
22414 value: view.sort?.field,
22415 options: orderOptions,
22416 onChange: (value) => {
22417 onChangeView({
22418 ...view,
22419 sort: {
22420 direction: view?.sort?.direction || "desc",
22421 field: value
22422 },
22423 showLevels: false
22424 });
22425 }
22426 }
22427 );
22428 }
22429 function SortDirectionControl() {
22430 const { view, fields, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22431 const sortableFields = fields.filter(
22432 (field) => field.enableSorting !== false
22433 );
22434 if (sortableFields.length === 0) {
22435 return null;
22436 }
22437 let value = view.sort?.direction;
22438 if (!value && view.sort?.field) {
22439 value = "desc";
22440 }
22441 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22442 import_components27.__experimentalToggleGroupControl,
22443 {
22444 className: "dataviews-view-config__sort-direction",
22445 isBlock: true,
22446 label: (0, import_i18n31.__)("Order"),
22447 value,
22448 onChange: (newDirection) => {
22449 if (newDirection === "asc" || newDirection === "desc") {
22450 onChangeView({
22451 ...view,
22452 sort: {
22453 direction: newDirection,
22454 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22455 fields.find(
22456 (field) => field.enableSorting !== false
22457 )?.id || ""
22458 },
22459 showLevels: false
22460 });
22461 return;
22462 }
22463 (0, import_warning.default)("Invalid direction");
22464 },
22465 children: SORTING_DIRECTIONS.map((direction) => {
22466 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22467 import_components27.__experimentalToggleGroupControlOptionIcon,
22468 {
22469 value: direction,
22470 icon: sortIcons[direction],
22471 label: sortLabels[direction]
22472 },
22473 direction
22474 );
22475 })
22476 }
22477 );
22478 }
22479 function ItemsPerPageControl() {
22480 const { view, config, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22481 const { infiniteScrollEnabled } = view;
22482 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22483 return null;
22484 }
22485 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22486 import_components27.__experimentalToggleGroupControl,
22487 {
22488 isBlock: true,
22489 label: (0, import_i18n31.__)("Items per page"),
22490 value: view.perPage || 10,
22491 disabled: !view?.sort?.field,
22492 onChange: (newItemsPerPage) => {
22493 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22494 onChangeView({
22495 ...view,
22496 perPage: newItemsPerPageNumber,
22497 page: 1
22498 });
22499 },
22500 children: config.perPageSizes.map((value) => {
22501 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22502 import_components27.__experimentalToggleGroupControlOption,
22503 {
22504 value,
22505 label: value.toString()
22506 },
22507 value
22508 );
22509 })
22510 }
22511 );
22512 }
22513 function ResetViewButton() {
22514 const { onReset } = (0, import_element56.useContext)(dataviews_context_default);
22515 if (onReset === void 0) {
22516 return null;
22517 }
22518 const isDisabled = onReset === false;
22519 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22520 import_components27.Button,
22521 {
22522 variant: "tertiary",
22523 size: "compact",
22524 disabled: isDisabled,
22525 accessibleWhenDisabled: true,
22526 className: "dataviews-view-config__reset-button",
22527 onClick: () => {
22528 if (typeof onReset === "function") {
22529 onReset();
22530 }
22531 },
22532 children: (0, import_i18n31.__)("Reset view")
22533 }
22534 );
22535 }
22536 function DataviewsViewConfigDropdown() {
22537 const { view, onReset } = (0, import_element56.useContext)(dataviews_context_default);
22538 const popoverId = (0, import_compose11.useInstanceId)(
22539 _DataViewsViewConfig,
22540 "dataviews-view-config-dropdown"
22541 );
22542 const activeLayout = VIEW_LAYOUTS.find(
22543 (layout) => layout.type === view.type
22544 );
22545 const isModified = typeof onReset === "function";
22546 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22547 import_components27.Dropdown,
22548 {
22549 expandOnMobile: true,
22550 popoverProps: {
22551 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22552 id: popoverId
22553 },
22554 renderToggle: ({ onToggle, isOpen }) => {
22555 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22556 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22557 import_components27.Button,
22558 {
22559 size: "compact",
22560 icon: cog_default,
22561 label: (0, import_i18n31._x)(
22562 "View options",
22563 "View is used as a noun"
22564 ),
22565 onClick: onToggle,
22566 "aria-expanded": isOpen ? "true" : "false",
22567 "aria-controls": popoverId
22568 }
22569 ),
22570 isModified && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22571 ] });
22572 },
22573 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22574 import_components27.__experimentalDropdownContentWrapper,
22575 {
22576 paddingSize: "medium",
22577 className: "dataviews-config__popover-content-wrapper",
22578 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22579 Stack,
22580 {
22581 direction: "column",
22582 className: "dataviews-view-config",
22583 gap: "xl",
22584 children: [
22585 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22586 Stack,
22587 {
22588 direction: "row",
22589 justify: "space-between",
22590 align: "center",
22591 className: "dataviews-view-config__header",
22592 children: [
22593 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22594 import_components27.__experimentalHeading,
22595 {
22596 level: 2,
22597 className: "dataviews-settings-section__title",
22598 children: (0, import_i18n31.__)("Appearance")
22599 }
22600 ),
22601 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ResetViewButton, {})
22602 ]
22603 }
22604 ),
22605 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22606 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22607 Stack,
22608 {
22609 direction: "row",
22610 gap: "sm",
22611 className: "dataviews-view-config__sort-controls",
22612 children: [
22613 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortFieldControl, {}),
22614 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortDirectionControl, {})
22615 ]
22616 }
22617 ),
22618 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(activeLayout.viewConfigOptions, {}),
22619 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ItemsPerPageControl, {}),
22620 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(PropertiesSection, {})
22621 ] })
22622 ]
22623 }
22624 )
22625 }
22626 )
22627 }
22628 );
22629 }
22630 function _DataViewsViewConfig() {
22631 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
22632 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ViewTypeMenu, {}),
22633 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DataviewsViewConfigDropdown, {})
22634 ] });
22635 }
22636 var DataViewsViewConfig = (0, import_element56.memo)(_DataViewsViewConfig);
22637 var dataviews_view_config_default = DataViewsViewConfig;
22638
22639 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22640 var import_components28 = __toESM(require_components(), 1);
22641 var import_element57 = __toESM(require_element(), 1);
22642
22643 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22644 function getCustomValidity(isValid2, validity) {
22645 let customValidity;
22646 if (isValid2?.required && validity?.required) {
22647 customValidity = validity?.required?.message ? validity.required : void 0;
22648 } else if (isValid2?.pattern && validity?.pattern) {
22649 customValidity = validity.pattern;
22650 } else if (isValid2?.min && validity?.min) {
22651 customValidity = validity.min;
22652 } else if (isValid2?.max && validity?.max) {
22653 customValidity = validity.max;
22654 } else if (isValid2?.minLength && validity?.minLength) {
22655 customValidity = validity.minLength;
22656 } else if (isValid2?.maxLength && validity?.maxLength) {
22657 customValidity = validity.maxLength;
22658 } else if (isValid2?.elements && validity?.elements) {
22659 customValidity = validity.elements;
22660 } else if (validity?.custom) {
22661 customValidity = validity.custom;
22662 }
22663 return customValidity;
22664 }
22665
22666 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22667 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22668 var { ValidatedCheckboxControl } = unlock3(import_components28.privateApis);
22669 function Checkbox({
22670 field,
22671 onChange,
22672 data,
22673 hideLabelFromVision,
22674 markWhenOptional,
22675 validity
22676 }) {
22677 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22678 const disabled2 = field.isDisabled({ item: data, field });
22679 const onChangeControl = (0, import_element57.useCallback)(() => {
22680 onChange(
22681 setValue({ item: data, value: !getValue({ item: data }) })
22682 );
22683 }, [data, getValue, onChange, setValue]);
22684 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22685 ValidatedCheckboxControl,
22686 {
22687 required: !!field.isValid?.required,
22688 markWhenOptional,
22689 customValidity: getCustomValidity(isValid2, validity),
22690 hidden: hideLabelFromVision,
22691 label,
22692 help: description,
22693 checked: getValue({ item: data }),
22694 onChange: onChangeControl,
22695 disabled: disabled2
22696 }
22697 );
22698 }
22699
22700 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22701 var import_components29 = __toESM(require_components(), 1);
22702 var import_element58 = __toESM(require_element(), 1);
22703 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22704 var { ValidatedComboboxControl } = unlock3(import_components29.privateApis);
22705 function Combobox3({
22706 data,
22707 field,
22708 onChange,
22709 hideLabelFromVision,
22710 validity
22711 }) {
22712 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22713 const value = getValue({ item: data }) ?? "";
22714 const onChangeControl = (0, import_element58.useCallback)(
22715 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22716 [data, onChange, setValue]
22717 );
22718 const { elements, isLoading } = useElements({
22719 elements: field.elements,
22720 getElements: field.getElements
22721 });
22722 if (isLoading) {
22723 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components29.Spinner, {});
22724 }
22725 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22726 ValidatedComboboxControl,
22727 {
22728 required: !!field.isValid?.required,
22729 customValidity: getCustomValidity(isValid2, validity),
22730 label,
22731 value,
22732 help: description,
22733 placeholder,
22734 options: elements,
22735 onChange: onChangeControl,
22736 hideLabelFromVision,
22737 allowReset: true,
22738 expandOnFocus: true
22739 }
22740 );
22741 }
22742
22743 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22744 var import_components31 = __toESM(require_components(), 1);
22745 var import_element61 = __toESM(require_element(), 1);
22746 var import_i18n33 = __toESM(require_i18n(), 1);
22747 var import_date3 = __toESM(require_date(), 1);
22748
22749 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22750 var import_components30 = __toESM(require_components(), 1);
22751 var import_element59 = __toESM(require_element(), 1);
22752 var import_i18n32 = __toESM(require_i18n(), 1);
22753 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22754 var TIME_UNITS_OPTIONS = {
22755 [OPERATOR_IN_THE_PAST]: [
22756 { value: "days", label: (0, import_i18n32.__)("Days") },
22757 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22758 { value: "months", label: (0, import_i18n32.__)("Months") },
22759 { value: "years", label: (0, import_i18n32.__)("Years") }
22760 ],
22761 [OPERATOR_OVER]: [
22762 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22763 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22764 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22765 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22766 ]
22767 };
22768 function RelativeDateControl({
22769 className,
22770 data,
22771 field,
22772 onChange,
22773 hideLabelFromVision,
22774 operator
22775 }) {
22776 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22777 const { id, label, description, getValue, setValue } = field;
22778 const disabled2 = field.isDisabled({ item: data, field });
22779 const fieldValue = getValue({ item: data });
22780 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22781 const onChangeValue = (0, import_element59.useCallback)(
22782 (newValue) => onChange(
22783 setValue({
22784 item: data,
22785 value: { value: Number(newValue), unit }
22786 })
22787 ),
22788 [onChange, setValue, data, unit]
22789 );
22790 const onChangeUnit = (0, import_element59.useCallback)(
22791 (newUnit) => onChange(
22792 setValue({
22793 item: data,
22794 value: { value: relValue, unit: newUnit }
22795 })
22796 ),
22797 [onChange, setValue, data, relValue]
22798 );
22799 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22800 import_components30.BaseControl,
22801 {
22802 id,
22803 className: clsx_default(className, "dataviews-controls__relative-date"),
22804 label,
22805 hideLabelFromVision,
22806 help: description,
22807 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22808 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22809 import_components30.__experimentalNumberControl,
22810 {
22811 className: "dataviews-controls__relative-date-number",
22812 spinControls: "none",
22813 min: 1,
22814 step: 1,
22815 value: relValue,
22816 onChange: onChangeValue,
22817 disabled: disabled2
22818 }
22819 ),
22820 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22821 import_components30.SelectControl,
22822 {
22823 className: "dataviews-controls__relative-date-unit",
22824 label: (0, import_i18n32.__)("Unit"),
22825 value: unit,
22826 options,
22827 onChange: onChangeUnit,
22828 hideLabelFromVision: true,
22829 disabled: disabled2
22830 }
22831 )
22832 ] })
22833 }
22834 );
22835 }
22836
22837 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22838 var import_element60 = __toESM(require_element(), 1);
22839 function useDisabledDateMatchers(isValid2, parseDateFn) {
22840 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22841 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22842 const disabledMatchers = (0, import_element60.useMemo)(() => {
22843 const matchers = [];
22844 if (minConstraint) {
22845 const minDate = parseDateFn(minConstraint);
22846 if (minDate) {
22847 matchers.push({ before: minDate });
22848 }
22849 }
22850 if (maxConstraint) {
22851 const maxDate = parseDateFn(maxConstraint);
22852 if (maxDate) {
22853 matchers.push({ after: maxDate });
22854 }
22855 }
22856 return matchers.length > 0 ? matchers : void 0;
22857 }, [minConstraint, maxConstraint, parseDateFn]);
22858 return { minConstraint, maxConstraint, disabledMatchers };
22859 }
22860
22861 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22862 var import_date2 = __toESM(require_date(), 1);
22863 function parseDateTime(dateTimeString) {
22864 if (!dateTimeString) {
22865 return null;
22866 }
22867 const parsed = (0, import_date2.getDate)(dateTimeString);
22868 return parsed && isValid(parsed) ? parsed : null;
22869 }
22870
22871 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22872 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22873 var { DateCalendar, ValidatedInputControl } = unlock3(import_components31.privateApis);
22874 var formatDateTime = (value) => {
22875 if (!value) {
22876 return "";
22877 }
22878 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22879 };
22880 function CalendarDateTimeControl({
22881 data,
22882 field,
22883 onChange,
22884 hideLabelFromVision,
22885 markWhenOptional,
22886 validity,
22887 config
22888 }) {
22889 const { compact } = config || {};
22890 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22891 const disabled2 = field.isDisabled({ item: data, field });
22892 const fieldValue = getValue({ item: data });
22893 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22894 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
22895 const parsedDate = parseDateTime(value);
22896 return parsedDate || /* @__PURE__ */ new Date();
22897 });
22898 const inputControlRef = (0, import_element61.useRef)(null);
22899 const validationTimeoutRef = (0, import_element61.useRef)(void 0);
22900 const previousFocusRef = (0, import_element61.useRef)(null);
22901 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22902 const onChangeCallback = (0, import_element61.useCallback)(
22903 (newValue) => onChange(setValue({ item: data, value: newValue })),
22904 [data, onChange, setValue]
22905 );
22906 (0, import_element61.useEffect)(() => {
22907 return () => {
22908 if (validationTimeoutRef.current) {
22909 clearTimeout(validationTimeoutRef.current);
22910 }
22911 };
22912 }, []);
22913 const onSelectDate = (0, import_element61.useCallback)(
22914 (newDate) => {
22915 let dateTimeValue;
22916 if (newDate) {
22917 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22918 let wpTime;
22919 if (value) {
22920 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22921 } else {
22922 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22923 }
22924 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22925 dateTimeValue = finalDateTime.toISOString();
22926 onChangeCallback(dateTimeValue);
22927 if (validationTimeoutRef.current) {
22928 clearTimeout(validationTimeoutRef.current);
22929 }
22930 } else {
22931 onChangeCallback(void 0);
22932 }
22933 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22934 validationTimeoutRef.current = setTimeout(() => {
22935 if (inputControlRef.current) {
22936 inputControlRef.current.focus();
22937 inputControlRef.current.blur();
22938 onChangeCallback(dateTimeValue);
22939 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22940 previousFocusRef.current.focus();
22941 }
22942 }
22943 }, 0);
22944 },
22945 [onChangeCallback, value]
22946 );
22947 const handleManualDateTimeChange = (0, import_element61.useCallback)(
22948 (newValue) => {
22949 if (newValue) {
22950 const dateTime = (0, import_date3.getDate)(newValue);
22951 onChangeCallback(dateTime.toISOString());
22952 const parsedDate = parseDateTime(dateTime.toISOString());
22953 if (parsedDate) {
22954 setCalendarMonth(parsedDate);
22955 }
22956 } else {
22957 onChangeCallback(void 0);
22958 }
22959 },
22960 [onChangeCallback]
22961 );
22962 const { format: fieldFormat } = field;
22963 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22964 const {
22965 timezone: { string: timezoneString }
22966 } = (0, import_date3.getSettings)();
22967 let displayLabel = label;
22968 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22969 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22970 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22971 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22972 }
22973 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22974 import_components31.BaseControl,
22975 {
22976 id,
22977 label: displayLabel,
22978 help: description,
22979 hideLabelFromVision,
22980 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22981 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22982 ValidatedInputControl,
22983 {
22984 ref: inputControlRef,
22985 required: !!isValid2?.required,
22986 customValidity: getCustomValidity(isValid2, validity),
22987 type: "datetime-local",
22988 label: (0, import_i18n33.__)("Date time"),
22989 hideLabelFromVision: true,
22990 value: formatDateTime(value),
22991 onChange: handleManualDateTimeChange,
22992 disabled: disabled2,
22993 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22994 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22995 }
22996 ),
22997 !compact && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22998 DateCalendar,
22999 {
23000 style: { width: "100%" },
23001 selected: value ? parseDateTime(value) || void 0 : void 0,
23002 onSelect: onSelectDate,
23003 month: calendarMonth,
23004 onMonthChange: setCalendarMonth,
23005 timeZone: timezoneString || void 0,
23006 weekStartsOn,
23007 disabled: disabled2 || disabledMatchers
23008 }
23009 )
23010 ] })
23011 }
23012 );
23013 }
23014 function DateTime({
23015 data,
23016 field,
23017 onChange,
23018 hideLabelFromVision,
23019 markWhenOptional,
23020 operator,
23021 validity,
23022 config
23023 }) {
23024 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23025 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23026 RelativeDateControl,
23027 {
23028 className: "dataviews-controls__datetime",
23029 data,
23030 field,
23031 onChange,
23032 hideLabelFromVision,
23033 operator
23034 }
23035 );
23036 }
23037 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23038 CalendarDateTimeControl,
23039 {
23040 data,
23041 field,
23042 onChange,
23043 hideLabelFromVision,
23044 markWhenOptional,
23045 validity,
23046 config
23047 }
23048 );
23049 }
23050
23051 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23052 var import_components32 = __toESM(require_components(), 1);
23053 var import_element62 = __toESM(require_element(), 1);
23054 var import_i18n34 = __toESM(require_i18n(), 1);
23055 var import_date4 = __toESM(require_date(), 1);
23056 import { speak } from "@wordpress/a11y";
23057 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
23058 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components32.privateApis);
23059 var DATE_PRESETS = [
23060 {
23061 id: "today",
23062 label: (0, import_i18n34.__)("Today"),
23063 getValue: () => (0, import_date4.getDate)(null)
23064 },
23065 {
23066 id: "yesterday",
23067 label: (0, import_i18n34.__)("Yesterday"),
23068 getValue: () => {
23069 const today = (0, import_date4.getDate)(null);
23070 return subDays(today, 1);
23071 }
23072 },
23073 {
23074 id: "past-week",
23075 label: (0, import_i18n34.__)("Past week"),
23076 getValue: () => {
23077 const today = (0, import_date4.getDate)(null);
23078 return subDays(today, 7);
23079 }
23080 },
23081 {
23082 id: "past-month",
23083 label: (0, import_i18n34.__)("Past month"),
23084 getValue: () => {
23085 const today = (0, import_date4.getDate)(null);
23086 return subMonths(today, 1);
23087 }
23088 }
23089 ];
23090 var DATE_RANGE_PRESETS = [
23091 {
23092 id: "last-7-days",
23093 label: (0, import_i18n34.__)("Last 7 days"),
23094 getValue: () => {
23095 const today = (0, import_date4.getDate)(null);
23096 return [subDays(today, 7), today];
23097 }
23098 },
23099 {
23100 id: "last-30-days",
23101 label: (0, import_i18n34.__)("Last 30 days"),
23102 getValue: () => {
23103 const today = (0, import_date4.getDate)(null);
23104 return [subDays(today, 30), today];
23105 }
23106 },
23107 {
23108 id: "month-to-date",
23109 label: (0, import_i18n34.__)("Month to date"),
23110 getValue: () => {
23111 const today = (0, import_date4.getDate)(null);
23112 return [startOfMonth(today), today];
23113 }
23114 },
23115 {
23116 id: "last-year",
23117 label: (0, import_i18n34.__)("Last year"),
23118 getValue: () => {
23119 const today = (0, import_date4.getDate)(null);
23120 return [subYears(today, 1), today];
23121 }
23122 },
23123 {
23124 id: "year-to-date",
23125 label: (0, import_i18n34.__)("Year to date"),
23126 getValue: () => {
23127 const today = (0, import_date4.getDate)(null);
23128 return [startOfYear(today), today];
23129 }
23130 }
23131 ];
23132 var parseDate = (dateString) => {
23133 if (!dateString) {
23134 return null;
23135 }
23136 const parsed = (0, import_date4.getDate)(dateString);
23137 return parsed && isValid(parsed) ? parsed : null;
23138 };
23139 var formatDate = (date) => {
23140 if (!date) {
23141 return "";
23142 }
23143 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23144 };
23145 function ValidatedDateControl({
23146 field,
23147 validity,
23148 inputRefs,
23149 isTouched,
23150 setIsTouched,
23151 children
23152 }) {
23153 const { isValid: isValid2 } = field;
23154 const [customValidity, setCustomValidity] = (0, import_element62.useState)(void 0);
23155 const validateRefs = (0, import_element62.useCallback)(() => {
23156 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23157 for (const ref of refs) {
23158 const input = ref.current;
23159 if (input && !input.validity.valid) {
23160 setCustomValidity({
23161 type: "invalid",
23162 message: input.validationMessage
23163 });
23164 return;
23165 }
23166 }
23167 setCustomValidity(void 0);
23168 }, [inputRefs]);
23169 (0, import_element62.useEffect)(() => {
23170 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23171 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23172 for (const ref of refs) {
23173 const input = ref.current;
23174 if (input) {
23175 input.setCustomValidity(
23176 result?.type === "invalid" && result.message ? result.message : ""
23177 );
23178 }
23179 }
23180 }, [inputRefs, isValid2, validity]);
23181 (0, import_element62.useEffect)(() => {
23182 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23183 const handleInvalid = (event) => {
23184 event.preventDefault();
23185 setIsTouched(true);
23186 };
23187 for (const ref of refs) {
23188 ref.current?.addEventListener("invalid", handleInvalid);
23189 }
23190 return () => {
23191 for (const ref of refs) {
23192 ref.current?.removeEventListener("invalid", handleInvalid);
23193 }
23194 };
23195 }, [inputRefs, setIsTouched]);
23196 (0, import_element62.useEffect)(() => {
23197 if (!isTouched) {
23198 return;
23199 }
23200 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23201 if (result) {
23202 setCustomValidity(result);
23203 } else {
23204 validateRefs();
23205 }
23206 }, [isTouched, isValid2, validity, validateRefs]);
23207 (0, import_element62.useEffect)(() => {
23208 if (isTouched && customValidity?.message) {
23209 speak(customValidity.message);
23210 }
23211 }, [isTouched, customValidity?.message]);
23212 const onBlur = (event) => {
23213 if (isTouched) {
23214 return;
23215 }
23216 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23217 setIsTouched(true);
23218 }
23219 };
23220 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { onBlur, children: [
23221 children,
23222 customValidity && /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23223 "p",
23224 {
23225 className: clsx_default(
23226 "components-validated-control__indicator",
23227 customValidity.type === "invalid" ? "is-invalid" : void 0
23228 ),
23229 children: [
23230 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23231 import_components32.Icon,
23232 {
23233 className: "components-validated-control__indicator-icon",
23234 icon: error_default,
23235 size: 16,
23236 fill: "currentColor"
23237 }
23238 ),
23239 customValidity.message
23240 ]
23241 }
23242 )
23243 ] });
23244 }
23245 function CalendarDateControl({
23246 data,
23247 field,
23248 onChange,
23249 hideLabelFromVision,
23250 markWhenOptional,
23251 validity
23252 }) {
23253 const {
23254 id,
23255 label,
23256 description,
23257 setValue,
23258 getValue,
23259 isValid: isValid2,
23260 format: fieldFormat
23261 } = field;
23262 const disabled2 = field.isDisabled({ item: data, field });
23263 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
23264 null
23265 );
23266 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23267 const fieldValue = getValue({ item: data });
23268 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23269 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
23270 const parsedDate = parseDate(value);
23271 return parsedDate || /* @__PURE__ */ new Date();
23272 });
23273 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
23274 const validityTargetRef = (0, import_element62.useRef)(null);
23275 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23276 const onChangeCallback = (0, import_element62.useCallback)(
23277 (newValue) => onChange(setValue({ item: data, value: newValue })),
23278 [data, onChange, setValue]
23279 );
23280 const onSelectDate = (0, import_element62.useCallback)(
23281 (newDate) => {
23282 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23283 onChangeCallback(dateValue);
23284 setSelectedPresetId(null);
23285 setIsTouched(true);
23286 },
23287 [onChangeCallback]
23288 );
23289 const handlePresetClick = (0, import_element62.useCallback)(
23290 (preset) => {
23291 const presetDate = preset.getValue();
23292 const dateValue = formatDate(presetDate);
23293 setCalendarMonth(presetDate);
23294 onChangeCallback(dateValue);
23295 setSelectedPresetId(preset.id);
23296 setIsTouched(true);
23297 },
23298 [onChangeCallback]
23299 );
23300 const handleManualDateChange = (0, import_element62.useCallback)(
23301 (newValue) => {
23302 onChangeCallback(newValue);
23303 if (newValue) {
23304 const parsedDate = parseDate(newValue);
23305 if (parsedDate) {
23306 setCalendarMonth(parsedDate);
23307 }
23308 }
23309 setSelectedPresetId(null);
23310 setIsTouched(true);
23311 },
23312 [onChangeCallback]
23313 );
23314 const {
23315 timezone: { string: timezoneString }
23316 } = (0, import_date4.getSettings)();
23317 let displayLabel = label;
23318 if (isValid2?.required && !markWhenOptional) {
23319 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23320 } else if (!isValid2?.required && markWhenOptional) {
23321 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23322 }
23323 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23324 ValidatedDateControl,
23325 {
23326 field,
23327 validity,
23328 inputRefs: validityTargetRef,
23329 isTouched,
23330 setIsTouched,
23331 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23332 import_components32.BaseControl,
23333 {
23334 id,
23335 className: "dataviews-controls__date",
23336 label: displayLabel,
23337 help: description,
23338 hideLabelFromVision,
23339 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23340 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23341 Stack,
23342 {
23343 direction: "row",
23344 gap: "sm",
23345 wrap: "wrap",
23346 justify: "flex-start",
23347 children: [
23348 DATE_PRESETS.map((preset) => {
23349 const isSelected2 = selectedPresetId === preset.id;
23350 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23351 import_components32.Button,
23352 {
23353 className: "dataviews-controls__date-preset",
23354 variant: "tertiary",
23355 isPressed: isSelected2,
23356 size: "small",
23357 disabled: disabled2,
23358 accessibleWhenDisabled: true,
23359 onClick: () => handlePresetClick(preset),
23360 children: preset.label
23361 },
23362 preset.id
23363 );
23364 }),
23365 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23366 import_components32.Button,
23367 {
23368 className: "dataviews-controls__date-preset",
23369 variant: "tertiary",
23370 isPressed: !selectedPresetId,
23371 size: "small",
23372 disabled: !!selectedPresetId || disabled2,
23373 accessibleWhenDisabled: true,
23374 children: (0, import_i18n34.__)("Custom")
23375 }
23376 )
23377 ]
23378 }
23379 ),
23380 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23381 import_components32.__experimentalInputControl,
23382 {
23383 ref: validityTargetRef,
23384 type: "date",
23385 label: (0, import_i18n34.__)("Date"),
23386 hideLabelFromVision: true,
23387 value,
23388 onChange: handleManualDateChange,
23389 required: !!field.isValid?.required,
23390 disabled: disabled2,
23391 min: minConstraint,
23392 max: maxConstraint
23393 }
23394 ),
23395 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23396 DateCalendar2,
23397 {
23398 style: { width: "100%" },
23399 selected: value ? parseDate(value) || void 0 : void 0,
23400 onSelect: onSelectDate,
23401 month: calendarMonth,
23402 onMonthChange: setCalendarMonth,
23403 timeZone: timezoneString || void 0,
23404 weekStartsOn,
23405 disabled: disabled2 || disabledMatchers,
23406 disableNavigation: disabled2
23407 }
23408 )
23409 ] })
23410 }
23411 )
23412 }
23413 );
23414 }
23415 function CalendarDateRangeControl({
23416 data,
23417 field,
23418 onChange,
23419 hideLabelFromVision,
23420 markWhenOptional,
23421 validity
23422 }) {
23423 const {
23424 id,
23425 label,
23426 description,
23427 getValue,
23428 setValue,
23429 isValid: isValid2,
23430 format: fieldFormat
23431 } = field;
23432 const disabled2 = field.isDisabled({ item: data, field });
23433 let value;
23434 const fieldValue = getValue({ item: data });
23435 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23436 value = fieldValue;
23437 }
23438 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23439 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23440 const onChangeCallback = (0, import_element62.useCallback)(
23441 (newValue) => {
23442 onChange(
23443 setValue({
23444 item: data,
23445 value: newValue
23446 })
23447 );
23448 },
23449 [data, onChange, setValue]
23450 );
23451 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
23452 null
23453 );
23454 const selectedRange = (0, import_element62.useMemo)(() => {
23455 if (!value) {
23456 return { from: void 0, to: void 0 };
23457 }
23458 const [from, to] = value;
23459 return {
23460 from: parseDate(from) || void 0,
23461 to: parseDate(to) || void 0
23462 };
23463 }, [value]);
23464 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
23465 return selectedRange.from || /* @__PURE__ */ new Date();
23466 });
23467 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
23468 const fromInputRef = (0, import_element62.useRef)(null);
23469 const toInputRef = (0, import_element62.useRef)(null);
23470 const updateDateRange = (0, import_element62.useCallback)(
23471 (fromDate, toDate2) => {
23472 if (fromDate && toDate2) {
23473 onChangeCallback([
23474 formatDate(fromDate),
23475 formatDate(toDate2)
23476 ]);
23477 } else if (!fromDate && !toDate2) {
23478 onChangeCallback(void 0);
23479 }
23480 },
23481 [onChangeCallback]
23482 );
23483 const onSelectCalendarRange = (0, import_element62.useCallback)(
23484 (newRange) => {
23485 updateDateRange(newRange?.from, newRange?.to);
23486 setSelectedPresetId(null);
23487 setIsTouched(true);
23488 },
23489 [updateDateRange]
23490 );
23491 const handlePresetClick = (0, import_element62.useCallback)(
23492 (preset) => {
23493 const [startDate, endDate] = preset.getValue();
23494 setCalendarMonth(startDate);
23495 updateDateRange(startDate, endDate);
23496 setSelectedPresetId(preset.id);
23497 setIsTouched(true);
23498 },
23499 [updateDateRange]
23500 );
23501 const handleManualDateChange = (0, import_element62.useCallback)(
23502 (fromOrTo, newValue) => {
23503 const [currentFrom, currentTo] = value || [
23504 void 0,
23505 void 0
23506 ];
23507 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23508 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23509 updateDateRange(updatedFrom, updatedTo);
23510 if (newValue) {
23511 const parsedDate = parseDate(newValue);
23512 if (parsedDate) {
23513 setCalendarMonth(parsedDate);
23514 }
23515 }
23516 setSelectedPresetId(null);
23517 setIsTouched(true);
23518 },
23519 [value, updateDateRange]
23520 );
23521 const { timezone } = (0, import_date4.getSettings)();
23522 let displayLabel = label;
23523 if (field.isValid?.required && !markWhenOptional) {
23524 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23525 } else if (!field.isValid?.required && markWhenOptional) {
23526 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23527 }
23528 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23529 ValidatedDateControl,
23530 {
23531 field,
23532 validity,
23533 inputRefs: [fromInputRef, toInputRef],
23534 isTouched,
23535 setIsTouched,
23536 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23537 import_components32.BaseControl,
23538 {
23539 id,
23540 className: "dataviews-controls__date",
23541 label: displayLabel,
23542 help: description,
23543 hideLabelFromVision,
23544 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23545 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23546 Stack,
23547 {
23548 direction: "row",
23549 gap: "sm",
23550 wrap: "wrap",
23551 justify: "flex-start",
23552 children: [
23553 DATE_RANGE_PRESETS.map((preset) => {
23554 const isSelected2 = selectedPresetId === preset.id;
23555 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23556 import_components32.Button,
23557 {
23558 className: "dataviews-controls__date-preset",
23559 variant: "tertiary",
23560 isPressed: isSelected2,
23561 size: "small",
23562 disabled: disabled2,
23563 accessibleWhenDisabled: true,
23564 onClick: () => handlePresetClick(preset),
23565 children: preset.label
23566 },
23567 preset.id
23568 );
23569 }),
23570 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23571 import_components32.Button,
23572 {
23573 className: "dataviews-controls__date-preset",
23574 variant: "tertiary",
23575 isPressed: !selectedPresetId,
23576 size: "small",
23577 accessibleWhenDisabled: true,
23578 disabled: !!selectedPresetId || disabled2,
23579 children: (0, import_i18n34.__)("Custom")
23580 }
23581 )
23582 ]
23583 }
23584 ),
23585 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23586 Stack,
23587 {
23588 direction: "row",
23589 gap: "sm",
23590 justify: "space-between",
23591 className: "dataviews-controls__date-range-inputs",
23592 children: [
23593 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23594 import_components32.__experimentalInputControl,
23595 {
23596 ref: fromInputRef,
23597 type: "date",
23598 label: (0, import_i18n34.__)("From"),
23599 hideLabelFromVision: true,
23600 value: value?.[0],
23601 onChange: (newValue) => handleManualDateChange("from", newValue),
23602 required: !!field.isValid?.required,
23603 disabled: disabled2,
23604 min: minConstraint,
23605 max: maxConstraint
23606 }
23607 ),
23608 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23609 import_components32.__experimentalInputControl,
23610 {
23611 ref: toInputRef,
23612 type: "date",
23613 label: (0, import_i18n34.__)("To"),
23614 hideLabelFromVision: true,
23615 value: value?.[1],
23616 onChange: (newValue) => handleManualDateChange("to", newValue),
23617 required: !!field.isValid?.required,
23618 disabled: disabled2,
23619 min: minConstraint,
23620 max: maxConstraint
23621 }
23622 )
23623 ]
23624 }
23625 ),
23626 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23627 DateRangeCalendar,
23628 {
23629 style: { width: "100%" },
23630 selected: selectedRange,
23631 onSelect: onSelectCalendarRange,
23632 month: calendarMonth,
23633 onMonthChange: setCalendarMonth,
23634 timeZone: timezone.string || void 0,
23635 weekStartsOn,
23636 disabled: disabled2 || disabledMatchers
23637 }
23638 )
23639 ] })
23640 }
23641 )
23642 }
23643 );
23644 }
23645 function DateControl({
23646 data,
23647 field,
23648 onChange,
23649 hideLabelFromVision,
23650 markWhenOptional,
23651 operator,
23652 validity
23653 }) {
23654 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23655 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23656 RelativeDateControl,
23657 {
23658 className: "dataviews-controls__date",
23659 data,
23660 field,
23661 onChange,
23662 hideLabelFromVision,
23663 operator
23664 }
23665 );
23666 }
23667 if (operator === OPERATOR_BETWEEN) {
23668 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23669 CalendarDateRangeControl,
23670 {
23671 data,
23672 field,
23673 onChange,
23674 hideLabelFromVision,
23675 markWhenOptional,
23676 validity
23677 }
23678 );
23679 }
23680 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23681 CalendarDateControl,
23682 {
23683 data,
23684 field,
23685 onChange,
23686 hideLabelFromVision,
23687 markWhenOptional,
23688 validity
23689 }
23690 );
23691 }
23692
23693 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23694 var import_components33 = __toESM(require_components(), 1);
23695 var import_element63 = __toESM(require_element(), 1);
23696 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23697 var { ValidatedSelectControl } = unlock3(import_components33.privateApis);
23698 function Select({
23699 data,
23700 field,
23701 onChange,
23702 hideLabelFromVision,
23703 markWhenOptional,
23704 validity
23705 }) {
23706 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23707 const disabled2 = field.isDisabled({ item: data, field });
23708 const isMultiple = type === "array";
23709 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23710 const onChangeControl = (0, import_element63.useCallback)(
23711 (newValue) => onChange(setValue({ item: data, value: newValue })),
23712 [data, onChange, setValue]
23713 );
23714 const { elements, isLoading } = useElements({
23715 elements: field.elements,
23716 getElements: field.getElements
23717 });
23718 if (isLoading) {
23719 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components33.Spinner, {});
23720 }
23721 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
23722 ValidatedSelectControl,
23723 {
23724 required: !!field.isValid?.required,
23725 markWhenOptional,
23726 customValidity: getCustomValidity(isValid2, validity),
23727 label,
23728 value,
23729 help: description,
23730 options: elements,
23731 onChange: onChangeControl,
23732 hideLabelFromVision,
23733 multiple: isMultiple,
23734 disabled: disabled2
23735 }
23736 );
23737 }
23738
23739 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23740 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23741 var ELEMENTS_THRESHOLD = 10;
23742 function AdaptiveSelect(props) {
23743 const { field } = props;
23744 const { elements } = useElements({
23745 elements: field.elements,
23746 getElements: field.getElements
23747 });
23748 if (elements.length >= ELEMENTS_THRESHOLD) {
23749 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Combobox3, { ...props });
23750 }
23751 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Select, { ...props });
23752 }
23753
23754 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23755 var import_components35 = __toESM(require_components(), 1);
23756
23757 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23758 var import_components34 = __toESM(require_components(), 1);
23759 var import_element64 = __toESM(require_element(), 1);
23760 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23761 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components34.privateApis);
23762 function ValidatedText({
23763 data,
23764 field,
23765 onChange,
23766 hideLabelFromVision,
23767 markWhenOptional,
23768 type,
23769 prefix,
23770 suffix,
23771 validity
23772 }) {
23773 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23774 const value = getValue({ item: data });
23775 const disabled2 = field.isDisabled({ item: data, field });
23776 const onChangeControl = (0, import_element64.useCallback)(
23777 (newValue) => onChange(
23778 setValue({
23779 item: data,
23780 value: newValue
23781 })
23782 ),
23783 [data, setValue, onChange]
23784 );
23785 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23786 ValidatedInputControl2,
23787 {
23788 required: !!isValid2.required,
23789 markWhenOptional,
23790 customValidity: getCustomValidity(isValid2, validity),
23791 label,
23792 placeholder,
23793 value: value ?? "",
23794 help: description,
23795 onChange: onChangeControl,
23796 hideLabelFromVision,
23797 type,
23798 prefix,
23799 suffix,
23800 disabled: disabled2,
23801 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23802 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23803 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
23804 }
23805 );
23806 }
23807
23808 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23809 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23810 function Email({
23811 data,
23812 field,
23813 onChange,
23814 hideLabelFromVision,
23815 markWhenOptional,
23816 validity
23817 }) {
23818 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23819 ValidatedText,
23820 {
23821 ...{
23822 data,
23823 field,
23824 onChange,
23825 hideLabelFromVision,
23826 markWhenOptional,
23827 validity,
23828 type: "email",
23829 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 }) })
23830 }
23831 }
23832 );
23833 }
23834
23835 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23836 var import_components36 = __toESM(require_components(), 1);
23837 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23838 function Telephone({
23839 data,
23840 field,
23841 onChange,
23842 hideLabelFromVision,
23843 markWhenOptional,
23844 validity
23845 }) {
23846 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23847 ValidatedText,
23848 {
23849 ...{
23850 data,
23851 field,
23852 onChange,
23853 hideLabelFromVision,
23854 markWhenOptional,
23855 validity,
23856 type: "tel",
23857 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 }) })
23858 }
23859 }
23860 );
23861 }
23862
23863 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23864 var import_components37 = __toESM(require_components(), 1);
23865 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23866 function Url({
23867 data,
23868 field,
23869 onChange,
23870 hideLabelFromVision,
23871 markWhenOptional,
23872 validity
23873 }) {
23874 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23875 ValidatedText,
23876 {
23877 ...{
23878 data,
23879 field,
23880 onChange,
23881 hideLabelFromVision,
23882 markWhenOptional,
23883 validity,
23884 type: "url",
23885 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 }) })
23886 }
23887 }
23888 );
23889 }
23890
23891 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23892 var import_components38 = __toESM(require_components(), 1);
23893 var import_element65 = __toESM(require_element(), 1);
23894 var import_i18n35 = __toESM(require_i18n(), 1);
23895 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23896 var { ValidatedNumberControl } = unlock3(import_components38.privateApis);
23897 function toNumberOrEmpty(value) {
23898 if (value === "" || value === void 0) {
23899 return "";
23900 }
23901 const number = Number(value);
23902 return Number.isFinite(number) ? number : "";
23903 }
23904 function BetweenControls({
23905 value,
23906 onChange,
23907 hideLabelFromVision,
23908 step
23909 }) {
23910 const [min2 = "", max2 = ""] = value;
23911 const onChangeMin = (0, import_element65.useCallback)(
23912 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23913 [onChange, max2]
23914 );
23915 const onChangeMax = (0, import_element65.useCallback)(
23916 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23917 [onChange, min2]
23918 );
23919 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23920 import_components38.BaseControl,
23921 {
23922 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23923 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23924 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23925 import_components38.__experimentalNumberControl,
23926 {
23927 label: (0, import_i18n35.__)("Min."),
23928 value: min2,
23929 max: max2 ? Number(max2) - step : void 0,
23930 onChange: onChangeMin,
23931 hideLabelFromVision,
23932 step
23933 }
23934 ),
23935 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23936 import_components38.__experimentalNumberControl,
23937 {
23938 label: (0, import_i18n35.__)("Max."),
23939 value: max2,
23940 min: min2 ? Number(min2) + step : void 0,
23941 onChange: onChangeMax,
23942 hideLabelFromVision,
23943 step
23944 }
23945 )
23946 ] })
23947 }
23948 );
23949 }
23950 function ValidatedNumber({
23951 data,
23952 field,
23953 onChange,
23954 hideLabelFromVision,
23955 markWhenOptional,
23956 operator,
23957 validity
23958 }) {
23959 const decimals = field.format?.decimals ?? 0;
23960 const step = Math.pow(10, Math.abs(decimals) * -1);
23961 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23962 const value = getValue({ item: data }) ?? "";
23963 const disabled2 = field.isDisabled({ item: data, field });
23964 const onChangeControl = (0, import_element65.useCallback)(
23965 (newValue) => {
23966 onChange(
23967 setValue({
23968 item: data,
23969 // Do not convert an empty string or undefined to a number,
23970 // otherwise there's a mismatch between the UI control (empty)
23971 // and the data relied by onChange (0).
23972 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23973 })
23974 );
23975 },
23976 [data, onChange, setValue]
23977 );
23978 const onChangeBetweenControls = (0, import_element65.useCallback)(
23979 (newValue) => {
23980 onChange(
23981 setValue({
23982 item: data,
23983 value: newValue
23984 })
23985 );
23986 },
23987 [data, onChange, setValue]
23988 );
23989 if (operator === OPERATOR_BETWEEN) {
23990 let valueBetween = ["", ""];
23991 if (Array.isArray(value) && value.length === 2 && value.every(
23992 (element) => typeof element === "number" || element === ""
23993 )) {
23994 valueBetween = value;
23995 }
23996 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23997 BetweenControls,
23998 {
23999 value: valueBetween,
24000 onChange: onChangeBetweenControls,
24001 hideLabelFromVision,
24002 step
24003 }
24004 );
24005 }
24006 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24007 ValidatedNumberControl,
24008 {
24009 required: !!isValid2.required,
24010 markWhenOptional,
24011 customValidity: getCustomValidity(isValid2, validity),
24012 label,
24013 help: description,
24014 value,
24015 onChange: onChangeControl,
24016 hideLabelFromVision,
24017 step,
24018 min: isValid2.min ? isValid2.min.constraint : void 0,
24019 max: isValid2.max ? isValid2.max.constraint : void 0,
24020 disabled: disabled2
24021 }
24022 );
24023 }
24024
24025 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24026 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24027 function Integer(props) {
24028 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
24029 }
24030
24031 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24032 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24033 function Number2(props) {
24034 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ValidatedNumber, { ...props });
24035 }
24036
24037 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24038 var import_components39 = __toESM(require_components(), 1);
24039 var import_element66 = __toESM(require_element(), 1);
24040 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24041 var { ValidatedRadioControl } = unlock3(import_components39.privateApis);
24042 function Radio({
24043 data,
24044 field,
24045 onChange,
24046 hideLabelFromVision,
24047 markWhenOptional,
24048 validity
24049 }) {
24050 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24051 const disabled2 = field.isDisabled({ item: data, field });
24052 const { elements, isLoading } = useElements({
24053 elements: field.elements,
24054 getElements: field.getElements
24055 });
24056 const value = getValue({ item: data });
24057 const onChangeControl = (0, import_element66.useCallback)(
24058 (newValue) => onChange(setValue({ item: data, value: newValue })),
24059 [data, onChange, setValue]
24060 );
24061 if (isLoading) {
24062 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components39.Spinner, {});
24063 }
24064 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24065 ValidatedRadioControl,
24066 {
24067 required: !!field.isValid?.required,
24068 markWhenOptional,
24069 customValidity: getCustomValidity(isValid2, validity),
24070 label,
24071 help: description,
24072 onChange: onChangeControl,
24073 options: elements,
24074 selected: value,
24075 hideLabelFromVision,
24076 disabled: disabled2
24077 }
24078 );
24079 }
24080
24081 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24082 var import_element67 = __toESM(require_element(), 1);
24083 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24084 function Text3({
24085 data,
24086 field,
24087 onChange,
24088 hideLabelFromVision,
24089 markWhenOptional,
24090 config,
24091 validity
24092 }) {
24093 const { prefix, suffix } = config || {};
24094 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24095 ValidatedText,
24096 {
24097 ...{
24098 data,
24099 field,
24100 onChange,
24101 hideLabelFromVision,
24102 markWhenOptional,
24103 validity,
24104 prefix: prefix ? (0, import_element67.createElement)(prefix) : void 0,
24105 suffix: suffix ? (0, import_element67.createElement)(suffix) : void 0
24106 }
24107 }
24108 );
24109 }
24110
24111 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24112 var import_components40 = __toESM(require_components(), 1);
24113 var import_element68 = __toESM(require_element(), 1);
24114 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24115 var { ValidatedToggleControl } = unlock3(import_components40.privateApis);
24116 function Toggle({
24117 field,
24118 onChange,
24119 data,
24120 hideLabelFromVision,
24121 markWhenOptional,
24122 validity
24123 }) {
24124 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24125 const disabled2 = field.isDisabled({ item: data, field });
24126 const onChangeControl = (0, import_element68.useCallback)(() => {
24127 onChange(
24128 setValue({ item: data, value: !getValue({ item: data }) })
24129 );
24130 }, [onChange, setValue, data, getValue]);
24131 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24132 ValidatedToggleControl,
24133 {
24134 required: !!isValid2.required,
24135 markWhenOptional,
24136 customValidity: getCustomValidity(isValid2, validity),
24137 hidden: hideLabelFromVision,
24138 label,
24139 help: description,
24140 checked: getValue({ item: data }),
24141 onChange: onChangeControl,
24142 disabled: disabled2
24143 }
24144 );
24145 }
24146
24147 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24148 var import_components41 = __toESM(require_components(), 1);
24149 var import_element69 = __toESM(require_element(), 1);
24150 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24151 var { ValidatedTextareaControl } = unlock3(import_components41.privateApis);
24152 function Textarea({
24153 data,
24154 field,
24155 onChange,
24156 hideLabelFromVision,
24157 markWhenOptional,
24158 config,
24159 validity
24160 }) {
24161 const { rows = 4 } = config || {};
24162 const disabled2 = field.isDisabled({ item: data, field });
24163 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24164 const value = field.getValue({ item: data });
24165 const onChangeControl = (0, import_element69.useCallback)(
24166 (newValue) => onChange(setValue({ item: data, value: newValue })),
24167 [data, onChange, setValue]
24168 );
24169 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24170 ValidatedTextareaControl,
24171 {
24172 required: !!isValid2.required,
24173 markWhenOptional,
24174 customValidity: getCustomValidity(isValid2, validity),
24175 label,
24176 placeholder,
24177 value: value ?? "",
24178 help: description,
24179 onChange: onChangeControl,
24180 rows,
24181 disabled: disabled2,
24182 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24183 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24184 __next40pxDefaultSize: true,
24185 hideLabelFromVision
24186 }
24187 );
24188 }
24189
24190 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24191 var import_element71 = __toESM(require_element(), 1);
24192
24193 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24194 var import_components42 = __toESM(require_components(), 1);
24195 var import_compose12 = __toESM(require_compose(), 1);
24196 var import_element70 = __toESM(require_element(), 1);
24197 var import_rich_text2 = __toESM(require_rich_text(), 1);
24198
24199 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24200 var EMPTY_ARRAY6 = [];
24201 function getAllowedFormats({
24202 allowedFormats,
24203 disableFormats
24204 }) {
24205 if (disableFormats) {
24206 return EMPTY_ARRAY6;
24207 }
24208 return allowedFormats;
24209 }
24210
24211 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24212 var import_rich_text = __toESM(require_rich_text(), 1);
24213 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24214 var import_react24 = __toESM(require_react(), 1);
24215 var EMPTY_CONTEXT = {};
24216 function Edit({
24217 onChange,
24218 onFocus,
24219 value,
24220 forwardedRef,
24221 settings,
24222 isVisible: isVisible2
24223 }) {
24224 const { name, edit: EditFunction } = settings;
24225 if (!EditFunction) {
24226 return null;
24227 }
24228 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24229 const isActive = activeFormat !== void 0;
24230 const activeObject = (0, import_rich_text.getActiveObject)(value);
24231 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24232 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24233 EditFunction,
24234 {
24235 isActive,
24236 isVisible: isVisible2,
24237 activeAttributes: isActive ? activeFormat.attributes || {} : {},
24238 isObjectActive,
24239 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24240 value,
24241 onChange,
24242 onFocus,
24243 contentRef: forwardedRef,
24244 context: EMPTY_CONTEXT
24245 },
24246 name
24247 );
24248 }
24249 function FormatEdit({
24250 formatTypes,
24251 ...props
24252 }) {
24253 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react24.createElement)(Edit, { settings, ...props, key: settings.name }));
24254 }
24255
24256 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24257 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24258 var {
24259 ValidatedContentEditableControl: RichTextControlShell,
24260 withIgnoreIMEEvents
24261 } = unlock3(import_components42.privateApis);
24262 var {
24263 useRichText,
24264 KeyboardShortcutContext,
24265 InputEventContext,
24266 shortcutsListener,
24267 inputEventsListener
24268 } = unlock3(import_rich_text2.privateApis);
24269 var EMPTY_COMPLETERS = [];
24270 function RichTextControl({
24271 label,
24272 value: attrValue,
24273 onChange,
24274 placeholder,
24275 id,
24276 clientId,
24277 className,
24278 hideLabelFromVision,
24279 help,
24280 disabled: disabled2,
24281 required,
24282 markWhenOptional,
24283 customValidity,
24284 allowedFormats,
24285 disableFormats,
24286 withoutInteractiveFormatting,
24287 preserveWhiteSpace,
24288 disableLineBreaks,
24289 focusOnMount,
24290 completers = EMPTY_COMPLETERS
24291 }) {
24292 const [selection, setSelection] = (0, import_element70.useState)({
24293 start: void 0,
24294 end: void 0
24295 });
24296 const [isSelected2, setIsSelected] = (0, import_element70.useState)(false);
24297 const anchorRef = (0, import_element70.useRef)(void 0);
24298 const inputEvents = (0, import_element70.useRef)(/* @__PURE__ */ new Set());
24299 const keyboardShortcuts = (0, import_element70.useRef)(
24300 /* @__PURE__ */ new Set()
24301 );
24302 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24303 const adjustedAllowedFormats = getAllowedFormats({
24304 allowedFormats,
24305 disableFormats
24306 });
24307 const {
24308 value,
24309 onChange: onRichTextChange,
24310 ref: richTextRef,
24311 formatTypes,
24312 getValue
24313 } = useRichText({
24314 value: attrValue,
24315 onChange,
24316 selectionStart: selection.start,
24317 selectionEnd: selection.end,
24318 onSelectionChange: (start, end) => setSelection({ start, end }),
24319 __unstableIsSelected: isSelected2,
24320 preserveWhiteSpace: !!preserveWhiteSpace,
24321 placeholder,
24322 __unstableDisableFormats: disableFormats,
24323 allowedFormats: adjustedAllowedFormats,
24324 withoutInteractiveFormatting,
24325 __unstableFormatTypeHandlerContext: (0, import_element70.useMemo)(
24326 () => ({
24327 richTextIdentifier: id,
24328 blockClientId: clientId
24329 }),
24330 [id, clientId]
24331 )
24332 });
24333 function onFocus() {
24334 anchorRef.current?.focus();
24335 }
24336 const eventListenersPropsRef = (0, import_element70.useRef)({
24337 keyboardShortcuts,
24338 inputEvents
24339 });
24340 const inputRulePropsRef = (0, import_element70.useRef)({
24341 formatTypes,
24342 getValue,
24343 onChange: onRichTextChange
24344 });
24345 (0, import_element70.useInsertionEffect)(() => {
24346 inputRulePropsRef.current = {
24347 formatTypes,
24348 getValue,
24349 onChange: onRichTextChange
24350 };
24351 });
24352 const enterRef = (0, import_compose12.useRefEffect)(
24353 (element) => {
24354 if (disabled2) {
24355 return;
24356 }
24357 const onKeyDown = withIgnoreIMEEvents((event) => {
24358 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24359 return;
24360 }
24361 event.preventDefault();
24362 if (disableLineBreaks) {
24363 return;
24364 }
24365 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24366 const current = getCurrentValue2();
24367 handleChange(
24368 (0, import_rich_text2.insert)(
24369 current,
24370 "\n",
24371 current.start ?? current.text.length,
24372 current.end ?? current.text.length
24373 )
24374 );
24375 });
24376 element.addEventListener("keydown", onKeyDown);
24377 return () => element.removeEventListener("keydown", onKeyDown);
24378 },
24379 [disableLineBreaks, disabled2]
24380 );
24381 const eventListenersRef = (0, import_compose12.useRefEffect)(
24382 (element) => {
24383 if (!isSelected2) {
24384 return;
24385 }
24386 const cleanupShortcuts = shortcutsListener(
24387 eventListenersPropsRef
24388 )(element);
24389 const cleanupInputEvents = inputEventsListener(
24390 eventListenersPropsRef
24391 )(element);
24392 function onFormatInput(event) {
24393 if (event.inputType !== "insertText" && event.type !== "compositionend") {
24394 return;
24395 }
24396 const {
24397 formatTypes: types,
24398 getValue: getCurrentValue2,
24399 onChange: handleChange
24400 } = inputRulePropsRef.current;
24401 const current = getCurrentValue2();
24402 const transformed = types.reduce(
24403 (accumulator, {
24404 __unstableInputRule
24405 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24406 current
24407 );
24408 if (transformed !== current) {
24409 handleChange({
24410 ...transformed,
24411 activeFormats: current.activeFormats
24412 });
24413 }
24414 }
24415 element.addEventListener("input", onFormatInput);
24416 element.addEventListener("compositionend", onFormatInput);
24417 return () => {
24418 cleanupShortcuts();
24419 cleanupInputEvents();
24420 element.removeEventListener("input", onFormatInput);
24421 element.removeEventListener("compositionend", onFormatInput);
24422 };
24423 },
24424 [isSelected2]
24425 );
24426 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24427 {
24428 completers,
24429 record: value,
24430 onChange: onRichTextChange,
24431 // This control's completers insert their completion into the value;
24432 // none replace the whole value, so the required `onReplace` is a
24433 // no-op here.
24434 onReplace: () => {
24435 }
24436 }
24437 );
24438 const focusOnMountRef = (0, import_compose12.useRefEffect)(
24439 (element) => {
24440 if (focusOnMount && !disabled2) {
24441 element.focus();
24442 }
24443 },
24444 [focusOnMount, disabled2]
24445 );
24446 const editableRef = (0, import_compose12.useMergeRefs)([
24447 richTextRef,
24448 anchorRef,
24449 eventListenersRef,
24450 enterRef,
24451 focusOnMountRef,
24452 autocompleteRef
24453 ]);
24454 return (
24455 // Focus boundary for the field's selection: `onFocus` selects on entry;
24456 // the spread `useFocusOutside` handlers deselect once focus leaves.
24457 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24458 "div",
24459 {
24460 ...focusOutside,
24461 onFocus: (event) => {
24462 setIsSelected(true);
24463 focusOutside.onFocus(event);
24464 },
24465 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_components42.SlotFillProvider, { children: [
24466 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24467 RichTextControlShell,
24468 {
24469 label,
24470 id,
24471 className: clsx_default(
24472 "dataviews-controls__richtext",
24473 className
24474 ),
24475 placeholder,
24476 hideLabelFromVision,
24477 help,
24478 disabled: disabled2,
24479 required,
24480 markWhenOptional,
24481 customValidity,
24482 value: value.text,
24483 "aria-multiline": !disableLineBreaks,
24484 ...autocompleteProps,
24485 ref: editableRef
24486 }
24487 ),
24488 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24489 KeyboardShortcutContext.Provider,
24490 {
24491 value: keyboardShortcuts,
24492 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24493 FormatEdit,
24494 {
24495 value,
24496 onChange: onRichTextChange,
24497 onFocus,
24498 formatTypes,
24499 forwardedRef: anchorRef,
24500 isVisible: true
24501 }
24502 ) })
24503 }
24504 )
24505 ] })
24506 }
24507 )
24508 );
24509 }
24510
24511 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24512 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24513 function RichText({
24514 data,
24515 field,
24516 onChange,
24517 hideLabelFromVision,
24518 markWhenOptional,
24519 config,
24520 validity
24521 }) {
24522 const {
24523 className,
24524 clientId,
24525 allowedFormats,
24526 disableFormats,
24527 withoutInteractiveFormatting,
24528 preserveWhiteSpace,
24529 disableLineBreaks
24530 } = config || {};
24531 const disabled2 = field.isDisabled({ item: data, field });
24532 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24533 const value = field.getValue({ item: data }) ?? "";
24534 const onChangeControl = (0, import_element71.useCallback)(
24535 (newValue) => onChange(setValue({ item: data, value: newValue })),
24536 [data, onChange, setValue]
24537 );
24538 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24539 RichTextControl,
24540 {
24541 label,
24542 value,
24543 onChange: onChangeControl,
24544 placeholder,
24545 id,
24546 hideLabelFromVision,
24547 help: description,
24548 disabled: disabled2,
24549 required: !!isValid2.required,
24550 markWhenOptional,
24551 customValidity: getCustomValidity(isValid2, validity),
24552 className,
24553 clientId,
24554 allowedFormats,
24555 disableFormats,
24556 withoutInteractiveFormatting,
24557 preserveWhiteSpace,
24558 disableLineBreaks
24559 }
24560 );
24561 }
24562
24563 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24564 var import_components43 = __toESM(require_components(), 1);
24565 var import_element72 = __toESM(require_element(), 1);
24566 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24567 var { ValidatedToggleGroupControl } = unlock3(import_components43.privateApis);
24568 function ToggleGroup({
24569 data,
24570 field,
24571 onChange,
24572 hideLabelFromVision,
24573 markWhenOptional,
24574 validity
24575 }) {
24576 const { getValue, setValue, isValid: isValid2 } = field;
24577 const disabled2 = field.isDisabled({ item: data, field });
24578 const value = getValue({ item: data });
24579 const onChangeControl = (0, import_element72.useCallback)(
24580 (newValue) => onChange(setValue({ item: data, value: newValue })),
24581 [data, onChange, setValue]
24582 );
24583 const { elements, isLoading } = useElements({
24584 elements: field.elements,
24585 getElements: field.getElements
24586 });
24587 if (isLoading) {
24588 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components43.Spinner, {});
24589 }
24590 if (elements.length === 0) {
24591 return null;
24592 }
24593 const selectedOption = elements.find((el) => el.value === value);
24594 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24595 ValidatedToggleGroupControl,
24596 {
24597 required: !!field.isValid?.required,
24598 markWhenOptional,
24599 customValidity: getCustomValidity(isValid2, validity),
24600 isBlock: true,
24601 label: field.label,
24602 help: selectedOption?.description || field.description,
24603 onChange: onChangeControl,
24604 value,
24605 hideLabelFromVision,
24606 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24607 import_components43.__experimentalToggleGroupControlOption,
24608 {
24609 label: el.label,
24610 value: el.value,
24611 disabled: disabled2
24612 },
24613 el.value
24614 ))
24615 }
24616 );
24617 }
24618
24619 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24620 var import_components44 = __toESM(require_components(), 1);
24621 var import_element73 = __toESM(require_element(), 1);
24622 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24623 var { ValidatedFormTokenField } = unlock3(import_components44.privateApis);
24624 function ArrayControl({
24625 data,
24626 field,
24627 onChange,
24628 hideLabelFromVision,
24629 markWhenOptional,
24630 validity
24631 }) {
24632 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24633 const value = getValue({ item: data });
24634 const disabled2 = field.isDisabled({ item: data, field });
24635 const { elements, isLoading } = useElements({
24636 elements: field.elements,
24637 getElements: field.getElements
24638 });
24639 const arrayValueAsElements = (0, import_element73.useMemo)(
24640 () => Array.isArray(value) ? value.map((token) => {
24641 const element = elements?.find(
24642 (suggestion) => suggestion.value === token
24643 );
24644 return element || { value: token, label: token };
24645 }) : [],
24646 [value, elements]
24647 );
24648 const onChangeControl = (0, import_element73.useCallback)(
24649 (tokens) => {
24650 const valueTokens = tokens.map((token) => {
24651 if (typeof token === "object" && "value" in token) {
24652 return token.value;
24653 }
24654 return token;
24655 });
24656 onChange(setValue({ item: data, value: valueTokens }));
24657 },
24658 [onChange, setValue, data]
24659 );
24660 if (isLoading) {
24661 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components44.Spinner, {});
24662 }
24663 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24664 ValidatedFormTokenField,
24665 {
24666 required: !!isValid2?.required,
24667 markWhenOptional,
24668 customValidity: getCustomValidity(isValid2, validity),
24669 label: hideLabelFromVision ? void 0 : label,
24670 value: arrayValueAsElements,
24671 onChange: onChangeControl,
24672 placeholder,
24673 suggestions: elements?.map((element) => element.value),
24674 disabled: disabled2,
24675 __experimentalValidateInput: (token) => {
24676 if (field.isValid?.elements && elements) {
24677 return elements.some(
24678 (element) => element.value === token || element.label === token
24679 );
24680 }
24681 return true;
24682 },
24683 __experimentalExpandOnFocus: elements && elements.length > 0,
24684 help: description ?? (field.isValid?.elements ? "" : void 0),
24685 displayTransform: (token) => {
24686 if (typeof token === "object" && "label" in token) {
24687 return token.label;
24688 }
24689 if (typeof token === "string" && elements) {
24690 const element = elements.find(
24691 (el) => el.value === token
24692 );
24693 return element?.label || token;
24694 }
24695 return token;
24696 },
24697 __experimentalRenderItem: ({ item }) => {
24698 if (typeof item === "string" && elements) {
24699 const element = elements.find(
24700 (el) => el.value === item
24701 );
24702 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { children: element?.label || item });
24703 }
24704 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { children: item });
24705 }
24706 }
24707 );
24708 }
24709
24710 // node_modules/colord/index.mjs
24711 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24712 var t = function(r3) {
24713 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24714 };
24715 var n = function(r3, t2, n2) {
24716 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24717 };
24718 var e = function(r3, t2, n2) {
24719 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24720 };
24721 var u = function(r3) {
24722 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24723 };
24724 var a = function(r3) {
24725 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24726 };
24727 var o = function(r3) {
24728 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24729 };
24730 var i = /^#([0-9a-f]{3,8})$/i;
24731 var s = function(r3) {
24732 var t2 = r3.toString(16);
24733 return t2.length < 2 ? "0" + t2 : t2;
24734 };
24735 var h = function(r3) {
24736 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;
24737 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24738 };
24739 var b = function(r3) {
24740 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24741 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24742 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;
24743 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 };
24744 };
24745 var g = function(r3) {
24746 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24747 };
24748 var d = function(r3) {
24749 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24750 };
24751 var f = function(r3) {
24752 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 }));
24753 var t2, n2, e2;
24754 };
24755 var c = function(r3) {
24756 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 };
24757 var t2, n2, e2, u2;
24758 };
24759 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24760 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24761 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24762 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24763 var y = { string: [[function(r3) {
24764 var t2 = i.exec(r3);
24765 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;
24766 }, "hex"], [function(r3) {
24767 var t2 = v.exec(r3) || m.exec(r3);
24768 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;
24769 }, "rgb"], [function(t2) {
24770 var n2 = l.exec(t2) || p.exec(t2);
24771 if (!n2) return null;
24772 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) });
24773 return f(a2);
24774 }, "hsl"]], object: [[function(r3) {
24775 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24776 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24777 }, "rgb"], [function(r3) {
24778 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24779 if (!t(n2) || !t(e2) || !t(u2)) return null;
24780 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24781 return f(i2);
24782 }, "hsl"], [function(r3) {
24783 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24784 if (!t(n2) || !t(a2) || !t(o2)) return null;
24785 var h2 = (function(r4) {
24786 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24787 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24788 return b(h2);
24789 }, "hsv"]] };
24790 var N = function(r3, t2) {
24791 for (var n2 = 0; n2 < t2.length; n2++) {
24792 var e2 = t2[n2][0](r3);
24793 if (e2) return [e2, t2[n2][1]];
24794 }
24795 return [null, void 0];
24796 };
24797 var x = function(r3) {
24798 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24799 };
24800 var M = function(r3, t2) {
24801 var n2 = c(r3);
24802 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24803 };
24804 var H = function(r3) {
24805 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24806 };
24807 var $ = function(r3, t2) {
24808 var n2 = c(r3);
24809 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24810 };
24811 var j = (function() {
24812 function r3(r4) {
24813 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24814 }
24815 return r3.prototype.isValid = function() {
24816 return null !== this.parsed;
24817 }, r3.prototype.brightness = function() {
24818 return n(H(this.rgba), 2);
24819 }, r3.prototype.isDark = function() {
24820 return H(this.rgba) < 0.5;
24821 }, r3.prototype.isLight = function() {
24822 return H(this.rgba) >= 0.5;
24823 }, r3.prototype.toHex = function() {
24824 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;
24825 var r4, t2, e2, u2, a2, i2;
24826 }, r3.prototype.toRgb = function() {
24827 return o(this.rgba);
24828 }, r3.prototype.toRgbString = function() {
24829 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 + ")";
24830 var r4, t2, n2, e2, u2;
24831 }, r3.prototype.toHsl = function() {
24832 return d(c(this.rgba));
24833 }, r3.prototype.toHslString = function() {
24834 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 + "%)";
24835 var r4, t2, n2, e2, u2;
24836 }, r3.prototype.toHsv = function() {
24837 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24838 var r4;
24839 }, r3.prototype.invert = function() {
24840 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24841 var r4;
24842 }, r3.prototype.saturate = function(r4) {
24843 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24844 }, r3.prototype.desaturate = function(r4) {
24845 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24846 }, r3.prototype.grayscale = function() {
24847 return w(M(this.rgba, -1));
24848 }, r3.prototype.lighten = function(r4) {
24849 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24850 }, r3.prototype.darken = function(r4) {
24851 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24852 }, r3.prototype.rotate = function(r4) {
24853 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24854 }, r3.prototype.alpha = function(r4) {
24855 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24856 var t2;
24857 }, r3.prototype.hue = function(r4) {
24858 var t2 = c(this.rgba);
24859 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24860 }, r3.prototype.isEqual = function(r4) {
24861 return this.toHex() === w(r4).toHex();
24862 }, r3;
24863 })();
24864 var w = function(r3) {
24865 return r3 instanceof j ? r3 : new j(r3);
24866 };
24867
24868 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24869 var import_components45 = __toESM(require_components(), 1);
24870 var import_element74 = __toESM(require_element(), 1);
24871 var import_i18n36 = __toESM(require_i18n(), 1);
24872 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24873 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components45.privateApis);
24874 var ColorPickerDropdown = ({
24875 color,
24876 onColorChange,
24877 disabled: disabled2
24878 }) => {
24879 const validColor = color && w(color).isValid() ? color : "#ffffff";
24880 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24881 import_components45.Dropdown,
24882 {
24883 className: "dataviews-controls__color-picker-dropdown",
24884 popoverProps: { resize: false },
24885 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24886 import_components45.Button,
24887 {
24888 onClick: onToggle,
24889 "aria-label": (0, import_i18n36.__)("Open color picker"),
24890 size: "small",
24891 disabled: disabled2,
24892 accessibleWhenDisabled: true,
24893 icon: () => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
24894 }
24895 ),
24896 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24897 import_components45.ColorPicker,
24898 {
24899 color: validColor,
24900 onChange: onColorChange,
24901 enableAlpha: true
24902 }
24903 ) })
24904 }
24905 );
24906 };
24907 function Color({
24908 data,
24909 field,
24910 onChange,
24911 hideLabelFromVision,
24912 markWhenOptional,
24913 validity
24914 }) {
24915 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24916 const disabled2 = field.isDisabled({ item: data, field });
24917 const value = field.getValue({ item: data }) || "";
24918 const handleColorChange = (0, import_element74.useCallback)(
24919 (newColor) => {
24920 onChange(setValue({ item: data, value: newColor }));
24921 },
24922 [data, onChange, setValue]
24923 );
24924 const handleInputChange = (0, import_element74.useCallback)(
24925 (newValue) => {
24926 onChange(setValue({ item: data, value: newValue || "" }));
24927 },
24928 [data, onChange, setValue]
24929 );
24930 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24931 ValidatedInputControl3,
24932 {
24933 required: !!field.isValid?.required,
24934 markWhenOptional,
24935 customValidity: getCustomValidity(isValid2, validity),
24936 label,
24937 placeholder,
24938 value,
24939 help: description,
24940 onChange: handleInputChange,
24941 hideLabelFromVision,
24942 type: "text",
24943 disabled: disabled2,
24944 prefix: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24945 ColorPickerDropdown,
24946 {
24947 color: value,
24948 onColorChange: handleColorChange,
24949 disabled: disabled2
24950 }
24951 ) })
24952 }
24953 );
24954 }
24955
24956 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24957 var import_components46 = __toESM(require_components(), 1);
24958 var import_element75 = __toESM(require_element(), 1);
24959 var import_i18n37 = __toESM(require_i18n(), 1);
24960 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24961 function Password({
24962 data,
24963 field,
24964 onChange,
24965 hideLabelFromVision,
24966 markWhenOptional,
24967 validity
24968 }) {
24969 const [isVisible2, setIsVisible] = (0, import_element75.useState)(false);
24970 const disabled2 = field.isDisabled({ item: data, field });
24971 const toggleVisibility = (0, import_element75.useCallback)(() => {
24972 setIsVisible((prev) => !prev);
24973 }, []);
24974 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24975 ValidatedText,
24976 {
24977 ...{
24978 data,
24979 field,
24980 onChange,
24981 hideLabelFromVision,
24982 markWhenOptional,
24983 validity,
24984 type: isVisible2 ? "text" : "password",
24985 suffix: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24986 import_components46.Button,
24987 {
24988 icon: isVisible2 ? unseen_default : seen_default,
24989 onClick: toggleVisibility,
24990 size: "small",
24991 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24992 disabled: disabled2,
24993 accessibleWhenDisabled: true
24994 }
24995 ) })
24996 }
24997 }
24998 );
24999 }
25000
25001 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25002 function hasElements(field) {
25003 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25004 }
25005
25006 // packages/dataviews/build-module/components/dataform-controls/index.mjs
25007 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25008 var FORM_CONTROLS = {
25009 adaptiveSelect: AdaptiveSelect,
25010 array: ArrayControl,
25011 checkbox: Checkbox,
25012 color: Color,
25013 combobox: Combobox3,
25014 datetime: DateTime,
25015 date: DateControl,
25016 email: Email,
25017 telephone: Telephone,
25018 url: Url,
25019 integer: Integer,
25020 number: Number2,
25021 password: Password,
25022 radio: Radio,
25023 select: Select,
25024 text: Text3,
25025 toggle: Toggle,
25026 textarea: Textarea,
25027 richtext: RichText,
25028 toggleGroup: ToggleGroup
25029 };
25030 function isEditConfig(value) {
25031 return value && typeof value === "object" && typeof value.control === "string";
25032 }
25033 function createConfiguredControl(config) {
25034 const { control, ...controlConfig } = config;
25035 const BaseControlType = getControlByType(control);
25036 if (BaseControlType === null) {
25037 return null;
25038 }
25039 return function ConfiguredControl(props) {
25040 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(BaseControlType, { ...props, config: controlConfig });
25041 };
25042 }
25043 function getControl(field, fallback) {
25044 if (typeof field.Edit === "function") {
25045 return field.Edit;
25046 }
25047 if (typeof field.Edit === "string") {
25048 return getControlByType(field.Edit);
25049 }
25050 if (isEditConfig(field.Edit)) {
25051 return createConfiguredControl(field.Edit);
25052 }
25053 if (hasElements(field) && field.type !== "array") {
25054 return getControlByType("adaptiveSelect");
25055 }
25056 if (fallback === null) {
25057 return null;
25058 }
25059 return getControlByType(fallback);
25060 }
25061 function getControlByType(type) {
25062 if (Object.keys(FORM_CONTROLS).includes(type)) {
25063 return FORM_CONTROLS[type];
25064 }
25065 return null;
25066 }
25067
25068 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25069 function getFilterBy(field, defaultOperators, validOperators) {
25070 if (field.filterBy === false) {
25071 return false;
25072 }
25073 const operators = field.filterBy?.operators?.filter(
25074 (op) => validOperators.includes(op)
25075 ) ?? defaultOperators;
25076 if (operators.length === 0) {
25077 return false;
25078 }
25079 return {
25080 isPrimary: !!field.filterBy?.isPrimary,
25081 operators
25082 };
25083 }
25084 var get_filter_by_default = getFilterBy;
25085
25086 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25087 var getValueFromId = (id) => ({ item }) => {
25088 const path = id.split(".");
25089 let value = item;
25090 for (const segment of path) {
25091 if (value.hasOwnProperty(segment)) {
25092 value = value[segment];
25093 } else {
25094 value = void 0;
25095 }
25096 }
25097 return value;
25098 };
25099 var get_value_from_id_default = getValueFromId;
25100
25101 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25102 var setValueFromId = (id) => ({ value }) => {
25103 const path = id.split(".");
25104 const result = {};
25105 let current = result;
25106 for (const segment of path.slice(0, -1)) {
25107 current[segment] = {};
25108 current = current[segment];
25109 }
25110 current[path.at(-1)] = value;
25111 return result;
25112 };
25113 var set_value_from_id_default = setValueFromId;
25114
25115 // packages/dataviews/build-module/field-types/email.mjs
25116 var import_i18n38 = __toESM(require_i18n(), 1);
25117
25118 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25119 function RenderFromElements({
25120 item,
25121 field
25122 }) {
25123 const { elements, isLoading } = useElements({
25124 elements: field.elements,
25125 getElements: field.getElements
25126 });
25127 const value = field.getValue({ item });
25128 if (isLoading) {
25129 return value;
25130 }
25131 if (elements.length === 0) {
25132 return value;
25133 }
25134 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25135 }
25136
25137 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25138 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25139 function render({
25140 item,
25141 field
25142 }) {
25143 if (field.hasElements) {
25144 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RenderFromElements, { item, field });
25145 }
25146 return field.getValueFormatted({ item, field });
25147 }
25148
25149 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25150 var sort_text_default = (a2, b2, direction) => {
25151 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25152 };
25153
25154 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25155 function isValidRequired(item, field) {
25156 const value = field.getValue({ item });
25157 return ![void 0, "", null].includes(value);
25158 }
25159
25160 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25161 function isValidMinLength(item, field) {
25162 if (typeof field.isValid.minLength?.constraint !== "number") {
25163 return false;
25164 }
25165 const value = field.getValue({ item });
25166 if ([void 0, "", null].includes(value)) {
25167 return true;
25168 }
25169 return String(value).length >= field.isValid.minLength.constraint;
25170 }
25171
25172 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25173 function isValidMaxLength(item, field) {
25174 if (typeof field.isValid.maxLength?.constraint !== "number") {
25175 return false;
25176 }
25177 const value = field.getValue({ item });
25178 if ([void 0, "", null].includes(value)) {
25179 return true;
25180 }
25181 return String(value).length <= field.isValid.maxLength.constraint;
25182 }
25183
25184 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25185 function isValidPattern(item, field) {
25186 if (field.isValid.pattern?.constraint === void 0) {
25187 return true;
25188 }
25189 try {
25190 const regexp = new RegExp(field.isValid.pattern.constraint);
25191 const value = field.getValue({ item });
25192 if ([void 0, "", null].includes(value)) {
25193 return true;
25194 }
25195 return regexp.test(String(value));
25196 } catch {
25197 return false;
25198 }
25199 }
25200
25201 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25202 function isValidElements(item, field) {
25203 const elements = field.elements ?? [];
25204 const validValues = elements.map((el) => el.value);
25205 if (validValues.length === 0) {
25206 return true;
25207 }
25208 const value = field.getValue({ item });
25209 return [].concat(value).every((v2) => validValues.includes(v2));
25210 }
25211
25212 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25213 function getValueFormatted({
25214 item,
25215 field
25216 }) {
25217 return field.getValue({ item });
25218 }
25219 var get_value_formatted_default_default = getValueFormatted;
25220
25221 // packages/dataviews/build-module/field-types/email.mjs
25222 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])?)*$/;
25223 function isValidCustom(item, field) {
25224 const value = field.getValue({ item });
25225 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25226 return (0, import_i18n38.__)("Value must be a valid email address.");
25227 }
25228 return null;
25229 }
25230 var email_default = {
25231 type: "email",
25232 render,
25233 Edit: "email",
25234 sort: sort_text_default,
25235 enableSorting: true,
25236 enableGlobalSearch: false,
25237 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25238 validOperators: [
25239 OPERATOR_IS,
25240 OPERATOR_IS_NOT,
25241 OPERATOR_CONTAINS,
25242 OPERATOR_NOT_CONTAINS,
25243 OPERATOR_STARTS_WITH,
25244 // Multiple selection
25245 OPERATOR_IS_ANY,
25246 OPERATOR_IS_NONE,
25247 OPERATOR_IS_ALL,
25248 OPERATOR_IS_NOT_ALL
25249 ],
25250 format: {},
25251 getValueFormatted: get_value_formatted_default_default,
25252 validate: {
25253 required: isValidRequired,
25254 pattern: isValidPattern,
25255 minLength: isValidMinLength,
25256 maxLength: isValidMaxLength,
25257 elements: isValidElements,
25258 custom: isValidCustom
25259 }
25260 };
25261
25262 // packages/dataviews/build-module/field-types/integer.mjs
25263 var import_i18n39 = __toESM(require_i18n(), 1);
25264
25265 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25266 var sort_number_default = (a2, b2, direction) => {
25267 return direction === "asc" ? a2 - b2 : b2 - a2;
25268 };
25269
25270 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25271 function isValidMin(item, field) {
25272 if (typeof field.isValid.min?.constraint !== "number") {
25273 return false;
25274 }
25275 const value = field.getValue({ item });
25276 if ([void 0, "", null].includes(value)) {
25277 return true;
25278 }
25279 return Number(value) >= field.isValid.min.constraint;
25280 }
25281
25282 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25283 function isValidMax(item, field) {
25284 if (typeof field.isValid.max?.constraint !== "number") {
25285 return false;
25286 }
25287 const value = field.getValue({ item });
25288 if ([void 0, "", null].includes(value)) {
25289 return true;
25290 }
25291 return Number(value) <= field.isValid.max.constraint;
25292 }
25293
25294 // packages/dataviews/build-module/field-types/integer.mjs
25295 var format2 = {
25296 separatorThousand: ","
25297 };
25298 function getValueFormatted2({
25299 item,
25300 field
25301 }) {
25302 let value = field.getValue({ item });
25303 if (value === null || value === void 0) {
25304 return "";
25305 }
25306 value = Number(value);
25307 if (!Number.isFinite(value)) {
25308 return String(value);
25309 }
25310 let formatInteger;
25311 if (field.type !== "integer") {
25312 formatInteger = format2;
25313 } else {
25314 formatInteger = field.format;
25315 }
25316 const { separatorThousand } = formatInteger;
25317 const integerValue = Math.trunc(value);
25318 if (!separatorThousand) {
25319 return String(integerValue);
25320 }
25321 return String(integerValue).replace(
25322 /\B(?=(\d{3})+(?!\d))/g,
25323 separatorThousand
25324 );
25325 }
25326 function isValidCustom2(item, field) {
25327 const value = field.getValue({ item });
25328 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25329 return (0, import_i18n39.__)("Value must be an integer.");
25330 }
25331 return null;
25332 }
25333 var integer_default = {
25334 type: "integer",
25335 render,
25336 Edit: "integer",
25337 sort: sort_number_default,
25338 enableSorting: true,
25339 enableGlobalSearch: false,
25340 defaultOperators: [
25341 OPERATOR_IS,
25342 OPERATOR_IS_NOT,
25343 OPERATOR_LESS_THAN,
25344 OPERATOR_GREATER_THAN,
25345 OPERATOR_LESS_THAN_OR_EQUAL,
25346 OPERATOR_GREATER_THAN_OR_EQUAL,
25347 OPERATOR_BETWEEN
25348 ],
25349 validOperators: [
25350 // Single-selection
25351 OPERATOR_IS,
25352 OPERATOR_IS_NOT,
25353 OPERATOR_LESS_THAN,
25354 OPERATOR_GREATER_THAN,
25355 OPERATOR_LESS_THAN_OR_EQUAL,
25356 OPERATOR_GREATER_THAN_OR_EQUAL,
25357 OPERATOR_BETWEEN,
25358 // Multiple-selection
25359 OPERATOR_IS_ANY,
25360 OPERATOR_IS_NONE,
25361 OPERATOR_IS_ALL,
25362 OPERATOR_IS_NOT_ALL
25363 ],
25364 format: format2,
25365 getValueFormatted: getValueFormatted2,
25366 validate: {
25367 required: isValidRequired,
25368 min: isValidMin,
25369 max: isValidMax,
25370 elements: isValidElements,
25371 custom: isValidCustom2
25372 }
25373 };
25374
25375 // packages/dataviews/build-module/field-types/number.mjs
25376 var import_i18n40 = __toESM(require_i18n(), 1);
25377 var format3 = {
25378 separatorThousand: ",",
25379 separatorDecimal: ".",
25380 decimals: 2
25381 };
25382 function getValueFormatted3({
25383 item,
25384 field
25385 }) {
25386 let value = field.getValue({ item });
25387 if (value === null || value === void 0) {
25388 return "";
25389 }
25390 value = Number(value);
25391 if (!Number.isFinite(value)) {
25392 return String(value);
25393 }
25394 let formatNumber;
25395 if (field.type !== "number") {
25396 formatNumber = format3;
25397 } else {
25398 formatNumber = field.format;
25399 }
25400 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25401 const fixedValue = value.toFixed(decimals);
25402 const [integerPart, decimalPart] = fixedValue.split(".");
25403 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25404 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25405 }
25406 function isEmpty(value) {
25407 return value === "" || value === void 0 || value === null;
25408 }
25409 function isValidCustom3(item, field) {
25410 const value = field.getValue({ item });
25411 if (!isEmpty(value) && !Number.isFinite(value)) {
25412 return (0, import_i18n40.__)("Value must be a number.");
25413 }
25414 return null;
25415 }
25416 var number_default = {
25417 type: "number",
25418 render,
25419 Edit: "number",
25420 sort: sort_number_default,
25421 enableSorting: true,
25422 enableGlobalSearch: false,
25423 defaultOperators: [
25424 OPERATOR_IS,
25425 OPERATOR_IS_NOT,
25426 OPERATOR_LESS_THAN,
25427 OPERATOR_GREATER_THAN,
25428 OPERATOR_LESS_THAN_OR_EQUAL,
25429 OPERATOR_GREATER_THAN_OR_EQUAL,
25430 OPERATOR_BETWEEN
25431 ],
25432 validOperators: [
25433 // Single-selection
25434 OPERATOR_IS,
25435 OPERATOR_IS_NOT,
25436 OPERATOR_LESS_THAN,
25437 OPERATOR_GREATER_THAN,
25438 OPERATOR_LESS_THAN_OR_EQUAL,
25439 OPERATOR_GREATER_THAN_OR_EQUAL,
25440 OPERATOR_BETWEEN,
25441 // Multiple-selection
25442 OPERATOR_IS_ANY,
25443 OPERATOR_IS_NONE,
25444 OPERATOR_IS_ALL,
25445 OPERATOR_IS_NOT_ALL
25446 ],
25447 format: format3,
25448 getValueFormatted: getValueFormatted3,
25449 validate: {
25450 required: isValidRequired,
25451 min: isValidMin,
25452 max: isValidMax,
25453 elements: isValidElements,
25454 custom: isValidCustom3
25455 }
25456 };
25457
25458 // packages/dataviews/build-module/field-types/text.mjs
25459 var text_default = {
25460 type: "text",
25461 render,
25462 Edit: "text",
25463 sort: sort_text_default,
25464 enableSorting: true,
25465 enableGlobalSearch: false,
25466 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25467 validOperators: [
25468 // Single selection
25469 OPERATOR_IS,
25470 OPERATOR_IS_NOT,
25471 OPERATOR_CONTAINS,
25472 OPERATOR_NOT_CONTAINS,
25473 OPERATOR_STARTS_WITH,
25474 // Multiple selection
25475 OPERATOR_IS_ANY,
25476 OPERATOR_IS_NONE,
25477 OPERATOR_IS_ALL,
25478 OPERATOR_IS_NOT_ALL
25479 ],
25480 format: {},
25481 getValueFormatted: get_value_formatted_default_default,
25482 validate: {
25483 required: isValidRequired,
25484 pattern: isValidPattern,
25485 minLength: isValidMinLength,
25486 maxLength: isValidMaxLength,
25487 elements: isValidElements
25488 }
25489 };
25490
25491 // packages/dataviews/build-module/field-types/datetime.mjs
25492 var import_date7 = __toESM(require_date(), 1);
25493
25494 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25495 var import_date6 = __toESM(require_date(), 1);
25496 function parseDateLike(value) {
25497 if (!value) {
25498 return null;
25499 }
25500 if (!isValid(new Date(value))) {
25501 return null;
25502 }
25503 const parsed = (0, import_date6.getDate)(value);
25504 return parsed && isValid(parsed) ? parsed : null;
25505 }
25506 function validateDateLikeBoundary(item, field, boundary) {
25507 const constraint = field.isValid[boundary]?.constraint;
25508 if (typeof constraint !== "string") {
25509 return false;
25510 }
25511 const value = field.getValue({ item });
25512 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25513 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25514 return true;
25515 }
25516 const parsedConstraint = parseDateLike(constraint);
25517 const parsedValue = parseDateLike(String(boundaryValue));
25518 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25519 }
25520 function isValidMinDate(item, field) {
25521 return validateDateLikeBoundary(item, field, "min");
25522 }
25523 function isValidMaxDate(item, field) {
25524 return validateDateLikeBoundary(item, field, "max");
25525 }
25526
25527 // packages/dataviews/build-module/field-types/datetime.mjs
25528 var format4 = {
25529 datetime: (0, import_date7.getSettings)().formats.datetime,
25530 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25531 };
25532 function getValueFormatted4({
25533 item,
25534 field
25535 }) {
25536 const value = field.getValue({ item });
25537 if (["", void 0, null].includes(value)) {
25538 return "";
25539 }
25540 let formatDatetime;
25541 if (field.type !== "datetime") {
25542 formatDatetime = format4;
25543 } else {
25544 formatDatetime = field.format;
25545 }
25546 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25547 }
25548 var sort = (a2, b2, direction) => {
25549 const timeA = new Date(a2).getTime();
25550 const timeB = new Date(b2).getTime();
25551 return direction === "asc" ? timeA - timeB : timeB - timeA;
25552 };
25553 var datetime_default = {
25554 type: "datetime",
25555 render,
25556 Edit: "datetime",
25557 sort,
25558 enableSorting: true,
25559 enableGlobalSearch: false,
25560 defaultOperators: [
25561 OPERATOR_ON,
25562 OPERATOR_NOT_ON,
25563 OPERATOR_BEFORE,
25564 OPERATOR_AFTER,
25565 OPERATOR_BEFORE_INC,
25566 OPERATOR_AFTER_INC,
25567 OPERATOR_IN_THE_PAST,
25568 OPERATOR_OVER
25569 ],
25570 validOperators: [
25571 OPERATOR_ON,
25572 OPERATOR_NOT_ON,
25573 OPERATOR_BEFORE,
25574 OPERATOR_AFTER,
25575 OPERATOR_BEFORE_INC,
25576 OPERATOR_AFTER_INC,
25577 OPERATOR_IN_THE_PAST,
25578 OPERATOR_OVER
25579 ],
25580 format: format4,
25581 getValueFormatted: getValueFormatted4,
25582 validate: {
25583 required: isValidRequired,
25584 elements: isValidElements,
25585 min: isValidMinDate,
25586 max: isValidMaxDate
25587 }
25588 };
25589
25590 // packages/dataviews/build-module/field-types/date.mjs
25591 var import_date8 = __toESM(require_date(), 1);
25592 var format5 = {
25593 date: (0, import_date8.getSettings)().formats.date,
25594 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25595 };
25596 function getValueFormatted5({
25597 item,
25598 field
25599 }) {
25600 const value = field.getValue({ item });
25601 if (["", void 0, null].includes(value)) {
25602 return "";
25603 }
25604 let formatDate2;
25605 if (field.type !== "date") {
25606 formatDate2 = format5;
25607 } else {
25608 formatDate2 = field.format;
25609 }
25610 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25611 }
25612 var sort2 = (a2, b2, direction) => {
25613 const timeA = new Date(a2).getTime();
25614 const timeB = new Date(b2).getTime();
25615 return direction === "asc" ? timeA - timeB : timeB - timeA;
25616 };
25617 var date_default = {
25618 type: "date",
25619 render,
25620 Edit: "date",
25621 sort: sort2,
25622 enableSorting: true,
25623 enableGlobalSearch: false,
25624 defaultOperators: [
25625 OPERATOR_ON,
25626 OPERATOR_NOT_ON,
25627 OPERATOR_BEFORE,
25628 OPERATOR_AFTER,
25629 OPERATOR_BEFORE_INC,
25630 OPERATOR_AFTER_INC,
25631 OPERATOR_IN_THE_PAST,
25632 OPERATOR_OVER,
25633 OPERATOR_BETWEEN
25634 ],
25635 validOperators: [
25636 OPERATOR_ON,
25637 OPERATOR_NOT_ON,
25638 OPERATOR_BEFORE,
25639 OPERATOR_AFTER,
25640 OPERATOR_BEFORE_INC,
25641 OPERATOR_AFTER_INC,
25642 OPERATOR_IN_THE_PAST,
25643 OPERATOR_OVER,
25644 OPERATOR_BETWEEN
25645 ],
25646 format: format5,
25647 getValueFormatted: getValueFormatted5,
25648 validate: {
25649 required: isValidRequired,
25650 elements: isValidElements,
25651 min: isValidMinDate,
25652 max: isValidMaxDate
25653 }
25654 };
25655
25656 // packages/dataviews/build-module/field-types/boolean.mjs
25657 var import_i18n41 = __toESM(require_i18n(), 1);
25658
25659 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25660 function isValidRequiredForBool(item, field) {
25661 const value = field.getValue({ item });
25662 return value === true;
25663 }
25664
25665 // packages/dataviews/build-module/field-types/boolean.mjs
25666 function getValueFormatted6({
25667 item,
25668 field
25669 }) {
25670 const value = field.getValue({ item });
25671 if (value === true) {
25672 return (0, import_i18n41.__)("True");
25673 }
25674 if (value === false) {
25675 return (0, import_i18n41.__)("False");
25676 }
25677 return "";
25678 }
25679 function isValidCustom4(item, field) {
25680 const value = field.getValue({ item });
25681 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25682 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25683 }
25684 return null;
25685 }
25686 var sort3 = (a2, b2, direction) => {
25687 const boolA = Boolean(a2);
25688 const boolB = Boolean(b2);
25689 if (boolA === boolB) {
25690 return 0;
25691 }
25692 if (direction === "asc") {
25693 return boolA ? 1 : -1;
25694 }
25695 return boolA ? -1 : 1;
25696 };
25697 var boolean_default = {
25698 type: "boolean",
25699 render,
25700 Edit: "checkbox",
25701 sort: sort3,
25702 validate: {
25703 required: isValidRequiredForBool,
25704 elements: isValidElements,
25705 custom: isValidCustom4
25706 },
25707 enableSorting: true,
25708 enableGlobalSearch: false,
25709 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25710 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25711 format: {},
25712 getValueFormatted: getValueFormatted6
25713 };
25714
25715 // packages/dataviews/build-module/field-types/media.mjs
25716 var media_default = {
25717 type: "media",
25718 render: () => null,
25719 Edit: null,
25720 sort: () => 0,
25721 enableSorting: false,
25722 enableGlobalSearch: false,
25723 defaultOperators: [],
25724 validOperators: [],
25725 format: {},
25726 getValueFormatted: get_value_formatted_default_default,
25727 // cannot validate any constraint, so
25728 // the only available validation for the field author
25729 // would be providing a custom validator.
25730 validate: {}
25731 };
25732
25733 // packages/dataviews/build-module/field-types/array.mjs
25734 var import_i18n42 = __toESM(require_i18n(), 1);
25735
25736 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25737 function isValidRequiredForArray(item, field) {
25738 const value = field.getValue({ item });
25739 return Array.isArray(value) && value.length > 0 && value.every(
25740 (element) => ![void 0, "", null].includes(element)
25741 );
25742 }
25743
25744 // packages/dataviews/build-module/field-types/array.mjs
25745 function getValueFormatted7({
25746 item,
25747 field
25748 }) {
25749 const value = field.getValue({ item });
25750 const arr = Array.isArray(value) ? value : [];
25751 return arr.join(", ");
25752 }
25753 function render2({ item, field }) {
25754 return getValueFormatted7({ item, field });
25755 }
25756 function isValidCustom5(item, field) {
25757 const value = field.getValue({ item });
25758 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25759 return (0, import_i18n42.__)("Value must be an array.");
25760 }
25761 if (!value.every((v2) => typeof v2 === "string")) {
25762 return (0, import_i18n42.__)("Every value must be a string.");
25763 }
25764 return null;
25765 }
25766 var sort4 = (a2, b2, direction) => {
25767 const arrA = Array.isArray(a2) ? a2 : [];
25768 const arrB = Array.isArray(b2) ? b2 : [];
25769 if (arrA.length !== arrB.length) {
25770 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25771 }
25772 const joinedA = arrA.join(",");
25773 const joinedB = arrB.join(",");
25774 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25775 };
25776 var array_default = {
25777 type: "array",
25778 render: render2,
25779 Edit: "array",
25780 sort: sort4,
25781 enableSorting: true,
25782 enableGlobalSearch: false,
25783 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25784 validOperators: [
25785 OPERATOR_IS_ANY,
25786 OPERATOR_IS_NONE,
25787 OPERATOR_IS_ALL,
25788 OPERATOR_IS_NOT_ALL
25789 ],
25790 format: {},
25791 getValueFormatted: getValueFormatted7,
25792 validate: {
25793 required: isValidRequiredForArray,
25794 elements: isValidElements,
25795 custom: isValidCustom5
25796 }
25797 };
25798
25799 // packages/dataviews/build-module/field-types/password.mjs
25800 function getValueFormatted8({
25801 item,
25802 field
25803 }) {
25804 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25805 }
25806 var password_default = {
25807 type: "password",
25808 render,
25809 Edit: "password",
25810 sort: () => 0,
25811 // Passwords should not be sortable for security reasons
25812 enableSorting: false,
25813 enableGlobalSearch: false,
25814 defaultOperators: [],
25815 validOperators: [],
25816 format: {},
25817 getValueFormatted: getValueFormatted8,
25818 validate: {
25819 required: isValidRequired,
25820 pattern: isValidPattern,
25821 minLength: isValidMinLength,
25822 maxLength: isValidMaxLength,
25823 elements: isValidElements
25824 }
25825 };
25826
25827 // packages/dataviews/build-module/field-types/telephone.mjs
25828 var telephone_default = {
25829 type: "telephone",
25830 render,
25831 Edit: "telephone",
25832 sort: sort_text_default,
25833 enableSorting: true,
25834 enableGlobalSearch: false,
25835 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25836 validOperators: [
25837 OPERATOR_IS,
25838 OPERATOR_IS_NOT,
25839 OPERATOR_CONTAINS,
25840 OPERATOR_NOT_CONTAINS,
25841 OPERATOR_STARTS_WITH,
25842 // Multiple selection
25843 OPERATOR_IS_ANY,
25844 OPERATOR_IS_NONE,
25845 OPERATOR_IS_ALL,
25846 OPERATOR_IS_NOT_ALL
25847 ],
25848 format: {},
25849 getValueFormatted: get_value_formatted_default_default,
25850 validate: {
25851 required: isValidRequired,
25852 pattern: isValidPattern,
25853 minLength: isValidMinLength,
25854 maxLength: isValidMaxLength,
25855 elements: isValidElements
25856 }
25857 };
25858
25859 // packages/dataviews/build-module/field-types/color.mjs
25860 var import_i18n43 = __toESM(require_i18n(), 1);
25861 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25862 function render3({ item, field }) {
25863 if (field.hasElements) {
25864 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(RenderFromElements, { item, field });
25865 }
25866 const value = get_value_formatted_default_default({ item, field });
25867 if (!value || !w(value).isValid()) {
25868 return value;
25869 }
25870 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25871 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25872 "div",
25873 {
25874 style: {
25875 width: "16px",
25876 height: "16px",
25877 borderRadius: "50%",
25878 backgroundColor: value,
25879 border: "1px solid #ddd",
25880 flexShrink: 0
25881 }
25882 }
25883 ),
25884 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: value })
25885 ] });
25886 }
25887 function isValidCustom6(item, field) {
25888 const value = field.getValue({ item });
25889 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25890 return (0, import_i18n43.__)("Value must be a valid color.");
25891 }
25892 return null;
25893 }
25894 var sort5 = (a2, b2, direction) => {
25895 const colorA = w(a2);
25896 const colorB = w(b2);
25897 if (!colorA.isValid() && !colorB.isValid()) {
25898 return 0;
25899 }
25900 if (!colorA.isValid()) {
25901 return direction === "asc" ? 1 : -1;
25902 }
25903 if (!colorB.isValid()) {
25904 return direction === "asc" ? -1 : 1;
25905 }
25906 const hslA = colorA.toHsl();
25907 const hslB = colorB.toHsl();
25908 if (hslA.h !== hslB.h) {
25909 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25910 }
25911 if (hslA.s !== hslB.s) {
25912 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25913 }
25914 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25915 };
25916 var color_default = {
25917 type: "color",
25918 render: render3,
25919 Edit: "color",
25920 sort: sort5,
25921 enableSorting: true,
25922 enableGlobalSearch: false,
25923 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25924 validOperators: [
25925 OPERATOR_IS,
25926 OPERATOR_IS_NOT,
25927 OPERATOR_IS_ANY,
25928 OPERATOR_IS_NONE
25929 ],
25930 format: {},
25931 getValueFormatted: get_value_formatted_default_default,
25932 validate: {
25933 required: isValidRequired,
25934 elements: isValidElements,
25935 custom: isValidCustom6
25936 }
25937 };
25938
25939 // packages/dataviews/build-module/field-types/url.mjs
25940 var url_default = {
25941 type: "url",
25942 render,
25943 Edit: "url",
25944 sort: sort_text_default,
25945 enableSorting: true,
25946 enableGlobalSearch: false,
25947 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25948 validOperators: [
25949 OPERATOR_IS,
25950 OPERATOR_IS_NOT,
25951 OPERATOR_CONTAINS,
25952 OPERATOR_NOT_CONTAINS,
25953 OPERATOR_STARTS_WITH,
25954 // Multiple selection
25955 OPERATOR_IS_ANY,
25956 OPERATOR_IS_NONE,
25957 OPERATOR_IS_ALL,
25958 OPERATOR_IS_NOT_ALL
25959 ],
25960 format: {},
25961 getValueFormatted: get_value_formatted_default_default,
25962 validate: {
25963 required: isValidRequired,
25964 pattern: isValidPattern,
25965 minLength: isValidMinLength,
25966 maxLength: isValidMaxLength,
25967 elements: isValidElements
25968 }
25969 };
25970
25971 // packages/dataviews/build-module/field-types/no-type.mjs
25972 var sort6 = (a2, b2, direction) => {
25973 if (typeof a2 === "number" && typeof b2 === "number") {
25974 return sort_number_default(a2, b2, direction);
25975 }
25976 return sort_text_default(a2, b2, direction);
25977 };
25978 var no_type_default = {
25979 // type: no type for this one
25980 render,
25981 Edit: null,
25982 sort: sort6,
25983 enableSorting: true,
25984 enableGlobalSearch: false,
25985 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25986 validOperators: getAllOperatorNames(),
25987 format: {},
25988 getValueFormatted: get_value_formatted_default_default,
25989 validate: {
25990 required: isValidRequired,
25991 elements: isValidElements
25992 }
25993 };
25994
25995 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25996 function supportsNumericRangeConstraint(type) {
25997 return type === "integer" || type === "number";
25998 }
25999 function supportsDateRangeConstraint(type) {
26000 return type === "date" || type === "datetime";
26001 }
26002 function normalizeRangeRule(value, fieldType, key) {
26003 const validator = fieldType.validate[key];
26004 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26005 return { constraint: value, validate: validator };
26006 }
26007 return void 0;
26008 }
26009 function getIsValid(field, fieldType) {
26010 const rules = field.isValid;
26011 let required;
26012 if (rules?.required === true && fieldType.validate.required !== void 0) {
26013 required = {
26014 constraint: true,
26015 validate: fieldType.validate.required
26016 };
26017 }
26018 let elements;
26019 if ((rules?.elements === true || // elements is enabled unless the field opts-out
26020 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26021 elements = {
26022 constraint: true,
26023 validate: fieldType.validate.elements
26024 };
26025 }
26026 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26027 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26028 const minLengthValue = rules?.minLength;
26029 let minLength;
26030 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26031 minLength = {
26032 constraint: minLengthValue,
26033 validate: fieldType.validate.minLength
26034 };
26035 }
26036 const maxLengthValue = rules?.maxLength;
26037 let maxLength;
26038 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26039 maxLength = {
26040 constraint: maxLengthValue,
26041 validate: fieldType.validate.maxLength
26042 };
26043 }
26044 const patternValue = rules?.pattern;
26045 let pattern;
26046 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26047 pattern = {
26048 constraint: patternValue,
26049 validate: fieldType.validate.pattern
26050 };
26051 }
26052 const custom = rules?.custom ?? fieldType.validate.custom;
26053 return {
26054 required,
26055 elements,
26056 min: min2,
26057 max: max2,
26058 minLength,
26059 maxLength,
26060 pattern,
26061 custom
26062 };
26063 }
26064
26065 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26066 function getFilter(fieldType) {
26067 return fieldType.validOperators.reduce((accumulator, operator) => {
26068 const operatorObj = getOperatorByName(operator);
26069 if (operatorObj?.filter) {
26070 accumulator[operator] = operatorObj.filter;
26071 }
26072 return accumulator;
26073 }, {});
26074 }
26075
26076 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26077 function getFormat(field, fieldType) {
26078 return {
26079 ...fieldType.format,
26080 ...field.format
26081 };
26082 }
26083 var get_format_default = getFormat;
26084
26085 // packages/dataviews/build-module/field-types/index.mjs
26086 function getFieldTypeByName(type) {
26087 const found = [
26088 email_default,
26089 integer_default,
26090 number_default,
26091 text_default,
26092 datetime_default,
26093 date_default,
26094 boolean_default,
26095 media_default,
26096 array_default,
26097 password_default,
26098 telephone_default,
26099 color_default,
26100 url_default
26101 ].find((fieldType) => fieldType?.type === type);
26102 if (!!found) {
26103 return found;
26104 }
26105 return no_type_default;
26106 }
26107 function normalizeFields(fields) {
26108 return fields.map((field) => {
26109 const fieldType = getFieldTypeByName(field.type);
26110 const getValue = field.getValue || get_value_from_id_default(field.id);
26111 const sort7 = function(a2, b2, direction) {
26112 const aValue = getValue({ item: a2 });
26113 const bValue = getValue({ item: b2 });
26114 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26115 };
26116 return {
26117 id: field.id,
26118 label: field.label || field.id,
26119 header: field.header || field.label || field.id,
26120 description: field.description,
26121 placeholder: field.placeholder,
26122 getValue,
26123 setValue: field.setValue || set_value_from_id_default(field.id),
26124 elements: field.elements,
26125 getElements: field.getElements,
26126 hasElements: hasElements(field),
26127 isVisible: field.isVisible,
26128 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26129 enableHiding: field.enableHiding ?? true,
26130 readOnly: field.readOnly ?? false,
26131 // The type provides defaults for the following props
26132 type: fieldType.type,
26133 render: field.render ?? fieldType.render,
26134 Edit: getControl(field, fieldType.Edit),
26135 sort: sort7,
26136 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26137 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26138 isValid: getIsValid(field, fieldType),
26139 filterBy: get_filter_by_default(
26140 field,
26141 fieldType.defaultOperators,
26142 fieldType.validOperators
26143 ),
26144 filter: getFilter(fieldType),
26145 format: get_format_default(field, fieldType),
26146 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26147 };
26148 });
26149 }
26150
26151 // packages/dataviews/build-module/hooks/use-data.mjs
26152 var import_element76 = __toESM(require_element(), 1);
26153 function useData({
26154 view,
26155 data: shownData,
26156 getItemId,
26157 isLoading,
26158 paginationInfo,
26159 selection
26160 }) {
26161 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26162 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element76.useState)(
26163 !isLoading
26164 );
26165 (0, import_element76.useEffect)(() => {
26166 if (!isLoading) {
26167 setHasInitiallyLoaded(true);
26168 }
26169 }, [isLoading]);
26170 const previousDataRef = (0, import_element76.useRef)(shownData);
26171 const previousPaginationInfoRef = (0, import_element76.useRef)(paginationInfo);
26172 (0, import_element76.useEffect)(() => {
26173 if (!isLoading) {
26174 previousDataRef.current = shownData;
26175 previousPaginationInfoRef.current = paginationInfo;
26176 }
26177 }, [shownData, isLoading, paginationInfo]);
26178 const [visibleEntries, setVisibleEntries] = (0, import_element76.useState)([]);
26179 const positionMapRef = (0, import_element76.useRef)(/* @__PURE__ */ new Map());
26180 const allLoadedRecordsRef = (0, import_element76.useRef)([]);
26181 const prevViewParamsRef = (0, import_element76.useRef)({
26182 search: void 0,
26183 filters: void 0,
26184 perPage: void 0
26185 });
26186 const scrollDirectionRef = (0, import_element76.useRef)(void 0);
26187 const prevStartPositionRef = (0, import_element76.useRef)(void 0);
26188 const hasInitializedRef = (0, import_element76.useRef)(false);
26189 const allLoadedRecords = (0, import_element76.useMemo)(() => {
26190 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26191 if (view.startPosition < prevStartPositionRef.current) {
26192 scrollDirectionRef.current = "up";
26193 } else if (view.startPosition > prevStartPositionRef.current) {
26194 scrollDirectionRef.current = "down";
26195 }
26196 }
26197 prevStartPositionRef.current = view.startPosition;
26198 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26199 const prevFiltersKey = prevViewParamsRef.current.filters;
26200 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26201 hasInitializedRef.current = true;
26202 prevViewParamsRef.current = {
26203 search: view.search,
26204 filters: currentFiltersKey,
26205 perPage: view.perPage
26206 };
26207 if (shouldReset) {
26208 positionMapRef.current.clear();
26209 scrollDirectionRef.current = void 0;
26210 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26211 const records = shownData.map((record, index2) => {
26212 const position = startPosition + index2;
26213 positionMapRef.current.set(getItemId(record), position);
26214 return {
26215 ...record,
26216 position
26217 };
26218 });
26219 allLoadedRecordsRef.current = records;
26220 return records;
26221 }
26222 const prev = allLoadedRecordsRef.current;
26223 const shownDataIds = new Set(shownData.map(getItemId));
26224 const scrollDirection = scrollDirectionRef.current;
26225 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26226 const newRecords = shownData.map((record, index2) => {
26227 const itemId = getItemId(record);
26228 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26229 if (position !== void 0) {
26230 positionMapRef.current.set(itemId, position);
26231 }
26232 return {
26233 ...record,
26234 position
26235 };
26236 });
26237 if (newRecords.length === 0) {
26238 return prev;
26239 }
26240 const prevWithoutDuplicates = prev.filter(
26241 (record) => !shownDataIds.has(getItemId(record))
26242 );
26243 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26244 allRecords.sort((a2, b2) => {
26245 const posA = a2.position;
26246 const posB = b2.position;
26247 return posA - posB;
26248 });
26249 let result = allRecords;
26250 if (visibleEntries.length > 0) {
26251 const visibleMin = Math.min(...visibleEntries);
26252 const visibleMax = Math.max(...visibleEntries);
26253 const buffer = 20;
26254 const recordPositions = allRecords.map(
26255 (r3) => r3.position
26256 );
26257 const minRecordPos = Math.min(...recordPositions);
26258 const maxRecordPos = Math.max(...recordPositions);
26259 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26260 if (hasOverlap) {
26261 result = allRecords.filter((record) => {
26262 const itemId = getItemId(record);
26263 const isSelected2 = selection?.includes(itemId);
26264 if (isSelected2) {
26265 return true;
26266 }
26267 const itemPosition = record.position;
26268 if (scrollDirection === "up") {
26269 return itemPosition <= visibleMax + buffer;
26270 } else if (scrollDirection === "down") {
26271 return itemPosition >= visibleMin - buffer;
26272 }
26273 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26274 });
26275 }
26276 }
26277 allLoadedRecordsRef.current = result;
26278 return result;
26279 }, [
26280 shownData,
26281 view.search,
26282 view.filters,
26283 view.perPage,
26284 view.startPosition,
26285 view.infiniteScrollEnabled,
26286 visibleEntries,
26287 selection,
26288 getItemId
26289 ]);
26290 if (!isInfiniteScrollEnabled) {
26291 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26292 return {
26293 data: dataToReturn.map((item) => ({
26294 ...item,
26295 position: void 0
26296 })),
26297 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26298 hasInitiallyLoaded,
26299 setVisibleEntries: void 0
26300 };
26301 }
26302 return {
26303 data: allLoadedRecords,
26304 paginationInfo,
26305 hasInitiallyLoaded,
26306 setVisibleEntries
26307 };
26308 }
26309
26310 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26311 var import_element77 = __toESM(require_element(), 1);
26312 var import_compose13 = __toESM(require_compose(), 1);
26313 function captureAnchorElement(container, anchorElementRef, direction) {
26314 const containerRect = container.getBoundingClientRect();
26315 const centerY = containerRect.top + containerRect.height / 2;
26316 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26317 if (items.length === 0) {
26318 return false;
26319 }
26320 const bestAnchor = items.reduce((best, item) => {
26321 const itemRect = item.getBoundingClientRect();
26322 const itemCenterY = itemRect.top + itemRect.height / 2;
26323 const distance = Math.abs(itemCenterY - centerY);
26324 const bestRect = best.getBoundingClientRect();
26325 const bestCenterY = bestRect.top + bestRect.height / 2;
26326 const bestDistance = Math.abs(bestCenterY - centerY);
26327 return distance < bestDistance ? item : best;
26328 });
26329 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26330 const anchorRect = bestAnchor.getBoundingClientRect();
26331 anchorElementRef.current = {
26332 posinset,
26333 viewportOffset: anchorRect.top - containerRect.top,
26334 scrollTop: container.scrollTop,
26335 direction
26336 };
26337 return true;
26338 }
26339 function useInfiniteScroll({
26340 view,
26341 onChangeView,
26342 isLoading,
26343 paginationInfo,
26344 containerRef,
26345 setVisibleEntries
26346 }) {
26347 const anchorElementRef = (0, import_element77.useRef)(null);
26348 const viewRef = (0, import_element77.useRef)(view);
26349 const isLoadingRef = (0, import_element77.useRef)(isLoading);
26350 const onChangeViewRef = (0, import_element77.useRef)(onChangeView);
26351 const totalItemsRef = (0, import_element77.useRef)(paginationInfo.totalItems);
26352 (0, import_element77.useLayoutEffect)(() => {
26353 viewRef.current = view;
26354 isLoadingRef.current = isLoading;
26355 onChangeViewRef.current = onChangeView;
26356 totalItemsRef.current = paginationInfo.totalItems;
26357 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26358 const intersectionObserverCallback = (0, import_element77.useCallback)(
26359 (entries) => {
26360 if (!setVisibleEntries) {
26361 return;
26362 }
26363 setVisibleEntries((prev) => {
26364 const newVisibleEntries = new Set(prev);
26365 let hasChanged = false;
26366 entries.forEach((entry) => {
26367 const posInSet = Number(
26368 entry.target?.attributes?.getNamedItem(
26369 "aria-posinset"
26370 )?.value
26371 );
26372 if (isNaN(posInSet)) {
26373 return;
26374 }
26375 if (entry.isIntersecting) {
26376 if (!newVisibleEntries.has(posInSet)) {
26377 newVisibleEntries.add(posInSet);
26378 hasChanged = true;
26379 }
26380 } else if (newVisibleEntries.has(posInSet)) {
26381 newVisibleEntries.delete(posInSet);
26382 hasChanged = true;
26383 }
26384 });
26385 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26386 });
26387 },
26388 [setVisibleEntries]
26389 );
26390 (0, import_element77.useLayoutEffect)(() => {
26391 const container = containerRef.current;
26392 const anchor = anchorElementRef.current;
26393 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26394 return;
26395 }
26396 const anchorElement = container.querySelector(
26397 `[aria-posinset="${anchor.posinset}"]`
26398 );
26399 if (anchorElement) {
26400 const containerRect = container.getBoundingClientRect();
26401 const anchorRect = anchorElement.getBoundingClientRect();
26402 const currentOffset = anchorRect.top - containerRect.top;
26403 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26404 if (Math.abs(scrollAdjustment) > 1) {
26405 container.scrollTop += scrollAdjustment;
26406 }
26407 }
26408 anchorElementRef.current = null;
26409 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26410 const intersectionObserverRef = (0, import_element77.useRef)(
26411 null
26412 );
26413 (0, import_element77.useEffect)(() => {
26414 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26415 if (intersectionObserverRef.current) {
26416 intersectionObserverRef.current.disconnect();
26417 intersectionObserverRef.current = null;
26418 }
26419 return;
26420 }
26421 intersectionObserverRef.current = new IntersectionObserver(
26422 intersectionObserverCallback,
26423 { root: null, rootMargin: "0px", threshold: 0.1 }
26424 );
26425 return () => {
26426 if (intersectionObserverRef.current) {
26427 intersectionObserverRef.current.disconnect();
26428 intersectionObserverRef.current = null;
26429 }
26430 };
26431 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26432 (0, import_element77.useEffect)(() => {
26433 if (!view.infiniteScrollEnabled || !containerRef.current) {
26434 return;
26435 }
26436 let lastScrollTop = 0;
26437 const BOTTOM_THRESHOLD = 600;
26438 const TOP_THRESHOLD = 800;
26439 const handleScroll = (0, import_compose13.throttle)((event) => {
26440 const currentView = viewRef.current;
26441 const totalItems = totalItemsRef.current;
26442 const target = event.target;
26443 const scrollTop = target.scrollTop;
26444 const scrollHeight = target.scrollHeight;
26445 const clientHeight = target.clientHeight;
26446 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26447 lastScrollTop = scrollTop;
26448 if (isLoadingRef.current) {
26449 return;
26450 }
26451 const currentStartPosition = currentView.startPosition || 1;
26452 const batchSize = currentView.perPage || 10;
26453 const currentEndPosition = Math.min(
26454 currentStartPosition + batchSize,
26455 totalItems
26456 );
26457 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26458 if (currentEndPosition < totalItems) {
26459 const newStartPosition = currentEndPosition;
26460 captureAnchorElement(target, anchorElementRef, "down");
26461 onChangeViewRef.current({
26462 ...currentView,
26463 startPosition: newStartPosition
26464 });
26465 }
26466 }
26467 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26468 if (currentStartPosition > 1) {
26469 const calculatedStartPosition = currentStartPosition - batchSize;
26470 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26471 captureAnchorElement(target, anchorElementRef, "up");
26472 onChangeViewRef.current({
26473 ...currentView,
26474 startPosition: newStartPosition
26475 });
26476 }
26477 }
26478 }, 50);
26479 const container = containerRef.current;
26480 container.addEventListener("scroll", handleScroll);
26481 return () => {
26482 container.removeEventListener("scroll", handleScroll);
26483 handleScroll.cancel();
26484 };
26485 }, [containerRef, view.infiniteScrollEnabled]);
26486 return {
26487 intersectionObserver: intersectionObserverRef.current
26488 };
26489 }
26490
26491 // packages/dataviews/build-module/dataviews/index.mjs
26492 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
26493 var defaultGetItemId = (item) => item.id;
26494 var defaultIsItemClickable = () => true;
26495 var EMPTY_ARRAY7 = [];
26496 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26497 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26498 (viewLayout) => !viewLayout.isPicker
26499 );
26500 function DefaultUI({
26501 header,
26502 search = true,
26503 searchLabel = void 0
26504 }) {
26505 const { view } = (0, import_element78.useContext)(dataviews_context_default);
26506 const isInfiniteScroll = view.infiniteScrollEnabled;
26507 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_jsx_runtime113.Fragment, { children: [
26508 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(
26509 Stack,
26510 {
26511 direction: "row",
26512 align: "top",
26513 justify: "space-between",
26514 className: clsx_default("dataviews__view-actions", {
26515 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26516 }),
26517 gap: "xs",
26518 children: [
26519 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(
26520 Stack,
26521 {
26522 direction: "row",
26523 justify: "start",
26524 gap: "sm",
26525 className: "dataviews__search",
26526 children: [
26527 search && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(dataviews_search_default, { label: searchLabel }),
26528 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(toggle_default, {})
26529 ]
26530 }
26531 ),
26532 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26533 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(dataviews_view_config_default, {}),
26534 header
26535 ] })
26536 ]
26537 }
26538 ),
26539 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26540 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataViewsLayout, {}),
26541 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataViewsFooter, {})
26542 ] });
26543 }
26544 function DataViews({
26545 view,
26546 onChangeView,
26547 fields,
26548 search = true,
26549 searchLabel = void 0,
26550 actions = EMPTY_ARRAY7,
26551 data,
26552 getItemId = defaultGetItemId,
26553 getItemLevel,
26554 isLoading = false,
26555 paginationInfo,
26556 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26557 selection: selectionProperty,
26558 onChangeSelection,
26559 onClickItem,
26560 renderItemLink,
26561 isItemClickable = defaultIsItemClickable,
26562 header,
26563 children,
26564 config = { perPageSizes: [10, 20, 50, 100] },
26565 empty,
26566 onReset
26567 }) {
26568 const [selectionState, setSelectionState] = (0, import_element78.useState)([]);
26569 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26570 const selection = isUncontrolled ? selectionState : selectionProperty;
26571 const {
26572 data: displayData,
26573 paginationInfo: displayPaginationInfo,
26574 hasInitiallyLoaded,
26575 setVisibleEntries
26576 } = useData({
26577 view,
26578 data,
26579 getItemId,
26580 isLoading,
26581 selection,
26582 paginationInfo
26583 });
26584 const containerRef = (0, import_element78.useRef)(null);
26585 const [containerWidth, setContainerWidth] = (0, import_element78.useState)(0);
26586 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
26587 (resizeObserverEntries) => {
26588 setContainerWidth(
26589 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26590 );
26591 },
26592 { box: "border-box" }
26593 );
26594 const [openedFilter, setOpenedFilter] = (0, import_element78.useState)(null);
26595 function setSelectionWithChange(value) {
26596 const newValue = typeof value === "function" ? value(selection) : value;
26597 if (isUncontrolled) {
26598 setSelectionState(newValue);
26599 }
26600 if (onChangeSelection) {
26601 onChangeSelection(newValue);
26602 }
26603 }
26604 const _fields = (0, import_element78.useMemo)(() => normalizeFields(fields), [fields]);
26605 const _selection = (0, import_element78.useMemo)(() => {
26606 if (view.infiniteScrollEnabled) {
26607 return selection;
26608 }
26609 return selection.filter(
26610 (id) => data.some((item) => getItemId(item) === id)
26611 );
26612 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26613 const filters = use_filters_default(_fields, view);
26614 const hasPrimaryOrLockedFilters = (0, import_element78.useMemo)(
26615 () => (filters || []).some(
26616 (filter) => filter.isPrimary || filter.isLocked
26617 ),
26618 [filters]
26619 );
26620 const [isShowingFilter, setIsShowingFilter] = (0, import_element78.useState)(
26621 hasPrimaryOrLockedFilters
26622 );
26623 const { intersectionObserver } = useInfiniteScroll({
26624 view,
26625 onChangeView,
26626 isLoading,
26627 paginationInfo,
26628 containerRef,
26629 setVisibleEntries
26630 });
26631 (0, import_element78.useEffect)(() => {
26632 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26633 setIsShowingFilter(true);
26634 }
26635 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26636 const defaultLayouts = (0, import_element78.useMemo)(
26637 () => Object.fromEntries(
26638 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26639 return dataViewsLayouts.some(
26640 (viewLayout) => viewLayout.type === layoutType
26641 );
26642 }).map(([key, value]) => [
26643 key,
26644 value === true ? {} : value
26645 ])
26646 ),
26647 [defaultLayoutsProperty]
26648 );
26649 if (!defaultLayouts[view.type]) {
26650 return null;
26651 }
26652 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26653 dataviews_context_default.Provider,
26654 {
26655 value: {
26656 view,
26657 onChangeView,
26658 fields: _fields,
26659 actions,
26660 data: displayData,
26661 isLoading,
26662 paginationInfo: displayPaginationInfo,
26663 selection: _selection,
26664 onChangeSelection: setSelectionWithChange,
26665 openedFilter,
26666 setOpenedFilter,
26667 getItemId,
26668 getItemLevel,
26669 isItemClickable,
26670 onClickItem,
26671 renderItemLink,
26672 containerWidth,
26673 containerRef,
26674 resizeObserverRef,
26675 defaultLayouts,
26676 filters,
26677 isShowingFilter,
26678 setIsShowingFilter,
26679 config,
26680 empty,
26681 hasInitiallyLoaded,
26682 onReset,
26683 intersectionObserver
26684 },
26685 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26686 DefaultUI,
26687 {
26688 header,
26689 search,
26690 searchLabel
26691 }
26692 ) })
26693 }
26694 );
26695 }
26696 var DataViewsSubComponents = DataViews;
26697 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26698 DataViewsSubComponents.Filters = filters_default;
26699 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26700 DataViewsSubComponents.FiltersToggle = toggle_default;
26701 DataViewsSubComponents.Layout = DataViewsLayout;
26702 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26703 DataViewsSubComponents.Pagination = DataViewsPagination;
26704 DataViewsSubComponents.Search = dataviews_search_default;
26705 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26706 DataViewsSubComponents.Footer = DataViewsFooter;
26707 var dataviews_default = DataViewsSubComponents;
26708
26709 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26710 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26711 var import_deprecated = __toESM(require_deprecated(), 1);
26712 function normalizeSearchInput2(input = "") {
26713 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26714 }
26715 var EMPTY_ARRAY8 = [];
26716 function filterSortAndPaginate(data, view, fields) {
26717 if (!data) {
26718 return {
26719 data: EMPTY_ARRAY8,
26720 paginationInfo: { totalItems: 0, totalPages: 0 }
26721 };
26722 }
26723 const _fields = normalizeFields(fields);
26724 let filteredData = [...data];
26725 if (view.search) {
26726 const normalizedSearch = normalizeSearchInput2(view.search);
26727 filteredData = filteredData.filter((item) => {
26728 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26729 const fieldValue = field.getValue({ item });
26730 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26731 return values.some(
26732 (value) => normalizeSearchInput2(String(value)).includes(
26733 normalizedSearch
26734 )
26735 );
26736 });
26737 });
26738 }
26739 if (view.filters && view.filters?.length > 0) {
26740 view.filters.forEach((filter) => {
26741 const field = _fields.find(
26742 (_field) => _field.id === filter.field
26743 );
26744 if (field) {
26745 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26746 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26747 since: "7.0",
26748 alternative: "'isNone'"
26749 });
26750 }
26751 const handler = field.filter[filter.operator];
26752 if (handler) {
26753 filteredData = filteredData.filter(
26754 (item) => handler(item, field, filter.value)
26755 );
26756 }
26757 }
26758 });
26759 }
26760 const sortByField = view.sort?.field ? _fields.find((field) => {
26761 return field.enableSorting !== false && field.id === view.sort?.field;
26762 }) : null;
26763 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26764 return field.enableSorting !== false && field.id === view.groupBy?.field;
26765 }) : null;
26766 if (sortByField || groupByField) {
26767 filteredData.sort((a2, b2) => {
26768 if (groupByField) {
26769 const groupCompare = groupByField.sort(
26770 a2,
26771 b2,
26772 view.groupBy?.direction ?? "asc"
26773 );
26774 if (groupCompare !== 0) {
26775 return groupCompare;
26776 }
26777 }
26778 if (sortByField) {
26779 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26780 }
26781 return 0;
26782 });
26783 }
26784 let totalItems = filteredData.length;
26785 let totalPages = 1;
26786 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26787 const start = view.startPosition - 1;
26788 const end = Math.min(start + view.perPage, totalItems);
26789 filteredData = filteredData?.slice(start, end);
26790 } else if (view.page !== void 0 && view.perPage !== void 0) {
26791 const start = (view.page - 1) * view.perPage;
26792 totalItems = filteredData?.length || 0;
26793 totalPages = Math.ceil(totalItems / view.perPage);
26794 filteredData = filteredData?.slice(start, start + view.perPage);
26795 }
26796 return {
26797 data: filteredData,
26798 paginationInfo: {
26799 totalItems,
26800 totalPages
26801 }
26802 };
26803 }
26804
26805 // packages/admin-ui/build-module/navigable-region/index.mjs
26806 var import_element79 = __toESM(require_element(), 1);
26807 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
26808 var NavigableRegion = (0, import_element79.forwardRef)(
26809 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
26810 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26811 Tag,
26812 {
26813 ref,
26814 className: clsx_default("admin-ui-navigable-region", className),
26815 "aria-label": ariaLabel,
26816 role: "region",
26817 tabIndex: "-1",
26818 ...props,
26819 children
26820 }
26821 );
26822 }
26823 );
26824 NavigableRegion.displayName = "NavigableRegion";
26825 var navigable_region_default = NavigableRegion;
26826
26827 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
26828 var import_components47 = __toESM(require_components(), 1);
26829 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components47.createSlotFill)("SidebarToggle");
26830
26831 // packages/admin-ui/build-module/page/header.mjs
26832 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
26833 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
26834 function getRuntime7() {
26835 const globalScope = globalThis;
26836 if (globalScope.__wpStyleRuntime) {
26837 return globalScope.__wpStyleRuntime;
26838 }
26839 globalScope.__wpStyleRuntime = {
26840 documents: /* @__PURE__ */ new Map(),
26841 styles: /* @__PURE__ */ new Map(),
26842 injectedStyles: /* @__PURE__ */ new WeakMap()
26843 };
26844 if (typeof document !== "undefined") {
26845 registerDocument7(document);
26846 }
26847 return globalScope.__wpStyleRuntime;
26848 }
26849 function documentContainsStyleHash7(targetDocument, hash) {
26850 if (!targetDocument.head) {
26851 return false;
26852 }
26853 for (const style of targetDocument.head.querySelectorAll(
26854 `style[${STYLE_HASH_ATTRIBUTE7}]`
26855 )) {
26856 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
26857 return true;
26858 }
26859 }
26860 return false;
26861 }
26862 function injectStyle7(targetDocument, hash, css) {
26863 if (!targetDocument.head) {
26864 return;
26865 }
26866 const runtime = getRuntime7();
26867 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26868 if (!injectedStyles) {
26869 injectedStyles = /* @__PURE__ */ new Set();
26870 runtime.injectedStyles.set(targetDocument, injectedStyles);
26871 }
26872 if (injectedStyles.has(hash)) {
26873 return;
26874 }
26875 if (documentContainsStyleHash7(targetDocument, hash)) {
26876 injectedStyles.add(hash);
26877 return;
26878 }
26879 const style = targetDocument.createElement("style");
26880 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
26881 style.appendChild(targetDocument.createTextNode(css));
26882 targetDocument.head.appendChild(style);
26883 injectedStyles.add(hash);
26884 }
26885 function registerDocument7(targetDocument) {
26886 const runtime = getRuntime7();
26887 runtime.documents.set(
26888 targetDocument,
26889 (runtime.documents.get(targetDocument) ?? 0) + 1
26890 );
26891 for (const [hash, css] of runtime.styles) {
26892 injectStyle7(targetDocument, hash, css);
26893 }
26894 return () => {
26895 const count = runtime.documents.get(targetDocument);
26896 if (count === void 0) {
26897 return;
26898 }
26899 if (count <= 1) {
26900 runtime.documents.delete(targetDocument);
26901 return;
26902 }
26903 runtime.documents.set(targetDocument, count - 1);
26904 };
26905 }
26906 function registerStyle7(hash, css) {
26907 const runtime = getRuntime7();
26908 runtime.styles.set(hash, css);
26909 for (const targetDocument of runtime.documents.keys()) {
26910 injectStyle7(targetDocument, hash, css);
26911 }
26912 }
26913 if (typeof process === "undefined" || true) {
26914 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)}}");
26915 }
26916 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" };
26917 function Header({
26918 headingLevel = 1,
26919 breadcrumbs,
26920 badges,
26921 visual,
26922 title,
26923 subTitle,
26924 actions,
26925 showSidebarToggle = true
26926 }) {
26927 const HeadingTag = `h${headingLevel}`;
26928 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
26929 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
26930 Stack,
26931 {
26932 className: style_default6["header-content"],
26933 direction: "row",
26934 gap: "sm",
26935 justify: "space-between",
26936 children: [
26937 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
26938 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26939 SidebarToggleSlot,
26940 {
26941 bubblesVirtually: true,
26942 className: style_default6["sidebar-toggle-slot"]
26943 }
26944 ),
26945 visual && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26946 "div",
26947 {
26948 className: style_default6["header-visual"],
26949 "aria-hidden": "true",
26950 children: visual
26951 }
26952 ),
26953 title && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26954 Text,
26955 {
26956 className: style_default6["header-title"],
26957 render: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(HeadingTag, {}),
26958 variant: "heading-lg",
26959 children: title
26960 }
26961 ),
26962 breadcrumbs,
26963 badges
26964 ] }),
26965 actions && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26966 Stack,
26967 {
26968 align: "center",
26969 className: style_default6["header-actions"],
26970 direction: "row",
26971 gap: "sm",
26972 children: actions
26973 }
26974 )
26975 ]
26976 }
26977 ),
26978 subTitle && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26979 Text,
26980 {
26981 render: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("p", {}),
26982 variant: "body-md",
26983 className: style_default6["header-subtitle"],
26984 children: subTitle
26985 }
26986 )
26987 ] });
26988 }
26989
26990 // packages/admin-ui/build-module/page/index.mjs
26991 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26992 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
26993 function getRuntime8() {
26994 const globalScope = globalThis;
26995 if (globalScope.__wpStyleRuntime) {
26996 return globalScope.__wpStyleRuntime;
26997 }
26998 globalScope.__wpStyleRuntime = {
26999 documents: /* @__PURE__ */ new Map(),
27000 styles: /* @__PURE__ */ new Map(),
27001 injectedStyles: /* @__PURE__ */ new WeakMap()
27002 };
27003 if (typeof document !== "undefined") {
27004 registerDocument8(document);
27005 }
27006 return globalScope.__wpStyleRuntime;
27007 }
27008 function documentContainsStyleHash8(targetDocument, hash) {
27009 if (!targetDocument.head) {
27010 return false;
27011 }
27012 for (const style of targetDocument.head.querySelectorAll(
27013 `style[${STYLE_HASH_ATTRIBUTE8}]`
27014 )) {
27015 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
27016 return true;
27017 }
27018 }
27019 return false;
27020 }
27021 function injectStyle8(targetDocument, hash, css) {
27022 if (!targetDocument.head) {
27023 return;
27024 }
27025 const runtime = getRuntime8();
27026 let injectedStyles = runtime.injectedStyles.get(targetDocument);
27027 if (!injectedStyles) {
27028 injectedStyles = /* @__PURE__ */ new Set();
27029 runtime.injectedStyles.set(targetDocument, injectedStyles);
27030 }
27031 if (injectedStyles.has(hash)) {
27032 return;
27033 }
27034 if (documentContainsStyleHash8(targetDocument, hash)) {
27035 injectedStyles.add(hash);
27036 return;
27037 }
27038 const style = targetDocument.createElement("style");
27039 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
27040 style.appendChild(targetDocument.createTextNode(css));
27041 targetDocument.head.appendChild(style);
27042 injectedStyles.add(hash);
27043 }
27044 function registerDocument8(targetDocument) {
27045 const runtime = getRuntime8();
27046 runtime.documents.set(
27047 targetDocument,
27048 (runtime.documents.get(targetDocument) ?? 0) + 1
27049 );
27050 for (const [hash, css] of runtime.styles) {
27051 injectStyle8(targetDocument, hash, css);
27052 }
27053 return () => {
27054 const count = runtime.documents.get(targetDocument);
27055 if (count === void 0) {
27056 return;
27057 }
27058 if (count <= 1) {
27059 runtime.documents.delete(targetDocument);
27060 return;
27061 }
27062 runtime.documents.set(targetDocument, count - 1);
27063 };
27064 }
27065 function registerStyle8(hash, css) {
27066 const runtime = getRuntime8();
27067 runtime.styles.set(hash, css);
27068 for (const targetDocument of runtime.documents.keys()) {
27069 injectStyle8(targetDocument, hash, css);
27070 }
27071 }
27072 if (typeof process === "undefined" || true) {
27073 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)}}");
27074 }
27075 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" };
27076 function Page({
27077 headingLevel,
27078 breadcrumbs,
27079 badges,
27080 visual,
27081 title,
27082 subTitle,
27083 children,
27084 className,
27085 actions,
27086 ariaLabel,
27087 hasPadding = false,
27088 showSidebarToggle = true
27089 }) {
27090 const classes = clsx_default(style_default7.page, className);
27091 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
27092 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
27093 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27094 Header,
27095 {
27096 headingLevel,
27097 breadcrumbs,
27098 badges,
27099 visual,
27100 title,
27101 subTitle,
27102 actions,
27103 showSidebarToggle
27104 }
27105 ),
27106 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27107 "div",
27108 {
27109 className: clsx_default(
27110 style_default7.content,
27111 style_default7["has-padding"]
27112 ),
27113 children
27114 }
27115 ) : children
27116 ] });
27117 }
27118 Page.SidebarToggleFill = SidebarToggleFill;
27119 var page_default = Page;
27120
27121 // routes/pattern-list/stage.tsx
27122 var import_core_data4 = __toESM(require_core_data());
27123 var import_components48 = __toESM(require_components());
27124 var import_data11 = __toESM(require_data());
27125 var import_element82 = __toESM(require_element());
27126 var import_editor = __toESM(require_editor());
27127 var import_patterns3 = __toESM(require_patterns());
27128 var import_i18n48 = __toESM(require_i18n());
27129
27130 // routes/lock-unlock/index.ts
27131 var import_private_apis4 = __toESM(require_private_apis());
27132 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
27133 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
27134 "@wordpress/routes"
27135 );
27136
27137 // routes/pattern-list/view-utils.ts
27138 var import_i18n44 = __toESM(require_i18n());
27139 var LAYOUT_GRID2 = "grid";
27140 var LAYOUT_TABLE2 = "table";
27141 var DEFAULT_VIEW = {
27142 type: LAYOUT_GRID2,
27143 perPage: 20,
27144 sort: {
27145 field: "title",
27146 direction: "asc"
27147 },
27148 filters: [],
27149 fields: ["sync-status"],
27150 layout: {
27151 badgeFields: ["sync-status"]
27152 },
27153 titleField: "title",
27154 mediaField: "preview"
27155 };
27156 var DEFAULT_VIEWS = [
27157 {
27158 slug: "all",
27159 label: (0, import_i18n44.__)("All patterns")
27160 },
27161 {
27162 slug: "my-patterns",
27163 label: (0, import_i18n44.__)("My patterns")
27164 },
27165 {
27166 slug: "registered",
27167 label: (0, import_i18n44.__)("Registered")
27168 }
27169 ];
27170 var DEFAULT_LAYOUTS2 = {
27171 [LAYOUT_TABLE2]: true,
27172 [LAYOUT_GRID2]: {
27173 layout: {
27174 badgeFields: ["sync-status"]
27175 }
27176 }
27177 };
27178
27179 // routes/pattern-list/fields/preview.tsx
27180 var import_i18n45 = __toESM(require_i18n());
27181 import { Preview } from "@wordpress/lazy-editor";
27182 function PreviewField({ item }) {
27183 return /* @__PURE__ */ React.createElement(
27184 Preview,
27185 {
27186 blocks: item.blocks,
27187 content: item.content,
27188 description: item.description
27189 }
27190 );
27191 }
27192 var previewField = {
27193 label: (0, import_i18n45.__)("Preview"),
27194 id: "preview",
27195 render: PreviewField,
27196 enableSorting: false
27197 };
27198
27199 // routes/pattern-list/fields/sync-status.tsx
27200 var import_i18n46 = __toESM(require_i18n());
27201 var import_patterns = __toESM(require_patterns());
27202 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
27203 var OPERATOR_IS2 = "is";
27204 var SYNC_FILTERS = [
27205 {
27206 value: PATTERN_SYNC_TYPES.full,
27207 label: (0, import_i18n46._x)("Synced", "pattern (singular)"),
27208 description: (0, import_i18n46.__)("Patterns that are kept in sync across the site.")
27209 },
27210 {
27211 value: PATTERN_SYNC_TYPES.unsynced,
27212 label: (0, import_i18n46._x)("Not synced", "pattern (singular)"),
27213 description: (0, import_i18n46.__)(
27214 "Patterns that can be changed freely without affecting the site."
27215 )
27216 }
27217 ];
27218 var patternStatusField = {
27219 label: (0, import_i18n46.__)("Sync status"),
27220 id: "sync-status",
27221 render: ({ item }) => {
27222 const syncStatus = item.syncStatus;
27223 return /* @__PURE__ */ React.createElement(
27224 "span",
27225 {
27226 className: `routes-pattern-list__field-sync-status-${syncStatus}`
27227 },
27228 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
27229 );
27230 },
27231 elements: SYNC_FILTERS,
27232 filterBy: {
27233 operators: [OPERATOR_IS2],
27234 isPrimary: true
27235 },
27236 enableSorting: false
27237 };
27238
27239 // routes/pattern-list/fields/category.tsx
27240 var import_i18n47 = __toESM(require_i18n());
27241 var import_data9 = __toESM(require_data());
27242 var import_core_data2 = __toESM(require_core_data());
27243 var import_element80 = __toESM(require_element());
27244 var OPERATOR_IS3 = "is";
27245 function CategoryField({ item }) {
27246 const blockPatternCategories = (0, import_data9.useSelect)(
27247 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
27248 []
27249 );
27250 const categoryLabels = (0, import_element80.useMemo)(() => {
27251 if (!item.categories || !Array.isArray(item.categories)) {
27252 return [];
27253 }
27254 return item.categories.map((catSlug) => {
27255 const category = blockPatternCategories?.find(
27256 (cat) => cat.name === catSlug
27257 );
27258 return category ? category.label || category.name : null;
27259 }).filter(Boolean);
27260 }, [item.categories, blockPatternCategories]);
27261 if (categoryLabels.length === 0) {
27262 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
27263 }
27264 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
27265 }
27266 function usePatternCategories() {
27267 const userPatternCategories = (0, import_data9.useSelect)(
27268 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
27269 []
27270 );
27271 const blockPatternCategories = (0, import_data9.useSelect)(
27272 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
27273 []
27274 );
27275 return (0, import_element80.useMemo)(() => {
27276 const categoryMap = /* @__PURE__ */ new Map();
27277 userPatternCategories?.forEach((cat) => {
27278 if (!categoryMap.has(cat.name)) {
27279 categoryMap.set(cat.name, {
27280 value: cat.name,
27281 label: cat.label || cat.name
27282 });
27283 }
27284 });
27285 blockPatternCategories?.forEach((cat) => {
27286 if (!categoryMap.has(cat.name)) {
27287 categoryMap.set(cat.name, {
27288 value: cat.name,
27289 label: cat.label || cat.name
27290 });
27291 }
27292 });
27293 return Array.from(categoryMap.values()).sort(
27294 (a2, b2) => a2.label.localeCompare(b2.label)
27295 );
27296 }, [userPatternCategories, blockPatternCategories]);
27297 }
27298 function usePatternCategoryField() {
27299 const categories = usePatternCategories();
27300 return {
27301 label: (0, import_i18n47.__)("Category"),
27302 id: "category",
27303 render: CategoryField,
27304 elements: categories,
27305 getValue: ({ item }) => {
27306 return item.categories;
27307 },
27308 filterBy: {
27309 operators: [OPERATOR_IS3],
27310 isPrimary: true
27311 },
27312 enableSorting: false
27313 };
27314 }
27315
27316 // routes/pattern-list/use-patterns.ts
27317 var import_data10 = __toESM(require_data());
27318 var import_core_data3 = __toESM(require_core_data());
27319 var import_element81 = __toESM(require_element());
27320 var import_patterns2 = __toESM(require_patterns());
27321 var import_block_editor = __toESM(require_block_editor());
27322
27323 // routes/pattern-list/utils.ts
27324 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
27325
27326 // routes/pattern-list/use-patterns.ts
27327 var {
27328 PATTERN_TYPES,
27329 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
27330 EXCLUDED_PATTERN_SOURCES,
27331 PATTERN_DEFAULT_CATEGORY
27332 } = unlock4(import_patterns2.privateApis);
27333 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
27334 import_block_editor.privateApis
27335 );
27336 function normalizeThemePattern(pattern) {
27337 return {
27338 id: pattern.name,
27339 title: pattern.title,
27340 content: pattern.content,
27341 keywords: pattern.keywords || [],
27342 type: PATTERN_TYPES.theme,
27343 // Normalize categories to always be an array of slugs
27344 categories: pattern.categories || [],
27345 // Theme patterns are always unsynced
27346 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
27347 description: pattern.description || ""
27348 };
27349 }
27350 function normalizeUserPattern(pattern, userPatternCategories) {
27351 const categories = [];
27352 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
27353 pattern.wp_pattern_category.forEach((catId) => {
27354 const category = userPatternCategories?.find(
27355 (cat) => cat.id === catId
27356 );
27357 if (category) {
27358 categories.push(category.name);
27359 }
27360 });
27361 }
27362 const numericId = pattern.id;
27363 return {
27364 id: pattern.name || pattern.id.toString(),
27365 _recordId: numericId,
27366 // Keep numeric ID for permissions lookup
27367 keywords: [],
27368 type: PATTERN_TYPES.user,
27369 // Normalize categories to always be an array of slugs
27370 categories,
27371 // Normalize sync status
27372 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
27373 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
27374 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
27375 description: pattern.excerpt?.raw || "",
27376 blocks: pattern.blocks
27377 };
27378 }
27379 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
27380 return unmatchedTerms.filter(
27381 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
27382 (unprocessedTerm) => unprocessedTerm.includes(term)
27383 )
27384 );
27385 };
27386 function getItemSearchRank(item, searchTerm, config) {
27387 const { categoryId, hasCategory, onlyFilterByCategory } = config;
27388 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
27389 if (!rank || onlyFilterByCategory) {
27390 return rank;
27391 }
27392 const normalizedSearchInput = normalizeString2(searchTerm);
27393 const normalizedTitle = normalizeString2(item.title);
27394 if (normalizedSearchInput === normalizedTitle) {
27395 rank += 30;
27396 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
27397 rank += 20;
27398 } else {
27399 const terms = [
27400 item.id,
27401 item.title,
27402 item.description,
27403 ...item.keywords
27404 ].join(" ");
27405 const normalizedSearchTerms = extractWords(normalizedSearchInput);
27406 const unmatchedTerms = removeMatchingTerms(
27407 normalizedSearchTerms,
27408 terms
27409 );
27410 if (unmatchedTerms.length === 0) {
27411 rank += 10;
27412 }
27413 }
27414 return rank;
27415 }
27416 function searchItems(items = [], searchInput = "", config = {}) {
27417 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
27418 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
27419 const searchRankConfig = { ...config, onlyFilterByCategory };
27420 const threshold = onlyFilterByCategory ? 0 : 1;
27421 const rankedItems = items.map((item) => {
27422 return [
27423 item,
27424 getItemSearchRank(item, searchInput, searchRankConfig)
27425 ];
27426 }).filter(([, rank]) => rank > threshold);
27427 if (normalizedSearchTerms.length === 0) {
27428 return rankedItems.map(([item]) => item);
27429 }
27430 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
27431 return rankedItems.map(([item]) => item);
27432 }
27433 var selectThemePatterns = (0, import_data10.createSelector)(
27434 (select2) => {
27435 const { getBlockPatterns } = select2(import_core_data3.store);
27436 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
27437 const restBlockPatterns = getBlockPatterns();
27438 const patterns = (restBlockPatterns || []).filter(
27439 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
27440 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
27441 return {
27442 patterns,
27443 isResolving: isResolvingSelector("getBlockPatterns")
27444 };
27445 },
27446 (select2) => [
27447 select2(import_core_data3.store).getBlockPatterns(),
27448 select2(import_core_data3.store).isResolving("getBlockPatterns")
27449 ]
27450 );
27451 var selectUserPatterns = (0, import_data10.createSelector)(
27452 (select2, syncStatus = void 0, search = "") => {
27453 const {
27454 getEntityRecords,
27455 isResolving: isResolvingSelector,
27456 getUserPatternCategories
27457 } = select2(import_core_data3.store);
27458 const query = { per_page: -1 };
27459 const patternPosts = getEntityRecords(
27460 "postType",
27461 PATTERN_TYPES.user,
27462 query
27463 );
27464 const userPatternCategories = getUserPatternCategories();
27465 let patterns = (patternPosts ?? []).map(
27466 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
27467 );
27468 const isResolving = isResolvingSelector("getEntityRecords", [
27469 "postType",
27470 PATTERN_TYPES.user,
27471 query
27472 ]);
27473 if (syncStatus) {
27474 patterns = patterns.filter(
27475 (pattern) => pattern.syncStatus === syncStatus
27476 );
27477 }
27478 patterns = searchItems(patterns, search, {
27479 // We exit user pattern retrieval early if we aren't in the
27480 // catch-all category for user created patterns, so it has
27481 // to be in the category.
27482 categoryId: PATTERN_DEFAULT_CATEGORY,
27483 hasCategory: () => true
27484 });
27485 return {
27486 patterns,
27487 isResolving,
27488 categories: userPatternCategories
27489 };
27490 },
27491 (select2) => [
27492 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
27493 per_page: -1
27494 }),
27495 select2(import_core_data3.store).isResolving("getEntityRecords", [
27496 "postType",
27497 PATTERN_TYPES.user,
27498 { per_page: -1 }
27499 ]),
27500 select2(import_core_data3.store).getUserPatternCategories()
27501 ]
27502 );
27503 var selectPatterns = (0, import_data10.createSelector)(
27504 (select2, categoryId, syncStatus, search = "") => {
27505 const {
27506 patterns: themePatterns,
27507 isResolving: isResolvingThemePatterns
27508 } = selectThemePatterns(select2);
27509 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
27510 let patterns = [
27511 ...themePatterns || [],
27512 ...userPatterns || []
27513 ];
27514 if (syncStatus) {
27515 patterns = patterns.filter(
27516 (pattern) => pattern.syncStatus === syncStatus
27517 );
27518 }
27519 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27520 patterns = searchItems(patterns, search, {
27521 categoryId,
27522 hasCategory: (item, currentCategory) => {
27523 return item.categories?.includes(currentCategory);
27524 }
27525 });
27526 } else {
27527 patterns = searchItems(patterns, search, {
27528 categoryId: PATTERN_DEFAULT_CATEGORY,
27529 hasCategory: () => true
27530 });
27531 }
27532 return {
27533 patterns,
27534 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
27535 };
27536 },
27537 (select2) => [
27538 selectThemePatterns(select2),
27539 selectUserPatterns(select2)
27540 ]
27541 );
27542 function useAugmentPatternsWithPermissions(patterns) {
27543 const idsAndTypes = (0, import_element81.useMemo)(
27544 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
27545 record.type,
27546 record._recordId,
27547 record.id
27548 ]) ?? [],
27549 [patterns]
27550 );
27551 const permissions = (0, import_data10.useSelect)(
27552 (select2) => {
27553 const { getEntityRecordPermissions } = unlock4(
27554 select2(import_core_data3.store)
27555 );
27556 return idsAndTypes.reduce(
27557 (acc, [type, numericId, stringId]) => {
27558 acc[stringId] = getEntityRecordPermissions(
27559 "postType",
27560 type,
27561 numericId
27562 );
27563 return acc;
27564 },
27565 {}
27566 );
27567 },
27568 [idsAndTypes]
27569 );
27570 return (0, import_element81.useMemo)(
27571 () => patterns?.map((record) => ({
27572 ...record,
27573 permissions: permissions?.[record.id] ?? {}
27574 })) ?? [],
27575 [patterns, permissions]
27576 );
27577 }
27578 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
27579 return (0, import_data10.useSelect)(
27580 (select2) => {
27581 if (postType === PATTERN_TYPES.user) {
27582 const result = selectUserPatterns(select2, syncStatus, search);
27583 let { patterns } = result;
27584 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27585 patterns = patterns.filter(
27586 (pattern) => pattern.categories.includes(categoryId)
27587 );
27588 }
27589 return {
27590 patterns,
27591 isResolving: result.isResolving
27592 };
27593 } else if (postType === PATTERN_TYPES.theme) {
27594 const result = selectThemePatterns(select2);
27595 let { patterns } = result;
27596 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27597 patterns = patterns.filter(
27598 (pattern) => pattern.categories.includes(categoryId)
27599 );
27600 }
27601 patterns = searchItems(patterns, search, {
27602 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
27603 hasCategory: () => true
27604 });
27605 return {
27606 patterns,
27607 isResolving: result.isResolving
27608 };
27609 }
27610 return selectPatterns(select2, categoryId, syncStatus, search);
27611 },
27612 [categoryId, postType, search, syncStatus]
27613 );
27614 };
27615 var use_patterns_default = usePatterns;
27616
27617 // routes/pattern-list/style.scss
27618 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='a3942f3f8d']")) {
27619 const style = document.createElement("style");
27620 style.setAttribute("data-wp-hash", "a3942f3f8d");
27621 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)}"));
27622 document.head.appendChild(style);
27623 }
27624
27625 // routes/pattern-list/stage.tsx
27626 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
27627 var { Tabs } = unlock4(import_components48.privateApis);
27628 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
27629 function PatternList() {
27630 const invalidate = useInvalidate();
27631 const { type = "all" } = useParams({
27632 from: "/patterns/list/$type"
27633 });
27634 const navigate = useNavigate();
27635 const searchParams = useSearch({ from: "/patterns/list/$type" });
27636 const postTypeObject = (0, import_data11.useSelect)(
27637 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
27638 []
27639 );
27640 const labels = postTypeObject?.labels;
27641 const canCreateRecord = (0, import_data11.useSelect)(
27642 (select2) => select2(import_core_data4.store).canUser("create", {
27643 kind: "postType",
27644 name: "wp_block"
27645 }),
27646 []
27647 );
27648 const [showPatternModal, setShowPatternModal] = (0, import_element82.useState)(false);
27649 const handleQueryParamsChange = (0, import_element82.useCallback)(
27650 (params) => {
27651 navigate({
27652 search: {
27653 ...searchParams,
27654 ...params
27655 }
27656 });
27657 },
27658 [searchParams, navigate]
27659 );
27660 const { view, isModified, updateView, resetToDefault } = useView({
27661 kind: "postType",
27662 name: "wp_block",
27663 slug: "default-new",
27664 defaultView: DEFAULT_VIEW,
27665 queryParams: searchParams,
27666 onChangeQueryParams: handleQueryParamsChange
27667 });
27668 const onReset = () => {
27669 resetToDefault();
27670 invalidate();
27671 };
27672 const onChangeView = (newView) => {
27673 updateView(newView);
27674 if (newView.type !== view.type) {
27675 invalidate();
27676 }
27677 };
27678 const categoryFilter = (0, import_element82.useMemo)(() => {
27679 const filter = view.filters?.find((f2) => f2.field === "category");
27680 return filter?.value || "all-patterns";
27681 }, [view.filters]);
27682 const syncStatusFilter = (0, import_element82.useMemo)(() => {
27683 const filter = view.filters?.find((f2) => f2.field === "sync-status");
27684 return filter?.value;
27685 }, [view.filters]);
27686 const patternType = (0, import_element82.useMemo)(() => {
27687 if (type === "my-patterns") {
27688 return PATTERN_TYPES2.user;
27689 } else if (type === "registered") {
27690 return PATTERN_TYPES2.theme;
27691 }
27692 return null;
27693 }, [type]);
27694 const { patterns, isResolving } = use_patterns_default(
27695 patternType,
27696 categoryFilter,
27697 {
27698 search: view.search,
27699 syncStatus: syncStatusFilter
27700 }
27701 );
27702 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
27703 const patternCategoryField = usePatternCategoryField();
27704 const fields = (0, import_element82.useMemo)(() => {
27705 const patternFields = [
27706 previewField,
27707 patternTitleField,
27708 patternCategoryField
27709 ];
27710 if (type === "my-patterns" || type === "all") {
27711 patternFields.push(patternStatusField);
27712 }
27713 return patternFields;
27714 }, [type, patternCategoryField]);
27715 const { data: posts, paginationInfo } = (0, import_element82.useMemo)(() => {
27716 const viewWithoutFilters = { ...view };
27717 delete viewWithoutFilters.search;
27718 viewWithoutFilters.filters = [];
27719 return filterSortAndPaginate(
27720 patternsWithPermissions,
27721 viewWithoutFilters,
27722 fields
27723 );
27724 }, [patternsWithPermissions, view, fields]);
27725 const { totalItems, totalPages } = paginationInfo;
27726 const cleanupDeletedPostIdsFromUrl = (0, import_element82.useCallback)(
27727 (deletedItems) => {
27728 const deletedIds = deletedItems.map((item) => item.id);
27729 const currentPostIds = searchParams.postIds || [];
27730 const remainingPostIds = currentPostIds.filter(
27731 (id) => !deletedIds.includes(id)
27732 );
27733 if (remainingPostIds.length !== currentPostIds.length) {
27734 navigate({
27735 search: {
27736 ...searchParams,
27737 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
27738 }
27739 });
27740 } else {
27741 invalidate();
27742 }
27743 },
27744 [invalidate, searchParams, navigate]
27745 );
27746 const postTypeActions = usePostActions({
27747 postType: "wp_block",
27748 context: "list",
27749 onActionPerformed: (actionId, items) => {
27750 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
27751 cleanupDeletedPostIdsFromUrl(items);
27752 }
27753 }
27754 });
27755 const actions = (0, import_element82.useMemo)(() => {
27756 return [
27757 ...postTypeActions?.flatMap((action) => {
27758 if (action.id === "view-post-revisions") {
27759 return [];
27760 }
27761 return [action];
27762 })
27763 ];
27764 }, [postTypeActions]);
27765 const handleTabChange = (0, import_element82.useCallback)(
27766 (typeSlug) => {
27767 navigate({
27768 to: `/patterns/list/${typeSlug}`
27769 });
27770 },
27771 [navigate]
27772 );
27773 if (!postTypeObject) {
27774 return null;
27775 }
27776 const selection = searchParams.postIds ?? [];
27777 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
27778 selection.push(posts[0].id);
27779 }
27780 if (view.type === "list") {
27781 selection.splice(1);
27782 }
27783 return /* @__PURE__ */ React.createElement(
27784 page_default,
27785 {
27786 title: (0, import_i18n48.__)("Patterns"),
27787 headingLevel: 2,
27788 subTitle: (0, import_i18n48.__)(
27789 "Reusable design elements for your site. Create once, use everywhere."
27790 ),
27791 className: "pattern-page",
27792 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
27793 import_components48.Button,
27794 {
27795 variant: "primary",
27796 onClick: () => setShowPatternModal(true),
27797 size: "compact"
27798 },
27799 labels.add_new_item
27800 ),
27801 hasPadding: false
27802 },
27803 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
27804 Tabs,
27805 {
27806 onSelect: handleTabChange,
27807 selectedTabId: type ?? "all"
27808 },
27809 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
27810 (filter) => /* @__PURE__ */ React.createElement(
27811 Tabs.Tab,
27812 {
27813 tabId: filter.slug,
27814 key: filter.slug
27815 },
27816 filter.label
27817 )
27818 ))
27819 )),
27820 /* @__PURE__ */ React.createElement(
27821 dataviews_default,
27822 {
27823 data: posts,
27824 fields,
27825 view,
27826 onChangeView,
27827 actions,
27828 isLoading: isResolving,
27829 paginationInfo: {
27830 totalItems,
27831 totalPages
27832 },
27833 defaultLayouts: DEFAULT_LAYOUTS2,
27834 selection,
27835 onReset: isModified ? onReset : false,
27836 onChangeSelection: (items) => {
27837 navigate({
27838 search: {
27839 ...searchParams,
27840 postIds: items.length > 0 ? items : void 0,
27841 edit: items.length === 0 ? void 0 : searchParams.edit
27842 }
27843 });
27844 },
27845 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
27846 renderItemLink: ({
27847 item,
27848 ...props
27849 }) => /* @__PURE__ */ React.createElement(
27850 Link,
27851 {
27852 to: `/types/wp_block/edit/${encodeURIComponent(
27853 item.id
27854 )}`,
27855 ...props,
27856 onClick: (event) => {
27857 event.stopPropagation();
27858 }
27859 }
27860 )
27861 }
27862 ),
27863 showPatternModal && /* @__PURE__ */ React.createElement(
27864 CreatePatternModal,
27865 {
27866 onClose: () => setShowPatternModal(false),
27867 onSuccess: ({
27868 pattern
27869 }) => {
27870 setShowPatternModal(false);
27871 navigate({
27872 to: `/types/wp_block/edit/${encodeURIComponent(
27873 pattern.id
27874 )}`
27875 });
27876 },
27877 content: []
27878 }
27879 )
27880 );
27881 }
27882 var stage = PatternList;
27883 export {
27884 stage
27885 };
27886 /*! Bundled license information:
27887
27888 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27889 (**
27890 * @license React
27891 * use-sync-external-store-shim.development.js
27892 *
27893 * Copyright (c) Meta Platforms, Inc. and affiliates.
27894 *
27895 * This source code is licensed under the MIT license found in the
27896 * LICENSE file in the root directory of this source tree.
27897 *)
27898
27899 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27900 (**
27901 * @license React
27902 * use-sync-external-store-shim/with-selector.development.js
27903 *
27904 * Copyright (c) Meta Platforms, Inc. and affiliates.
27905 *
27906 * This source code is licensed under the MIT license found in the
27907 * LICENSE file in the root directory of this source tree.
27908 *)
27909 */
27910