PluginProbe
Gutenberg / 23.5.3
Gutenberg v23.5.3
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / widgets / activity / render.js

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

26,637 lines 927.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/core-data
46 var require_core_data = __commonJS({
47 "package-external:@wordpress/core-data"(exports, module) {
48 module.exports = window.wp.coreData;
49 }
50 });
51
52 // package-external:@wordpress/i18n
53 var require_i18n = __commonJS({
54 "package-external:@wordpress/i18n"(exports, module) {
55 module.exports = window.wp.i18n;
56 }
57 });
58
59 // package-external:@wordpress/date
60 var require_date = __commonJS({
61 "package-external:@wordpress/date"(exports, module) {
62 module.exports = window.wp.date;
63 }
64 });
65
66 // package-external:@wordpress/html-entities
67 var require_html_entities = __commonJS({
68 "package-external:@wordpress/html-entities"(exports, module) {
69 module.exports = window.wp.htmlEntities;
70 }
71 });
72
73 // package-external:@wordpress/components
74 var require_components = __commonJS({
75 "package-external:@wordpress/components"(exports, module) {
76 module.exports = window.wp.components;
77 }
78 });
79
80 // package-external:@wordpress/primitives
81 var require_primitives = __commonJS({
82 "package-external:@wordpress/primitives"(exports, module) {
83 module.exports = window.wp.primitives;
84 }
85 });
86
87 // vendor-external:react/jsx-runtime
88 var require_jsx_runtime = __commonJS({
89 "vendor-external:react/jsx-runtime"(exports, module) {
90 module.exports = window.ReactJSXRuntime;
91 }
92 });
93
94 // package-external:@wordpress/compose
95 var require_compose = __commonJS({
96 "package-external:@wordpress/compose"(exports, module) {
97 module.exports = window.wp.compose;
98 }
99 });
100
101 // vendor-external:react
102 var require_react = __commonJS({
103 "vendor-external:react"(exports, module) {
104 module.exports = window.React;
105 }
106 });
107
108 // vendor-external:react-dom
109 var require_react_dom = __commonJS({
110 "vendor-external:react-dom"(exports, module) {
111 module.exports = window.ReactDOM;
112 }
113 });
114
115 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
116 var require_use_sync_external_store_shim_development = __commonJS({
117 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
118 "use strict";
119 (function() {
120 function is(x2, y2) {
121 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
122 }
123 function useSyncExternalStore$2(subscribe2, getSnapshot) {
124 didWarnOld18Alpha || void 0 === React49.startTransition || (didWarnOld18Alpha = true, console.error(
125 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
126 ));
127 var value = getSnapshot();
128 if (!didWarnUncachedGetSnapshot) {
129 var cachedValue = getSnapshot();
130 objectIs(value, cachedValue) || (console.error(
131 "The result of getSnapshot should be cached to avoid an infinite loop"
132 ), didWarnUncachedGetSnapshot = true);
133 }
134 cachedValue = useState36({
135 inst: { value, getSnapshot }
136 });
137 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
138 useLayoutEffect5(
139 function() {
140 inst.value = value;
141 inst.getSnapshot = getSnapshot;
142 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
143 },
144 [subscribe2, value, getSnapshot]
145 );
146 useEffect31(
147 function() {
148 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
149 return subscribe2(function() {
150 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
151 });
152 },
153 [subscribe2]
154 );
155 useDebugValue2(value);
156 return value;
157 }
158 function checkIfSnapshotChanged(inst) {
159 var latestGetSnapshot = inst.getSnapshot;
160 inst = inst.value;
161 try {
162 var nextValue = latestGetSnapshot();
163 return !objectIs(inst, nextValue);
164 } catch (error) {
165 return true;
166 }
167 }
168 function useSyncExternalStore$1(subscribe2, getSnapshot) {
169 return getSnapshot();
170 }
171 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
172 var React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React49.useState, useEffect31 = React49.useEffect, useLayoutEffect5 = React49.useLayoutEffect, useDebugValue2 = React49.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
173 exports.useSyncExternalStore = void 0 !== React49.useSyncExternalStore ? React49.useSyncExternalStore : shim;
174 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
175 })();
176 }
177 });
178
179 // node_modules/use-sync-external-store/shim/index.js
180 var require_shim = __commonJS({
181 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
182 "use strict";
183 if (false) {
184 module.exports = null;
185 } else {
186 module.exports = require_use_sync_external_store_shim_development();
187 }
188 }
189 });
190
191 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
192 var require_with_selector_development = __commonJS({
193 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
194 "use strict";
195 (function() {
196 function is(x2, y2) {
197 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
198 }
199 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
200 var React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React49.useRef, useEffect31 = React49.useEffect, useMemo40 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
201 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
202 var instRef = useRef46(null);
203 if (null === instRef.current) {
204 var inst = { hasValue: false, value: null };
205 instRef.current = inst;
206 } else inst = instRef.current;
207 instRef = useMemo40(
208 function() {
209 function memoizedSelector(nextSnapshot) {
210 if (!hasMemo) {
211 hasMemo = true;
212 memoizedSnapshot = nextSnapshot;
213 nextSnapshot = selector2(nextSnapshot);
214 if (void 0 !== isEqual && inst.hasValue) {
215 var currentSelection = inst.value;
216 if (isEqual(currentSelection, nextSnapshot))
217 return memoizedSelection = currentSelection;
218 }
219 return memoizedSelection = nextSnapshot;
220 }
221 currentSelection = memoizedSelection;
222 if (objectIs(memoizedSnapshot, nextSnapshot))
223 return currentSelection;
224 var nextSelection = selector2(nextSnapshot);
225 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
226 return memoizedSnapshot = nextSnapshot, currentSelection;
227 memoizedSnapshot = nextSnapshot;
228 return memoizedSelection = nextSelection;
229 }
230 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
231 return [
232 function() {
233 return memoizedSelector(getSnapshot());
234 },
235 null === maybeGetServerSnapshot ? void 0 : function() {
236 return memoizedSelector(maybeGetServerSnapshot());
237 }
238 ];
239 },
240 [getSnapshot, getServerSnapshot, selector2, isEqual]
241 );
242 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
243 useEffect31(
244 function() {
245 inst.hasValue = true;
246 inst.value = value;
247 },
248 [value]
249 );
250 useDebugValue2(value);
251 return value;
252 };
253 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
254 })();
255 }
256 });
257
258 // node_modules/use-sync-external-store/shim/with-selector.js
259 var require_with_selector = __commonJS({
260 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
261 "use strict";
262 if (false) {
263 module.exports = null;
264 } else {
265 module.exports = require_with_selector_development();
266 }
267 }
268 });
269
270 // package-external:@wordpress/theme
271 var require_theme = __commonJS({
272 "package-external:@wordpress/theme"(exports, module) {
273 module.exports = window.wp.theme;
274 }
275 });
276
277 // package-external:@wordpress/private-apis
278 var require_private_apis = __commonJS({
279 "package-external:@wordpress/private-apis"(exports, module) {
280 module.exports = window.wp.privateApis;
281 }
282 });
283
284 // package-external:@wordpress/keycodes
285 var require_keycodes = __commonJS({
286 "package-external:@wordpress/keycodes"(exports, module) {
287 module.exports = window.wp.keycodes;
288 }
289 });
290
291 // node_modules/remove-accents/index.js
292 var require_remove_accents = __commonJS({
293 "node_modules/remove-accents/index.js"(exports, module) {
294 var characterMap = {
295 "\xC0": "A",
296 "\xC1": "A",
297 "\xC2": "A",
298 "\xC3": "A",
299 "\xC4": "A",
300 "\xC5": "A",
301 "\u1EA4": "A",
302 "\u1EAE": "A",
303 "\u1EB2": "A",
304 "\u1EB4": "A",
305 "\u1EB6": "A",
306 "\xC6": "AE",
307 "\u1EA6": "A",
308 "\u1EB0": "A",
309 "\u0202": "A",
310 "\u1EA2": "A",
311 "\u1EA0": "A",
312 "\u1EA8": "A",
313 "\u1EAA": "A",
314 "\u1EAC": "A",
315 "\xC7": "C",
316 "\u1E08": "C",
317 "\xC8": "E",
318 "\xC9": "E",
319 "\xCA": "E",
320 "\xCB": "E",
321 "\u1EBE": "E",
322 "\u1E16": "E",
323 "\u1EC0": "E",
324 "\u1E14": "E",
325 "\u1E1C": "E",
326 "\u0206": "E",
327 "\u1EBA": "E",
328 "\u1EBC": "E",
329 "\u1EB8": "E",
330 "\u1EC2": "E",
331 "\u1EC4": "E",
332 "\u1EC6": "E",
333 "\xCC": "I",
334 "\xCD": "I",
335 "\xCE": "I",
336 "\xCF": "I",
337 "\u1E2E": "I",
338 "\u020A": "I",
339 "\u1EC8": "I",
340 "\u1ECA": "I",
341 "\xD0": "D",
342 "\xD1": "N",
343 "\xD2": "O",
344 "\xD3": "O",
345 "\xD4": "O",
346 "\xD5": "O",
347 "\xD6": "O",
348 "\xD8": "O",
349 "\u1ED0": "O",
350 "\u1E4C": "O",
351 "\u1E52": "O",
352 "\u020E": "O",
353 "\u1ECE": "O",
354 "\u1ECC": "O",
355 "\u1ED4": "O",
356 "\u1ED6": "O",
357 "\u1ED8": "O",
358 "\u1EDC": "O",
359 "\u1EDE": "O",
360 "\u1EE0": "O",
361 "\u1EDA": "O",
362 "\u1EE2": "O",
363 "\xD9": "U",
364 "\xDA": "U",
365 "\xDB": "U",
366 "\xDC": "U",
367 "\u1EE6": "U",
368 "\u1EE4": "U",
369 "\u1EEC": "U",
370 "\u1EEE": "U",
371 "\u1EF0": "U",
372 "\xDD": "Y",
373 "\xE0": "a",
374 "\xE1": "a",
375 "\xE2": "a",
376 "\xE3": "a",
377 "\xE4": "a",
378 "\xE5": "a",
379 "\u1EA5": "a",
380 "\u1EAF": "a",
381 "\u1EB3": "a",
382 "\u1EB5": "a",
383 "\u1EB7": "a",
384 "\xE6": "ae",
385 "\u1EA7": "a",
386 "\u1EB1": "a",
387 "\u0203": "a",
388 "\u1EA3": "a",
389 "\u1EA1": "a",
390 "\u1EA9": "a",
391 "\u1EAB": "a",
392 "\u1EAD": "a",
393 "\xE7": "c",
394 "\u1E09": "c",
395 "\xE8": "e",
396 "\xE9": "e",
397 "\xEA": "e",
398 "\xEB": "e",
399 "\u1EBF": "e",
400 "\u1E17": "e",
401 "\u1EC1": "e",
402 "\u1E15": "e",
403 "\u1E1D": "e",
404 "\u0207": "e",
405 "\u1EBB": "e",
406 "\u1EBD": "e",
407 "\u1EB9": "e",
408 "\u1EC3": "e",
409 "\u1EC5": "e",
410 "\u1EC7": "e",
411 "\xEC": "i",
412 "\xED": "i",
413 "\xEE": "i",
414 "\xEF": "i",
415 "\u1E2F": "i",
416 "\u020B": "i",
417 "\u1EC9": "i",
418 "\u1ECB": "i",
419 "\xF0": "d",
420 "\xF1": "n",
421 "\xF2": "o",
422 "\xF3": "o",
423 "\xF4": "o",
424 "\xF5": "o",
425 "\xF6": "o",
426 "\xF8": "o",
427 "\u1ED1": "o",
428 "\u1E4D": "o",
429 "\u1E53": "o",
430 "\u020F": "o",
431 "\u1ECF": "o",
432 "\u1ECD": "o",
433 "\u1ED5": "o",
434 "\u1ED7": "o",
435 "\u1ED9": "o",
436 "\u1EDD": "o",
437 "\u1EDF": "o",
438 "\u1EE1": "o",
439 "\u1EDB": "o",
440 "\u1EE3": "o",
441 "\xF9": "u",
442 "\xFA": "u",
443 "\xFB": "u",
444 "\xFC": "u",
445 "\u1EE7": "u",
446 "\u1EE5": "u",
447 "\u1EED": "u",
448 "\u1EEF": "u",
449 "\u1EF1": "u",
450 "\xFD": "y",
451 "\xFF": "y",
452 "\u0100": "A",
453 "\u0101": "a",
454 "\u0102": "A",
455 "\u0103": "a",
456 "\u0104": "A",
457 "\u0105": "a",
458 "\u0106": "C",
459 "\u0107": "c",
460 "\u0108": "C",
461 "\u0109": "c",
462 "\u010A": "C",
463 "\u010B": "c",
464 "\u010C": "C",
465 "\u010D": "c",
466 "C\u0306": "C",
467 "c\u0306": "c",
468 "\u010E": "D",
469 "\u010F": "d",
470 "\u0110": "D",
471 "\u0111": "d",
472 "\u0112": "E",
473 "\u0113": "e",
474 "\u0114": "E",
475 "\u0115": "e",
476 "\u0116": "E",
477 "\u0117": "e",
478 "\u0118": "E",
479 "\u0119": "e",
480 "\u011A": "E",
481 "\u011B": "e",
482 "\u011C": "G",
483 "\u01F4": "G",
484 "\u011D": "g",
485 "\u01F5": "g",
486 "\u011E": "G",
487 "\u011F": "g",
488 "\u0120": "G",
489 "\u0121": "g",
490 "\u0122": "G",
491 "\u0123": "g",
492 "\u0124": "H",
493 "\u0125": "h",
494 "\u0126": "H",
495 "\u0127": "h",
496 "\u1E2A": "H",
497 "\u1E2B": "h",
498 "\u0128": "I",
499 "\u0129": "i",
500 "\u012A": "I",
501 "\u012B": "i",
502 "\u012C": "I",
503 "\u012D": "i",
504 "\u012E": "I",
505 "\u012F": "i",
506 "\u0130": "I",
507 "\u0131": "i",
508 "\u0132": "IJ",
509 "\u0133": "ij",
510 "\u0134": "J",
511 "\u0135": "j",
512 "\u0136": "K",
513 "\u0137": "k",
514 "\u1E30": "K",
515 "\u1E31": "k",
516 "K\u0306": "K",
517 "k\u0306": "k",
518 "\u0139": "L",
519 "\u013A": "l",
520 "\u013B": "L",
521 "\u013C": "l",
522 "\u013D": "L",
523 "\u013E": "l",
524 "\u013F": "L",
525 "\u0140": "l",
526 "\u0141": "l",
527 "\u0142": "l",
528 "\u1E3E": "M",
529 "\u1E3F": "m",
530 "M\u0306": "M",
531 "m\u0306": "m",
532 "\u0143": "N",
533 "\u0144": "n",
534 "\u0145": "N",
535 "\u0146": "n",
536 "\u0147": "N",
537 "\u0148": "n",
538 "\u0149": "n",
539 "N\u0306": "N",
540 "n\u0306": "n",
541 "\u014C": "O",
542 "\u014D": "o",
543 "\u014E": "O",
544 "\u014F": "o",
545 "\u0150": "O",
546 "\u0151": "o",
547 "\u0152": "OE",
548 "\u0153": "oe",
549 "P\u0306": "P",
550 "p\u0306": "p",
551 "\u0154": "R",
552 "\u0155": "r",
553 "\u0156": "R",
554 "\u0157": "r",
555 "\u0158": "R",
556 "\u0159": "r",
557 "R\u0306": "R",
558 "r\u0306": "r",
559 "\u0212": "R",
560 "\u0213": "r",
561 "\u015A": "S",
562 "\u015B": "s",
563 "\u015C": "S",
564 "\u015D": "s",
565 "\u015E": "S",
566 "\u0218": "S",
567 "\u0219": "s",
568 "\u015F": "s",
569 "\u0160": "S",
570 "\u0161": "s",
571 "\u0162": "T",
572 "\u0163": "t",
573 "\u021B": "t",
574 "\u021A": "T",
575 "\u0164": "T",
576 "\u0165": "t",
577 "\u0166": "T",
578 "\u0167": "t",
579 "T\u0306": "T",
580 "t\u0306": "t",
581 "\u0168": "U",
582 "\u0169": "u",
583 "\u016A": "U",
584 "\u016B": "u",
585 "\u016C": "U",
586 "\u016D": "u",
587 "\u016E": "U",
588 "\u016F": "u",
589 "\u0170": "U",
590 "\u0171": "u",
591 "\u0172": "U",
592 "\u0173": "u",
593 "\u0216": "U",
594 "\u0217": "u",
595 "V\u0306": "V",
596 "v\u0306": "v",
597 "\u0174": "W",
598 "\u0175": "w",
599 "\u1E82": "W",
600 "\u1E83": "w",
601 "X\u0306": "X",
602 "x\u0306": "x",
603 "\u0176": "Y",
604 "\u0177": "y",
605 "\u0178": "Y",
606 "Y\u0306": "Y",
607 "y\u0306": "y",
608 "\u0179": "Z",
609 "\u017A": "z",
610 "\u017B": "Z",
611 "\u017C": "z",
612 "\u017D": "Z",
613 "\u017E": "z",
614 "\u017F": "s",
615 "\u0192": "f",
616 "\u01A0": "O",
617 "\u01A1": "o",
618 "\u01AF": "U",
619 "\u01B0": "u",
620 "\u01CD": "A",
621 "\u01CE": "a",
622 "\u01CF": "I",
623 "\u01D0": "i",
624 "\u01D1": "O",
625 "\u01D2": "o",
626 "\u01D3": "U",
627 "\u01D4": "u",
628 "\u01D5": "U",
629 "\u01D6": "u",
630 "\u01D7": "U",
631 "\u01D8": "u",
632 "\u01D9": "U",
633 "\u01DA": "u",
634 "\u01DB": "U",
635 "\u01DC": "u",
636 "\u1EE8": "U",
637 "\u1EE9": "u",
638 "\u1E78": "U",
639 "\u1E79": "u",
640 "\u01FA": "A",
641 "\u01FB": "a",
642 "\u01FC": "AE",
643 "\u01FD": "ae",
644 "\u01FE": "O",
645 "\u01FF": "o",
646 "\xDE": "TH",
647 "\xFE": "th",
648 "\u1E54": "P",
649 "\u1E55": "p",
650 "\u1E64": "S",
651 "\u1E65": "s",
652 "X\u0301": "X",
653 "x\u0301": "x",
654 "\u0403": "\u0413",
655 "\u0453": "\u0433",
656 "\u040C": "\u041A",
657 "\u045C": "\u043A",
658 "A\u030B": "A",
659 "a\u030B": "a",
660 "E\u030B": "E",
661 "e\u030B": "e",
662 "I\u030B": "I",
663 "i\u030B": "i",
664 "\u01F8": "N",
665 "\u01F9": "n",
666 "\u1ED2": "O",
667 "\u1ED3": "o",
668 "\u1E50": "O",
669 "\u1E51": "o",
670 "\u1EEA": "U",
671 "\u1EEB": "u",
672 "\u1E80": "W",
673 "\u1E81": "w",
674 "\u1EF2": "Y",
675 "\u1EF3": "y",
676 "\u0200": "A",
677 "\u0201": "a",
678 "\u0204": "E",
679 "\u0205": "e",
680 "\u0208": "I",
681 "\u0209": "i",
682 "\u020C": "O",
683 "\u020D": "o",
684 "\u0210": "R",
685 "\u0211": "r",
686 "\u0214": "U",
687 "\u0215": "u",
688 "B\u030C": "B",
689 "b\u030C": "b",
690 "\u010C\u0323": "C",
691 "\u010D\u0323": "c",
692 "\xCA\u030C": "E",
693 "\xEA\u030C": "e",
694 "F\u030C": "F",
695 "f\u030C": "f",
696 "\u01E6": "G",
697 "\u01E7": "g",
698 "\u021E": "H",
699 "\u021F": "h",
700 "J\u030C": "J",
701 "\u01F0": "j",
702 "\u01E8": "K",
703 "\u01E9": "k",
704 "M\u030C": "M",
705 "m\u030C": "m",
706 "P\u030C": "P",
707 "p\u030C": "p",
708 "Q\u030C": "Q",
709 "q\u030C": "q",
710 "\u0158\u0329": "R",
711 "\u0159\u0329": "r",
712 "\u1E66": "S",
713 "\u1E67": "s",
714 "V\u030C": "V",
715 "v\u030C": "v",
716 "W\u030C": "W",
717 "w\u030C": "w",
718 "X\u030C": "X",
719 "x\u030C": "x",
720 "Y\u030C": "Y",
721 "y\u030C": "y",
722 "A\u0327": "A",
723 "a\u0327": "a",
724 "B\u0327": "B",
725 "b\u0327": "b",
726 "\u1E10": "D",
727 "\u1E11": "d",
728 "\u0228": "E",
729 "\u0229": "e",
730 "\u0190\u0327": "E",
731 "\u025B\u0327": "e",
732 "\u1E28": "H",
733 "\u1E29": "h",
734 "I\u0327": "I",
735 "i\u0327": "i",
736 "\u0197\u0327": "I",
737 "\u0268\u0327": "i",
738 "M\u0327": "M",
739 "m\u0327": "m",
740 "O\u0327": "O",
741 "o\u0327": "o",
742 "Q\u0327": "Q",
743 "q\u0327": "q",
744 "U\u0327": "U",
745 "u\u0327": "u",
746 "X\u0327": "X",
747 "x\u0327": "x",
748 "Z\u0327": "Z",
749 "z\u0327": "z",
750 "\u0439": "\u0438",
751 "\u0419": "\u0418",
752 "\u0451": "\u0435",
753 "\u0401": "\u0415"
754 };
755 var chars = Object.keys(characterMap).join("|");
756 var allAccents = new RegExp(chars, "g");
757 var firstAccent = new RegExp(chars, "");
758 function matcher(match2) {
759 return characterMap[match2];
760 }
761 var removeAccents3 = function(string) {
762 return string.replace(allAccents, matcher);
763 };
764 var hasAccents = function(string) {
765 return !!string.match(firstAccent);
766 };
767 module.exports = removeAccents3;
768 module.exports.has = hasAccents;
769 module.exports.remove = removeAccents3;
770 }
771 });
772
773 // node_modules/fast-deep-equal/es6/index.js
774 var require_es6 = __commonJS({
775 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
776 "use strict";
777 module.exports = function equal(a2, b2) {
778 if (a2 === b2) return true;
779 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
780 if (a2.constructor !== b2.constructor) return false;
781 var length, i2, keys;
782 if (Array.isArray(a2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (!equal(a2[i2], b2[i2])) return false;
787 return true;
788 }
789 if (a2 instanceof Map && b2 instanceof Map) {
790 if (a2.size !== b2.size) return false;
791 for (i2 of a2.entries())
792 if (!b2.has(i2[0])) return false;
793 for (i2 of a2.entries())
794 if (!equal(i2[1], b2.get(i2[0]))) return false;
795 return true;
796 }
797 if (a2 instanceof Set && b2 instanceof Set) {
798 if (a2.size !== b2.size) return false;
799 for (i2 of a2.entries())
800 if (!b2.has(i2[0])) return false;
801 return true;
802 }
803 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
804 length = a2.length;
805 if (length != b2.length) return false;
806 for (i2 = length; i2-- !== 0; )
807 if (a2[i2] !== b2[i2]) return false;
808 return true;
809 }
810 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
811 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
812 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
813 keys = Object.keys(a2);
814 length = keys.length;
815 if (length !== Object.keys(b2).length) return false;
816 for (i2 = length; i2-- !== 0; )
817 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
818 for (i2 = length; i2-- !== 0; ) {
819 var key = keys[i2];
820 if (!equal(a2[key], b2[key])) return false;
821 }
822 return true;
823 }
824 return a2 !== a2 && b2 !== b2;
825 };
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // package-external:@wordpress/deprecated
837 var require_deprecated = __commonJS({
838 "package-external:@wordpress/deprecated"(exports, module) {
839 module.exports = window.wp.deprecated;
840 }
841 });
842
843 // widgets/activity/render.tsx
844 var import_element84 = __toESM(require_element());
845 var import_data6 = __toESM(require_data());
846 var import_core_data = __toESM(require_core_data());
847 var import_i18n45 = __toESM(require_i18n());
848 var import_date10 = __toESM(require_date());
849 var import_html_entities = __toESM(require_html_entities());
850 var import_components46 = __toESM(require_components());
851
852 // packages/icons/build-module/icon/index.mjs
853 var import_element = __toESM(require_element(), 1);
854 var icon_default = (0, import_element.forwardRef)(
855 ({ icon, size: size4 = 24, ...props }, ref) => {
856 return (0, import_element.cloneElement)(icon, {
857 width: size4,
858 height: size4,
859 ...props,
860 ref
861 });
862 }
863 );
864
865 // packages/icons/build-module/library/arrow-down.mjs
866 var import_primitives = __toESM(require_primitives(), 1);
867 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
868 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
869
870 // packages/icons/build-module/library/arrow-left.mjs
871 var import_primitives2 = __toESM(require_primitives(), 1);
872 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
873 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
874
875 // packages/icons/build-module/library/arrow-right.mjs
876 var import_primitives3 = __toESM(require_primitives(), 1);
877 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
878 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
879
880 // packages/icons/build-module/library/arrow-up.mjs
881 var import_primitives4 = __toESM(require_primitives(), 1);
882 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
883 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
884
885 // packages/icons/build-module/library/block-table.mjs
886 var import_primitives5 = __toESM(require_primitives(), 1);
887 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
888 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
889
890 // packages/icons/build-module/library/category.mjs
891 var import_primitives6 = __toESM(require_primitives(), 1);
892 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
893 var category_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
894
895 // packages/icons/build-module/library/check.mjs
896 var import_primitives7 = __toESM(require_primitives(), 1);
897 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
898 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
899
900 // packages/icons/build-module/library/close-small.mjs
901 var import_primitives8 = __toESM(require_primitives(), 1);
902 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
903 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
904
905 // packages/icons/build-module/library/cog.mjs
906 var import_primitives9 = __toESM(require_primitives(), 1);
907 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
908 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
909
910 // packages/icons/build-module/library/comment.mjs
911 var import_primitives10 = __toESM(require_primitives(), 1);
912 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
913 var comment_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) });
914
915 // packages/icons/build-module/library/envelope.mjs
916 var import_primitives11 = __toESM(require_primitives(), 1);
917 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
918 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
919
920 // packages/icons/build-module/library/error.mjs
921 var import_primitives12 = __toESM(require_primitives(), 1);
922 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
923 var error_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
924
925 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
926 var import_primitives13 = __toESM(require_primitives(), 1);
927 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
928 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
929
930 // packages/icons/build-module/library/format-list-bullets.mjs
931 var import_primitives14 = __toESM(require_primitives(), 1);
932 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
933 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
934
935 // packages/icons/build-module/library/funnel.mjs
936 var import_primitives15 = __toESM(require_primitives(), 1);
937 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
938 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
939
940 // packages/icons/build-module/library/link.mjs
941 var import_primitives16 = __toESM(require_primitives(), 1);
942 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
943 var link_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
944
945 // packages/icons/build-module/library/mobile.mjs
946 var import_primitives17 = __toESM(require_primitives(), 1);
947 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
948 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
949
950 // packages/icons/build-module/library/more-vertical.mjs
951 var import_primitives18 = __toESM(require_primitives(), 1);
952 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
953 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
954
955 // packages/icons/build-module/library/next.mjs
956 var import_primitives19 = __toESM(require_primitives(), 1);
957 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
958 var next_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
959
960 // packages/icons/build-module/library/post-list.mjs
961 var import_primitives20 = __toESM(require_primitives(), 1);
962 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
963 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { d: "M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z" }) });
964
965 // packages/icons/build-module/library/previous.mjs
966 var import_primitives21 = __toESM(require_primitives(), 1);
967 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
968 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
969
970 // packages/icons/build-module/library/scheduled.mjs
971 var import_primitives22 = __toESM(require_primitives(), 1);
972 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
973 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
974
975 // packages/icons/build-module/library/search.mjs
976 var import_primitives23 = __toESM(require_primitives(), 1);
977 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
978 var search_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
979
980 // packages/icons/build-module/library/seen.mjs
981 var import_primitives24 = __toESM(require_primitives(), 1);
982 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
983 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
984
985 // packages/icons/build-module/library/unseen.mjs
986 var import_primitives25 = __toESM(require_primitives(), 1);
987 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
988 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
989
990 // node_modules/clsx/dist/clsx.mjs
991 function r(e2) {
992 var t2, f2, n2 = "";
993 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
994 else if ("object" == typeof e2) if (Array.isArray(e2)) {
995 var o2 = e2.length;
996 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
997 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
998 return n2;
999 }
1000 function clsx() {
1001 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1002 return n2;
1003 }
1004 var clsx_default = clsx;
1005
1006 // packages/dataviews/build-module/dataviews/index.mjs
1007 var import_element83 = __toESM(require_element(), 1);
1008 var import_compose13 = __toESM(require_compose(), 1);
1009
1010 // node_modules/@base-ui/utils/esm/safeReact.js
1011 var React = __toESM(require_react(), 1);
1012 var SafeReact = {
1013 ...React
1014 };
1015
1016 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1017 var React2 = __toESM(require_react(), 1);
1018 var UNINITIALIZED = {};
1019 function useRefWithInit(init2, initArg) {
1020 const ref = React2.useRef(UNINITIALIZED);
1021 if (ref.current === UNINITIALIZED) {
1022 ref.current = init2(initArg);
1023 }
1024 return ref;
1025 }
1026
1027 // node_modules/@base-ui/utils/esm/useStableCallback.js
1028 var useInsertionEffect = SafeReact.useInsertionEffect;
1029 var useSafeInsertionEffect = (
1030 // React 17 doesn't have useInsertionEffect.
1031 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1032 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1033 );
1034 function useStableCallback(callback) {
1035 const stable = useRefWithInit(createStableCallback).current;
1036 stable.next = callback;
1037 useSafeInsertionEffect(stable.effect);
1038 return stable.trampoline;
1039 }
1040 function createStableCallback() {
1041 const stable = {
1042 next: void 0,
1043 callback: assertNotCalled,
1044 trampoline: (...args) => stable.callback?.(...args),
1045 effect: () => {
1046 stable.callback = stable.next;
1047 }
1048 };
1049 return stable;
1050 }
1051 function assertNotCalled() {
1052 if (true) {
1053 throw (
1054 /* minify-error-disabled */
1055 new Error("Base UI: Cannot call an event handler while rendering.")
1056 );
1057 }
1058 }
1059
1060 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1061 var React3 = __toESM(require_react(), 1);
1062 var noop = () => {
1063 };
1064 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
1065
1066 // node_modules/@base-ui/utils/esm/warn.js
1067 var set;
1068 if (true) {
1069 set = /* @__PURE__ */ new Set();
1070 }
1071 function warn(...messages) {
1072 if (true) {
1073 const messageKey = messages.join(" ");
1074 if (!set.has(messageKey)) {
1075 set.add(messageKey);
1076 console.warn(`Base UI: ${messageKey}`);
1077 }
1078 }
1079 }
1080
1081 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1082 var React4 = __toESM(require_react(), 1);
1083 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1084 if (true) DirectionContext.displayName = "DirectionContext";
1085 function useDirection() {
1086 const context = React4.useContext(DirectionContext);
1087 return context?.direction ?? "ltr";
1088 }
1089
1090 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1091 var React7 = __toESM(require_react(), 1);
1092
1093 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1094 function useMergedRefs(a2, b2, c2, d2) {
1095 const forkRef = useRefWithInit(createForkRef).current;
1096 if (didChange(forkRef, a2, b2, c2, d2)) {
1097 update(forkRef, [a2, b2, c2, d2]);
1098 }
1099 return forkRef.callback;
1100 }
1101 function useMergedRefsN(refs) {
1102 const forkRef = useRefWithInit(createForkRef).current;
1103 if (didChangeN(forkRef, refs)) {
1104 update(forkRef, refs);
1105 }
1106 return forkRef.callback;
1107 }
1108 function createForkRef() {
1109 return {
1110 callback: null,
1111 cleanup: null,
1112 refs: []
1113 };
1114 }
1115 function didChange(forkRef, a2, b2, c2, d2) {
1116 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1117 }
1118 function didChangeN(forkRef, newRefs) {
1119 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1120 }
1121 function update(forkRef, refs) {
1122 forkRef.refs = refs;
1123 if (refs.every((ref) => ref == null)) {
1124 forkRef.callback = null;
1125 return;
1126 }
1127 forkRef.callback = (instance) => {
1128 if (forkRef.cleanup) {
1129 forkRef.cleanup();
1130 forkRef.cleanup = null;
1131 }
1132 if (instance != null) {
1133 const cleanupCallbacks = Array(refs.length).fill(null);
1134 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1135 const ref = refs[i2];
1136 if (ref == null) {
1137 continue;
1138 }
1139 switch (typeof ref) {
1140 case "function": {
1141 const refCleanup = ref(instance);
1142 if (typeof refCleanup === "function") {
1143 cleanupCallbacks[i2] = refCleanup;
1144 }
1145 break;
1146 }
1147 case "object": {
1148 ref.current = instance;
1149 break;
1150 }
1151 default:
1152 }
1153 }
1154 forkRef.cleanup = () => {
1155 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1156 const ref = refs[i2];
1157 if (ref == null) {
1158 continue;
1159 }
1160 switch (typeof ref) {
1161 case "function": {
1162 const cleanupCallback = cleanupCallbacks[i2];
1163 if (typeof cleanupCallback === "function") {
1164 cleanupCallback();
1165 } else {
1166 ref(null);
1167 }
1168 break;
1169 }
1170 case "object": {
1171 ref.current = null;
1172 break;
1173 }
1174 default:
1175 }
1176 }
1177 };
1178 }
1179 };
1180 }
1181
1182 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1183 var React6 = __toESM(require_react(), 1);
1184
1185 // node_modules/@base-ui/utils/esm/reactVersion.js
1186 var React5 = __toESM(require_react(), 1);
1187 var majorVersion = parseInt(React5.version, 10);
1188 function isReactVersionAtLeast(reactVersionToCheck) {
1189 return majorVersion >= reactVersionToCheck;
1190 }
1191
1192 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1193 function getReactElementRef(element) {
1194 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1195 return null;
1196 }
1197 const reactElement = element;
1198 const propsWithRef = reactElement.props;
1199 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1200 }
1201
1202 // node_modules/@base-ui/utils/esm/mergeObjects.js
1203 function mergeObjects(a2, b2) {
1204 if (a2 && !b2) {
1205 return a2;
1206 }
1207 if (!a2 && b2) {
1208 return b2;
1209 }
1210 if (a2 || b2) {
1211 return {
1212 ...a2,
1213 ...b2
1214 };
1215 }
1216 return void 0;
1217 }
1218
1219 // node_modules/@base-ui/utils/esm/empty.js
1220 function NOOP() {
1221 }
1222 var EMPTY_ARRAY = Object.freeze([]);
1223 var EMPTY_OBJECT = Object.freeze({});
1224
1225 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1226 function getStateAttributesProps(state, customMapping) {
1227 const props = {};
1228 for (const key in state) {
1229 const value = state[key];
1230 if (customMapping?.hasOwnProperty(key)) {
1231 const customProps = customMapping[key](value);
1232 if (customProps != null) {
1233 Object.assign(props, customProps);
1234 }
1235 continue;
1236 }
1237 if (value === true) {
1238 props[`data-${key.toLowerCase()}`] = "";
1239 } else if (value) {
1240 props[`data-${key.toLowerCase()}`] = value.toString();
1241 }
1242 }
1243 return props;
1244 }
1245
1246 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1247 function resolveClassName(className, state) {
1248 return typeof className === "function" ? className(state) : className;
1249 }
1250
1251 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1252 function resolveStyle(style, state) {
1253 return typeof style === "function" ? style(state) : style;
1254 }
1255
1256 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1257 var EMPTY_PROPS = {};
1258 function mergeProps(a2, b2, c2, d2, e2) {
1259 if (!c2 && !d2 && !e2 && !a2) {
1260 return createInitialMergedProps(b2);
1261 }
1262 let merged = createInitialMergedProps(a2);
1263 if (b2) {
1264 merged = mergeInto(merged, b2);
1265 }
1266 if (c2) {
1267 merged = mergeInto(merged, c2);
1268 }
1269 if (d2) {
1270 merged = mergeInto(merged, d2);
1271 }
1272 if (e2) {
1273 merged = mergeInto(merged, e2);
1274 }
1275 return merged;
1276 }
1277 function mergePropsN(props) {
1278 if (props.length === 0) {
1279 return EMPTY_PROPS;
1280 }
1281 if (props.length === 1) {
1282 return createInitialMergedProps(props[0]);
1283 }
1284 let merged = createInitialMergedProps(props[0]);
1285 for (let i2 = 1; i2 < props.length; i2 += 1) {
1286 merged = mergeInto(merged, props[i2]);
1287 }
1288 return merged;
1289 }
1290 function createInitialMergedProps(inputProps) {
1291 if (isPropsGetter(inputProps)) {
1292 return {
1293 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1294 };
1295 }
1296 return copyInitialProps(inputProps);
1297 }
1298 function mergeInto(merged, inputProps) {
1299 if (isPropsGetter(inputProps)) {
1300 return resolvePropsGetter(inputProps, merged);
1301 }
1302 return mutablyMergeInto(merged, inputProps);
1303 }
1304 function copyInitialProps(inputProps) {
1305 const copiedProps = {
1306 ...inputProps
1307 };
1308 for (const propName in copiedProps) {
1309 const propValue = copiedProps[propName];
1310 if (isEventHandler(propName, propValue)) {
1311 copiedProps[propName] = wrapEventHandler(propValue);
1312 }
1313 }
1314 return copiedProps;
1315 }
1316 function mutablyMergeInto(mergedProps, externalProps) {
1317 if (!externalProps) {
1318 return mergedProps;
1319 }
1320 for (const propName in externalProps) {
1321 const externalPropValue = externalProps[propName];
1322 switch (propName) {
1323 case "style": {
1324 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1325 break;
1326 }
1327 case "className": {
1328 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1329 break;
1330 }
1331 default: {
1332 if (isEventHandler(propName, externalPropValue)) {
1333 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1334 } else {
1335 mergedProps[propName] = externalPropValue;
1336 }
1337 }
1338 }
1339 }
1340 return mergedProps;
1341 }
1342 function isEventHandler(key, value) {
1343 const code0 = key.charCodeAt(0);
1344 const code1 = key.charCodeAt(1);
1345 const code2 = key.charCodeAt(2);
1346 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1347 }
1348 function isPropsGetter(inputProps) {
1349 return typeof inputProps === "function";
1350 }
1351 function resolvePropsGetter(inputProps, previousProps) {
1352 if (isPropsGetter(inputProps)) {
1353 return inputProps(previousProps);
1354 }
1355 return inputProps ?? EMPTY_PROPS;
1356 }
1357 function mergeEventHandlers(ourHandler, theirHandler) {
1358 if (!theirHandler) {
1359 return ourHandler;
1360 }
1361 if (!ourHandler) {
1362 return wrapEventHandler(theirHandler);
1363 }
1364 return (...args) => {
1365 const event = args[0];
1366 if (isSyntheticEvent(event)) {
1367 const baseUIEvent = event;
1368 makeEventPreventable(baseUIEvent);
1369 const result2 = theirHandler(...args);
1370 if (!baseUIEvent.baseUIHandlerPrevented) {
1371 ourHandler?.(...args);
1372 }
1373 return result2;
1374 }
1375 const result = theirHandler(...args);
1376 ourHandler?.(...args);
1377 return result;
1378 };
1379 }
1380 function wrapEventHandler(handler) {
1381 if (!handler) {
1382 return handler;
1383 }
1384 return (...args) => {
1385 const event = args[0];
1386 if (isSyntheticEvent(event)) {
1387 makeEventPreventable(event);
1388 }
1389 return handler(...args);
1390 };
1391 }
1392 function makeEventPreventable(event) {
1393 event.preventBaseUIHandler = () => {
1394 event.baseUIHandlerPrevented = true;
1395 };
1396 return event;
1397 }
1398 function mergeClassNames(ourClassName, theirClassName) {
1399 if (theirClassName) {
1400 if (ourClassName) {
1401 return theirClassName + " " + ourClassName;
1402 }
1403 return theirClassName;
1404 }
1405 return ourClassName;
1406 }
1407 function isSyntheticEvent(event) {
1408 return event != null && typeof event === "object" && "nativeEvent" in event;
1409 }
1410
1411 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1412 var import_react = __toESM(require_react(), 1);
1413 function useRenderElement(element, componentProps, params = {}) {
1414 const renderProp = componentProps.render;
1415 const outProps = useRenderElementProps(componentProps, params);
1416 if (params.enabled === false) {
1417 return null;
1418 }
1419 const state = params.state ?? EMPTY_OBJECT;
1420 return evaluateRenderProp(element, renderProp, outProps, state);
1421 }
1422 function useRenderElementProps(componentProps, params = {}) {
1423 const {
1424 className: classNameProp,
1425 style: styleProp,
1426 render: renderProp
1427 } = componentProps;
1428 const {
1429 state = EMPTY_OBJECT,
1430 ref,
1431 props,
1432 stateAttributesMapping: stateAttributesMapping3,
1433 enabled = true
1434 } = params;
1435 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1436 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1437 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1438 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1439 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1440 if (typeof document !== "undefined") {
1441 if (!enabled) {
1442 useMergedRefs(null, null);
1443 } else if (Array.isArray(ref)) {
1444 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1445 } else {
1446 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1447 }
1448 }
1449 if (!enabled) {
1450 return EMPTY_OBJECT;
1451 }
1452 if (className !== void 0) {
1453 outProps.className = mergeClassNames(outProps.className, className);
1454 }
1455 if (style !== void 0) {
1456 outProps.style = mergeObjects(outProps.style, style);
1457 }
1458 return outProps;
1459 }
1460 function resolveRenderFunctionProps(props) {
1461 if (Array.isArray(props)) {
1462 return mergePropsN(props);
1463 }
1464 return mergeProps(void 0, props);
1465 }
1466 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1467 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1468 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1469 function evaluateRenderProp(element, render4, props, state) {
1470 if (render4) {
1471 if (typeof render4 === "function") {
1472 if (true) {
1473 warnIfRenderPropLooksLikeComponent(render4);
1474 }
1475 return render4(props, state);
1476 }
1477 const mergedProps = mergeProps(props, render4.props);
1478 mergedProps.ref = props.ref;
1479 let newElement = render4;
1480 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1481 const children = React7.Children.toArray(render4);
1482 newElement = children[0];
1483 }
1484 if (true) {
1485 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1486 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1487 }
1488 }
1489 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1490 }
1491 if (element) {
1492 if (typeof element === "string") {
1493 return renderTag(element, props);
1494 }
1495 }
1496 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1497 }
1498 function warnIfRenderPropLooksLikeComponent(renderFn) {
1499 const functionName = renderFn.name;
1500 if (functionName.length === 0) {
1501 return;
1502 }
1503 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1504 return;
1505 }
1506 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1507 return;
1508 }
1509 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1510 }
1511 function renderTag(Tag, props) {
1512 if (Tag === "button") {
1513 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1514 type: "button",
1515 ...props,
1516 key: props.key
1517 });
1518 }
1519 if (Tag === "img") {
1520 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1521 alt: "",
1522 ...props,
1523 key: props.key
1524 });
1525 }
1526 return /* @__PURE__ */ React7.createElement(Tag, props);
1527 }
1528
1529 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1530 var reason_parts_exports = {};
1531 __export(reason_parts_exports, {
1532 cancelOpen: () => cancelOpen,
1533 chipRemovePress: () => chipRemovePress,
1534 clearPress: () => clearPress,
1535 closePress: () => closePress,
1536 closeWatcher: () => closeWatcher,
1537 decrementPress: () => decrementPress,
1538 disabled: () => disabled,
1539 drag: () => drag,
1540 escapeKey: () => escapeKey,
1541 focusOut: () => focusOut,
1542 imperativeAction: () => imperativeAction,
1543 incrementPress: () => incrementPress,
1544 initial: () => initial,
1545 inputBlur: () => inputBlur,
1546 inputChange: () => inputChange,
1547 inputClear: () => inputClear,
1548 inputPaste: () => inputPaste,
1549 inputPress: () => inputPress,
1550 itemPress: () => itemPress,
1551 keyboard: () => keyboard,
1552 linkPress: () => linkPress,
1553 listNavigation: () => listNavigation,
1554 missing: () => missing,
1555 none: () => none,
1556 outsidePress: () => outsidePress,
1557 pointer: () => pointer,
1558 scrub: () => scrub,
1559 siblingOpen: () => siblingOpen,
1560 swipe: () => swipe,
1561 trackPress: () => trackPress,
1562 triggerFocus: () => triggerFocus,
1563 triggerHover: () => triggerHover,
1564 triggerPress: () => triggerPress,
1565 wheel: () => wheel,
1566 windowResize: () => windowResize
1567 });
1568 var none = "none";
1569 var triggerPress = "trigger-press";
1570 var triggerHover = "trigger-hover";
1571 var triggerFocus = "trigger-focus";
1572 var outsidePress = "outside-press";
1573 var itemPress = "item-press";
1574 var closePress = "close-press";
1575 var linkPress = "link-press";
1576 var clearPress = "clear-press";
1577 var chipRemovePress = "chip-remove-press";
1578 var trackPress = "track-press";
1579 var incrementPress = "increment-press";
1580 var decrementPress = "decrement-press";
1581 var inputChange = "input-change";
1582 var inputClear = "input-clear";
1583 var inputBlur = "input-blur";
1584 var inputPaste = "input-paste";
1585 var inputPress = "input-press";
1586 var focusOut = "focus-out";
1587 var escapeKey = "escape-key";
1588 var closeWatcher = "close-watcher";
1589 var listNavigation = "list-navigation";
1590 var keyboard = "keyboard";
1591 var pointer = "pointer";
1592 var drag = "drag";
1593 var wheel = "wheel";
1594 var scrub = "scrub";
1595 var cancelOpen = "cancel-open";
1596 var siblingOpen = "sibling-open";
1597 var disabled = "disabled";
1598 var missing = "missing";
1599 var initial = "initial";
1600 var imperativeAction = "imperative-action";
1601 var swipe = "swipe";
1602 var windowResize = "window-resize";
1603
1604 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1605 function createChangeEventDetails(reason, event, trigger, customProperties) {
1606 let canceled = false;
1607 let allowPropagation = false;
1608 const custom = customProperties ?? EMPTY_OBJECT;
1609 const details = {
1610 reason,
1611 event: event ?? new Event("base-ui"),
1612 cancel() {
1613 canceled = true;
1614 },
1615 allowPropagation() {
1616 allowPropagation = true;
1617 },
1618 get isCanceled() {
1619 return canceled;
1620 },
1621 get isPropagationAllowed() {
1622 return allowPropagation;
1623 },
1624 trigger,
1625 ...custom
1626 };
1627 return details;
1628 }
1629
1630 // node_modules/@base-ui/utils/esm/useId.js
1631 var React8 = __toESM(require_react(), 1);
1632 var globalId = 0;
1633 function useGlobalId(idOverride, prefix = "mui") {
1634 const [defaultId, setDefaultId] = React8.useState(idOverride);
1635 const id = idOverride || defaultId;
1636 React8.useEffect(() => {
1637 if (defaultId == null) {
1638 globalId += 1;
1639 setDefaultId(`${prefix}-${globalId}`);
1640 }
1641 }, [defaultId, prefix]);
1642 return id;
1643 }
1644 var maybeReactUseId = SafeReact.useId;
1645 function useId(idOverride, prefix) {
1646 if (maybeReactUseId !== void 0) {
1647 const reactId = maybeReactUseId();
1648 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1649 }
1650 return useGlobalId(idOverride, prefix);
1651 }
1652
1653 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1654 function useBaseUiId(idOverride) {
1655 return useId(idOverride, "base-ui");
1656 }
1657
1658 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1659 var React10 = __toESM(require_react(), 1);
1660
1661 // node_modules/@base-ui/utils/esm/useOnMount.js
1662 var React9 = __toESM(require_react(), 1);
1663 var EMPTY = [];
1664 function useOnMount(fn) {
1665 React9.useEffect(fn, EMPTY);
1666 }
1667
1668 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1669 var EMPTY2 = null;
1670 var LAST_RAF = globalThis.requestAnimationFrame;
1671 var Scheduler = class {
1672 /* This implementation uses an array as a backing data-structure for frame callbacks.
1673 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1674 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1675 * be much more efficient if there is a call pattern that alterns as
1676 * "request-cancel-request-cancel-…".
1677 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1678 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1679 callbacks = [];
1680 callbacksCount = 0;
1681 nextId = 1;
1682 startId = 1;
1683 isScheduled = false;
1684 tick = (timestamp) => {
1685 this.isScheduled = false;
1686 const currentCallbacks = this.callbacks;
1687 const currentCallbacksCount = this.callbacksCount;
1688 this.callbacks = [];
1689 this.callbacksCount = 0;
1690 this.startId = this.nextId;
1691 if (currentCallbacksCount > 0) {
1692 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1693 currentCallbacks[i2]?.(timestamp);
1694 }
1695 }
1696 };
1697 request(fn) {
1698 const id = this.nextId;
1699 this.nextId += 1;
1700 this.callbacks.push(fn);
1701 this.callbacksCount += 1;
1702 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1703 if (!this.isScheduled || didRAFChange) {
1704 requestAnimationFrame(this.tick);
1705 this.isScheduled = true;
1706 }
1707 return id;
1708 }
1709 cancel(id) {
1710 const index2 = id - this.startId;
1711 if (index2 < 0 || index2 >= this.callbacks.length) {
1712 return;
1713 }
1714 this.callbacks[index2] = null;
1715 this.callbacksCount -= 1;
1716 }
1717 };
1718 var scheduler = new Scheduler();
1719 var AnimationFrame = class _AnimationFrame {
1720 static create() {
1721 return new _AnimationFrame();
1722 }
1723 static request(fn) {
1724 return scheduler.request(fn);
1725 }
1726 static cancel(id) {
1727 return scheduler.cancel(id);
1728 }
1729 currentId = EMPTY2;
1730 /**
1731 * Executes `fn` after `delay`, clearing any previously scheduled call.
1732 */
1733 request(fn) {
1734 this.cancel();
1735 this.currentId = scheduler.request(() => {
1736 this.currentId = EMPTY2;
1737 fn();
1738 });
1739 }
1740 cancel = () => {
1741 if (this.currentId !== EMPTY2) {
1742 scheduler.cancel(this.currentId);
1743 this.currentId = EMPTY2;
1744 }
1745 };
1746 disposeEffect = () => {
1747 return this.cancel;
1748 };
1749 };
1750 function useAnimationFrame() {
1751 const timeout = useRefWithInit(AnimationFrame.create).current;
1752 useOnMount(timeout.disposeEffect);
1753 return timeout;
1754 }
1755
1756 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1757 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1758 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1759 const [mounted, setMounted] = React10.useState(open);
1760 if (open && !mounted) {
1761 setMounted(true);
1762 setTransitionStatus("starting");
1763 }
1764 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1765 setTransitionStatus("ending");
1766 }
1767 if (!open && !mounted && transitionStatus === "ending") {
1768 setTransitionStatus(void 0);
1769 }
1770 useIsoLayoutEffect(() => {
1771 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1772 const frame = AnimationFrame.request(() => {
1773 setTransitionStatus("ending");
1774 });
1775 return () => {
1776 AnimationFrame.cancel(frame);
1777 };
1778 }
1779 return void 0;
1780 }, [open, mounted, transitionStatus, deferEndingState]);
1781 useIsoLayoutEffect(() => {
1782 if (!open || enableIdleState) {
1783 return void 0;
1784 }
1785 const frame = AnimationFrame.request(() => {
1786 setTransitionStatus(void 0);
1787 });
1788 return () => {
1789 AnimationFrame.cancel(frame);
1790 };
1791 }, [enableIdleState, open]);
1792 useIsoLayoutEffect(() => {
1793 if (!open || !enableIdleState) {
1794 return void 0;
1795 }
1796 if (open && mounted && transitionStatus !== "idle") {
1797 setTransitionStatus("starting");
1798 }
1799 const frame = AnimationFrame.request(() => {
1800 setTransitionStatus("idle");
1801 });
1802 return () => {
1803 AnimationFrame.cancel(frame);
1804 };
1805 }, [enableIdleState, open, mounted, transitionStatus]);
1806 return {
1807 mounted,
1808 setMounted,
1809 transitionStatus
1810 };
1811 }
1812
1813 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1814 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1815 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1816 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1817 return TransitionStatusDataAttributes2;
1818 })({});
1819 var STARTING_HOOK = {
1820 [TransitionStatusDataAttributes.startingStyle]: ""
1821 };
1822 var ENDING_HOOK = {
1823 [TransitionStatusDataAttributes.endingStyle]: ""
1824 };
1825 var transitionStatusMapping = {
1826 transitionStatus(value) {
1827 if (value === "starting") {
1828 return STARTING_HOOK;
1829 }
1830 if (value === "ending") {
1831 return ENDING_HOOK;
1832 }
1833 return null;
1834 }
1835 };
1836
1837 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1838 function hasWindow() {
1839 return typeof window !== "undefined";
1840 }
1841 function getNodeName(node) {
1842 if (isNode(node)) {
1843 return (node.nodeName || "").toLowerCase();
1844 }
1845 return "#document";
1846 }
1847 function getWindow(node) {
1848 var _node$ownerDocument;
1849 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1850 }
1851 function getDocumentElement(node) {
1852 var _ref;
1853 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1854 }
1855 function isNode(value) {
1856 if (!hasWindow()) {
1857 return false;
1858 }
1859 return value instanceof Node || value instanceof getWindow(value).Node;
1860 }
1861 function isElement(value) {
1862 if (!hasWindow()) {
1863 return false;
1864 }
1865 return value instanceof Element || value instanceof getWindow(value).Element;
1866 }
1867 function isHTMLElement(value) {
1868 if (!hasWindow()) {
1869 return false;
1870 }
1871 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1872 }
1873 function isShadowRoot(value) {
1874 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1875 return false;
1876 }
1877 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1878 }
1879 function isOverflowElement(element) {
1880 const {
1881 overflow,
1882 overflowX,
1883 overflowY,
1884 display
1885 } = getComputedStyle2(element);
1886 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1887 }
1888 function isTableElement(element) {
1889 return /^(table|td|th)$/.test(getNodeName(element));
1890 }
1891 function isTopLayer(element) {
1892 try {
1893 if (element.matches(":popover-open")) {
1894 return true;
1895 }
1896 } catch (_e) {
1897 }
1898 try {
1899 return element.matches(":modal");
1900 } catch (_e) {
1901 return false;
1902 }
1903 }
1904 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1905 var containRe = /paint|layout|strict|content/;
1906 var isNotNone = (value) => !!value && value !== "none";
1907 var isWebKitValue;
1908 function isContainingBlock(elementOrCss) {
1909 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1910 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
1911 }
1912 function getContainingBlock(element) {
1913 let currentNode = getParentNode(element);
1914 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1915 if (isContainingBlock(currentNode)) {
1916 return currentNode;
1917 } else if (isTopLayer(currentNode)) {
1918 return null;
1919 }
1920 currentNode = getParentNode(currentNode);
1921 }
1922 return null;
1923 }
1924 function isWebKit() {
1925 if (isWebKitValue == null) {
1926 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1927 }
1928 return isWebKitValue;
1929 }
1930 function isLastTraversableNode(node) {
1931 return /^(html|body|#document)$/.test(getNodeName(node));
1932 }
1933 function getComputedStyle2(element) {
1934 return getWindow(element).getComputedStyle(element);
1935 }
1936 function getNodeScroll(element) {
1937 if (isElement(element)) {
1938 return {
1939 scrollLeft: element.scrollLeft,
1940 scrollTop: element.scrollTop
1941 };
1942 }
1943 return {
1944 scrollLeft: element.scrollX,
1945 scrollTop: element.scrollY
1946 };
1947 }
1948 function getParentNode(node) {
1949 if (getNodeName(node) === "html") {
1950 return node;
1951 }
1952 const result = (
1953 // Step into the shadow DOM of the parent of a slotted node.
1954 node.assignedSlot || // DOM Element detected.
1955 node.parentNode || // ShadowRoot detected.
1956 isShadowRoot(node) && node.host || // Fallback.
1957 getDocumentElement(node)
1958 );
1959 return isShadowRoot(result) ? result.host : result;
1960 }
1961 function getNearestOverflowAncestor(node) {
1962 const parentNode = getParentNode(node);
1963 if (isLastTraversableNode(parentNode)) {
1964 return node.ownerDocument ? node.ownerDocument.body : node.body;
1965 }
1966 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1967 return parentNode;
1968 }
1969 return getNearestOverflowAncestor(parentNode);
1970 }
1971 function getOverflowAncestors(node, list, traverseIframes) {
1972 var _node$ownerDocument2;
1973 if (list === void 0) {
1974 list = [];
1975 }
1976 if (traverseIframes === void 0) {
1977 traverseIframes = true;
1978 }
1979 const scrollableAncestor = getNearestOverflowAncestor(node);
1980 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1981 const win = getWindow(scrollableAncestor);
1982 if (isBody) {
1983 const frameElement = getFrameElement(win);
1984 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1985 } else {
1986 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1987 }
1988 }
1989 function getFrameElement(win) {
1990 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1991 }
1992
1993 // node_modules/@base-ui/utils/esm/detectBrowser.js
1994 var hasNavigator = typeof navigator !== "undefined";
1995 var nav = getNavigatorData();
1996 var platform = getPlatform();
1997 var userAgent = getUserAgent();
1998 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1999 var isIOS = (
2000 // iPads can claim to be MacIntel
2001 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2002 );
2003 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2004 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2005 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2006 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2007 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2008 var isJSDOM = userAgent.includes("jsdom/");
2009 function getNavigatorData() {
2010 if (!hasNavigator) {
2011 return {
2012 platform: "",
2013 maxTouchPoints: -1
2014 };
2015 }
2016 const uaData = navigator.userAgentData;
2017 if (uaData?.platform) {
2018 return {
2019 platform: uaData.platform,
2020 maxTouchPoints: navigator.maxTouchPoints
2021 };
2022 }
2023 return {
2024 platform: navigator.platform ?? "",
2025 maxTouchPoints: navigator.maxTouchPoints ?? -1
2026 };
2027 }
2028 function getUserAgent() {
2029 if (!hasNavigator) {
2030 return "";
2031 }
2032 const uaData = navigator.userAgentData;
2033 if (uaData && Array.isArray(uaData.brands)) {
2034 return uaData.brands.map(({
2035 brand,
2036 version: version2
2037 }) => `${brand}/${version2}`).join(" ");
2038 }
2039 return navigator.userAgent;
2040 }
2041 function getPlatform() {
2042 if (!hasNavigator) {
2043 return "";
2044 }
2045 const uaData = navigator.userAgentData;
2046 if (uaData?.platform) {
2047 return uaData.platform;
2048 }
2049 return navigator.platform ?? "";
2050 }
2051
2052 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2053 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2054 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2055
2056 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2057 function activeElement(doc) {
2058 let element = doc.activeElement;
2059 while (element?.shadowRoot?.activeElement != null) {
2060 element = element.shadowRoot.activeElement;
2061 }
2062 return element;
2063 }
2064 function contains(parent, child) {
2065 if (!parent || !child) {
2066 return false;
2067 }
2068 const rootNode = child.getRootNode?.();
2069 if (parent.contains(child)) {
2070 return true;
2071 }
2072 if (rootNode && isShadowRoot(rootNode)) {
2073 let next = child;
2074 while (next) {
2075 if (parent === next) {
2076 return true;
2077 }
2078 next = next.parentNode || next.host;
2079 }
2080 }
2081 return false;
2082 }
2083 function getTarget(event) {
2084 if ("composedPath" in event) {
2085 return event.composedPath()[0];
2086 }
2087 return event.target;
2088 }
2089
2090 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2091 function isTargetInsideEnabledTrigger(target, triggerElements) {
2092 if (!isElement(target)) {
2093 return false;
2094 }
2095 const targetElement = target;
2096 if (triggerElements.hasElement(targetElement)) {
2097 return !targetElement.hasAttribute("data-trigger-disabled");
2098 }
2099 for (const [, trigger] of triggerElements.entries()) {
2100 if (contains(trigger, targetElement)) {
2101 return !trigger.hasAttribute("data-trigger-disabled");
2102 }
2103 }
2104 return false;
2105 }
2106 function isEventTargetWithin(event, node) {
2107 if (node == null) {
2108 return false;
2109 }
2110 if ("composedPath" in event) {
2111 return event.composedPath().includes(node);
2112 }
2113 const eventAgain = event;
2114 return eventAgain.target != null && node.contains(eventAgain.target);
2115 }
2116 function isRootElement(element) {
2117 return element.matches("html,body");
2118 }
2119 function isTypeableElement(element) {
2120 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2121 }
2122 function isInteractiveElement(element) {
2123 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2124 }
2125 function matchesFocusVisible(element) {
2126 if (!element || isJSDOM) {
2127 return true;
2128 }
2129 try {
2130 return element.matches(":focus-visible");
2131 } catch (_e) {
2132 return true;
2133 }
2134 }
2135
2136 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2137 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2138 const directChildren = nodes.filter((node) => node.parentId === id);
2139 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2140 }
2141
2142 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2143 function isReactEvent(event) {
2144 return "nativeEvent" in event;
2145 }
2146 function isMouseLikePointerType(pointerType, strict) {
2147 const values = ["mouse", "pen"];
2148 if (!strict) {
2149 values.push("", void 0);
2150 }
2151 return values.includes(pointerType);
2152 }
2153 function isClickLikeEvent(event) {
2154 const type = event.type;
2155 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2156 }
2157
2158 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2159 var sides = ["top", "right", "bottom", "left"];
2160 var min = Math.min;
2161 var max = Math.max;
2162 var round = Math.round;
2163 var floor = Math.floor;
2164 var createCoords = (v2) => ({
2165 x: v2,
2166 y: v2
2167 });
2168 var oppositeSideMap = {
2169 left: "right",
2170 right: "left",
2171 bottom: "top",
2172 top: "bottom"
2173 };
2174 function clamp(start, value, end) {
2175 return max(start, min(value, end));
2176 }
2177 function evaluate(value, param) {
2178 return typeof value === "function" ? value(param) : value;
2179 }
2180 function getSide(placement) {
2181 return placement.split("-")[0];
2182 }
2183 function getAlignment(placement) {
2184 return placement.split("-")[1];
2185 }
2186 function getOppositeAxis(axis) {
2187 return axis === "x" ? "y" : "x";
2188 }
2189 function getAxisLength(axis) {
2190 return axis === "y" ? "height" : "width";
2191 }
2192 function getSideAxis(placement) {
2193 const firstChar = placement[0];
2194 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2195 }
2196 function getAlignmentAxis(placement) {
2197 return getOppositeAxis(getSideAxis(placement));
2198 }
2199 function getAlignmentSides(placement, rects, rtl) {
2200 if (rtl === void 0) {
2201 rtl = false;
2202 }
2203 const alignment = getAlignment(placement);
2204 const alignmentAxis = getAlignmentAxis(placement);
2205 const length = getAxisLength(alignmentAxis);
2206 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2207 if (rects.reference[length] > rects.floating[length]) {
2208 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2209 }
2210 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2211 }
2212 function getExpandedPlacements(placement) {
2213 const oppositePlacement = getOppositePlacement(placement);
2214 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2215 }
2216 function getOppositeAlignmentPlacement(placement) {
2217 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2218 }
2219 var lrPlacement = ["left", "right"];
2220 var rlPlacement = ["right", "left"];
2221 var tbPlacement = ["top", "bottom"];
2222 var btPlacement = ["bottom", "top"];
2223 function getSideList(side, isStart, rtl) {
2224 switch (side) {
2225 case "top":
2226 case "bottom":
2227 if (rtl) return isStart ? rlPlacement : lrPlacement;
2228 return isStart ? lrPlacement : rlPlacement;
2229 case "left":
2230 case "right":
2231 return isStart ? tbPlacement : btPlacement;
2232 default:
2233 return [];
2234 }
2235 }
2236 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2237 const alignment = getAlignment(placement);
2238 let list = getSideList(getSide(placement), direction === "start", rtl);
2239 if (alignment) {
2240 list = list.map((side) => side + "-" + alignment);
2241 if (flipAlignment) {
2242 list = list.concat(list.map(getOppositeAlignmentPlacement));
2243 }
2244 }
2245 return list;
2246 }
2247 function getOppositePlacement(placement) {
2248 const side = getSide(placement);
2249 return oppositeSideMap[side] + placement.slice(side.length);
2250 }
2251 function expandPaddingObject(padding) {
2252 return {
2253 top: 0,
2254 right: 0,
2255 bottom: 0,
2256 left: 0,
2257 ...padding
2258 };
2259 }
2260 function getPaddingObject(padding) {
2261 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2262 top: padding,
2263 right: padding,
2264 bottom: padding,
2265 left: padding
2266 };
2267 }
2268 function rectToClientRect(rect) {
2269 const {
2270 x: x2,
2271 y: y2,
2272 width,
2273 height
2274 } = rect;
2275 return {
2276 width,
2277 height,
2278 top: y2,
2279 left: x2,
2280 right: x2 + width,
2281 bottom: y2 + height,
2282 x: x2,
2283 y: y2
2284 };
2285 }
2286
2287 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2288 function isHiddenByStyles(styles) {
2289 return styles.visibility === "hidden" || styles.visibility === "collapse";
2290 }
2291 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2292 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2293 return false;
2294 }
2295 if (typeof element.checkVisibility === "function") {
2296 return element.checkVisibility();
2297 }
2298 return styles.display !== "none" && styles.display !== "contents";
2299 }
2300
2301 // node_modules/@base-ui/utils/esm/owner.js
2302 function ownerDocument(node) {
2303 return node?.ownerDocument || document;
2304 }
2305
2306 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2307 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2308 function getParentElement(element) {
2309 const assignedSlot = element.assignedSlot;
2310 if (assignedSlot) {
2311 return assignedSlot;
2312 }
2313 if (element.parentElement) {
2314 return element.parentElement;
2315 }
2316 const rootNode = element.getRootNode();
2317 return isShadowRoot(rootNode) ? rootNode.host : null;
2318 }
2319 function getDetailsSummary(details) {
2320 for (const child of Array.from(details.children)) {
2321 if (getNodeName(child) === "summary") {
2322 return child;
2323 }
2324 }
2325 return null;
2326 }
2327 function isWithinOpenDetailsSummary(element, details) {
2328 const summary = getDetailsSummary(details);
2329 return !!summary && (element === summary || contains(summary, element));
2330 }
2331 function isFocusableCandidate(element) {
2332 const nodeName = element ? getNodeName(element) : "";
2333 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
2334 }
2335 function isFocusableElement(element) {
2336 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2337 return false;
2338 }
2339 for (let current = element; current; current = getParentElement(current)) {
2340 const isAncestor = current !== element;
2341 const isSlot = getNodeName(current) === "slot";
2342 if (current.hasAttribute("inert")) {
2343 return false;
2344 }
2345 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2346 return false;
2347 }
2348 }
2349 return true;
2350 }
2351 function isVisibleInTabbableTree(element, isAncestor) {
2352 const styles = getComputedStyle2(element);
2353 if (!isAncestor) {
2354 return isElementVisible(element, styles);
2355 }
2356 return styles.display !== "none";
2357 }
2358 function getTabIndex(element) {
2359 const tabIndex = element.tabIndex;
2360 if (tabIndex < 0) {
2361 const nodeName = getNodeName(element);
2362 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2363 return 0;
2364 }
2365 }
2366 return tabIndex;
2367 }
2368 function getNamedRadioInput(element) {
2369 if (getNodeName(element) !== "input") {
2370 return null;
2371 }
2372 const input = element;
2373 return input.type === "radio" && input.name !== "" ? input : null;
2374 }
2375 function isTabbableRadio(element, candidates) {
2376 const input = getNamedRadioInput(element);
2377 if (!input) {
2378 return true;
2379 }
2380 const checkedRadio = candidates.find((candidate) => {
2381 const radio = getNamedRadioInput(candidate);
2382 return radio?.name === input.name && radio.form === input.form && radio.checked;
2383 });
2384 if (checkedRadio) {
2385 return checkedRadio === input;
2386 }
2387 return candidates.find((candidate) => {
2388 const radio = getNamedRadioInput(candidate);
2389 return radio?.name === input.name && radio.form === input.form;
2390 }) === input;
2391 }
2392 function getComposedChildren(container) {
2393 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2394 const assignedElements = container.assignedElements({
2395 flatten: true
2396 });
2397 if (assignedElements.length > 0) {
2398 return assignedElements;
2399 }
2400 }
2401 if (isHTMLElement(container) && container.shadowRoot) {
2402 return Array.from(container.shadowRoot.children);
2403 }
2404 return Array.from(container.children);
2405 }
2406 function appendCandidates(container, list) {
2407 getComposedChildren(container).forEach((child) => {
2408 if (isFocusableCandidate(child)) {
2409 list.push(child);
2410 }
2411 appendCandidates(child, list);
2412 });
2413 }
2414 function appendMatchingElements(container, selector2, list) {
2415 getComposedChildren(container).forEach((child) => {
2416 if (isHTMLElement(child) && child.matches(selector2)) {
2417 list.push(child);
2418 }
2419 appendMatchingElements(child, selector2, list);
2420 });
2421 }
2422 function focusable(container) {
2423 const candidates = [];
2424 appendCandidates(container, candidates);
2425 return candidates.filter(isFocusableElement);
2426 }
2427 function tabbable(container) {
2428 const candidates = focusable(container);
2429 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2430 }
2431 function getTabbableIn(container, dir) {
2432 const list = tabbable(container);
2433 const len = list.length;
2434 if (len === 0) {
2435 return void 0;
2436 }
2437 const active = activeElement(ownerDocument(container));
2438 const index2 = list.indexOf(active);
2439 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2440 return list[nextIndex];
2441 }
2442 function getNextTabbable(referenceElement) {
2443 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2444 }
2445 function getPreviousTabbable(referenceElement) {
2446 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2447 }
2448 function isOutsideEvent(event, container) {
2449 const containerElement = container || event.currentTarget;
2450 const relatedTarget = event.relatedTarget;
2451 return !relatedTarget || !contains(containerElement, relatedTarget);
2452 }
2453 function disableFocusInside(container) {
2454 const tabbableElements = tabbable(container);
2455 tabbableElements.forEach((element) => {
2456 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2457 element.setAttribute("tabindex", "-1");
2458 });
2459 }
2460 function enableFocusInside(container) {
2461 const elements = [];
2462 appendMatchingElements(container, "[data-tabindex]", elements);
2463 elements.forEach((element) => {
2464 const tabindex = element.dataset.tabindex;
2465 delete element.dataset.tabindex;
2466 if (tabindex) {
2467 element.setAttribute("tabindex", tabindex);
2468 } else {
2469 element.removeAttribute("tabindex");
2470 }
2471 });
2472 }
2473
2474 // node_modules/@base-ui/utils/esm/addEventListener.js
2475 function addEventListener(target, type, listener, options) {
2476 target.addEventListener(type, listener, options);
2477 return () => {
2478 target.removeEventListener(type, listener, options);
2479 };
2480 }
2481
2482 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2483 function useValueAsRef(value) {
2484 const latest = useRefWithInit(createLatestRef, value).current;
2485 latest.next = value;
2486 useIsoLayoutEffect(latest.effect);
2487 return latest;
2488 }
2489 function createLatestRef(value) {
2490 const latest = {
2491 current: value,
2492 next: value,
2493 effect: () => {
2494 latest.current = latest.next;
2495 }
2496 };
2497 return latest;
2498 }
2499
2500 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2501 var React11 = __toESM(require_react(), 1);
2502
2503 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2504 var ReactDOM = __toESM(require_react_dom(), 1);
2505
2506 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2507 function resolveRef(maybeRef) {
2508 if (maybeRef == null) {
2509 return maybeRef;
2510 }
2511 return "current" in maybeRef ? maybeRef.current : maybeRef;
2512 }
2513
2514 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2515 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2516 const frame = useAnimationFrame();
2517 return useStableCallback((fnToExecute, signal = null) => {
2518 frame.cancel();
2519 const element = resolveRef(elementOrRef);
2520 if (element == null) {
2521 return;
2522 }
2523 const resolvedElement = element;
2524 const done = () => {
2525 ReactDOM.flushSync(fnToExecute);
2526 };
2527 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2528 fnToExecute();
2529 return;
2530 }
2531 function exec() {
2532 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2533 if (!signal?.aborted) {
2534 done();
2535 }
2536 }).catch(() => {
2537 if (treatAbortedAsFinished) {
2538 if (!signal?.aborted) {
2539 done();
2540 }
2541 return;
2542 }
2543 const currentAnimations = resolvedElement.getAnimations();
2544 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2545 exec();
2546 }
2547 });
2548 }
2549 if (waitForStartingStyleRemoved) {
2550 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2551 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2552 frame.request(exec);
2553 return;
2554 }
2555 const attributeObserver = new MutationObserver(() => {
2556 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2557 attributeObserver.disconnect();
2558 exec();
2559 }
2560 });
2561 attributeObserver.observe(resolvedElement, {
2562 attributes: true,
2563 attributeFilter: [startingStyleAttribute]
2564 });
2565 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2566 once: true
2567 });
2568 return;
2569 }
2570 frame.request(exec);
2571 });
2572 }
2573
2574 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2575 function useOpenChangeComplete(parameters) {
2576 const {
2577 enabled = true,
2578 open,
2579 ref,
2580 onComplete: onCompleteParam
2581 } = parameters;
2582 const onComplete = useStableCallback(onCompleteParam);
2583 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2584 React11.useEffect(() => {
2585 if (!enabled) {
2586 return void 0;
2587 }
2588 const abortController = new AbortController();
2589 runOnceAnimationsFinish(onComplete, abortController.signal);
2590 return () => {
2591 abortController.abort();
2592 };
2593 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2594 }
2595
2596 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2597 var React12 = __toESM(require_react(), 1);
2598 function useOnFirstRender(fn) {
2599 const ref = React12.useRef(true);
2600 if (ref.current) {
2601 ref.current = false;
2602 fn();
2603 }
2604 }
2605
2606 // node_modules/@base-ui/utils/esm/useTimeout.js
2607 var EMPTY3 = 0;
2608 var Timeout = class _Timeout {
2609 static create() {
2610 return new _Timeout();
2611 }
2612 currentId = EMPTY3;
2613 /**
2614 * Executes `fn` after `delay`, clearing any previously scheduled call.
2615 */
2616 start(delay, fn) {
2617 this.clear();
2618 this.currentId = setTimeout(() => {
2619 this.currentId = EMPTY3;
2620 fn();
2621 }, delay);
2622 }
2623 isStarted() {
2624 return this.currentId !== EMPTY3;
2625 }
2626 clear = () => {
2627 if (this.currentId !== EMPTY3) {
2628 clearTimeout(this.currentId);
2629 this.currentId = EMPTY3;
2630 }
2631 };
2632 disposeEffect = () => {
2633 return this.clear;
2634 };
2635 };
2636 function useTimeout() {
2637 const timeout = useRefWithInit(Timeout.create).current;
2638 useOnMount(timeout.disposeEffect);
2639 return timeout;
2640 }
2641
2642 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2643 var React13 = __toESM(require_react(), 1);
2644
2645 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2646 function resolveValue(value, pointerType) {
2647 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2648 return 0;
2649 }
2650 if (typeof value === "function") {
2651 return value();
2652 }
2653 return value;
2654 }
2655 function getDelay(value, prop, pointerType) {
2656 const result = resolveValue(value, pointerType);
2657 if (typeof result === "number") {
2658 return result;
2659 }
2660 return result?.[prop];
2661 }
2662 function getRestMs(value) {
2663 if (typeof value === "function") {
2664 return value();
2665 }
2666 return value;
2667 }
2668 function isClickLikeOpenEvent(openEventType, interactedInside) {
2669 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2670 }
2671 function isHoverOpenEvent(openEventType) {
2672 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2673 }
2674
2675 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2676 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2677 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2678 hasProvider: false,
2679 timeoutMs: 0,
2680 delayRef: {
2681 current: 0
2682 },
2683 initialDelayRef: {
2684 current: 0
2685 },
2686 timeout: new Timeout(),
2687 currentIdRef: {
2688 current: null
2689 },
2690 currentContextRef: {
2691 current: null
2692 }
2693 });
2694 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2695 function FloatingDelayGroup(props) {
2696 const {
2697 children,
2698 delay,
2699 timeoutMs = 0
2700 } = props;
2701 const delayRef = React13.useRef(delay);
2702 const initialDelayRef = React13.useRef(delay);
2703 const currentIdRef = React13.useRef(null);
2704 const currentContextRef = React13.useRef(null);
2705 const timeout = useTimeout();
2706 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FloatingDelayGroupContext.Provider, {
2707 value: React13.useMemo(() => ({
2708 hasProvider: true,
2709 delayRef,
2710 initialDelayRef,
2711 currentIdRef,
2712 timeoutMs,
2713 currentContextRef,
2714 timeout
2715 }), [timeoutMs, timeout]),
2716 children
2717 });
2718 }
2719 function useDelayGroup(context, options = {
2720 open: false
2721 }) {
2722 const {
2723 open
2724 } = options;
2725 const store = "rootStore" in context ? context.rootStore : context;
2726 const floatingId = store.useState("floatingId");
2727 const groupContext = React13.useContext(FloatingDelayGroupContext);
2728 const {
2729 currentIdRef,
2730 delayRef,
2731 timeoutMs,
2732 initialDelayRef,
2733 currentContextRef,
2734 hasProvider,
2735 timeout
2736 } = groupContext;
2737 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2738 useIsoLayoutEffect(() => {
2739 function unset() {
2740 setIsInstantPhase(false);
2741 currentContextRef.current?.setIsInstantPhase(false);
2742 currentIdRef.current = null;
2743 currentContextRef.current = null;
2744 delayRef.current = initialDelayRef.current;
2745 }
2746 if (!currentIdRef.current) {
2747 return void 0;
2748 }
2749 if (!open && currentIdRef.current === floatingId) {
2750 setIsInstantPhase(false);
2751 if (timeoutMs) {
2752 const closingId = floatingId;
2753 timeout.start(timeoutMs, () => {
2754 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2755 return;
2756 }
2757 unset();
2758 });
2759 return () => {
2760 timeout.clear();
2761 };
2762 }
2763 unset();
2764 }
2765 return void 0;
2766 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2767 useIsoLayoutEffect(() => {
2768 if (!open) {
2769 return;
2770 }
2771 const prevContext = currentContextRef.current;
2772 const prevId = currentIdRef.current;
2773 timeout.clear();
2774 currentContextRef.current = {
2775 onOpenChange: store.setOpen,
2776 setIsInstantPhase
2777 };
2778 currentIdRef.current = floatingId;
2779 delayRef.current = {
2780 open: 0,
2781 close: getDelay(initialDelayRef.current, "close")
2782 };
2783 if (prevId !== null && prevId !== floatingId) {
2784 setIsInstantPhase(true);
2785 prevContext?.setIsInstantPhase(true);
2786 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2787 } else {
2788 setIsInstantPhase(false);
2789 prevContext?.setIsInstantPhase(false);
2790 }
2791 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2792 useIsoLayoutEffect(() => {
2793 return () => {
2794 currentContextRef.current = null;
2795 };
2796 }, [currentContextRef]);
2797 return React13.useMemo(() => ({
2798 hasProvider,
2799 delayRef,
2800 isInstantPhase
2801 }), [hasProvider, delayRef, isInstantPhase]);
2802 }
2803
2804 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2805 function mergeCleanups(...cleanups) {
2806 return () => {
2807 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2808 const cleanup = cleanups[i2];
2809 if (cleanup) {
2810 cleanup();
2811 }
2812 }
2813 };
2814 }
2815
2816 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2817 var React14 = __toESM(require_react(), 1);
2818
2819 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2820 var visuallyHiddenBase = {
2821 clipPath: "inset(50%)",
2822 overflow: "hidden",
2823 whiteSpace: "nowrap",
2824 border: 0,
2825 padding: 0,
2826 width: 1,
2827 height: 1,
2828 margin: -1
2829 };
2830 var visuallyHidden = {
2831 ...visuallyHiddenBase,
2832 position: "fixed",
2833 top: 0,
2834 left: 0
2835 };
2836 var visuallyHiddenInput = {
2837 ...visuallyHiddenBase,
2838 position: "absolute"
2839 };
2840
2841 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2842 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2843 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2844 const [role, setRole] = React14.useState();
2845 useIsoLayoutEffect(() => {
2846 if (isSafari) {
2847 setRole("button");
2848 }
2849 }, []);
2850 const restProps = {
2851 tabIndex: 0,
2852 // Role is only for VoiceOver
2853 role
2854 };
2855 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", {
2856 ...props,
2857 ref,
2858 style: visuallyHidden,
2859 "aria-hidden": role ? void 0 : true,
2860 ...restProps,
2861 "data-base-ui-focus-guard": ""
2862 });
2863 });
2864 if (true) FocusGuard.displayName = "FocusGuard";
2865
2866 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2867 function createAttribute(name) {
2868 return `data-base-ui-${name}`;
2869 }
2870
2871 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2872 var React15 = __toESM(require_react(), 1);
2873 var ReactDOM2 = __toESM(require_react_dom(), 1);
2874
2875 // node_modules/@base-ui/react/esm/internals/constants.js
2876 var DISABLED_TRANSITIONS_STYLE = {
2877 style: {
2878 transition: "none"
2879 }
2880 };
2881 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2882 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2883 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2884 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2885 var POPUP_COLLISION_AVOIDANCE = {
2886 fallbackAxisSide: "end"
2887 };
2888 var ownerVisuallyHidden = {
2889 clipPath: "inset(50%)",
2890 position: "fixed",
2891 top: 0,
2892 left: 0
2893 };
2894
2895 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2896 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2897 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2898 if (true) PortalContext.displayName = "PortalContext";
2899 var usePortalContext = () => React15.useContext(PortalContext);
2900 var attr = createAttribute("portal");
2901 function useFloatingPortalNode(props = {}) {
2902 const {
2903 ref,
2904 container: containerProp,
2905 componentProps = EMPTY_OBJECT,
2906 elementProps
2907 } = props;
2908 const uniqueId = useId();
2909 const portalContext = usePortalContext();
2910 const parentPortalNode = portalContext?.portalNode;
2911 const [containerElement, setContainerElement] = React15.useState(null);
2912 const [portalNode, setPortalNode] = React15.useState(null);
2913 const setPortalNodeRef = useStableCallback((node) => {
2914 if (node !== null) {
2915 setPortalNode(node);
2916 }
2917 });
2918 const containerRef = React15.useRef(null);
2919 useIsoLayoutEffect(() => {
2920 if (containerProp === null) {
2921 if (containerRef.current) {
2922 containerRef.current = null;
2923 setPortalNode(null);
2924 setContainerElement(null);
2925 }
2926 return;
2927 }
2928 if (uniqueId == null) {
2929 return;
2930 }
2931 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2932 if (resolvedContainer == null) {
2933 if (containerRef.current) {
2934 containerRef.current = null;
2935 setPortalNode(null);
2936 setContainerElement(null);
2937 }
2938 return;
2939 }
2940 if (containerRef.current !== resolvedContainer) {
2941 containerRef.current = resolvedContainer;
2942 setPortalNode(null);
2943 setContainerElement(resolvedContainer);
2944 }
2945 }, [containerProp, parentPortalNode, uniqueId]);
2946 const portalElement = useRenderElement("div", componentProps, {
2947 ref: [ref, setPortalNodeRef],
2948 props: [{
2949 id: uniqueId,
2950 [attr]: ""
2951 }, elementProps]
2952 });
2953 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2954 return {
2955 portalNode,
2956 portalSubtree
2957 };
2958 }
2959 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2960 const {
2961 render: render4,
2962 className,
2963 style,
2964 children,
2965 container,
2966 renderGuards,
2967 ...elementProps
2968 } = componentProps;
2969 const {
2970 portalNode,
2971 portalSubtree
2972 } = useFloatingPortalNode({
2973 container,
2974 ref: forwardedRef,
2975 componentProps,
2976 elementProps
2977 });
2978 const beforeOutsideRef = React15.useRef(null);
2979 const afterOutsideRef = React15.useRef(null);
2980 const beforeInsideRef = React15.useRef(null);
2981 const afterInsideRef = React15.useRef(null);
2982 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2983 const focusInsideDisabledRef = React15.useRef(false);
2984 const modal = focusManagerState?.modal;
2985 const open = focusManagerState?.open;
2986 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2987 React15.useEffect(() => {
2988 if (!portalNode || modal) {
2989 return void 0;
2990 }
2991 function onFocus(event) {
2992 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2993 if (event.type === "focusin") {
2994 if (focusInsideDisabledRef.current) {
2995 enableFocusInside(portalNode);
2996 focusInsideDisabledRef.current = false;
2997 }
2998 } else {
2999 disableFocusInside(portalNode);
3000 focusInsideDisabledRef.current = true;
3001 }
3002 }
3003 }
3004 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3005 }, [portalNode, modal]);
3006 React15.useEffect(() => {
3007 if (!portalNode || open !== false) {
3008 return;
3009 }
3010 enableFocusInside(portalNode);
3011 focusInsideDisabledRef.current = false;
3012 }, [open, portalNode]);
3013 const portalContextValue = React15.useMemo(() => ({
3014 beforeOutsideRef,
3015 afterOutsideRef,
3016 beforeInsideRef,
3017 afterInsideRef,
3018 portalNode,
3019 setFocusManagerState
3020 }), [portalNode]);
3021 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(React15.Fragment, {
3022 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(PortalContext.Provider, {
3023 value: portalContextValue,
3024 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3025 "data-type": "outside",
3026 ref: beforeOutsideRef,
3027 onFocus: (event) => {
3028 if (isOutsideEvent(event, portalNode)) {
3029 beforeInsideRef.current?.focus();
3030 } else {
3031 const domReference = focusManagerState ? focusManagerState.domReference : null;
3032 const prevTabbable = getPreviousTabbable(domReference);
3033 prevTabbable?.focus();
3034 }
3035 }
3036 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", {
3037 "aria-owns": portalNode.id,
3038 style: ownerVisuallyHidden
3039 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3040 "data-type": "outside",
3041 ref: afterOutsideRef,
3042 onFocus: (event) => {
3043 if (isOutsideEvent(event, portalNode)) {
3044 afterInsideRef.current?.focus();
3045 } else {
3046 const domReference = focusManagerState ? focusManagerState.domReference : null;
3047 const nextTabbable = getNextTabbable(domReference);
3048 nextTabbable?.focus();
3049 if (focusManagerState?.closeOnFocusOut) {
3050 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3051 }
3052 }
3053 }
3054 })]
3055 })]
3056 });
3057 });
3058 if (true) FloatingPortal.displayName = "FloatingPortal";
3059
3060 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3061 var React16 = __toESM(require_react(), 1);
3062
3063 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3064 function createEventEmitter() {
3065 const map = /* @__PURE__ */ new Map();
3066 return {
3067 emit(event, data) {
3068 map.get(event)?.forEach((listener) => listener(data));
3069 },
3070 on(event, listener) {
3071 if (!map.has(event)) {
3072 map.set(event, /* @__PURE__ */ new Set());
3073 }
3074 map.get(event).add(listener);
3075 },
3076 off(event, listener) {
3077 map.get(event)?.delete(listener);
3078 }
3079 };
3080 }
3081
3082 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3083 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3084 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3085 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3086 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3087 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3088 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3089 var useFloatingTree = (externalTree) => {
3090 const contextTree = React16.useContext(FloatingTreeContext);
3091 return externalTree ?? contextTree;
3092 };
3093
3094 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3095 var React17 = __toESM(require_react(), 1);
3096 function createVirtualElement(domElement, data) {
3097 let offsetX = null;
3098 let offsetY = null;
3099 let isAutoUpdateEvent = false;
3100 return {
3101 contextElement: domElement || void 0,
3102 getBoundingClientRect() {
3103 const domRect = domElement?.getBoundingClientRect() || {
3104 width: 0,
3105 height: 0,
3106 x: 0,
3107 y: 0
3108 };
3109 const isXAxis = data.axis === "x" || data.axis === "both";
3110 const isYAxis = data.axis === "y" || data.axis === "both";
3111 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3112 let width = domRect.width;
3113 let height = domRect.height;
3114 let x2 = domRect.x;
3115 let y2 = domRect.y;
3116 if (offsetX == null && data.x && isXAxis) {
3117 offsetX = domRect.x - data.x;
3118 }
3119 if (offsetY == null && data.y && isYAxis) {
3120 offsetY = domRect.y - data.y;
3121 }
3122 x2 -= offsetX || 0;
3123 y2 -= offsetY || 0;
3124 width = 0;
3125 height = 0;
3126 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3127 width = data.axis === "y" ? domRect.width : 0;
3128 height = data.axis === "x" ? domRect.height : 0;
3129 x2 = isXAxis && data.x != null ? data.x : x2;
3130 y2 = isYAxis && data.y != null ? data.y : y2;
3131 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3132 height = data.axis === "x" ? domRect.height : height;
3133 width = data.axis === "y" ? domRect.width : width;
3134 }
3135 isAutoUpdateEvent = true;
3136 return {
3137 width,
3138 height,
3139 x: x2,
3140 y: y2,
3141 top: y2,
3142 right: x2 + width,
3143 bottom: y2 + height,
3144 left: x2
3145 };
3146 }
3147 };
3148 }
3149 function isMouseBasedEvent(event) {
3150 return event != null && event.clientX != null;
3151 }
3152 function useClientPoint(context, props = {}) {
3153 const {
3154 enabled = true,
3155 axis = "both"
3156 } = props;
3157 const store = "rootStore" in context ? context.rootStore : context;
3158 const open = store.useState("open");
3159 const floating = store.useState("floatingElement");
3160 const domReference = store.useState("domReferenceElement");
3161 const dataRef = store.context.dataRef;
3162 const initialRef = React17.useRef(false);
3163 const cleanupListenerRef = React17.useRef(null);
3164 const [pointerType, setPointerType] = React17.useState();
3165 const [reactive, setReactive] = React17.useState([]);
3166 const resetReference = useStableCallback((reference2) => {
3167 store.set("positionReference", reference2);
3168 });
3169 const setReference = useStableCallback((newX, newY, referenceElement) => {
3170 if (initialRef.current) {
3171 return;
3172 }
3173 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3174 return;
3175 }
3176 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3177 x: newX,
3178 y: newY,
3179 axis,
3180 dataRef,
3181 pointerType
3182 }));
3183 });
3184 const handleReferenceEnterOrMove = useStableCallback((event) => {
3185 if (!open) {
3186 setReference(event.clientX, event.clientY, event.currentTarget);
3187 } else if (!cleanupListenerRef.current) {
3188 setReference(event.clientX, event.clientY, event.currentTarget);
3189 setReactive([]);
3190 }
3191 });
3192 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3193 React17.useEffect(() => {
3194 if (!enabled) {
3195 resetReference(domReference);
3196 return void 0;
3197 }
3198 if (!openCheck) {
3199 return void 0;
3200 }
3201 function cleanupListener() {
3202 cleanupListenerRef.current?.();
3203 cleanupListenerRef.current = null;
3204 }
3205 const win = getWindow(floating);
3206 function handleMouseMove(event) {
3207 const target = getTarget(event);
3208 if (!contains(floating, target)) {
3209 setReference(event.clientX, event.clientY);
3210 } else {
3211 cleanupListener();
3212 }
3213 }
3214 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3215 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3216 } else {
3217 resetReference(domReference);
3218 }
3219 return cleanupListener;
3220 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3221 React17.useEffect(() => () => {
3222 store.set("positionReference", null);
3223 }, [store]);
3224 React17.useEffect(() => {
3225 if (enabled && !floating) {
3226 initialRef.current = false;
3227 }
3228 }, [enabled, floating]);
3229 React17.useEffect(() => {
3230 if (!enabled && open) {
3231 initialRef.current = true;
3232 }
3233 }, [enabled, open]);
3234 const reference = React17.useMemo(() => {
3235 function setPointerTypeRef(event) {
3236 setPointerType(event.pointerType);
3237 }
3238 return {
3239 onPointerDown: setPointerTypeRef,
3240 onPointerEnter: setPointerTypeRef,
3241 onMouseMove: handleReferenceEnterOrMove,
3242 onMouseEnter: handleReferenceEnterOrMove
3243 };
3244 }, [handleReferenceEnterOrMove]);
3245 return React17.useMemo(() => enabled ? {
3246 reference,
3247 trigger: reference
3248 } : {}, [enabled, reference]);
3249 }
3250
3251 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3252 var React18 = __toESM(require_react(), 1);
3253 var bubbleHandlerKeys = {
3254 intentional: "onClick",
3255 sloppy: "onPointerDown"
3256 };
3257 function alwaysFalse() {
3258 return false;
3259 }
3260 function normalizeProp(normalizable) {
3261 return {
3262 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3263 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3264 };
3265 }
3266 function useDismiss(context, props = {}) {
3267 const {
3268 enabled = true,
3269 escapeKey: escapeKey2 = true,
3270 outsidePress: outsidePressProp = true,
3271 outsidePressEvent = "sloppy",
3272 referencePress = alwaysFalse,
3273 referencePressEvent = "sloppy",
3274 bubbles,
3275 externalTree
3276 } = props;
3277 const store = "rootStore" in context ? context.rootStore : context;
3278 const open = store.useState("open");
3279 const floatingElement = store.useState("floatingElement");
3280 const {
3281 dataRef
3282 } = store.context;
3283 const tree = useFloatingTree(externalTree);
3284 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3285 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3286 const outsidePressEnabled = outsidePress2 !== false;
3287 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3288 const {
3289 escapeKey: escapeKeyBubbles,
3290 outsidePress: outsidePressBubbles
3291 } = normalizeProp(bubbles);
3292 const pressStartedInsideRef = React18.useRef(false);
3293 const pressStartPreventedRef = React18.useRef(false);
3294 const suppressNextOutsideClickRef = React18.useRef(false);
3295 const isComposingRef = React18.useRef(false);
3296 const currentPointerTypeRef = React18.useRef("");
3297 const touchStateRef = React18.useRef(null);
3298 const cancelDismissOnEndTimeout = useTimeout();
3299 const clearInsideReactTreeTimeout = useTimeout();
3300 const clearInsideReactTree = useStableCallback(() => {
3301 clearInsideReactTreeTimeout.clear();
3302 dataRef.current.insideReactTree = false;
3303 });
3304 const hasBlockingChild = useStableCallback((bubbleKey) => {
3305 const nodeId = dataRef.current.floatingContext?.nodeId;
3306 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3307 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3308 });
3309 const isEventWithinOwnElements = useStableCallback((event) => {
3310 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3311 });
3312 const closeOnReferencePress = useStableCallback((event) => {
3313 if (!referencePress()) {
3314 return;
3315 }
3316 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3317 });
3318 const closeOnEscapeKeyDown = useStableCallback((event) => {
3319 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3320 return;
3321 }
3322 if (isComposingRef.current) {
3323 return;
3324 }
3325 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3326 return;
3327 }
3328 const native = isReactEvent(event) ? event.nativeEvent : event;
3329 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3330 store.setOpen(false, eventDetails);
3331 if (!eventDetails.isCanceled) {
3332 event.preventDefault();
3333 }
3334 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3335 event.stopPropagation();
3336 }
3337 });
3338 const markInsideReactTree = useStableCallback(() => {
3339 dataRef.current.insideReactTree = true;
3340 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3341 });
3342 const markPressStartedInsideReactTree = useStableCallback((event) => {
3343 if (!open || !enabled || event.button !== 0) {
3344 return;
3345 }
3346 const target = getTarget(event.nativeEvent);
3347 if (!contains(store.select("floatingElement"), target)) {
3348 return;
3349 }
3350 if (!pressStartedInsideRef.current) {
3351 pressStartedInsideRef.current = true;
3352 pressStartPreventedRef.current = false;
3353 }
3354 });
3355 const markInsidePressStartPrevented = useStableCallback((event) => {
3356 if (!open || !enabled) {
3357 return;
3358 }
3359 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3360 return;
3361 }
3362 if (pressStartedInsideRef.current) {
3363 pressStartPreventedRef.current = true;
3364 }
3365 });
3366 React18.useEffect(() => {
3367 if (!open || !enabled) {
3368 return void 0;
3369 }
3370 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3371 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3372 const compositionTimeout = new Timeout();
3373 const preventedPressSuppressionTimeout = new Timeout();
3374 function handleCompositionStart() {
3375 compositionTimeout.clear();
3376 isComposingRef.current = true;
3377 }
3378 function handleCompositionEnd() {
3379 compositionTimeout.start(
3380 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3381 // Only apply to WebKit for the test to remain 0ms.
3382 isWebKit() ? 5 : 0,
3383 () => {
3384 isComposingRef.current = false;
3385 }
3386 );
3387 }
3388 function suppressImmediateOutsideClickAfterPreventedStart() {
3389 suppressNextOutsideClickRef.current = true;
3390 preventedPressSuppressionTimeout.start(0, () => {
3391 suppressNextOutsideClickRef.current = false;
3392 });
3393 }
3394 function resetPressStartState() {
3395 pressStartedInsideRef.current = false;
3396 pressStartPreventedRef.current = false;
3397 }
3398 function getOutsidePressEvent() {
3399 const type = currentPointerTypeRef.current;
3400 const computedType = type === "pen" || !type ? "mouse" : type;
3401 const outsidePressEventValue = getOutsidePressEventProp();
3402 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3403 if (typeof resolved === "string") {
3404 return resolved;
3405 }
3406 return resolved[computedType];
3407 }
3408 function shouldIgnoreEvent(event) {
3409 const computedOutsidePressEvent = getOutsidePressEvent();
3410 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3411 }
3412 function isEventWithinFloatingTree(event) {
3413 const nodeId = dataRef.current.floatingContext?.nodeId;
3414 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3415 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3416 }
3417 function closeOnPressOutside(event) {
3418 if (shouldIgnoreEvent(event)) {
3419 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3420 preventedPressSuppressionTimeout.clear();
3421 suppressNextOutsideClickRef.current = false;
3422 }
3423 clearInsideReactTree();
3424 return;
3425 }
3426 if (dataRef.current.insideReactTree) {
3427 clearInsideReactTree();
3428 return;
3429 }
3430 const target = getTarget(event);
3431 const inertSelector = `[${createAttribute("inert")}]`;
3432 const targetRoot = isElement(target) ? target.getRootNode() : null;
3433 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3434 const triggers = store.context.triggerElements;
3435 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3436 return;
3437 }
3438 let targetRootAncestor = isElement(target) ? target : null;
3439 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3440 const nextParent = getParentNode(targetRootAncestor);
3441 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3442 break;
3443 }
3444 targetRootAncestor = nextParent;
3445 }
3446 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3447 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3448 // element was injected after the floating element rendered.
3449 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3450 return;
3451 }
3452 if (isHTMLElement(target) && !("touches" in event)) {
3453 const lastTraversableNode = isLastTraversableNode(target);
3454 const style = getComputedStyle2(target);
3455 const scrollRe = /auto|scroll/;
3456 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3457 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3458 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3459 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3460 const isRTL7 = style.direction === "rtl";
3461 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3462 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3463 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3464 return;
3465 }
3466 }
3467 if (isEventWithinFloatingTree(event)) {
3468 return;
3469 }
3470 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3471 preventedPressSuppressionTimeout.clear();
3472 suppressNextOutsideClickRef.current = false;
3473 return;
3474 }
3475 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3476 return;
3477 }
3478 if (hasBlockingChild("__outsidePressBubbles")) {
3479 return;
3480 }
3481 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3482 clearInsideReactTree();
3483 }
3484 function handlePointerDown(event) {
3485 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3486 return;
3487 }
3488 closeOnPressOutside(event);
3489 }
3490 function handleTouchStart(event) {
3491 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3492 return;
3493 }
3494 const touch = event.touches[0];
3495 if (touch) {
3496 touchStateRef.current = {
3497 startTime: Date.now(),
3498 startX: touch.clientX,
3499 startY: touch.clientY,
3500 dismissOnTouchEnd: false,
3501 dismissOnMouseDown: true
3502 };
3503 cancelDismissOnEndTimeout.start(1e3, () => {
3504 if (touchStateRef.current) {
3505 touchStateRef.current.dismissOnTouchEnd = false;
3506 touchStateRef.current.dismissOnMouseDown = false;
3507 }
3508 });
3509 }
3510 }
3511 function addTargetEventListenerOnce(event, listener) {
3512 const target = getTarget(event);
3513 if (!target) {
3514 return;
3515 }
3516 const unsubscribe2 = addEventListener(target, event.type, () => {
3517 listener(event);
3518 unsubscribe2();
3519 });
3520 }
3521 function handleTouchStartCapture(event) {
3522 currentPointerTypeRef.current = "touch";
3523 addTargetEventListenerOnce(event, handleTouchStart);
3524 }
3525 function closeOnPressOutsideCapture(event) {
3526 cancelDismissOnEndTimeout.clear();
3527 if (event.type === "pointerdown") {
3528 currentPointerTypeRef.current = event.pointerType;
3529 }
3530 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3531 return;
3532 }
3533 addTargetEventListenerOnce(event, (targetEvent) => {
3534 if (targetEvent.type === "pointerdown") {
3535 handlePointerDown(targetEvent);
3536 } else {
3537 closeOnPressOutside(targetEvent);
3538 }
3539 });
3540 }
3541 function handlePressEndCapture(event) {
3542 if (!pressStartedInsideRef.current) {
3543 return;
3544 }
3545 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3546 resetPressStartState();
3547 if (getOutsidePressEvent() !== "intentional") {
3548 return;
3549 }
3550 if (event.type === "pointercancel") {
3551 if (pressStartedInsideDefaultPrevented) {
3552 suppressImmediateOutsideClickAfterPreventedStart();
3553 }
3554 return;
3555 }
3556 if (isEventWithinFloatingTree(event)) {
3557 return;
3558 }
3559 if (pressStartedInsideDefaultPrevented) {
3560 suppressImmediateOutsideClickAfterPreventedStart();
3561 return;
3562 }
3563 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3564 return;
3565 }
3566 preventedPressSuppressionTimeout.clear();
3567 suppressNextOutsideClickRef.current = true;
3568 clearInsideReactTree();
3569 }
3570 function handleTouchMove(event) {
3571 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3572 return;
3573 }
3574 const touch = event.touches[0];
3575 if (!touch) {
3576 return;
3577 }
3578 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3579 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3580 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3581 if (distance > 5) {
3582 touchStateRef.current.dismissOnTouchEnd = true;
3583 }
3584 if (distance > 10) {
3585 closeOnPressOutside(event);
3586 cancelDismissOnEndTimeout.clear();
3587 touchStateRef.current = null;
3588 }
3589 }
3590 function handleTouchMoveCapture(event) {
3591 addTargetEventListenerOnce(event, handleTouchMove);
3592 }
3593 function handleTouchEnd(event) {
3594 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3595 return;
3596 }
3597 if (touchStateRef.current.dismissOnTouchEnd) {
3598 closeOnPressOutside(event);
3599 }
3600 cancelDismissOnEndTimeout.clear();
3601 touchStateRef.current = null;
3602 }
3603 function handleTouchEndCapture(event) {
3604 addTargetEventListenerOnce(event, handleTouchEnd);
3605 }
3606 const doc = ownerDocument(floatingElement);
3607 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true)));
3608 return () => {
3609 unsubscribe();
3610 compositionTimeout.clear();
3611 preventedPressSuppressionTimeout.clear();
3612 resetPressStartState();
3613 suppressNextOutsideClickRef.current = false;
3614 };
3615 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3616 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3617 const reference = React18.useMemo(() => ({
3618 onKeyDown: closeOnEscapeKeyDown,
3619 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3620 ...referencePressEvent !== "intentional" && {
3621 onClick: closeOnReferencePress
3622 }
3623 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3624 const floating = React18.useMemo(() => ({
3625 onKeyDown: closeOnEscapeKeyDown,
3626 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3627 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3628 // See https://github.com/mui/base-ui/pull/3379
3629 onPointerDown: markInsidePressStartPrevented,
3630 onMouseDown: markInsidePressStartPrevented,
3631 onClickCapture: markInsideReactTree,
3632 onMouseDownCapture(event) {
3633 markInsideReactTree();
3634 markPressStartedInsideReactTree(event);
3635 },
3636 onPointerDownCapture(event) {
3637 markInsideReactTree();
3638 markPressStartedInsideReactTree(event);
3639 },
3640 onMouseUpCapture: markInsideReactTree,
3641 onTouchEndCapture: markInsideReactTree,
3642 onTouchMoveCapture: markInsideReactTree
3643 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3644 return React18.useMemo(() => enabled ? {
3645 reference,
3646 floating,
3647 trigger: reference
3648 } : {}, [enabled, reference, floating]);
3649 }
3650
3651 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3652 var React25 = __toESM(require_react(), 1);
3653
3654 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3655 function computeCoordsFromPlacement(_ref, placement, rtl) {
3656 let {
3657 reference,
3658 floating
3659 } = _ref;
3660 const sideAxis = getSideAxis(placement);
3661 const alignmentAxis = getAlignmentAxis(placement);
3662 const alignLength = getAxisLength(alignmentAxis);
3663 const side = getSide(placement);
3664 const isVertical = sideAxis === "y";
3665 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3666 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3667 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3668 let coords;
3669 switch (side) {
3670 case "top":
3671 coords = {
3672 x: commonX,
3673 y: reference.y - floating.height
3674 };
3675 break;
3676 case "bottom":
3677 coords = {
3678 x: commonX,
3679 y: reference.y + reference.height
3680 };
3681 break;
3682 case "right":
3683 coords = {
3684 x: reference.x + reference.width,
3685 y: commonY
3686 };
3687 break;
3688 case "left":
3689 coords = {
3690 x: reference.x - floating.width,
3691 y: commonY
3692 };
3693 break;
3694 default:
3695 coords = {
3696 x: reference.x,
3697 y: reference.y
3698 };
3699 }
3700 switch (getAlignment(placement)) {
3701 case "start":
3702 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3703 break;
3704 case "end":
3705 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3706 break;
3707 }
3708 return coords;
3709 }
3710 async function detectOverflow(state, options) {
3711 var _await$platform$isEle;
3712 if (options === void 0) {
3713 options = {};
3714 }
3715 const {
3716 x: x2,
3717 y: y2,
3718 platform: platform3,
3719 rects,
3720 elements,
3721 strategy
3722 } = state;
3723 const {
3724 boundary = "clippingAncestors",
3725 rootBoundary = "viewport",
3726 elementContext = "floating",
3727 altBoundary = false,
3728 padding = 0
3729 } = evaluate(options, state);
3730 const paddingObject = getPaddingObject(padding);
3731 const altContext = elementContext === "floating" ? "reference" : "floating";
3732 const element = elements[altBoundary ? altContext : elementContext];
3733 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3734 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)),
3735 boundary,
3736 rootBoundary,
3737 strategy
3738 }));
3739 const rect = elementContext === "floating" ? {
3740 x: x2,
3741 y: y2,
3742 width: rects.floating.width,
3743 height: rects.floating.height
3744 } : rects.reference;
3745 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3746 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3747 x: 1,
3748 y: 1
3749 } : {
3750 x: 1,
3751 y: 1
3752 };
3753 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3754 elements,
3755 rect,
3756 offsetParent,
3757 strategy
3758 }) : rect);
3759 return {
3760 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3761 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3762 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3763 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3764 };
3765 }
3766 var MAX_RESET_COUNT = 50;
3767 var computePosition = async (reference, floating, config) => {
3768 const {
3769 placement = "bottom",
3770 strategy = "absolute",
3771 middleware = [],
3772 platform: platform3
3773 } = config;
3774 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3775 ...platform3,
3776 detectOverflow
3777 };
3778 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3779 let rects = await platform3.getElementRects({
3780 reference,
3781 floating,
3782 strategy
3783 });
3784 let {
3785 x: x2,
3786 y: y2
3787 } = computeCoordsFromPlacement(rects, placement, rtl);
3788 let statefulPlacement = placement;
3789 let resetCount = 0;
3790 const middlewareData = {};
3791 for (let i2 = 0; i2 < middleware.length; i2++) {
3792 const currentMiddleware = middleware[i2];
3793 if (!currentMiddleware) {
3794 continue;
3795 }
3796 const {
3797 name,
3798 fn
3799 } = currentMiddleware;
3800 const {
3801 x: nextX,
3802 y: nextY,
3803 data,
3804 reset
3805 } = await fn({
3806 x: x2,
3807 y: y2,
3808 initialPlacement: placement,
3809 placement: statefulPlacement,
3810 strategy,
3811 middlewareData,
3812 rects,
3813 platform: platformWithDetectOverflow,
3814 elements: {
3815 reference,
3816 floating
3817 }
3818 });
3819 x2 = nextX != null ? nextX : x2;
3820 y2 = nextY != null ? nextY : y2;
3821 middlewareData[name] = {
3822 ...middlewareData[name],
3823 ...data
3824 };
3825 if (reset && resetCount < MAX_RESET_COUNT) {
3826 resetCount++;
3827 if (typeof reset === "object") {
3828 if (reset.placement) {
3829 statefulPlacement = reset.placement;
3830 }
3831 if (reset.rects) {
3832 rects = reset.rects === true ? await platform3.getElementRects({
3833 reference,
3834 floating,
3835 strategy
3836 }) : reset.rects;
3837 }
3838 ({
3839 x: x2,
3840 y: y2
3841 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3842 }
3843 i2 = -1;
3844 }
3845 }
3846 return {
3847 x: x2,
3848 y: y2,
3849 placement: statefulPlacement,
3850 strategy,
3851 middlewareData
3852 };
3853 };
3854 var flip = function(options) {
3855 if (options === void 0) {
3856 options = {};
3857 }
3858 return {
3859 name: "flip",
3860 options,
3861 async fn(state) {
3862 var _middlewareData$arrow, _middlewareData$flip;
3863 const {
3864 placement,
3865 middlewareData,
3866 rects,
3867 initialPlacement,
3868 platform: platform3,
3869 elements
3870 } = state;
3871 const {
3872 mainAxis: checkMainAxis = true,
3873 crossAxis: checkCrossAxis = true,
3874 fallbackPlacements: specifiedFallbackPlacements,
3875 fallbackStrategy = "bestFit",
3876 fallbackAxisSideDirection = "none",
3877 flipAlignment = true,
3878 ...detectOverflowOptions
3879 } = evaluate(options, state);
3880 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3881 return {};
3882 }
3883 const side = getSide(placement);
3884 const initialSideAxis = getSideAxis(initialPlacement);
3885 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3886 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3887 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3888 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3889 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3890 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3891 }
3892 const placements2 = [initialPlacement, ...fallbackPlacements];
3893 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3894 const overflows = [];
3895 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3896 if (checkMainAxis) {
3897 overflows.push(overflow[side]);
3898 }
3899 if (checkCrossAxis) {
3900 const sides2 = getAlignmentSides(placement, rects, rtl);
3901 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3902 }
3903 overflowsData = [...overflowsData, {
3904 placement,
3905 overflows
3906 }];
3907 if (!overflows.every((side2) => side2 <= 0)) {
3908 var _middlewareData$flip2, _overflowsData$filter;
3909 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3910 const nextPlacement = placements2[nextIndex];
3911 if (nextPlacement) {
3912 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3913 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3914 // overflows the main axis.
3915 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3916 return {
3917 data: {
3918 index: nextIndex,
3919 overflows: overflowsData
3920 },
3921 reset: {
3922 placement: nextPlacement
3923 }
3924 };
3925 }
3926 }
3927 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
3928 if (!resetPlacement) {
3929 switch (fallbackStrategy) {
3930 case "bestFit": {
3931 var _overflowsData$filter2;
3932 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3933 if (hasFallbackAxisSideDirection) {
3934 const currentSideAxis = getSideAxis(d2.placement);
3935 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3936 // reading directions favoring greater width.
3937 currentSideAxis === "y";
3938 }
3939 return true;
3940 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
3941 if (placement2) {
3942 resetPlacement = placement2;
3943 }
3944 break;
3945 }
3946 case "initialPlacement":
3947 resetPlacement = initialPlacement;
3948 break;
3949 }
3950 }
3951 if (placement !== resetPlacement) {
3952 return {
3953 reset: {
3954 placement: resetPlacement
3955 }
3956 };
3957 }
3958 }
3959 return {};
3960 }
3961 };
3962 };
3963 function getSideOffsets(overflow, rect) {
3964 return {
3965 top: overflow.top - rect.height,
3966 right: overflow.right - rect.width,
3967 bottom: overflow.bottom - rect.height,
3968 left: overflow.left - rect.width
3969 };
3970 }
3971 function isAnySideFullyClipped(overflow) {
3972 return sides.some((side) => overflow[side] >= 0);
3973 }
3974 var hide = function(options) {
3975 if (options === void 0) {
3976 options = {};
3977 }
3978 return {
3979 name: "hide",
3980 options,
3981 async fn(state) {
3982 const {
3983 rects,
3984 platform: platform3
3985 } = state;
3986 const {
3987 strategy = "referenceHidden",
3988 ...detectOverflowOptions
3989 } = evaluate(options, state);
3990 switch (strategy) {
3991 case "referenceHidden": {
3992 const overflow = await platform3.detectOverflow(state, {
3993 ...detectOverflowOptions,
3994 elementContext: "reference"
3995 });
3996 const offsets = getSideOffsets(overflow, rects.reference);
3997 return {
3998 data: {
3999 referenceHiddenOffsets: offsets,
4000 referenceHidden: isAnySideFullyClipped(offsets)
4001 }
4002 };
4003 }
4004 case "escaped": {
4005 const overflow = await platform3.detectOverflow(state, {
4006 ...detectOverflowOptions,
4007 altBoundary: true
4008 });
4009 const offsets = getSideOffsets(overflow, rects.floating);
4010 return {
4011 data: {
4012 escapedOffsets: offsets,
4013 escaped: isAnySideFullyClipped(offsets)
4014 }
4015 };
4016 }
4017 default: {
4018 return {};
4019 }
4020 }
4021 }
4022 };
4023 };
4024 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4025 async function convertValueToCoords(state, options) {
4026 const {
4027 placement,
4028 platform: platform3,
4029 elements
4030 } = state;
4031 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4032 const side = getSide(placement);
4033 const alignment = getAlignment(placement);
4034 const isVertical = getSideAxis(placement) === "y";
4035 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4036 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4037 const rawValue = evaluate(options, state);
4038 let {
4039 mainAxis,
4040 crossAxis,
4041 alignmentAxis
4042 } = typeof rawValue === "number" ? {
4043 mainAxis: rawValue,
4044 crossAxis: 0,
4045 alignmentAxis: null
4046 } : {
4047 mainAxis: rawValue.mainAxis || 0,
4048 crossAxis: rawValue.crossAxis || 0,
4049 alignmentAxis: rawValue.alignmentAxis
4050 };
4051 if (alignment && typeof alignmentAxis === "number") {
4052 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4053 }
4054 return isVertical ? {
4055 x: crossAxis * crossAxisMulti,
4056 y: mainAxis * mainAxisMulti
4057 } : {
4058 x: mainAxis * mainAxisMulti,
4059 y: crossAxis * crossAxisMulti
4060 };
4061 }
4062 var offset = function(options) {
4063 if (options === void 0) {
4064 options = 0;
4065 }
4066 return {
4067 name: "offset",
4068 options,
4069 async fn(state) {
4070 var _middlewareData$offse, _middlewareData$arrow;
4071 const {
4072 x: x2,
4073 y: y2,
4074 placement,
4075 middlewareData
4076 } = state;
4077 const diffCoords = await convertValueToCoords(state, options);
4078 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4079 return {};
4080 }
4081 return {
4082 x: x2 + diffCoords.x,
4083 y: y2 + diffCoords.y,
4084 data: {
4085 ...diffCoords,
4086 placement
4087 }
4088 };
4089 }
4090 };
4091 };
4092 var shift = function(options) {
4093 if (options === void 0) {
4094 options = {};
4095 }
4096 return {
4097 name: "shift",
4098 options,
4099 async fn(state) {
4100 const {
4101 x: x2,
4102 y: y2,
4103 placement,
4104 platform: platform3
4105 } = state;
4106 const {
4107 mainAxis: checkMainAxis = true,
4108 crossAxis: checkCrossAxis = false,
4109 limiter = {
4110 fn: (_ref) => {
4111 let {
4112 x: x3,
4113 y: y3
4114 } = _ref;
4115 return {
4116 x: x3,
4117 y: y3
4118 };
4119 }
4120 },
4121 ...detectOverflowOptions
4122 } = evaluate(options, state);
4123 const coords = {
4124 x: x2,
4125 y: y2
4126 };
4127 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4128 const crossAxis = getSideAxis(getSide(placement));
4129 const mainAxis = getOppositeAxis(crossAxis);
4130 let mainAxisCoord = coords[mainAxis];
4131 let crossAxisCoord = coords[crossAxis];
4132 if (checkMainAxis) {
4133 const minSide = mainAxis === "y" ? "top" : "left";
4134 const maxSide = mainAxis === "y" ? "bottom" : "right";
4135 const min2 = mainAxisCoord + overflow[minSide];
4136 const max2 = mainAxisCoord - overflow[maxSide];
4137 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4138 }
4139 if (checkCrossAxis) {
4140 const minSide = crossAxis === "y" ? "top" : "left";
4141 const maxSide = crossAxis === "y" ? "bottom" : "right";
4142 const min2 = crossAxisCoord + overflow[minSide];
4143 const max2 = crossAxisCoord - overflow[maxSide];
4144 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4145 }
4146 const limitedCoords = limiter.fn({
4147 ...state,
4148 [mainAxis]: mainAxisCoord,
4149 [crossAxis]: crossAxisCoord
4150 });
4151 return {
4152 ...limitedCoords,
4153 data: {
4154 x: limitedCoords.x - x2,
4155 y: limitedCoords.y - y2,
4156 enabled: {
4157 [mainAxis]: checkMainAxis,
4158 [crossAxis]: checkCrossAxis
4159 }
4160 }
4161 };
4162 }
4163 };
4164 };
4165 var limitShift = function(options) {
4166 if (options === void 0) {
4167 options = {};
4168 }
4169 return {
4170 options,
4171 fn(state) {
4172 const {
4173 x: x2,
4174 y: y2,
4175 placement,
4176 rects,
4177 middlewareData
4178 } = state;
4179 const {
4180 offset: offset4 = 0,
4181 mainAxis: checkMainAxis = true,
4182 crossAxis: checkCrossAxis = true
4183 } = evaluate(options, state);
4184 const coords = {
4185 x: x2,
4186 y: y2
4187 };
4188 const crossAxis = getSideAxis(placement);
4189 const mainAxis = getOppositeAxis(crossAxis);
4190 let mainAxisCoord = coords[mainAxis];
4191 let crossAxisCoord = coords[crossAxis];
4192 const rawOffset = evaluate(offset4, state);
4193 const computedOffset = typeof rawOffset === "number" ? {
4194 mainAxis: rawOffset,
4195 crossAxis: 0
4196 } : {
4197 mainAxis: 0,
4198 crossAxis: 0,
4199 ...rawOffset
4200 };
4201 if (checkMainAxis) {
4202 const len = mainAxis === "y" ? "height" : "width";
4203 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4204 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4205 if (mainAxisCoord < limitMin) {
4206 mainAxisCoord = limitMin;
4207 } else if (mainAxisCoord > limitMax) {
4208 mainAxisCoord = limitMax;
4209 }
4210 }
4211 if (checkCrossAxis) {
4212 var _middlewareData$offse, _middlewareData$offse2;
4213 const len = mainAxis === "y" ? "width" : "height";
4214 const isOriginSide = originSides.has(getSide(placement));
4215 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
4216 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
4217 if (crossAxisCoord < limitMin) {
4218 crossAxisCoord = limitMin;
4219 } else if (crossAxisCoord > limitMax) {
4220 crossAxisCoord = limitMax;
4221 }
4222 }
4223 return {
4224 [mainAxis]: mainAxisCoord,
4225 [crossAxis]: crossAxisCoord
4226 };
4227 }
4228 };
4229 };
4230 var size = function(options) {
4231 if (options === void 0) {
4232 options = {};
4233 }
4234 return {
4235 name: "size",
4236 options,
4237 async fn(state) {
4238 var _state$middlewareData, _state$middlewareData2;
4239 const {
4240 placement,
4241 rects,
4242 platform: platform3,
4243 elements
4244 } = state;
4245 const {
4246 apply = () => {
4247 },
4248 ...detectOverflowOptions
4249 } = evaluate(options, state);
4250 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4251 const side = getSide(placement);
4252 const alignment = getAlignment(placement);
4253 const isYAxis = getSideAxis(placement) === "y";
4254 const {
4255 width,
4256 height
4257 } = rects.floating;
4258 let heightSide;
4259 let widthSide;
4260 if (side === "top" || side === "bottom") {
4261 heightSide = side;
4262 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4263 } else {
4264 widthSide = side;
4265 heightSide = alignment === "end" ? "top" : "bottom";
4266 }
4267 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4268 const maximumClippingWidth = width - overflow.left - overflow.right;
4269 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4270 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4271 const noShift = !state.middlewareData.shift;
4272 let availableHeight = overflowAvailableHeight;
4273 let availableWidth = overflowAvailableWidth;
4274 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4275 availableWidth = maximumClippingWidth;
4276 }
4277 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4278 availableHeight = maximumClippingHeight;
4279 }
4280 if (noShift && !alignment) {
4281 const xMin = max(overflow.left, 0);
4282 const xMax = max(overflow.right, 0);
4283 const yMin = max(overflow.top, 0);
4284 const yMax = max(overflow.bottom, 0);
4285 if (isYAxis) {
4286 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4287 } else {
4288 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4289 }
4290 }
4291 await apply({
4292 ...state,
4293 availableWidth,
4294 availableHeight
4295 });
4296 const nextDimensions = await platform3.getDimensions(elements.floating);
4297 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4298 return {
4299 reset: {
4300 rects: true
4301 }
4302 };
4303 }
4304 return {};
4305 }
4306 };
4307 };
4308
4309 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4310 function getCssDimensions(element) {
4311 const css = getComputedStyle2(element);
4312 let width = parseFloat(css.width) || 0;
4313 let height = parseFloat(css.height) || 0;
4314 const hasOffset = isHTMLElement(element);
4315 const offsetWidth = hasOffset ? element.offsetWidth : width;
4316 const offsetHeight = hasOffset ? element.offsetHeight : height;
4317 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4318 if (shouldFallback) {
4319 width = offsetWidth;
4320 height = offsetHeight;
4321 }
4322 return {
4323 width,
4324 height,
4325 $: shouldFallback
4326 };
4327 }
4328 function unwrapElement(element) {
4329 return !isElement(element) ? element.contextElement : element;
4330 }
4331 function getScale(element) {
4332 const domElement = unwrapElement(element);
4333 if (!isHTMLElement(domElement)) {
4334 return createCoords(1);
4335 }
4336 const rect = domElement.getBoundingClientRect();
4337 const {
4338 width,
4339 height,
4340 $: $2
4341 } = getCssDimensions(domElement);
4342 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4343 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4344 if (!x2 || !Number.isFinite(x2)) {
4345 x2 = 1;
4346 }
4347 if (!y2 || !Number.isFinite(y2)) {
4348 y2 = 1;
4349 }
4350 return {
4351 x: x2,
4352 y: y2
4353 };
4354 }
4355 var noOffsets = /* @__PURE__ */ createCoords(0);
4356 function getVisualOffsets(element) {
4357 const win = getWindow(element);
4358 if (!isWebKit() || !win.visualViewport) {
4359 return noOffsets;
4360 }
4361 return {
4362 x: win.visualViewport.offsetLeft,
4363 y: win.visualViewport.offsetTop
4364 };
4365 }
4366 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4367 if (isFixed === void 0) {
4368 isFixed = false;
4369 }
4370 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4371 return false;
4372 }
4373 return isFixed;
4374 }
4375 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4376 if (includeScale === void 0) {
4377 includeScale = false;
4378 }
4379 if (isFixedStrategy === void 0) {
4380 isFixedStrategy = false;
4381 }
4382 const clientRect = element.getBoundingClientRect();
4383 const domElement = unwrapElement(element);
4384 let scale = createCoords(1);
4385 if (includeScale) {
4386 if (offsetParent) {
4387 if (isElement(offsetParent)) {
4388 scale = getScale(offsetParent);
4389 }
4390 } else {
4391 scale = getScale(element);
4392 }
4393 }
4394 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4395 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4396 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4397 let width = clientRect.width / scale.x;
4398 let height = clientRect.height / scale.y;
4399 if (domElement) {
4400 const win = getWindow(domElement);
4401 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4402 let currentWin = win;
4403 let currentIFrame = getFrameElement(currentWin);
4404 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4405 const iframeScale = getScale(currentIFrame);
4406 const iframeRect = currentIFrame.getBoundingClientRect();
4407 const css = getComputedStyle2(currentIFrame);
4408 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4409 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4410 x2 *= iframeScale.x;
4411 y2 *= iframeScale.y;
4412 width *= iframeScale.x;
4413 height *= iframeScale.y;
4414 x2 += left;
4415 y2 += top;
4416 currentWin = getWindow(currentIFrame);
4417 currentIFrame = getFrameElement(currentWin);
4418 }
4419 }
4420 return rectToClientRect({
4421 width,
4422 height,
4423 x: x2,
4424 y: y2
4425 });
4426 }
4427 function getWindowScrollBarX(element, rect) {
4428 const leftScroll = getNodeScroll(element).scrollLeft;
4429 if (!rect) {
4430 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4431 }
4432 return rect.left + leftScroll;
4433 }
4434 function getHTMLOffset(documentElement, scroll) {
4435 const htmlRect = documentElement.getBoundingClientRect();
4436 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4437 const y2 = htmlRect.top + scroll.scrollTop;
4438 return {
4439 x: x2,
4440 y: y2
4441 };
4442 }
4443 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4444 let {
4445 elements,
4446 rect,
4447 offsetParent,
4448 strategy
4449 } = _ref;
4450 const isFixed = strategy === "fixed";
4451 const documentElement = getDocumentElement(offsetParent);
4452 const topLayer = elements ? isTopLayer(elements.floating) : false;
4453 if (offsetParent === documentElement || topLayer && isFixed) {
4454 return rect;
4455 }
4456 let scroll = {
4457 scrollLeft: 0,
4458 scrollTop: 0
4459 };
4460 let scale = createCoords(1);
4461 const offsets = createCoords(0);
4462 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4463 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4464 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4465 scroll = getNodeScroll(offsetParent);
4466 }
4467 if (isOffsetParentAnElement) {
4468 const offsetRect = getBoundingClientRect(offsetParent);
4469 scale = getScale(offsetParent);
4470 offsets.x = offsetRect.x + offsetParent.clientLeft;
4471 offsets.y = offsetRect.y + offsetParent.clientTop;
4472 }
4473 }
4474 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4475 return {
4476 width: rect.width * scale.x,
4477 height: rect.height * scale.y,
4478 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4479 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4480 };
4481 }
4482 function getClientRects(element) {
4483 return Array.from(element.getClientRects());
4484 }
4485 function getDocumentRect(element) {
4486 const html = getDocumentElement(element);
4487 const scroll = getNodeScroll(element);
4488 const body = element.ownerDocument.body;
4489 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4490 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4491 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4492 const y2 = -scroll.scrollTop;
4493 if (getComputedStyle2(body).direction === "rtl") {
4494 x2 += max(html.clientWidth, body.clientWidth) - width;
4495 }
4496 return {
4497 width,
4498 height,
4499 x: x2,
4500 y: y2
4501 };
4502 }
4503 var SCROLLBAR_MAX = 25;
4504 function getViewportRect(element, strategy) {
4505 const win = getWindow(element);
4506 const html = getDocumentElement(element);
4507 const visualViewport = win.visualViewport;
4508 let width = html.clientWidth;
4509 let height = html.clientHeight;
4510 let x2 = 0;
4511 let y2 = 0;
4512 if (visualViewport) {
4513 width = visualViewport.width;
4514 height = visualViewport.height;
4515 const visualViewportBased = isWebKit();
4516 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4517 x2 = visualViewport.offsetLeft;
4518 y2 = visualViewport.offsetTop;
4519 }
4520 }
4521 const windowScrollbarX = getWindowScrollBarX(html);
4522 if (windowScrollbarX <= 0) {
4523 const doc = html.ownerDocument;
4524 const body = doc.body;
4525 const bodyStyles = getComputedStyle(body);
4526 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4527 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4528 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4529 width -= clippingStableScrollbarWidth;
4530 }
4531 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4532 width += windowScrollbarX;
4533 }
4534 return {
4535 width,
4536 height,
4537 x: x2,
4538 y: y2
4539 };
4540 }
4541 function getInnerBoundingClientRect(element, strategy) {
4542 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4543 const top = clientRect.top + element.clientTop;
4544 const left = clientRect.left + element.clientLeft;
4545 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4546 const width = element.clientWidth * scale.x;
4547 const height = element.clientHeight * scale.y;
4548 const x2 = left * scale.x;
4549 const y2 = top * scale.y;
4550 return {
4551 width,
4552 height,
4553 x: x2,
4554 y: y2
4555 };
4556 }
4557 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4558 let rect;
4559 if (clippingAncestor === "viewport") {
4560 rect = getViewportRect(element, strategy);
4561 } else if (clippingAncestor === "document") {
4562 rect = getDocumentRect(getDocumentElement(element));
4563 } else if (isElement(clippingAncestor)) {
4564 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4565 } else {
4566 const visualOffsets = getVisualOffsets(element);
4567 rect = {
4568 x: clippingAncestor.x - visualOffsets.x,
4569 y: clippingAncestor.y - visualOffsets.y,
4570 width: clippingAncestor.width,
4571 height: clippingAncestor.height
4572 };
4573 }
4574 return rectToClientRect(rect);
4575 }
4576 function hasFixedPositionAncestor(element, stopNode) {
4577 const parentNode = getParentNode(element);
4578 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4579 return false;
4580 }
4581 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4582 }
4583 function getClippingElementAncestors(element, cache) {
4584 const cachedResult = cache.get(element);
4585 if (cachedResult) {
4586 return cachedResult;
4587 }
4588 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4589 let currentContainingBlockComputedStyle = null;
4590 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4591 let currentNode = elementIsFixed ? getParentNode(element) : element;
4592 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4593 const computedStyle = getComputedStyle2(currentNode);
4594 const currentNodeIsContaining = isContainingBlock(currentNode);
4595 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4596 currentContainingBlockComputedStyle = null;
4597 }
4598 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4599 if (shouldDropCurrentNode) {
4600 result = result.filter((ancestor) => ancestor !== currentNode);
4601 } else {
4602 currentContainingBlockComputedStyle = computedStyle;
4603 }
4604 currentNode = getParentNode(currentNode);
4605 }
4606 cache.set(element, result);
4607 return result;
4608 }
4609 function getClippingRect(_ref) {
4610 let {
4611 element,
4612 boundary,
4613 rootBoundary,
4614 strategy
4615 } = _ref;
4616 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4617 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4618 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4619 let top = firstRect.top;
4620 let right = firstRect.right;
4621 let bottom = firstRect.bottom;
4622 let left = firstRect.left;
4623 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4624 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4625 top = max(rect.top, top);
4626 right = min(rect.right, right);
4627 bottom = min(rect.bottom, bottom);
4628 left = max(rect.left, left);
4629 }
4630 return {
4631 width: right - left,
4632 height: bottom - top,
4633 x: left,
4634 y: top
4635 };
4636 }
4637 function getDimensions(element) {
4638 const {
4639 width,
4640 height
4641 } = getCssDimensions(element);
4642 return {
4643 width,
4644 height
4645 };
4646 }
4647 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4648 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4649 const documentElement = getDocumentElement(offsetParent);
4650 const isFixed = strategy === "fixed";
4651 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4652 let scroll = {
4653 scrollLeft: 0,
4654 scrollTop: 0
4655 };
4656 const offsets = createCoords(0);
4657 function setLeftRTLScrollbarOffset() {
4658 offsets.x = getWindowScrollBarX(documentElement);
4659 }
4660 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4661 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4662 scroll = getNodeScroll(offsetParent);
4663 }
4664 if (isOffsetParentAnElement) {
4665 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4666 offsets.x = offsetRect.x + offsetParent.clientLeft;
4667 offsets.y = offsetRect.y + offsetParent.clientTop;
4668 } else if (documentElement) {
4669 setLeftRTLScrollbarOffset();
4670 }
4671 }
4672 if (isFixed && !isOffsetParentAnElement && documentElement) {
4673 setLeftRTLScrollbarOffset();
4674 }
4675 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4676 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4677 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4678 return {
4679 x: x2,
4680 y: y2,
4681 width: rect.width,
4682 height: rect.height
4683 };
4684 }
4685 function isStaticPositioned(element) {
4686 return getComputedStyle2(element).position === "static";
4687 }
4688 function getTrueOffsetParent(element, polyfill) {
4689 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4690 return null;
4691 }
4692 if (polyfill) {
4693 return polyfill(element);
4694 }
4695 let rawOffsetParent = element.offsetParent;
4696 if (getDocumentElement(element) === rawOffsetParent) {
4697 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4698 }
4699 return rawOffsetParent;
4700 }
4701 function getOffsetParent(element, polyfill) {
4702 const win = getWindow(element);
4703 if (isTopLayer(element)) {
4704 return win;
4705 }
4706 if (!isHTMLElement(element)) {
4707 let svgOffsetParent = getParentNode(element);
4708 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4709 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4710 return svgOffsetParent;
4711 }
4712 svgOffsetParent = getParentNode(svgOffsetParent);
4713 }
4714 return win;
4715 }
4716 let offsetParent = getTrueOffsetParent(element, polyfill);
4717 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4718 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4719 }
4720 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4721 return win;
4722 }
4723 return offsetParent || getContainingBlock(element) || win;
4724 }
4725 var getElementRects = async function(data) {
4726 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4727 const getDimensionsFn = this.getDimensions;
4728 const floatingDimensions = await getDimensionsFn(data.floating);
4729 return {
4730 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4731 floating: {
4732 x: 0,
4733 y: 0,
4734 width: floatingDimensions.width,
4735 height: floatingDimensions.height
4736 }
4737 };
4738 };
4739 function isRTL(element) {
4740 return getComputedStyle2(element).direction === "rtl";
4741 }
4742 var platform2 = {
4743 convertOffsetParentRelativeRectToViewportRelativeRect,
4744 getDocumentElement,
4745 getClippingRect,
4746 getOffsetParent,
4747 getElementRects,
4748 getClientRects,
4749 getDimensions,
4750 getScale,
4751 isElement,
4752 isRTL
4753 };
4754 function rectsAreEqual(a2, b2) {
4755 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4756 }
4757 function observeMove(element, onMove) {
4758 let io = null;
4759 let timeoutId;
4760 const root = getDocumentElement(element);
4761 function cleanup() {
4762 var _io;
4763 clearTimeout(timeoutId);
4764 (_io = io) == null || _io.disconnect();
4765 io = null;
4766 }
4767 function refresh(skip, threshold) {
4768 if (skip === void 0) {
4769 skip = false;
4770 }
4771 if (threshold === void 0) {
4772 threshold = 1;
4773 }
4774 cleanup();
4775 const elementRectForRootMargin = element.getBoundingClientRect();
4776 const {
4777 left,
4778 top,
4779 width,
4780 height
4781 } = elementRectForRootMargin;
4782 if (!skip) {
4783 onMove();
4784 }
4785 if (!width || !height) {
4786 return;
4787 }
4788 const insetTop = floor(top);
4789 const insetRight = floor(root.clientWidth - (left + width));
4790 const insetBottom = floor(root.clientHeight - (top + height));
4791 const insetLeft = floor(left);
4792 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4793 const options = {
4794 rootMargin,
4795 threshold: max(0, min(1, threshold)) || 1
4796 };
4797 let isFirstUpdate = true;
4798 function handleObserve(entries) {
4799 const ratio = entries[0].intersectionRatio;
4800 if (ratio !== threshold) {
4801 if (!isFirstUpdate) {
4802 return refresh();
4803 }
4804 if (!ratio) {
4805 timeoutId = setTimeout(() => {
4806 refresh(false, 1e-7);
4807 }, 1e3);
4808 } else {
4809 refresh(false, ratio);
4810 }
4811 }
4812 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4813 refresh();
4814 }
4815 isFirstUpdate = false;
4816 }
4817 try {
4818 io = new IntersectionObserver(handleObserve, {
4819 ...options,
4820 // Handle <iframe>s
4821 root: root.ownerDocument
4822 });
4823 } catch (_e) {
4824 io = new IntersectionObserver(handleObserve, options);
4825 }
4826 io.observe(element);
4827 }
4828 refresh(true);
4829 return cleanup;
4830 }
4831 function autoUpdate(reference, floating, update2, options) {
4832 if (options === void 0) {
4833 options = {};
4834 }
4835 const {
4836 ancestorScroll = true,
4837 ancestorResize = true,
4838 elementResize = typeof ResizeObserver === "function",
4839 layoutShift = typeof IntersectionObserver === "function",
4840 animationFrame = false
4841 } = options;
4842 const referenceEl = unwrapElement(reference);
4843 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4844 ancestors.forEach((ancestor) => {
4845 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4846 passive: true
4847 });
4848 ancestorResize && ancestor.addEventListener("resize", update2);
4849 });
4850 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4851 let reobserveFrame = -1;
4852 let resizeObserver = null;
4853 if (elementResize) {
4854 resizeObserver = new ResizeObserver((_ref) => {
4855 let [firstEntry] = _ref;
4856 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4857 resizeObserver.unobserve(floating);
4858 cancelAnimationFrame(reobserveFrame);
4859 reobserveFrame = requestAnimationFrame(() => {
4860 var _resizeObserver;
4861 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4862 });
4863 }
4864 update2();
4865 });
4866 if (referenceEl && !animationFrame) {
4867 resizeObserver.observe(referenceEl);
4868 }
4869 if (floating) {
4870 resizeObserver.observe(floating);
4871 }
4872 }
4873 let frameId;
4874 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4875 if (animationFrame) {
4876 frameLoop();
4877 }
4878 function frameLoop() {
4879 const nextRefRect = getBoundingClientRect(reference);
4880 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4881 update2();
4882 }
4883 prevRefRect = nextRefRect;
4884 frameId = requestAnimationFrame(frameLoop);
4885 }
4886 update2();
4887 return () => {
4888 var _resizeObserver2;
4889 ancestors.forEach((ancestor) => {
4890 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4891 ancestorResize && ancestor.removeEventListener("resize", update2);
4892 });
4893 cleanupIo == null || cleanupIo();
4894 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4895 resizeObserver = null;
4896 if (animationFrame) {
4897 cancelAnimationFrame(frameId);
4898 }
4899 };
4900 }
4901 var offset2 = offset;
4902 var shift2 = shift;
4903 var flip2 = flip;
4904 var size2 = size;
4905 var hide2 = hide;
4906 var limitShift2 = limitShift;
4907 var computePosition2 = (reference, floating, options) => {
4908 const cache = /* @__PURE__ */ new Map();
4909 const mergedOptions = {
4910 platform: platform2,
4911 ...options
4912 };
4913 const platformWithCache = {
4914 ...mergedOptions.platform,
4915 _c: cache
4916 };
4917 return computePosition(reference, floating, {
4918 ...mergedOptions,
4919 platform: platformWithCache
4920 });
4921 };
4922
4923 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4924 var React19 = __toESM(require_react(), 1);
4925 var import_react2 = __toESM(require_react(), 1);
4926 var ReactDOM3 = __toESM(require_react_dom(), 1);
4927 var isClient = typeof document !== "undefined";
4928 var noop2 = function noop3() {
4929 };
4930 var index = isClient ? import_react2.useLayoutEffect : noop2;
4931 function deepEqual(a2, b2) {
4932 if (a2 === b2) {
4933 return true;
4934 }
4935 if (typeof a2 !== typeof b2) {
4936 return false;
4937 }
4938 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4939 return true;
4940 }
4941 let length;
4942 let i2;
4943 let keys;
4944 if (a2 && b2 && typeof a2 === "object") {
4945 if (Array.isArray(a2)) {
4946 length = a2.length;
4947 if (length !== b2.length) return false;
4948 for (i2 = length; i2-- !== 0; ) {
4949 if (!deepEqual(a2[i2], b2[i2])) {
4950 return false;
4951 }
4952 }
4953 return true;
4954 }
4955 keys = Object.keys(a2);
4956 length = keys.length;
4957 if (length !== Object.keys(b2).length) {
4958 return false;
4959 }
4960 for (i2 = length; i2-- !== 0; ) {
4961 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4962 return false;
4963 }
4964 }
4965 for (i2 = length; i2-- !== 0; ) {
4966 const key = keys[i2];
4967 if (key === "_owner" && a2.$$typeof) {
4968 continue;
4969 }
4970 if (!deepEqual(a2[key], b2[key])) {
4971 return false;
4972 }
4973 }
4974 return true;
4975 }
4976 return a2 !== a2 && b2 !== b2;
4977 }
4978 function getDPR(element) {
4979 if (typeof window === "undefined") {
4980 return 1;
4981 }
4982 const win = element.ownerDocument.defaultView || window;
4983 return win.devicePixelRatio || 1;
4984 }
4985 function roundByDPR(element, value) {
4986 const dpr = getDPR(element);
4987 return Math.round(value * dpr) / dpr;
4988 }
4989 function useLatestRef(value) {
4990 const ref = React19.useRef(value);
4991 index(() => {
4992 ref.current = value;
4993 });
4994 return ref;
4995 }
4996 function useFloating(options) {
4997 if (options === void 0) {
4998 options = {};
4999 }
5000 const {
5001 placement = "bottom",
5002 strategy = "absolute",
5003 middleware = [],
5004 platform: platform3,
5005 elements: {
5006 reference: externalReference,
5007 floating: externalFloating
5008 } = {},
5009 transform = true,
5010 whileElementsMounted,
5011 open
5012 } = options;
5013 const [data, setData] = React19.useState({
5014 x: 0,
5015 y: 0,
5016 strategy,
5017 placement,
5018 middlewareData: {},
5019 isPositioned: false
5020 });
5021 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
5022 if (!deepEqual(latestMiddleware, middleware)) {
5023 setLatestMiddleware(middleware);
5024 }
5025 const [_reference, _setReference] = React19.useState(null);
5026 const [_floating, _setFloating] = React19.useState(null);
5027 const setReference = React19.useCallback((node) => {
5028 if (node !== referenceRef.current) {
5029 referenceRef.current = node;
5030 _setReference(node);
5031 }
5032 }, []);
5033 const setFloating = React19.useCallback((node) => {
5034 if (node !== floatingRef.current) {
5035 floatingRef.current = node;
5036 _setFloating(node);
5037 }
5038 }, []);
5039 const referenceEl = externalReference || _reference;
5040 const floatingEl = externalFloating || _floating;
5041 const referenceRef = React19.useRef(null);
5042 const floatingRef = React19.useRef(null);
5043 const dataRef = React19.useRef(data);
5044 const hasWhileElementsMounted = whileElementsMounted != null;
5045 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5046 const platformRef = useLatestRef(platform3);
5047 const openRef = useLatestRef(open);
5048 const update2 = React19.useCallback(() => {
5049 if (!referenceRef.current || !floatingRef.current) {
5050 return;
5051 }
5052 const config = {
5053 placement,
5054 strategy,
5055 middleware: latestMiddleware
5056 };
5057 if (platformRef.current) {
5058 config.platform = platformRef.current;
5059 }
5060 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5061 const fullData = {
5062 ...data2,
5063 // The floating element's position may be recomputed while it's closed
5064 // but still mounted (such as when transitioning out). To ensure
5065 // `isPositioned` will be `false` initially on the next open, avoid
5066 // setting it to `true` when `open === false` (must be specified).
5067 isPositioned: openRef.current !== false
5068 };
5069 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5070 dataRef.current = fullData;
5071 ReactDOM3.flushSync(() => {
5072 setData(fullData);
5073 });
5074 }
5075 });
5076 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5077 index(() => {
5078 if (open === false && dataRef.current.isPositioned) {
5079 dataRef.current.isPositioned = false;
5080 setData((data2) => ({
5081 ...data2,
5082 isPositioned: false
5083 }));
5084 }
5085 }, [open]);
5086 const isMountedRef = React19.useRef(false);
5087 index(() => {
5088 isMountedRef.current = true;
5089 return () => {
5090 isMountedRef.current = false;
5091 };
5092 }, []);
5093 index(() => {
5094 if (referenceEl) referenceRef.current = referenceEl;
5095 if (floatingEl) floatingRef.current = floatingEl;
5096 if (referenceEl && floatingEl) {
5097 if (whileElementsMountedRef.current) {
5098 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5099 }
5100 update2();
5101 }
5102 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5103 const refs = React19.useMemo(() => ({
5104 reference: referenceRef,
5105 floating: floatingRef,
5106 setReference,
5107 setFloating
5108 }), [setReference, setFloating]);
5109 const elements = React19.useMemo(() => ({
5110 reference: referenceEl,
5111 floating: floatingEl
5112 }), [referenceEl, floatingEl]);
5113 const floatingStyles = React19.useMemo(() => {
5114 const initialStyles = {
5115 position: strategy,
5116 left: 0,
5117 top: 0
5118 };
5119 if (!elements.floating) {
5120 return initialStyles;
5121 }
5122 const x2 = roundByDPR(elements.floating, data.x);
5123 const y2 = roundByDPR(elements.floating, data.y);
5124 if (transform) {
5125 return {
5126 ...initialStyles,
5127 transform: "translate(" + x2 + "px, " + y2 + "px)",
5128 ...getDPR(elements.floating) >= 1.5 && {
5129 willChange: "transform"
5130 }
5131 };
5132 }
5133 return {
5134 position: strategy,
5135 left: x2,
5136 top: y2
5137 };
5138 }, [strategy, transform, elements.floating, data.x, data.y]);
5139 return React19.useMemo(() => ({
5140 ...data,
5141 update: update2,
5142 refs,
5143 elements,
5144 floatingStyles
5145 }), [data, update2, refs, elements, floatingStyles]);
5146 }
5147 var offset3 = (options, deps) => {
5148 const result = offset2(options);
5149 return {
5150 name: result.name,
5151 fn: result.fn,
5152 options: [options, deps]
5153 };
5154 };
5155 var shift3 = (options, deps) => {
5156 const result = shift2(options);
5157 return {
5158 name: result.name,
5159 fn: result.fn,
5160 options: [options, deps]
5161 };
5162 };
5163 var limitShift3 = (options, deps) => {
5164 const result = limitShift2(options);
5165 return {
5166 fn: result.fn,
5167 options: [options, deps]
5168 };
5169 };
5170 var flip3 = (options, deps) => {
5171 const result = flip2(options);
5172 return {
5173 name: result.name,
5174 fn: result.fn,
5175 options: [options, deps]
5176 };
5177 };
5178 var size3 = (options, deps) => {
5179 const result = size2(options);
5180 return {
5181 name: result.name,
5182 fn: result.fn,
5183 options: [options, deps]
5184 };
5185 };
5186 var hide3 = (options, deps) => {
5187 const result = hide2(options);
5188 return {
5189 name: result.name,
5190 fn: result.fn,
5191 options: [options, deps]
5192 };
5193 };
5194
5195 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5196 var React24 = __toESM(require_react(), 1);
5197
5198 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5199 var React23 = __toESM(require_react(), 1);
5200
5201 // node_modules/@base-ui/utils/esm/store/createSelector.js
5202 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5203 if (other.length > 0) {
5204 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5205 }
5206 let selector2;
5207 if (a2 && b2 && c2 && d2 && e2 && f2) {
5208 selector2 = (state, a1, a22, a3) => {
5209 const va = a2(state, a1, a22, a3);
5210 const vb = b2(state, a1, a22, a3);
5211 const vc = c2(state, a1, a22, a3);
5212 const vd = d2(state, a1, a22, a3);
5213 const ve = e2(state, a1, a22, a3);
5214 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5215 };
5216 } else if (a2 && b2 && c2 && d2 && e2) {
5217 selector2 = (state, a1, a22, a3) => {
5218 const va = a2(state, a1, a22, a3);
5219 const vb = b2(state, a1, a22, a3);
5220 const vc = c2(state, a1, a22, a3);
5221 const vd = d2(state, a1, a22, a3);
5222 return e2(va, vb, vc, vd, a1, a22, a3);
5223 };
5224 } else if (a2 && b2 && c2 && d2) {
5225 selector2 = (state, a1, a22, a3) => {
5226 const va = a2(state, a1, a22, a3);
5227 const vb = b2(state, a1, a22, a3);
5228 const vc = c2(state, a1, a22, a3);
5229 return d2(va, vb, vc, a1, a22, a3);
5230 };
5231 } else if (a2 && b2 && c2) {
5232 selector2 = (state, a1, a22, a3) => {
5233 const va = a2(state, a1, a22, a3);
5234 const vb = b2(state, a1, a22, a3);
5235 return c2(va, vb, a1, a22, a3);
5236 };
5237 } else if (a2 && b2) {
5238 selector2 = (state, a1, a22, a3) => {
5239 const va = a2(state, a1, a22, a3);
5240 return b2(va, a1, a22, a3);
5241 };
5242 } else if (a2) {
5243 selector2 = a2;
5244 } else {
5245 throw (
5246 /* minify-error-disabled */
5247 new Error("Missing arguments")
5248 );
5249 }
5250 return selector2;
5251 };
5252
5253 // node_modules/@base-ui/utils/esm/store/useStore.js
5254 var React21 = __toESM(require_react(), 1);
5255 var import_shim = __toESM(require_shim(), 1);
5256 var import_with_selector = __toESM(require_with_selector(), 1);
5257
5258 // node_modules/@base-ui/utils/esm/fastHooks.js
5259 var React20 = __toESM(require_react(), 1);
5260 var hooks = [];
5261 var currentInstance = void 0;
5262 function getInstance() {
5263 return currentInstance;
5264 }
5265 function register(hook) {
5266 hooks.push(hook);
5267 }
5268 function fastComponent(fn) {
5269 const FastComponent = (props, forwardedRef) => {
5270 const instance = useRefWithInit(createInstance).current;
5271 let result;
5272 try {
5273 currentInstance = instance;
5274 for (const hook of hooks) {
5275 hook.before(instance);
5276 }
5277 result = fn(props, forwardedRef);
5278 for (const hook of hooks) {
5279 hook.after(instance);
5280 }
5281 instance.didInitialize = true;
5282 } finally {
5283 currentInstance = void 0;
5284 }
5285 return result;
5286 };
5287 FastComponent.displayName = fn.displayName || fn.name;
5288 return FastComponent;
5289 }
5290 function fastComponentRef(fn) {
5291 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5292 }
5293 function createInstance() {
5294 return {
5295 didInitialize: false
5296 };
5297 }
5298
5299 // node_modules/@base-ui/utils/esm/store/useStore.js
5300 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5301 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5302 function useStore(store, selector2, a1, a2, a3) {
5303 return useStoreImplementation(store, selector2, a1, a2, a3);
5304 }
5305 function useStoreR19(store, selector2, a1, a2, a3) {
5306 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5307 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5308 }
5309 register({
5310 before(instance) {
5311 instance.syncIndex = 0;
5312 if (!instance.didInitialize) {
5313 instance.syncTick = 1;
5314 instance.syncHooks = [];
5315 instance.didChangeStore = true;
5316 instance.getSnapshot = () => {
5317 let didChange2 = false;
5318 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5319 const hook = instance.syncHooks[i2];
5320 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5321 if (hook.didChange || !Object.is(hook.value, value)) {
5322 didChange2 = true;
5323 hook.value = value;
5324 hook.didChange = false;
5325 }
5326 }
5327 if (didChange2) {
5328 instance.syncTick += 1;
5329 }
5330 return instance.syncTick;
5331 };
5332 }
5333 },
5334 after(instance) {
5335 if (instance.syncHooks.length > 0) {
5336 if (instance.didChangeStore) {
5337 instance.didChangeStore = false;
5338 instance.subscribe = (onStoreChange) => {
5339 const stores = /* @__PURE__ */ new Set();
5340 for (const hook of instance.syncHooks) {
5341 stores.add(hook.store);
5342 }
5343 const unsubscribes = [];
5344 for (const store of stores) {
5345 unsubscribes.push(store.subscribe(onStoreChange));
5346 }
5347 return () => {
5348 for (const unsubscribe of unsubscribes) {
5349 unsubscribe();
5350 }
5351 };
5352 };
5353 }
5354 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5355 }
5356 }
5357 });
5358 function useStoreFast(store, selector2, a1, a2, a3) {
5359 const instance = getInstance();
5360 if (!instance) {
5361 return useStoreR19(store, selector2, a1, a2, a3);
5362 }
5363 const index2 = instance.syncIndex;
5364 instance.syncIndex += 1;
5365 let hook;
5366 if (!instance.didInitialize) {
5367 hook = {
5368 store,
5369 selector: selector2,
5370 a1,
5371 a2,
5372 a3,
5373 value: selector2(store.getSnapshot(), a1, a2, a3),
5374 didChange: false
5375 };
5376 instance.syncHooks.push(hook);
5377 } else {
5378 hook = instance.syncHooks[index2];
5379 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5380 if (hook.store !== store) {
5381 instance.didChangeStore = true;
5382 }
5383 hook.store = store;
5384 hook.selector = selector2;
5385 hook.a1 = a1;
5386 hook.a2 = a2;
5387 hook.a3 = a3;
5388 hook.didChange = true;
5389 }
5390 }
5391 return hook.value;
5392 }
5393 function useStoreLegacy(store, selector2, a1, a2, a3) {
5394 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5395 }
5396
5397 // node_modules/@base-ui/utils/esm/store/Store.js
5398 var Store = class {
5399 /**
5400 * The current state of the store.
5401 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5402 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
5403 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5404 *
5405 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5406 */
5407 // Internal state to handle recursive `setState()` calls
5408 constructor(state) {
5409 this.state = state;
5410 this.listeners = /* @__PURE__ */ new Set();
5411 this.updateTick = 0;
5412 }
5413 /**
5414 * Registers a listener that will be called whenever the store's state changes.
5415 *
5416 * @param fn The listener function to be called on state changes.
5417 * @returns A function to unsubscribe the listener.
5418 */
5419 subscribe = (fn) => {
5420 this.listeners.add(fn);
5421 return () => {
5422 this.listeners.delete(fn);
5423 };
5424 };
5425 /**
5426 * Returns the current state of the store.
5427 */
5428 getSnapshot = () => {
5429 return this.state;
5430 };
5431 /**
5432 * Updates the entire store's state and notifies all registered listeners.
5433 *
5434 * @param newState The new state to set for the store.
5435 */
5436 setState(newState) {
5437 if (this.state === newState) {
5438 return;
5439 }
5440 this.state = newState;
5441 this.updateTick += 1;
5442 const currentTick = this.updateTick;
5443 for (const listener of this.listeners) {
5444 if (currentTick !== this.updateTick) {
5445 return;
5446 }
5447 listener(newState);
5448 }
5449 }
5450 /**
5451 * Merges the provided changes into the current state and notifies listeners if there are changes.
5452 *
5453 * @param changes An object containing the changes to apply to the current state.
5454 */
5455 update(changes) {
5456 for (const key in changes) {
5457 if (!Object.is(this.state[key], changes[key])) {
5458 this.setState({
5459 ...this.state,
5460 ...changes
5461 });
5462 return;
5463 }
5464 }
5465 }
5466 /**
5467 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5468 *
5469 * @param key The key in the store's state to update.
5470 * @param value The new value to set for the specified key.
5471 */
5472 set(key, value) {
5473 if (!Object.is(this.state[key], value)) {
5474 this.setState({
5475 ...this.state,
5476 [key]: value
5477 });
5478 }
5479 }
5480 /**
5481 * Gives the state a new reference and updates all registered listeners.
5482 */
5483 notifyAll() {
5484 const newState = {
5485 ...this.state
5486 };
5487 this.setState(newState);
5488 }
5489 use(selector2, a1, a2, a3) {
5490 return useStore(this, selector2, a1, a2, a3);
5491 }
5492 };
5493
5494 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5495 var React22 = __toESM(require_react(), 1);
5496 var ReactStore = class extends Store {
5497 /**
5498 * Creates a new ReactStore instance.
5499 *
5500 * @param state Initial state of the store.
5501 * @param context Non-reactive context values.
5502 * @param selectors Optional selectors for use with `useState`.
5503 */
5504 constructor(state, context = {}, selectors3) {
5505 super(state);
5506 this.context = context;
5507 this.selectors = selectors3;
5508 }
5509 /**
5510 * Non-reactive values such as refs, callbacks, etc.
5511 */
5512 /**
5513 * Synchronizes a single external value into the store.
5514 *
5515 * Note that the while the value in `state` is updated immediately, the value returned
5516 * by `useState` is updated before the next render (similarly to React's `useState`).
5517 */
5518 useSyncedValue(key, value) {
5519 React22.useDebugValue(key);
5520 const store = this;
5521 useIsoLayoutEffect(() => {
5522 if (store.state[key] !== value) {
5523 store.set(key, value);
5524 }
5525 }, [store, key, value]);
5526 }
5527 /**
5528 * Synchronizes a single external value into the store and
5529 * cleans it up (sets to `undefined`) on unmount.
5530 *
5531 * Note that the while the value in `state` is updated immediately, the value returned
5532 * by `useState` is updated before the next render (similarly to React's `useState`).
5533 */
5534 useSyncedValueWithCleanup(key, value) {
5535 const store = this;
5536 useIsoLayoutEffect(() => {
5537 if (store.state[key] !== value) {
5538 store.set(key, value);
5539 }
5540 return () => {
5541 store.set(key, void 0);
5542 };
5543 }, [store, key, value]);
5544 }
5545 /**
5546 * Synchronizes multiple external values into the store.
5547 *
5548 * Note that the while the values in `state` are updated immediately, the values returned
5549 * by `useState` are updated before the next render (similarly to React's `useState`).
5550 */
5551 useSyncedValues(statePart) {
5552 const store = this;
5553 if (true) {
5554 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
5555 const keys = React22.useRef(Object.keys(statePart)).current;
5556 const nextKeys = Object.keys(statePart);
5557 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5558 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5559 }
5560 }
5561 const dependencies = Object.values(statePart);
5562 useIsoLayoutEffect(() => {
5563 store.update(statePart);
5564 }, [store, ...dependencies]);
5565 }
5566 /**
5567 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5568 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5569 */
5570 useControlledProp(key, controlled) {
5571 React22.useDebugValue(key);
5572 const store = this;
5573 const isControlled = controlled !== void 0;
5574 useIsoLayoutEffect(() => {
5575 if (isControlled && !Object.is(store.state[key], controlled)) {
5576 store.setState({
5577 ...store.state,
5578 [key]: controlled
5579 });
5580 }
5581 }, [store, key, controlled, isControlled]);
5582 if (true) {
5583 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5584 if (!cache.has(key)) {
5585 cache.set(key, isControlled);
5586 }
5587 const previouslyControlled = cache.get(key);
5588 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5589 console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
5590 }
5591 }
5592 }
5593 /** Gets the current value from the store using a selector with the provided key.
5594 *
5595 * @param key Key of the selector to use.
5596 */
5597 select(key, a1, a2, a3) {
5598 const selector2 = this.selectors[key];
5599 return selector2(this.state, a1, a2, a3);
5600 }
5601 /**
5602 * Returns a value from the store's state using a selector function.
5603 * Used to subscribe to specific parts of the state.
5604 * This methods causes a rerender whenever the selected state changes.
5605 *
5606 * @param key Key of the selector to use.
5607 */
5608 useState(key, a1, a2, a3) {
5609 React22.useDebugValue(key);
5610 return useStore(this, this.selectors[key], a1, a2, a3);
5611 }
5612 /**
5613 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5614 * and assigns it to the context.
5615 *
5616 * @param key Key of the event callback. Must be a function in the context.
5617 * @param fn Function to assign.
5618 */
5619 useContextCallback(key, fn) {
5620 React22.useDebugValue(key);
5621 const stableFunction = useStableCallback(fn ?? NOOP);
5622 this.context[key] = stableFunction;
5623 }
5624 /**
5625 * Returns a stable setter function for a specific key in the store's state.
5626 * It's commonly used to pass as a ref callback to React elements.
5627 *
5628 * @param key Key of the state to set.
5629 */
5630 useStateSetter(key) {
5631 const ref = React22.useRef(void 0);
5632 if (ref.current === void 0) {
5633 ref.current = (value) => {
5634 this.set(key, value);
5635 };
5636 }
5637 return ref.current;
5638 }
5639 /**
5640 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5641 *
5642 * @param key Key of the selector to observe.
5643 * @param listener Listener function called when the selector result changes.
5644 */
5645 observe(selector2, listener) {
5646 let selectFn;
5647 if (typeof selector2 === "function") {
5648 selectFn = selector2;
5649 } else {
5650 selectFn = this.selectors[selector2];
5651 }
5652 let prevValue = selectFn(this.state);
5653 listener(prevValue, prevValue, this);
5654 return this.subscribe((nextState) => {
5655 const nextValue = selectFn(nextState);
5656 if (!Object.is(prevValue, nextValue)) {
5657 const oldValue = prevValue;
5658 prevValue = nextValue;
5659 listener(nextValue, oldValue, this);
5660 }
5661 });
5662 }
5663 };
5664
5665 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5666 var selectors = {
5667 open: createSelector((state) => state.open),
5668 transitionStatus: createSelector((state) => state.transitionStatus),
5669 domReferenceElement: createSelector((state) => state.domReferenceElement),
5670 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5671 floatingElement: createSelector((state) => state.floatingElement),
5672 floatingId: createSelector((state) => state.floatingId)
5673 };
5674 var FloatingRootStore = class extends ReactStore {
5675 constructor(options) {
5676 const {
5677 syncOnly,
5678 nested,
5679 onOpenChange,
5680 triggerElements,
5681 ...initialState
5682 } = options;
5683 super({
5684 ...initialState,
5685 positionReference: initialState.referenceElement,
5686 domReferenceElement: initialState.referenceElement
5687 }, {
5688 onOpenChange,
5689 dataRef: {
5690 current: {}
5691 },
5692 events: createEventEmitter(),
5693 nested,
5694 triggerElements
5695 }, selectors);
5696 this.syncOnly = syncOnly;
5697 }
5698 /**
5699 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5700 */
5701 syncOpenEvent = (newOpen, event) => {
5702 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5703 // click events to upgrade a hover-open.
5704 event != null && isClickLikeEvent(event)) {
5705 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5706 }
5707 };
5708 /**
5709 * Runs the root-owned side effects for an open state change.
5710 */
5711 dispatchOpenChange = (newOpen, eventDetails) => {
5712 this.syncOpenEvent(newOpen, eventDetails.event);
5713 const details = {
5714 open: newOpen,
5715 reason: eventDetails.reason,
5716 nativeEvent: eventDetails.event,
5717 nested: this.context.nested,
5718 triggerElement: eventDetails.trigger
5719 };
5720 this.context.events.emit("openchange", details);
5721 };
5722 /**
5723 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5724 *
5725 * @param newOpen The new open state.
5726 * @param eventDetails Details about the event that triggered the open state change.
5727 */
5728 setOpen = (newOpen, eventDetails) => {
5729 if (this.syncOnly) {
5730 this.context.onOpenChange?.(newOpen, eventDetails);
5731 return;
5732 }
5733 this.dispatchOpenChange(newOpen, eventDetails);
5734 this.context.onOpenChange?.(newOpen, eventDetails);
5735 };
5736 };
5737
5738 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5739 function useSyncedFloatingRootContext(options) {
5740 const {
5741 popupStore,
5742 treatPopupAsFloatingElement = false,
5743 floatingRootContext: floatingRootContextProp,
5744 floatingId,
5745 nested,
5746 onOpenChange
5747 } = options;
5748 const open = popupStore.useState("open");
5749 const referenceElement = popupStore.useState("activeTriggerElement");
5750 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5751 const triggerElements = popupStore.context.triggerElements;
5752 const handleOpenChange = onOpenChange;
5753 const internalStoreRef = React23.useRef(null);
5754 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5755 internalStoreRef.current = new FloatingRootStore({
5756 open,
5757 transitionStatus: void 0,
5758 referenceElement,
5759 floatingElement,
5760 triggerElements,
5761 onOpenChange: handleOpenChange,
5762 floatingId,
5763 syncOnly: true,
5764 nested
5765 });
5766 }
5767 const store = floatingRootContextProp ?? internalStoreRef.current;
5768 popupStore.useSyncedValue("floatingId", floatingId);
5769 useIsoLayoutEffect(() => {
5770 const valuesToSync = {
5771 open,
5772 floatingId,
5773 referenceElement,
5774 floatingElement
5775 };
5776 if (isElement(referenceElement)) {
5777 valuesToSync.domReferenceElement = referenceElement;
5778 }
5779 if (store.state.positionReference === store.state.referenceElement) {
5780 valuesToSync.positionReference = referenceElement;
5781 }
5782 store.update(valuesToSync);
5783 }, [open, floatingId, referenceElement, floatingElement, store]);
5784 store.context.onOpenChange = handleOpenChange;
5785 store.context.nested = nested;
5786 return store;
5787 }
5788
5789 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5790 var FOCUSABLE_POPUP_PROPS = {
5791 tabIndex: -1,
5792 [FOCUSABLE_ATTRIBUTE]: ""
5793 };
5794 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5795 const floatingId = useId();
5796 const nested = useFloatingParentNodeId() != null;
5797 const internalStoreRef = React24.useRef(null);
5798 if (externalStore === void 0 && internalStoreRef.current === null) {
5799 internalStoreRef.current = createStore2(floatingId, nested);
5800 }
5801 const store = externalStore ?? internalStoreRef.current;
5802 useSyncedFloatingRootContext({
5803 popupStore: store,
5804 treatPopupAsFloatingElement,
5805 floatingRootContext: store.state.floatingRootContext,
5806 floatingId,
5807 nested,
5808 onOpenChange: store.setOpen
5809 });
5810 return {
5811 store,
5812 internalStore: internalStoreRef.current
5813 };
5814 }
5815 function useTriggerRegistration(id, store) {
5816 const registeredElementIdRef = React24.useRef(null);
5817 const registeredElementRef = React24.useRef(null);
5818 return React24.useCallback((element) => {
5819 if (id === void 0) {
5820 return;
5821 }
5822 let shouldSyncTriggerCount = false;
5823 if (registeredElementIdRef.current !== null) {
5824 const registeredId = registeredElementIdRef.current;
5825 const registeredElement = registeredElementRef.current;
5826 const currentElement = store.context.triggerElements.getById(registeredId);
5827 if (registeredElement && currentElement === registeredElement) {
5828 store.context.triggerElements.delete(registeredId);
5829 shouldSyncTriggerCount = true;
5830 }
5831 registeredElementIdRef.current = null;
5832 registeredElementRef.current = null;
5833 }
5834 if (element !== null) {
5835 registeredElementIdRef.current = id;
5836 registeredElementRef.current = element;
5837 store.context.triggerElements.add(id, element);
5838 shouldSyncTriggerCount = true;
5839 }
5840 if (shouldSyncTriggerCount) {
5841 const triggerCount = store.context.triggerElements.size;
5842 if (store.select("open") && store.state.triggerCount !== triggerCount) {
5843 store.set("triggerCount", triggerCount);
5844 }
5845 }
5846 }, [store, id]);
5847 }
5848 function setOpenTriggerState(state, open, trigger) {
5849 const triggerId = trigger?.id ?? null;
5850 if (triggerId || open) {
5851 state.activeTriggerId = triggerId;
5852 state.activeTriggerElement = trigger ?? null;
5853 }
5854 }
5855 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5856 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5857 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5858 const registerTrigger = useStableCallback((element) => {
5859 baseRegisterTrigger(element);
5860 if (!element) {
5861 return;
5862 }
5863 const open = store.select("open");
5864 const activeTriggerId = store.select("activeTriggerId");
5865 if (activeTriggerId === triggerId) {
5866 store.update({
5867 activeTriggerElement: element,
5868 ...open ? stateUpdates : null
5869 });
5870 return;
5871 }
5872 if (activeTriggerId == null && open) {
5873 store.update({
5874 activeTriggerId: triggerId,
5875 activeTriggerElement: element,
5876 ...stateUpdates
5877 });
5878 }
5879 });
5880 useIsoLayoutEffect(() => {
5881 if (isMountedByThisTrigger) {
5882 store.update({
5883 activeTriggerElement: triggerElementRef.current,
5884 ...stateUpdates
5885 });
5886 }
5887 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5888 return {
5889 registerTrigger,
5890 isMountedByThisTrigger
5891 };
5892 }
5893 function useImplicitActiveTrigger(store) {
5894 const open = store.useState("open");
5895 const reactiveTriggerCount = store.useState("triggerCount");
5896 useIsoLayoutEffect(() => {
5897 if (!open) {
5898 if (store.state.triggerCount !== 0) {
5899 store.set("triggerCount", 0);
5900 }
5901 return;
5902 }
5903 const triggerCount = store.context.triggerElements.size;
5904 const stateUpdates = {};
5905 if (store.state.triggerCount !== triggerCount) {
5906 stateUpdates.triggerCount = triggerCount;
5907 }
5908 if (!store.select("activeTriggerId") && triggerCount === 1) {
5909 const iteratorResult = store.context.triggerElements.entries().next();
5910 if (!iteratorResult.done) {
5911 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5912 stateUpdates.activeTriggerId = implicitTriggerId;
5913 stateUpdates.activeTriggerElement = implicitTriggerElement;
5914 }
5915 }
5916 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5917 store.update(stateUpdates);
5918 }
5919 }, [open, store, reactiveTriggerCount]);
5920 }
5921 function useOpenStateTransitions(open, store, onUnmount) {
5922 const {
5923 mounted,
5924 setMounted,
5925 transitionStatus
5926 } = useTransitionStatus(open);
5927 store.useSyncedValues({
5928 mounted,
5929 transitionStatus
5930 });
5931 const forceUnmount = useStableCallback(() => {
5932 setMounted(false);
5933 store.update({
5934 activeTriggerId: null,
5935 activeTriggerElement: null,
5936 mounted: false,
5937 preventUnmountingOnClose: false
5938 });
5939 onUnmount?.();
5940 store.context.onOpenChangeComplete?.(false);
5941 });
5942 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5943 useOpenChangeComplete({
5944 enabled: mounted && !open && !preventUnmountingOnClose,
5945 open,
5946 ref: store.context.popupRef,
5947 onComplete() {
5948 if (!open) {
5949 forceUnmount();
5950 }
5951 }
5952 });
5953 return {
5954 forceUnmount,
5955 transitionStatus
5956 };
5957 }
5958 function usePopupInteractionProps(store, statePart) {
5959 store.useSyncedValues(statePart);
5960 useIsoLayoutEffect(() => () => {
5961 store.update({
5962 activeTriggerProps: EMPTY_OBJECT,
5963 inactiveTriggerProps: EMPTY_OBJECT,
5964 popupProps: EMPTY_OBJECT
5965 });
5966 }, [store]);
5967 }
5968
5969 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5970 var PopupTriggerMap = class {
5971 constructor() {
5972 this.elementsSet = /* @__PURE__ */ new Set();
5973 this.idMap = /* @__PURE__ */ new Map();
5974 }
5975 /**
5976 * Adds a trigger element with the given ID.
5977 *
5978 * Note: The provided element is assumed to not be registered under multiple IDs.
5979 */
5980 add(id, element) {
5981 const existingElement = this.idMap.get(id);
5982 if (existingElement === element) {
5983 return;
5984 }
5985 if (existingElement !== void 0) {
5986 this.elementsSet.delete(existingElement);
5987 }
5988 this.elementsSet.add(element);
5989 this.idMap.set(id, element);
5990 if (true) {
5991 if (this.elementsSet.size !== this.idMap.size) {
5992 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5993 }
5994 }
5995 }
5996 /**
5997 * Removes the trigger element with the given ID.
5998 */
5999 delete(id) {
6000 const element = this.idMap.get(id);
6001 if (element) {
6002 this.elementsSet.delete(element);
6003 this.idMap.delete(id);
6004 }
6005 }
6006 /**
6007 * Whether the given element is registered as a trigger.
6008 */
6009 hasElement(element) {
6010 return this.elementsSet.has(element);
6011 }
6012 /**
6013 * Whether there is a registered trigger element matching the given predicate.
6014 */
6015 hasMatchingElement(predicate) {
6016 for (const element of this.elementsSet) {
6017 if (predicate(element)) {
6018 return true;
6019 }
6020 }
6021 return false;
6022 }
6023 /**
6024 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6025 */
6026 getById(id) {
6027 return this.idMap.get(id);
6028 }
6029 /**
6030 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6031 */
6032 entries() {
6033 return this.idMap.entries();
6034 }
6035 /**
6036 * Returns an iterable of all registered trigger elements.
6037 */
6038 elements() {
6039 return this.elementsSet.values();
6040 }
6041 /**
6042 * Returns the number of registered trigger elements.
6043 */
6044 get size() {
6045 return this.idMap.size;
6046 }
6047 };
6048
6049 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6050 function getEmptyRootContext() {
6051 return new FloatingRootStore({
6052 open: false,
6053 transitionStatus: void 0,
6054 floatingElement: null,
6055 referenceElement: null,
6056 triggerElements: new PopupTriggerMap(),
6057 floatingId: void 0,
6058 syncOnly: false,
6059 nested: false,
6060 onOpenChange: void 0
6061 });
6062 }
6063
6064 // node_modules/@base-ui/react/esm/utils/popups/store.js
6065 function createInitialPopupStoreState() {
6066 return {
6067 open: false,
6068 openProp: void 0,
6069 mounted: false,
6070 transitionStatus: void 0,
6071 floatingRootContext: getEmptyRootContext(),
6072 floatingId: void 0,
6073 triggerCount: 0,
6074 preventUnmountingOnClose: false,
6075 payload: void 0,
6076 activeTriggerId: null,
6077 activeTriggerElement: null,
6078 triggerIdProp: void 0,
6079 popupElement: null,
6080 positionerElement: null,
6081 activeTriggerProps: EMPTY_OBJECT,
6082 inactiveTriggerProps: EMPTY_OBJECT,
6083 popupProps: EMPTY_OBJECT
6084 };
6085 }
6086 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6087 return new FloatingRootStore({
6088 open: false,
6089 transitionStatus: void 0,
6090 floatingElement: null,
6091 referenceElement: null,
6092 triggerElements,
6093 floatingId,
6094 syncOnly: true,
6095 nested,
6096 onOpenChange: void 0
6097 });
6098 }
6099 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6100 var openSelector = createSelector((state) => state.openProp ?? state.open);
6101 var popupIdSelector = createSelector((state) => {
6102 const popupId = state.popupElement?.id ?? state.floatingId;
6103 return popupId || void 0;
6104 });
6105 function triggerOwnsOpenPopup(state, triggerId) {
6106 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6107 }
6108 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6109 if (triggerOwnsOpenPopup(state, triggerId)) {
6110 return true;
6111 }
6112 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6113 }
6114 var popupStoreSelectors = {
6115 open: openSelector,
6116 mounted: createSelector((state) => state.mounted),
6117 transitionStatus: createSelector((state) => state.transitionStatus),
6118 floatingRootContext: createSelector((state) => state.floatingRootContext),
6119 triggerCount: createSelector((state) => state.triggerCount),
6120 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6121 payload: createSelector((state) => state.payload),
6122 activeTriggerId: activeTriggerIdSelector,
6123 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6124 popupId: popupIdSelector,
6125 /**
6126 * Whether the trigger with the given ID was used to open the popup.
6127 */
6128 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6129 /**
6130 * Whether the popup is open and was activated by a trigger with the given ID.
6131 */
6132 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6133 /**
6134 * Whether the popup is mounted and was activated by a trigger with the given ID.
6135 */
6136 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6137 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6138 /**
6139 * Popup id for the trigger that currently owns the open popup.
6140 */
6141 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6142 popupProps: createSelector((state) => state.popupProps),
6143 popupElement: createSelector((state) => state.popupElement),
6144 positionerElement: createSelector((state) => state.positionerElement)
6145 };
6146
6147 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6148 function useFloatingRootContext(options) {
6149 const {
6150 open = false,
6151 onOpenChange,
6152 elements = {}
6153 } = options;
6154 const floatingId = useId();
6155 const nested = useFloatingParentNodeId() != null;
6156 if (true) {
6157 const optionDomReference = elements.reference;
6158 if (optionDomReference && !isElement(optionDomReference)) {
6159 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6160 }
6161 }
6162 const store = useRefWithInit(() => new FloatingRootStore({
6163 open,
6164 transitionStatus: void 0,
6165 onOpenChange,
6166 referenceElement: elements.reference ?? null,
6167 floatingElement: elements.floating ?? null,
6168 triggerElements: new PopupTriggerMap(),
6169 floatingId,
6170 syncOnly: false,
6171 nested
6172 })).current;
6173 useIsoLayoutEffect(() => {
6174 const valuesToSync = {
6175 open,
6176 floatingId
6177 };
6178 if (elements.reference !== void 0) {
6179 valuesToSync.referenceElement = elements.reference;
6180 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6181 }
6182 if (elements.floating !== void 0) {
6183 valuesToSync.floatingElement = elements.floating;
6184 }
6185 store.update(valuesToSync);
6186 }, [open, floatingId, elements.reference, elements.floating, store]);
6187 store.context.onOpenChange = onOpenChange;
6188 store.context.nested = nested;
6189 return store;
6190 }
6191
6192 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6193 function useFloating2(options = {}) {
6194 const {
6195 nodeId,
6196 externalTree
6197 } = options;
6198 const internalStore = useFloatingRootContext(options);
6199 const store = options.rootContext || internalStore;
6200 const referenceElement = store.useState("referenceElement");
6201 const floatingElement = store.useState("floatingElement");
6202 const domReferenceElement = store.useState("domReferenceElement");
6203 const open = store.useState("open");
6204 const floatingId = store.useState("floatingId");
6205 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6206 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6207 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6208 const domReferenceRef = React25.useRef(null);
6209 const tree = useFloatingTree(externalTree);
6210 const storeElements = React25.useMemo(() => ({
6211 reference: referenceElement,
6212 floating: floatingElement,
6213 domReference: domReferenceElement
6214 }), [referenceElement, floatingElement, domReferenceElement]);
6215 const position = useFloating({
6216 ...options,
6217 elements: {
6218 ...storeElements,
6219 ...positionReference && {
6220 reference: positionReference
6221 }
6222 }
6223 });
6224 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6225 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6226 store.useSyncedValue("referenceElement", localDomReference ?? null);
6227 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6228 store.useSyncedValue("floatingElement", syncedFloatingElement);
6229 const setPositionReference = React25.useCallback((node) => {
6230 const computedPositionReference = isElement(node) ? {
6231 getBoundingClientRect: () => node.getBoundingClientRect(),
6232 getClientRects: () => node.getClientRects(),
6233 contextElement: node
6234 } : node;
6235 setPositionReferenceRaw(computedPositionReference);
6236 position.refs.setReference(computedPositionReference);
6237 }, [position.refs]);
6238 const setReference = React25.useCallback((node) => {
6239 if (isElement(node) || node === null) {
6240 domReferenceRef.current = node;
6241 setLocalDomReference(node);
6242 }
6243 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6244 // `null` to support `positionReference` + an unstable `reference`
6245 // callback ref.
6246 node !== null && !isElement(node)) {
6247 position.refs.setReference(node);
6248 }
6249 }, [position.refs, setLocalDomReference]);
6250 const setFloating = React25.useCallback((node) => {
6251 setLocalFloatingElement(node);
6252 position.refs.setFloating(node);
6253 }, [position.refs]);
6254 const refs = React25.useMemo(() => ({
6255 ...position.refs,
6256 setReference,
6257 setFloating,
6258 setPositionReference,
6259 domReference: domReferenceRef
6260 }), [position.refs, setReference, setFloating, setPositionReference]);
6261 const elements = React25.useMemo(() => ({
6262 ...position.elements,
6263 domReference: domReferenceElement
6264 }), [position.elements, domReferenceElement]);
6265 const context = React25.useMemo(() => ({
6266 ...position,
6267 dataRef: store.context.dataRef,
6268 open,
6269 onOpenChange: store.setOpen,
6270 events: store.context.events,
6271 floatingId,
6272 refs,
6273 elements,
6274 nodeId,
6275 rootStore: store
6276 }), [position, refs, elements, nodeId, store, open, floatingId]);
6277 useIsoLayoutEffect(() => {
6278 if (domReferenceElement) {
6279 domReferenceRef.current = domReferenceElement;
6280 }
6281 }, [domReferenceElement]);
6282 useIsoLayoutEffect(() => {
6283 store.context.dataRef.current.floatingContext = context;
6284 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6285 if (node) {
6286 node.context = context;
6287 }
6288 });
6289 return React25.useMemo(() => ({
6290 ...position,
6291 context,
6292 refs,
6293 elements,
6294 rootStore: store
6295 }), [position, refs, elements, context, store]);
6296 }
6297
6298 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6299 var React26 = __toESM(require_react(), 1);
6300 var isMacSafari = isMac && isSafari;
6301 function useFocus(context, props = {}) {
6302 const {
6303 enabled = true,
6304 delay
6305 } = props;
6306 const store = "rootStore" in context ? context.rootStore : context;
6307 const {
6308 events,
6309 dataRef
6310 } = store.context;
6311 const blockFocusRef = React26.useRef(false);
6312 const blockedReferenceRef = React26.useRef(null);
6313 const keyboardModalityRef = React26.useRef(true);
6314 const timeout = useTimeout();
6315 React26.useEffect(() => {
6316 const domReference = store.select("domReferenceElement");
6317 if (!enabled) {
6318 return void 0;
6319 }
6320 const win = getWindow(domReference);
6321 function onBlur() {
6322 const currentDomReference = store.select("domReferenceElement");
6323 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6324 blockFocusRef.current = true;
6325 }
6326 }
6327 function onKeyDown() {
6328 keyboardModalityRef.current = true;
6329 }
6330 function onPointerDown() {
6331 keyboardModalityRef.current = false;
6332 }
6333 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6334 }, [store, enabled]);
6335 React26.useEffect(() => {
6336 if (!enabled) {
6337 return void 0;
6338 }
6339 function onOpenChangeLocal(details) {
6340 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6341 const referenceElement = store.select("domReferenceElement");
6342 if (isElement(referenceElement)) {
6343 blockedReferenceRef.current = referenceElement;
6344 blockFocusRef.current = true;
6345 }
6346 }
6347 }
6348 events.on("openchange", onOpenChangeLocal);
6349 return () => {
6350 events.off("openchange", onOpenChangeLocal);
6351 };
6352 }, [events, enabled, store]);
6353 const reference = React26.useMemo(() => {
6354 function resetBlockedFocus() {
6355 blockFocusRef.current = false;
6356 blockedReferenceRef.current = null;
6357 }
6358 return {
6359 onMouseLeave() {
6360 resetBlockedFocus();
6361 },
6362 onFocus(event) {
6363 const focusTarget = event.currentTarget;
6364 if (blockFocusRef.current) {
6365 if (blockedReferenceRef.current === focusTarget) {
6366 return;
6367 }
6368 resetBlockedFocus();
6369 }
6370 const target = getTarget(event.nativeEvent);
6371 if (isElement(target)) {
6372 if (isMacSafari && !event.relatedTarget) {
6373 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6374 return;
6375 }
6376 } else if (!matchesFocusVisible(target)) {
6377 return;
6378 }
6379 }
6380 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6381 const {
6382 nativeEvent,
6383 currentTarget
6384 } = event;
6385 const delayValue = typeof delay === "function" ? delay() : delay;
6386 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6387 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6388 return;
6389 }
6390 timeout.start(delayValue, () => {
6391 if (blockFocusRef.current) {
6392 return;
6393 }
6394 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6395 });
6396 },
6397 onBlur(event) {
6398 resetBlockedFocus();
6399 const relatedTarget = event.relatedTarget;
6400 const nativeEvent = event.nativeEvent;
6401 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6402 timeout.start(0, () => {
6403 const domReference = store.select("domReferenceElement");
6404 const activeEl = activeElement(ownerDocument(domReference));
6405 if (!relatedTarget && activeEl === domReference) {
6406 return;
6407 }
6408 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6409 return;
6410 }
6411 const nextFocusedElement = relatedTarget ?? activeEl;
6412 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6413 return;
6414 }
6415 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6416 });
6417 }
6418 };
6419 }, [dataRef, delay, store, timeout]);
6420 return React26.useMemo(() => enabled ? {
6421 reference,
6422 trigger: reference
6423 } : {}, [enabled, reference]);
6424 }
6425
6426 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6427 var React27 = __toESM(require_react(), 1);
6428
6429 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6430 var HoverInteraction = class _HoverInteraction {
6431 constructor() {
6432 this.pointerType = void 0;
6433 this.interactedInside = false;
6434 this.handler = void 0;
6435 this.blockMouseMove = true;
6436 this.performedPointerEventsMutation = false;
6437 this.pointerEventsScopeElement = null;
6438 this.pointerEventsReferenceElement = null;
6439 this.pointerEventsFloatingElement = null;
6440 this.restTimeoutPending = false;
6441 this.openChangeTimeout = new Timeout();
6442 this.restTimeout = new Timeout();
6443 this.handleCloseOptions = void 0;
6444 }
6445 static create() {
6446 return new _HoverInteraction();
6447 }
6448 dispose = () => {
6449 this.openChangeTimeout.clear();
6450 this.restTimeout.clear();
6451 };
6452 disposeEffect = () => {
6453 return this.dispose;
6454 };
6455 };
6456 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6457 function clearSafePolygonPointerEventsMutation(instance) {
6458 if (!instance.performedPointerEventsMutation) {
6459 return;
6460 }
6461 const scopeElement = instance.pointerEventsScopeElement;
6462 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6463 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6464 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6465 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6466 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6467 }
6468 instance.performedPointerEventsMutation = false;
6469 instance.pointerEventsScopeElement = null;
6470 instance.pointerEventsReferenceElement = null;
6471 instance.pointerEventsFloatingElement = null;
6472 }
6473 function applySafePolygonPointerEventsMutation(instance, options) {
6474 const {
6475 scopeElement,
6476 referenceElement,
6477 floatingElement
6478 } = options;
6479 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6480 if (existingOwner && existingOwner !== instance) {
6481 clearSafePolygonPointerEventsMutation(existingOwner);
6482 }
6483 clearSafePolygonPointerEventsMutation(instance);
6484 instance.performedPointerEventsMutation = true;
6485 instance.pointerEventsScopeElement = scopeElement;
6486 instance.pointerEventsReferenceElement = referenceElement;
6487 instance.pointerEventsFloatingElement = floatingElement;
6488 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6489 scopeElement.style.pointerEvents = "none";
6490 referenceElement.style.pointerEvents = "auto";
6491 floatingElement.style.pointerEvents = "auto";
6492 }
6493 function useHoverInteractionSharedState(store) {
6494 const data = store.context.dataRef.current;
6495 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6496 if (!data.hoverInteractionState) {
6497 data.hoverInteractionState = instance;
6498 }
6499 useOnMount(data.hoverInteractionState.disposeEffect);
6500 return data.hoverInteractionState;
6501 }
6502
6503 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6504 function useHoverFloatingInteraction(context, parameters = {}) {
6505 const {
6506 enabled = true,
6507 closeDelay: closeDelayProp = 0,
6508 nodeId: nodeIdProp
6509 } = parameters;
6510 const store = "rootStore" in context ? context.rootStore : context;
6511 const open = store.useState("open");
6512 const floatingElement = store.useState("floatingElement");
6513 const domReferenceElement = store.useState("domReferenceElement");
6514 const {
6515 dataRef
6516 } = store.context;
6517 const tree = useFloatingTree();
6518 const parentId = useFloatingParentNodeId();
6519 const instance = useHoverInteractionSharedState(store);
6520 const childClosedTimeout = useTimeout();
6521 const isClickLikeOpenEvent2 = useStableCallback(() => {
6522 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6523 });
6524 const isHoverOpen = useStableCallback(() => {
6525 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6526 });
6527 const clearPointerEvents = useStableCallback(() => {
6528 clearSafePolygonPointerEventsMutation(instance);
6529 });
6530 useIsoLayoutEffect(() => {
6531 if (!open) {
6532 instance.pointerType = void 0;
6533 instance.restTimeoutPending = false;
6534 instance.interactedInside = false;
6535 clearPointerEvents();
6536 }
6537 }, [open, instance, clearPointerEvents]);
6538 React27.useEffect(() => {
6539 return clearPointerEvents;
6540 }, [clearPointerEvents]);
6541 useIsoLayoutEffect(() => {
6542 if (!enabled) {
6543 return void 0;
6544 }
6545 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6546 const ref = domReferenceElement;
6547 const floatingEl = floatingElement;
6548 const doc = ownerDocument(floatingElement);
6549 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6550 if (parentFloating) {
6551 parentFloating.style.pointerEvents = "";
6552 }
6553 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6554 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6555 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6556 applySafePolygonPointerEventsMutation(instance, {
6557 scopeElement,
6558 referenceElement: ref,
6559 floatingElement: floatingEl
6560 });
6561 return () => {
6562 clearPointerEvents();
6563 };
6564 }
6565 return void 0;
6566 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6567 React27.useEffect(() => {
6568 if (!enabled) {
6569 return void 0;
6570 }
6571 function hasParentChildren() {
6572 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6573 }
6574 function closeWithDelay(event) {
6575 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6576 const close = () => {
6577 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6578 tree?.events.emit("floating.closed", event);
6579 };
6580 if (closeDelay) {
6581 instance.openChangeTimeout.start(closeDelay, close);
6582 } else {
6583 instance.openChangeTimeout.clear();
6584 close();
6585 }
6586 }
6587 function handleInteractInside(event) {
6588 const target = getTarget(event);
6589 if (!isInteractiveElement(target)) {
6590 instance.interactedInside = false;
6591 return;
6592 }
6593 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6594 }
6595 function onFloatingMouseEnter() {
6596 instance.openChangeTimeout.clear();
6597 childClosedTimeout.clear();
6598 tree?.events.off("floating.closed", onNodeClosed);
6599 clearPointerEvents();
6600 }
6601 function onFloatingMouseLeave(event) {
6602 if (hasParentChildren() && tree) {
6603 tree.events.on("floating.closed", onNodeClosed);
6604 return;
6605 }
6606 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6607 return;
6608 }
6609 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6610 const relatedTarget = event.relatedTarget;
6611 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6612 if (isMovingIntoDescendantFloating) {
6613 return;
6614 }
6615 if (instance.handler) {
6616 instance.handler(event);
6617 return;
6618 }
6619 clearPointerEvents();
6620 if (!isClickLikeOpenEvent2()) {
6621 closeWithDelay(event);
6622 }
6623 }
6624 function onNodeClosed(event) {
6625 if (!tree || !parentId || hasParentChildren()) {
6626 return;
6627 }
6628 childClosedTimeout.start(0, () => {
6629 tree.events.off("floating.closed", onNodeClosed);
6630 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6631 tree.events.emit("floating.closed", event);
6632 });
6633 }
6634 const floating = floatingElement;
6635 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6636 tree?.events.off("floating.closed", onNodeClosed);
6637 });
6638 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6639 }
6640
6641 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6642 var React28 = __toESM(require_react(), 1);
6643 var ReactDOM4 = __toESM(require_react_dom(), 1);
6644 var EMPTY_REF = {
6645 current: null
6646 };
6647 function useHoverReferenceInteraction(context, props = {}) {
6648 const {
6649 enabled = true,
6650 delay = 0,
6651 handleClose = null,
6652 mouseOnly = false,
6653 restMs = 0,
6654 move = true,
6655 triggerElementRef = EMPTY_REF,
6656 externalTree,
6657 isActiveTrigger = true,
6658 getHandleCloseContext,
6659 isClosing,
6660 shouldOpen: shouldOpenProp
6661 } = props;
6662 const store = "rootStore" in context ? context.rootStore : context;
6663 const {
6664 dataRef,
6665 events
6666 } = store.context;
6667 const tree = useFloatingTree(externalTree);
6668 const instance = useHoverInteractionSharedState(store);
6669 const isHoverCloseActiveRef = React28.useRef(false);
6670 const handleCloseRef = useValueAsRef(handleClose);
6671 const delayRef = useValueAsRef(delay);
6672 const restMsRef = useValueAsRef(restMs);
6673 const enabledRef = useValueAsRef(enabled);
6674 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6675 const isClosingRef = useValueAsRef(isClosing);
6676 const isClickLikeOpenEvent2 = useStableCallback(() => {
6677 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6678 });
6679 const checkShouldOpen = useStableCallback(() => {
6680 return shouldOpenRef.current?.() !== false;
6681 });
6682 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6683 const allTriggers = store.context.triggerElements;
6684 if (allTriggers.hasElement(currentTarget)) {
6685 return !currentDomReference || !contains(currentDomReference, currentTarget);
6686 }
6687 if (!isElement(target)) {
6688 return false;
6689 }
6690 const targetElement = target;
6691 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6692 });
6693 const cleanupMouseMoveHandler = useStableCallback(() => {
6694 if (!instance.handler) {
6695 return;
6696 }
6697 const doc = ownerDocument(store.select("domReferenceElement"));
6698 doc.removeEventListener("mousemove", instance.handler);
6699 instance.handler = void 0;
6700 });
6701 const clearPointerEvents = useStableCallback(() => {
6702 clearSafePolygonPointerEventsMutation(instance);
6703 });
6704 if (isActiveTrigger) {
6705 instance.handleCloseOptions = handleCloseRef.current?.__options;
6706 }
6707 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6708 React28.useEffect(() => {
6709 if (!enabled) {
6710 return void 0;
6711 }
6712 function onOpenChangeLocal(details) {
6713 if (!details.open) {
6714 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6715 cleanupMouseMoveHandler();
6716 instance.openChangeTimeout.clear();
6717 instance.restTimeout.clear();
6718 instance.blockMouseMove = true;
6719 instance.restTimeoutPending = false;
6720 } else {
6721 isHoverCloseActiveRef.current = false;
6722 }
6723 }
6724 events.on("openchange", onOpenChangeLocal);
6725 return () => {
6726 events.off("openchange", onOpenChangeLocal);
6727 };
6728 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6729 React28.useEffect(() => {
6730 if (!enabled) {
6731 return void 0;
6732 }
6733 function closeWithDelay(event, runElseBranch = true) {
6734 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6735 if (closeDelay) {
6736 instance.openChangeTimeout.start(closeDelay, () => {
6737 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6738 tree?.events.emit("floating.closed", event);
6739 });
6740 } else if (runElseBranch) {
6741 instance.openChangeTimeout.clear();
6742 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6743 tree?.events.emit("floating.closed", event);
6744 }
6745 }
6746 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6747 if (!isElement(trigger)) {
6748 return void 0;
6749 }
6750 function onMouseEnter(event) {
6751 instance.openChangeTimeout.clear();
6752 instance.blockMouseMove = false;
6753 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6754 return;
6755 }
6756 const restMsValue = getRestMs(restMsRef.current);
6757 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6758 const eventTarget = getTarget(event);
6759 const currentTarget = event.currentTarget ?? null;
6760 const currentDomReference = store.select("domReferenceElement");
6761 let triggerNode = currentTarget;
6762 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6763 for (const triggerElement of store.context.triggerElements.elements()) {
6764 if (contains(triggerElement, eventTarget)) {
6765 triggerNode = triggerElement;
6766 break;
6767 }
6768 }
6769 }
6770 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6771 triggerNode = currentDomReference;
6772 }
6773 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6774 const isOpen = store.select("open");
6775 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6776 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6777 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6778 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6779 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6780 const shouldOpen = !isOpen || isOverInactive;
6781 if (shouldOpenImmediately) {
6782 if (checkShouldOpen()) {
6783 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6784 }
6785 return;
6786 }
6787 if (isRestOnlyDelay) {
6788 return;
6789 }
6790 if (openDelay) {
6791 instance.openChangeTimeout.start(openDelay, () => {
6792 if (shouldOpen && checkShouldOpen()) {
6793 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6794 }
6795 });
6796 } else if (shouldOpen) {
6797 if (checkShouldOpen()) {
6798 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6799 }
6800 }
6801 }
6802 function onMouseLeave(event) {
6803 if (isClickLikeOpenEvent2()) {
6804 clearPointerEvents();
6805 return;
6806 }
6807 cleanupMouseMoveHandler();
6808 const domReferenceElement = store.select("domReferenceElement");
6809 const doc = ownerDocument(domReferenceElement);
6810 instance.restTimeout.clear();
6811 instance.restTimeoutPending = false;
6812 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6813 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6814 return;
6815 }
6816 if (handleCloseRef.current && handleCloseContextBase) {
6817 if (!store.select("open")) {
6818 instance.openChangeTimeout.clear();
6819 }
6820 const currentTrigger = triggerElementRef.current;
6821 instance.handler = handleCloseRef.current({
6822 ...handleCloseContextBase,
6823 tree,
6824 x: event.clientX,
6825 y: event.clientY,
6826 onClose() {
6827 clearPointerEvents();
6828 cleanupMouseMoveHandler();
6829 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6830 closeWithDelay(event, true);
6831 }
6832 }
6833 });
6834 doc.addEventListener("mousemove", instance.handler);
6835 instance.handler(event);
6836 return;
6837 }
6838 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6839 if (shouldClose) {
6840 closeWithDelay(event);
6841 }
6842 }
6843 if (move) {
6844 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6845 once: true
6846 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6847 }
6848 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6849 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6850 return React28.useMemo(() => {
6851 if (!enabled) {
6852 return void 0;
6853 }
6854 function setPointerRef(event) {
6855 instance.pointerType = event.pointerType;
6856 }
6857 return {
6858 onPointerDown: setPointerRef,
6859 onPointerEnter: setPointerRef,
6860 onMouseMove(event) {
6861 const {
6862 nativeEvent
6863 } = event;
6864 const trigger = event.currentTarget;
6865 const currentDomReference = store.select("domReferenceElement");
6866 const currentOpen = store.select("open");
6867 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6868 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6869 return;
6870 }
6871 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6872 const floatingElement = store.select("floatingElement");
6873 if (floatingElement) {
6874 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6875 applySafePolygonPointerEventsMutation(instance, {
6876 scopeElement,
6877 referenceElement: trigger,
6878 floatingElement
6879 });
6880 }
6881 }
6882 const restMsValue = getRestMs(restMsRef.current);
6883 if (currentOpen && !isOverInactive || restMsValue === 0) {
6884 return;
6885 }
6886 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6887 return;
6888 }
6889 instance.restTimeout.clear();
6890 function handleMouseMove() {
6891 instance.restTimeoutPending = false;
6892 if (isClickLikeOpenEvent2()) {
6893 return;
6894 }
6895 const latestOpen = store.select("open");
6896 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6897 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6898 }
6899 }
6900 if (instance.pointerType === "touch") {
6901 ReactDOM4.flushSync(() => {
6902 handleMouseMove();
6903 });
6904 } else if (isOverInactive && currentOpen) {
6905 handleMouseMove();
6906 } else {
6907 instance.restTimeoutPending = true;
6908 instance.restTimeout.start(restMsValue, handleMouseMove);
6909 }
6910 }
6911 };
6912 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
6913 }
6914
6915 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6916 var CURSOR_SPEED_THRESHOLD = 0.1;
6917 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6918 var POLYGON_BUFFER = 0.5;
6919 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6920 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6921 }
6922 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6923 let isInsideValue = false;
6924 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6925 isInsideValue = !isInsideValue;
6926 }
6927 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6928 isInsideValue = !isInsideValue;
6929 }
6930 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6931 isInsideValue = !isInsideValue;
6932 }
6933 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6934 isInsideValue = !isInsideValue;
6935 }
6936 return isInsideValue;
6937 }
6938 function isInsideRect(pointX, pointY, rect) {
6939 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6940 }
6941 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6942 const minX = Math.min(x1, x2);
6943 const maxX = Math.max(x1, x2);
6944 const minY = Math.min(y1, y2);
6945 const maxY = Math.max(y1, y2);
6946 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6947 }
6948 function safePolygon(options = {}) {
6949 const {
6950 blockPointerEvents = false
6951 } = options;
6952 const timeout = new Timeout();
6953 const fn = ({
6954 x: x2,
6955 y: y2,
6956 placement,
6957 elements,
6958 onClose,
6959 nodeId,
6960 tree
6961 }) => {
6962 const side = placement?.split("-")[0];
6963 let hasLanded = false;
6964 let lastX = null;
6965 let lastY = null;
6966 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6967 function isCursorMovingSlowly(nextX, nextY) {
6968 const currentTime = performance.now();
6969 const elapsedTime = currentTime - lastCursorTime;
6970 if (lastX === null || lastY === null || elapsedTime === 0) {
6971 lastX = nextX;
6972 lastY = nextY;
6973 lastCursorTime = currentTime;
6974 return false;
6975 }
6976 const deltaX = nextX - lastX;
6977 const deltaY = nextY - lastY;
6978 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6979 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6980 lastX = nextX;
6981 lastY = nextY;
6982 lastCursorTime = currentTime;
6983 return distanceSquared < thresholdSquared;
6984 }
6985 function close() {
6986 timeout.clear();
6987 onClose();
6988 }
6989 return function onMouseMove(event) {
6990 timeout.clear();
6991 const domReference = elements.domReference;
6992 const floating = elements.floating;
6993 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6994 return void 0;
6995 }
6996 const {
6997 clientX,
6998 clientY
6999 } = event;
7000 const target = getTarget(event);
7001 const isLeave = event.type === "mouseleave";
7002 const isOverFloatingEl = contains(floating, target);
7003 const isOverReferenceEl = contains(domReference, target);
7004 if (isOverFloatingEl) {
7005 hasLanded = true;
7006 if (!isLeave) {
7007 return void 0;
7008 }
7009 }
7010 if (isOverReferenceEl) {
7011 hasLanded = false;
7012 if (!isLeave) {
7013 hasLanded = true;
7014 return void 0;
7015 }
7016 }
7017 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7018 return void 0;
7019 }
7020 function hasOpenChildNode() {
7021 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7022 }
7023 function closeIfNoOpenChild() {
7024 if (!hasOpenChildNode()) {
7025 close();
7026 }
7027 }
7028 if (hasOpenChildNode()) {
7029 return void 0;
7030 }
7031 const refRect = domReference.getBoundingClientRect();
7032 const rect = floating.getBoundingClientRect();
7033 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7034 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7035 const isFloatingWider = rect.width > refRect.width;
7036 const isFloatingTaller = rect.height > refRect.height;
7037 const left = (isFloatingWider ? refRect : rect).left;
7038 const right = (isFloatingWider ? refRect : rect).right;
7039 const top = (isFloatingTaller ? refRect : rect).top;
7040 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7041 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
7042 closeIfNoOpenChild();
7043 return void 0;
7044 }
7045 let isInsideTroughRect = false;
7046 switch (side) {
7047 case "top":
7048 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7049 break;
7050 case "bottom":
7051 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7052 break;
7053 case "left":
7054 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7055 break;
7056 case "right":
7057 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7058 break;
7059 default:
7060 }
7061 if (isInsideTroughRect) {
7062 return void 0;
7063 }
7064 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7065 closeIfNoOpenChild();
7066 return void 0;
7067 }
7068 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7069 closeIfNoOpenChild();
7070 return void 0;
7071 }
7072 let isInsidePolygon = false;
7073 switch (side) {
7074 case "top": {
7075 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7076 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7077 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7078 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7079 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7080 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7081 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7082 break;
7083 }
7084 case "bottom": {
7085 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7086 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7087 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7088 const cursorPointY = y2 - POLYGON_BUFFER;
7089 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7090 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7091 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7092 break;
7093 }
7094 case "left": {
7095 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7096 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7097 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7098 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7099 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7100 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7101 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7102 break;
7103 }
7104 case "right": {
7105 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7106 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7107 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7108 const cursorPointX = x2 - POLYGON_BUFFER;
7109 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7110 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7111 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7112 break;
7113 }
7114 default:
7115 }
7116 if (!isInsidePolygon) {
7117 closeIfNoOpenChild();
7118 } else if (!hasLanded) {
7119 timeout.start(40, closeIfNoOpenChild);
7120 }
7121 return void 0;
7122 };
7123 };
7124 fn.__options = {
7125 ...options,
7126 blockPointerEvents
7127 };
7128 return fn;
7129 }
7130
7131 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7132 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7133 CommonPopupDataAttributes2["open"] = "data-open";
7134 CommonPopupDataAttributes2["closed"] = "data-closed";
7135 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7136 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7137 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7138 CommonPopupDataAttributes2["side"] = "data-side";
7139 CommonPopupDataAttributes2["align"] = "data-align";
7140 return CommonPopupDataAttributes2;
7141 })({});
7142 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7143 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7144 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7145 return CommonTriggerDataAttributes2;
7146 })({});
7147 var TRIGGER_HOOK = {
7148 [CommonTriggerDataAttributes.popupOpen]: ""
7149 };
7150 var PRESSABLE_TRIGGER_HOOK = {
7151 [CommonTriggerDataAttributes.popupOpen]: "",
7152 [CommonTriggerDataAttributes.pressed]: ""
7153 };
7154 var POPUP_OPEN_HOOK = {
7155 [CommonPopupDataAttributes.open]: ""
7156 };
7157 var POPUP_CLOSED_HOOK = {
7158 [CommonPopupDataAttributes.closed]: ""
7159 };
7160 var ANCHOR_HIDDEN_HOOK = {
7161 [CommonPopupDataAttributes.anchorHidden]: ""
7162 };
7163 var triggerOpenStateMapping = {
7164 open(value) {
7165 if (value) {
7166 return TRIGGER_HOOK;
7167 }
7168 return null;
7169 }
7170 };
7171 var popupStateMapping = {
7172 open(value) {
7173 if (value) {
7174 return POPUP_OPEN_HOOK;
7175 }
7176 return POPUP_CLOSED_HOOK;
7177 },
7178 anchorHidden(value) {
7179 if (value) {
7180 return ANCHOR_HIDDEN_HOOK;
7181 }
7182 return null;
7183 }
7184 };
7185
7186 // node_modules/@base-ui/utils/esm/inertValue.js
7187 function inertValue(value) {
7188 if (isReactVersionAtLeast(19)) {
7189 return value;
7190 }
7191 return value ? "true" : void 0;
7192 }
7193
7194 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7195 var React29 = __toESM(require_react(), 1);
7196
7197 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7198 var baseArrow = (options) => ({
7199 name: "arrow",
7200 options,
7201 async fn(state) {
7202 const {
7203 x: x2,
7204 y: y2,
7205 placement,
7206 rects,
7207 platform: platform3,
7208 elements,
7209 middlewareData
7210 } = state;
7211 const {
7212 element,
7213 padding = 0,
7214 offsetParent = "real"
7215 } = evaluate(options, state) || {};
7216 if (element == null) {
7217 return {};
7218 }
7219 const paddingObject = getPaddingObject(padding);
7220 const coords = {
7221 x: x2,
7222 y: y2
7223 };
7224 const axis = getAlignmentAxis(placement);
7225 const length = getAxisLength(axis);
7226 const arrowDimensions = await platform3.getDimensions(element);
7227 const isYAxis = axis === "y";
7228 const minProp = isYAxis ? "top" : "left";
7229 const maxProp = isYAxis ? "bottom" : "right";
7230 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7231 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7232 const startDiff = coords[axis] - rects.reference[axis];
7233 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7234 let clientSize = elements.floating[clientProp] || rects.floating[length];
7235 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7236 clientSize = elements.floating[clientProp] || rects.floating[length];
7237 }
7238 const centerToReference = endDiff / 2 - startDiff / 2;
7239 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7240 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7241 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7242 const min2 = minPadding;
7243 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7244 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7245 const offset4 = clamp(min2, center, max2);
7246 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7247 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7248 return {
7249 [axis]: coords[axis] + alignmentOffset,
7250 data: {
7251 [axis]: offset4,
7252 centerOffset: center - offset4 - alignmentOffset,
7253 ...shouldAddOffset && {
7254 alignmentOffset
7255 }
7256 },
7257 reset: shouldAddOffset
7258 };
7259 }
7260 });
7261 var arrow4 = (options, deps) => ({
7262 ...baseArrow(options),
7263 options: [options, deps]
7264 });
7265
7266 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7267 var hide4 = {
7268 name: "hide",
7269 async fn(state) {
7270 const {
7271 width,
7272 height,
7273 x: x2,
7274 y: y2
7275 } = state.rects.reference;
7276 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7277 const nativeHideResult = await hide3().fn(state);
7278 return {
7279 data: {
7280 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7281 }
7282 };
7283 }
7284 };
7285
7286 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7287 var DEFAULT_SIDES = {
7288 sideX: "left",
7289 sideY: "top"
7290 };
7291 var adaptiveOrigin = {
7292 name: "adaptiveOrigin",
7293 async fn(state) {
7294 const {
7295 x: rawX,
7296 y: rawY,
7297 rects: {
7298 floating: floatRect
7299 },
7300 elements: {
7301 floating
7302 },
7303 platform: platform3,
7304 strategy,
7305 placement
7306 } = state;
7307 const win = getWindow(floating);
7308 const styles = win.getComputedStyle(floating);
7309 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7310 if (!hasTransition) {
7311 return {
7312 x: rawX,
7313 y: rawY,
7314 data: DEFAULT_SIDES
7315 };
7316 }
7317 const offsetParent = await platform3.getOffsetParent?.(floating);
7318 let offsetDimensions = {
7319 width: 0,
7320 height: 0
7321 };
7322 if (strategy === "fixed" && win?.visualViewport) {
7323 offsetDimensions = {
7324 width: win.visualViewport.width,
7325 height: win.visualViewport.height
7326 };
7327 } else if (offsetParent === win) {
7328 const doc = ownerDocument(floating);
7329 offsetDimensions = {
7330 width: doc.documentElement.clientWidth,
7331 height: doc.documentElement.clientHeight
7332 };
7333 } else if (await platform3.isElement?.(offsetParent)) {
7334 offsetDimensions = await platform3.getDimensions(offsetParent);
7335 }
7336 const currentSide = getSide(placement);
7337 let x2 = rawX;
7338 let y2 = rawY;
7339 if (currentSide === "left") {
7340 x2 = offsetDimensions.width - (rawX + floatRect.width);
7341 }
7342 if (currentSide === "top") {
7343 y2 = offsetDimensions.height - (rawY + floatRect.height);
7344 }
7345 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7346 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7347 return {
7348 x: x2,
7349 y: y2,
7350 data: {
7351 sideX,
7352 sideY
7353 }
7354 };
7355 }
7356 };
7357
7358 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7359 function getLogicalSide(sideParam, renderedSide, isRtl) {
7360 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7361 const logicalRight = isRtl ? "inline-start" : "inline-end";
7362 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7363 return {
7364 top: "top",
7365 right: isLogicalSideParam ? logicalRight : "right",
7366 bottom: "bottom",
7367 left: isLogicalSideParam ? logicalLeft : "left"
7368 }[renderedSide];
7369 }
7370 function getOffsetData(state, sideParam, isRtl) {
7371 const {
7372 rects,
7373 placement
7374 } = state;
7375 const data = {
7376 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7377 align: getAlignment(placement) || "center",
7378 anchor: {
7379 width: rects.reference.width,
7380 height: rects.reference.height
7381 },
7382 positioner: {
7383 width: rects.floating.width,
7384 height: rects.floating.height
7385 }
7386 };
7387 return data;
7388 }
7389 function useAnchorPositioning(params) {
7390 const {
7391 // Public parameters
7392 anchor,
7393 positionMethod = "absolute",
7394 side: sideParam = "bottom",
7395 sideOffset = 0,
7396 align = "center",
7397 alignOffset = 0,
7398 collisionBoundary,
7399 collisionPadding: collisionPaddingParam = 5,
7400 sticky = false,
7401 arrowPadding = 5,
7402 disableAnchorTracking = false,
7403 inline: inlineMiddleware,
7404 // Private parameters
7405 keepMounted = false,
7406 floatingRootContext,
7407 mounted,
7408 collisionAvoidance,
7409 shiftCrossAxis = false,
7410 nodeId,
7411 adaptiveOrigin: adaptiveOrigin2,
7412 lazyFlip = false,
7413 externalTree
7414 } = params;
7415 const [mountSide, setMountSide] = React29.useState(null);
7416 if (!mounted && mountSide !== null) {
7417 setMountSide(null);
7418 }
7419 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7420 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7421 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7422 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7423 const anchorFnCallback = useStableCallback(anchorFn);
7424 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7425 const anchorValueRef = useValueAsRef(anchor);
7426 const mountedRef = useValueAsRef(mounted);
7427 const direction = useDirection();
7428 const isRtl = direction === "rtl";
7429 const side = mountSide || {
7430 top: "top",
7431 right: "right",
7432 bottom: "bottom",
7433 left: "left",
7434 "inline-end": isRtl ? "left" : "right",
7435 "inline-start": isRtl ? "right" : "left"
7436 }[sideParam];
7437 const placement = align === "center" ? side : `${side}-${align}`;
7438 let collisionPadding = collisionPaddingParam;
7439 const bias = 1;
7440 const biasTop = sideParam === "bottom" ? bias : 0;
7441 const biasBottom = sideParam === "top" ? bias : 0;
7442 const biasLeft = sideParam === "right" ? bias : 0;
7443 const biasRight = sideParam === "left" ? bias : 0;
7444 if (typeof collisionPadding === "number") {
7445 collisionPadding = {
7446 top: collisionPadding + biasTop,
7447 right: collisionPadding + biasRight,
7448 bottom: collisionPadding + biasBottom,
7449 left: collisionPadding + biasLeft
7450 };
7451 } else if (collisionPadding) {
7452 collisionPadding = {
7453 top: (collisionPadding.top || 0) + biasTop,
7454 right: (collisionPadding.right || 0) + biasRight,
7455 bottom: (collisionPadding.bottom || 0) + biasBottom,
7456 left: (collisionPadding.left || 0) + biasLeft
7457 };
7458 }
7459 const commonCollisionProps = {
7460 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7461 padding: collisionPadding
7462 };
7463 const arrowRef = React29.useRef(null);
7464 const sideOffsetRef = useValueAsRef(sideOffset);
7465 const alignOffsetRef = useValueAsRef(alignOffset);
7466 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7467 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7468 const middleware = [];
7469 if (inlineMiddleware) {
7470 middleware.push(inlineMiddleware);
7471 }
7472 middleware.push(offset3((state) => {
7473 const data = getOffsetData(state, sideParam, isRtl);
7474 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7475 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7476 return {
7477 mainAxis: sideAxis,
7478 crossAxis: alignAxis,
7479 alignmentAxis: alignAxis
7480 };
7481 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7482 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7483 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7484 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7485 ...commonCollisionProps,
7486 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7487 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7488 padding: {
7489 top: collisionPadding.top + bias,
7490 right: collisionPadding.right + bias,
7491 bottom: collisionPadding.bottom + bias,
7492 left: collisionPadding.left + bias
7493 },
7494 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7495 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7496 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7497 });
7498 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7499 const html = ownerDocument(data.elements.floating).documentElement;
7500 return {
7501 ...commonCollisionProps,
7502 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7503 // for context menus.
7504 rootBoundary: shiftCrossAxis ? {
7505 x: 0,
7506 y: 0,
7507 width: html.clientWidth,
7508 height: html.clientHeight
7509 } : void 0,
7510 mainAxis: collisionAvoidanceAlign !== "none",
7511 crossAxis: crossAxisShiftEnabled,
7512 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7513 if (!arrowRef.current) {
7514 return {};
7515 }
7516 const {
7517 width,
7518 height
7519 } = arrowRef.current.getBoundingClientRect();
7520 const sideAxis = getSideAxis(getSide(limitData.placement));
7521 const arrowSize = sideAxis === "y" ? width : height;
7522 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7523 return {
7524 offset: arrowSize / 2 + offsetAmount / 2
7525 };
7526 })
7527 };
7528 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7529 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7530 middleware.push(shiftMiddleware, flipMiddleware);
7531 } else {
7532 middleware.push(flipMiddleware, shiftMiddleware);
7533 }
7534 middleware.push(size3({
7535 ...commonCollisionProps,
7536 apply({
7537 elements: {
7538 floating
7539 },
7540 availableWidth,
7541 availableHeight,
7542 rects
7543 }) {
7544 if (!mountedRef.current) {
7545 return;
7546 }
7547 const floatingStyle = floating.style;
7548 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7549 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7550 const dpr = getWindow(floating).devicePixelRatio || 1;
7551 const {
7552 x: x3,
7553 y: y3,
7554 width,
7555 height
7556 } = rects.reference;
7557 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7558 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7559 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7560 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7561 }
7562 }), arrow4((state) => ({
7563 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7564 // we'll create a fake element.
7565 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7566 padding: arrowPadding,
7567 offsetParent: "floating"
7568 }), [arrowPadding]), {
7569 name: "transformOrigin",
7570 fn(state) {
7571 const {
7572 elements: elements2,
7573 middlewareData: middlewareData2,
7574 placement: renderedPlacement2,
7575 rects,
7576 y: y3
7577 } = state;
7578 const currentRenderedSide = getSide(renderedPlacement2);
7579 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7580 const arrowEl = arrowRef.current;
7581 const arrowX = middlewareData2.arrow?.x || 0;
7582 const arrowY = middlewareData2.arrow?.y || 0;
7583 const arrowWidth = arrowEl?.clientWidth || 0;
7584 const arrowHeight = arrowEl?.clientHeight || 0;
7585 const transformX = arrowX + arrowWidth / 2;
7586 const transformY = arrowY + arrowHeight / 2;
7587 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7588 const halfAnchorHeight = rects.reference.height / 2;
7589 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7590 const isOverlappingAnchor = shiftY > sideOffsetValue;
7591 const adjacentTransformOrigin = {
7592 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7593 bottom: `${transformX}px ${-sideOffsetValue}px`,
7594 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7595 right: `${-sideOffsetValue}px ${transformY}px`
7596 }[currentRenderedSide];
7597 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7598 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7599 return {};
7600 }
7601 }, hide4, adaptiveOrigin2);
7602 useIsoLayoutEffect(() => {
7603 if (!mounted && floatingRootContext) {
7604 floatingRootContext.update({
7605 referenceElement: null,
7606 floatingElement: null,
7607 domReferenceElement: null,
7608 positionReference: null
7609 });
7610 }
7611 }, [mounted, floatingRootContext]);
7612 const autoUpdateOptions = React29.useMemo(() => ({
7613 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7614 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7615 }), [disableAnchorTracking]);
7616 const {
7617 refs,
7618 elements,
7619 x: x2,
7620 y: y2,
7621 middlewareData,
7622 update: update2,
7623 placement: renderedPlacement,
7624 context,
7625 isPositioned,
7626 floatingStyles: originalFloatingStyles
7627 } = useFloating2({
7628 rootContext: floatingRootContext,
7629 open: keepMounted ? mounted : void 0,
7630 placement,
7631 middleware,
7632 strategy: positionMethod,
7633 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7634 nodeId,
7635 externalTree
7636 });
7637 const {
7638 sideX,
7639 sideY
7640 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7641 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7642 const floatingStyles = React29.useMemo(() => {
7643 const base = adaptiveOrigin2 ? {
7644 position: resolvedPosition,
7645 [sideX]: x2,
7646 [sideY]: y2
7647 } : {
7648 position: resolvedPosition,
7649 ...originalFloatingStyles
7650 };
7651 if (!isPositioned) {
7652 base.opacity = 0;
7653 }
7654 return base;
7655 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7656 const registeredPositionReferenceRef = React29.useRef(null);
7657 useIsoLayoutEffect(() => {
7658 if (!mounted) {
7659 return;
7660 }
7661 const anchorValue = anchorValueRef.current;
7662 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7663 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7664 const finalAnchor = unwrappedElement || null;
7665 if (finalAnchor !== registeredPositionReferenceRef.current) {
7666 refs.setPositionReference(finalAnchor);
7667 registeredPositionReferenceRef.current = finalAnchor;
7668 }
7669 }, [mounted, refs, anchorDep, anchorValueRef]);
7670 React29.useEffect(() => {
7671 if (!mounted) {
7672 return;
7673 }
7674 const anchorValue = anchorValueRef.current;
7675 if (typeof anchorValue === "function") {
7676 return;
7677 }
7678 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7679 refs.setPositionReference(anchorValue.current);
7680 registeredPositionReferenceRef.current = anchorValue.current;
7681 }
7682 }, [mounted, refs, anchorDep, anchorValueRef]);
7683 React29.useEffect(() => {
7684 if (keepMounted && mounted && elements.domReference && elements.floating) {
7685 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7686 }
7687 return void 0;
7688 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7689 const renderedSide = getSide(renderedPlacement);
7690 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7691 const renderedAlign = getAlignment(renderedPlacement) || "center";
7692 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7693 useIsoLayoutEffect(() => {
7694 if (lazyFlip && mounted && isPositioned) {
7695 setMountSide(renderedSide);
7696 }
7697 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7698 const arrowStyles = React29.useMemo(() => ({
7699 position: "absolute",
7700 top: middlewareData.arrow?.y,
7701 left: middlewareData.arrow?.x
7702 }), [middlewareData.arrow]);
7703 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7704 return React29.useMemo(() => ({
7705 positionerStyles: floatingStyles,
7706 arrowStyles,
7707 arrowRef,
7708 arrowUncentered,
7709 side: logicalRenderedSide,
7710 align: renderedAlign,
7711 physicalSide: renderedSide,
7712 anchorHidden,
7713 refs,
7714 context,
7715 isPositioned,
7716 update: update2
7717 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7718 }
7719 function isRef(param) {
7720 return param != null && "current" in param;
7721 }
7722
7723 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7724 function getDisabledMountTransitionStyles(transitionStatus) {
7725 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7726 }
7727
7728 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7729 function usePositioner(componentProps, state, {
7730 styles,
7731 transitionStatus,
7732 props,
7733 refs,
7734 hidden,
7735 inert = false
7736 }) {
7737 const style = {
7738 ...styles
7739 };
7740 if (inert) {
7741 style.pointerEvents = "none";
7742 }
7743 return useRenderElement("div", componentProps, {
7744 state,
7745 ref: refs,
7746 props: [{
7747 role: "presentation",
7748 hidden,
7749 style
7750 }, getDisabledMountTransitionStyles(transitionStatus), props],
7751 stateAttributesMapping: popupStateMapping
7752 });
7753 }
7754
7755 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7756 var React32 = __toESM(require_react(), 1);
7757 var ReactDOM5 = __toESM(require_react_dom(), 1);
7758
7759 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7760 var React30 = __toESM(require_react(), 1);
7761 function usePreviousValue(value) {
7762 const [state, setState] = React30.useState({
7763 current: value,
7764 previous: null
7765 });
7766 if (value !== state.current) {
7767 setState({
7768 current: value,
7769 previous: state.current
7770 });
7771 }
7772 return state.previous;
7773 }
7774
7775 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7776 var React31 = __toESM(require_react(), 1);
7777
7778 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7779 function getCssDimensions2(element) {
7780 const css = getComputedStyle2(element);
7781 let width = parseFloat(css.width) || 0;
7782 let height = parseFloat(css.height) || 0;
7783 const hasOffset = isHTMLElement(element);
7784 const offsetWidth = hasOffset ? element.offsetWidth : width;
7785 const offsetHeight = hasOffset ? element.offsetHeight : height;
7786 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7787 if (shouldFallback) {
7788 width = offsetWidth;
7789 height = offsetHeight;
7790 }
7791 return {
7792 width,
7793 height
7794 };
7795 }
7796
7797 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7798 var DEFAULT_ENABLED = () => true;
7799 function usePopupAutoResize(parameters) {
7800 const {
7801 popupElement,
7802 positionerElement,
7803 content,
7804 mounted,
7805 enabled = DEFAULT_ENABLED,
7806 onMeasureLayout: onMeasureLayoutParam,
7807 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7808 side,
7809 direction
7810 } = parameters;
7811 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7812 const animationFrame = useAnimationFrame();
7813 const committedDimensionsRef = React31.useRef(null);
7814 const liveDimensionsRef = React31.useRef(null);
7815 const isInitialRenderRef = React31.useRef(true);
7816 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7817 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7818 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7819 const anchoringStyles = React31.useMemo(() => {
7820 let isOriginSide = side === "top";
7821 let isPhysicalLeft = side === "left";
7822 if (direction === "rtl") {
7823 isOriginSide = isOriginSide || side === "inline-end";
7824 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7825 } else {
7826 isOriginSide = isOriginSide || side === "inline-start";
7827 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7828 }
7829 return isOriginSide ? {
7830 position: "absolute",
7831 [side === "top" ? "bottom" : "top"]: "0",
7832 [isPhysicalLeft ? "right" : "left"]: "0"
7833 } : EMPTY_OBJECT;
7834 }, [side, direction]);
7835 useIsoLayoutEffect(() => {
7836 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7837 restoreAnchoringStylesRef.current = NOOP;
7838 isInitialRenderRef.current = true;
7839 committedDimensionsRef.current = null;
7840 liveDimensionsRef.current = null;
7841 return void 0;
7842 }
7843 if (!popupElement || !positionerElement) {
7844 return void 0;
7845 }
7846 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7847 const observer = new ResizeObserver((entries) => {
7848 const entry = entries[0];
7849 if (entry) {
7850 liveDimensionsRef.current = {
7851 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7852 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7853 };
7854 }
7855 });
7856 observer.observe(popupElement);
7857 setPopupCssSize(popupElement, "auto");
7858 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7859 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7860 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7861 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7862 "--available-width": "max-content",
7863 "--available-height": "max-content"
7864 });
7865 function restoreMeasurementOverrides() {
7866 restorePopupPosition();
7867 restorePopupTransform();
7868 restorePositionerAvailableSize();
7869 }
7870 function restoreMeasurementOverridesIncludingScale() {
7871 restoreMeasurementOverrides();
7872 restorePopupScale();
7873 }
7874 onMeasureLayout?.();
7875 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7876 setPositionerCssSize(positionerElement, "max-content");
7877 const dimensions = getCssDimensions2(popupElement);
7878 committedDimensionsRef.current = dimensions;
7879 setPositionerCssSize(positionerElement, dimensions);
7880 restoreMeasurementOverridesIncludingScale();
7881 onMeasureLayoutComplete?.(null, dimensions);
7882 isInitialRenderRef.current = false;
7883 return () => {
7884 observer.disconnect();
7885 restoreAnchoringStylesRef.current();
7886 restoreAnchoringStylesRef.current = NOOP;
7887 };
7888 }
7889 setPopupCssSize(popupElement, "auto");
7890 setPositionerCssSize(positionerElement, "max-content");
7891 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7892 const newDimensions = getCssDimensions2(popupElement);
7893 committedDimensionsRef.current = newDimensions;
7894 if (!previousDimensions) {
7895 setPositionerCssSize(positionerElement, newDimensions);
7896 restoreMeasurementOverridesIncludingScale();
7897 onMeasureLayoutComplete?.(null, newDimensions);
7898 return () => {
7899 observer.disconnect();
7900 animationFrame.cancel();
7901 restoreAnchoringStylesRef.current();
7902 restoreAnchoringStylesRef.current = NOOP;
7903 };
7904 }
7905 setPopupCssSize(popupElement, previousDimensions);
7906 restoreMeasurementOverridesIncludingScale();
7907 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7908 setPositionerCssSize(positionerElement, newDimensions);
7909 const abortController = new AbortController();
7910 animationFrame.request(() => {
7911 setPopupCssSize(popupElement, newDimensions);
7912 runOnceAnimationsFinish(() => {
7913 popupElement.style.setProperty("--popup-width", "auto");
7914 popupElement.style.setProperty("--popup-height", "auto");
7915 }, abortController.signal);
7916 });
7917 return () => {
7918 observer.disconnect();
7919 abortController.abort();
7920 animationFrame.cancel();
7921 restoreAnchoringStylesRef.current();
7922 restoreAnchoringStylesRef.current = NOOP;
7923 };
7924 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7925 }
7926 function overrideElementStyle(element, property, value) {
7927 const originalValue = element.style.getPropertyValue(property);
7928 element.style.setProperty(property, value);
7929 return () => {
7930 element.style.setProperty(property, originalValue);
7931 };
7932 }
7933 function applyElementStyles(element, styles) {
7934 const restorers = [];
7935 for (const [key, value] of Object.entries(styles)) {
7936 restorers.push(overrideElementStyle(element, key, value));
7937 }
7938 return restorers.length ? () => {
7939 restorers.forEach((restore) => restore());
7940 } : NOOP;
7941 }
7942 function setPopupCssSize(popupElement, size4) {
7943 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7944 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7945 popupElement.style.setProperty("--popup-width", width);
7946 popupElement.style.setProperty("--popup-height", height);
7947 }
7948 function setPositionerCssSize(positionerElement, size4) {
7949 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7950 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7951 positionerElement.style.setProperty("--positioner-width", width);
7952 positionerElement.style.setProperty("--positioner-height", height);
7953 }
7954
7955 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7956 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
7957 function usePopupViewport(parameters) {
7958 const {
7959 store,
7960 side,
7961 cssVars,
7962 children
7963 } = parameters;
7964 const direction = useDirection();
7965 const activeTrigger = store.useState("activeTriggerElement");
7966 const activeTriggerId = store.useState("activeTriggerId");
7967 const open = store.useState("open");
7968 const payload = store.useState("payload");
7969 const mounted = store.useState("mounted");
7970 const popupElement = store.useState("popupElement");
7971 const positionerElement = store.useState("positionerElement");
7972 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7973 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7974 const capturedNodeRef = React32.useRef(null);
7975 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7976 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7977 const currentContainerRef = React32.useRef(null);
7978 const previousContainerRef = React32.useRef(null);
7979 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7980 const cleanupFrame = useAnimationFrame();
7981 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7982 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7983 useIsoLayoutEffect(() => {
7984 store.set("hasViewport", true);
7985 return () => {
7986 store.set("hasViewport", false);
7987 };
7988 }, [store]);
7989 const handleMeasureLayout = useStableCallback(() => {
7990 currentContainerRef.current?.style.setProperty("animation", "none");
7991 currentContainerRef.current?.style.setProperty("transition", "none");
7992 previousContainerRef.current?.style.setProperty("display", "none");
7993 });
7994 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7995 currentContainerRef.current?.style.removeProperty("animation");
7996 currentContainerRef.current?.style.removeProperty("transition");
7997 previousContainerRef.current?.style.removeProperty("display");
7998 if (previousDimensions) {
7999 setPreviousContentDimensions(previousDimensions);
8000 }
8001 });
8002 const lastHandledTriggerRef = React32.useRef(null);
8003 useIsoLayoutEffect(() => {
8004 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8005 setPreviousContentNode(capturedNodeRef.current);
8006 setShowStartingStyleAttribute(true);
8007 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8008 setNewTriggerOffset(offset4);
8009 cleanupFrame.request(() => {
8010 ReactDOM5.flushSync(() => {
8011 setShowStartingStyleAttribute(false);
8012 });
8013 onAnimationsFinished(() => {
8014 setPreviousContentNode(null);
8015 setPreviousContentDimensions(null);
8016 capturedNodeRef.current = null;
8017 });
8018 });
8019 lastHandledTriggerRef.current = activeTrigger;
8020 }
8021 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8022 useIsoLayoutEffect(() => {
8023 const source = currentContainerRef.current;
8024 if (!source) {
8025 return;
8026 }
8027 const wrapper = ownerDocument(source).createElement("div");
8028 for (const child of Array.from(source.childNodes)) {
8029 wrapper.appendChild(child.cloneNode(true));
8030 }
8031 capturedNodeRef.current = wrapper;
8032 });
8033 const isTransitioning = previousContentNode != null;
8034 let childrenToRender;
8035 if (!isTransitioning) {
8036 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8037 "data-current": true,
8038 ref: currentContainerRef,
8039 children
8040 }, currentContentKey);
8041 } else {
8042 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React32.Fragment, {
8043 children: [/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8044 "data-previous": true,
8045 inert: inertValue(true),
8046 ref: previousContainerRef,
8047 style: {
8048 ...previousContentDimensions ? {
8049 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8050 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8051 } : null,
8052 position: "absolute"
8053 },
8054 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8055 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8056 "data-current": true,
8057 ref: currentContainerRef,
8058 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8059 children
8060 }, currentContentKey)]
8061 });
8062 }
8063 useIsoLayoutEffect(() => {
8064 const container = previousContainerRef.current;
8065 if (!container || !previousContentNode) {
8066 return;
8067 }
8068 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8069 }, [previousContentNode]);
8070 usePopupAutoResize({
8071 popupElement,
8072 positionerElement,
8073 mounted,
8074 content: payload,
8075 onMeasureLayout: handleMeasureLayout,
8076 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8077 side,
8078 direction
8079 });
8080 const state = {
8081 activationDirection: getActivationDirection(newTriggerOffset),
8082 transitioning: isTransitioning
8083 };
8084 return {
8085 children: childrenToRender,
8086 state
8087 };
8088 }
8089 function getActivationDirection(offset4) {
8090 if (!offset4) {
8091 return void 0;
8092 }
8093 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8094 }
8095 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8096 if (value > tolerance) {
8097 return positiveLabel;
8098 }
8099 if (value < -tolerance) {
8100 return negativeLabel;
8101 }
8102 return "";
8103 }
8104 function calculateRelativePosition(from, to) {
8105 const fromRect = from.getBoundingClientRect();
8106 const toRect = to.getBoundingClientRect();
8107 const fromCenter = {
8108 x: fromRect.left + fromRect.width / 2,
8109 y: fromRect.top + fromRect.height / 2
8110 };
8111 const toCenter = {
8112 x: toRect.left + toRect.width / 2,
8113 y: toRect.top + toRect.height / 2
8114 };
8115 return {
8116 horizontal: toCenter.x - fromCenter.x,
8117 vertical: toCenter.y - fromCenter.y
8118 };
8119 }
8120 function usePopupContentKey(activeTriggerId, payload) {
8121 const [contentKey, setContentKey] = React32.useState(0);
8122 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
8123 const previousPayloadRef = React32.useRef(payload);
8124 const pendingPayloadUpdateRef = React32.useRef(false);
8125 useIsoLayoutEffect(() => {
8126 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8127 const previousPayload = previousPayloadRef.current;
8128 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8129 const payloadChanged = payload !== previousPayload;
8130 if (triggerIdChanged) {
8131 setContentKey((value) => value + 1);
8132 pendingPayloadUpdateRef.current = !payloadChanged;
8133 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8134 setContentKey((value) => value + 1);
8135 pendingPayloadUpdateRef.current = false;
8136 }
8137 previousActiveTriggerIdRef.current = activeTriggerId;
8138 previousPayloadRef.current = payload;
8139 }, [activeTriggerId, payload]);
8140 return `${activeTriggerId ?? "current"}-${contentKey}`;
8141 }
8142
8143 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8144 var React33 = __toESM(require_react(), 1);
8145 var ReactDOM6 = __toESM(require_react_dom(), 1);
8146 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8147 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8148 const {
8149 children,
8150 container,
8151 className,
8152 render: render4,
8153 style,
8154 ...elementProps
8155 } = componentProps;
8156 const {
8157 portalNode,
8158 portalSubtree
8159 } = useFloatingPortalNode({
8160 container,
8161 ref: forwardedRef,
8162 componentProps,
8163 elementProps
8164 });
8165 if (!portalSubtree && !portalNode) {
8166 return null;
8167 }
8168 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(React33.Fragment, {
8169 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8170 });
8171 });
8172 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8173
8174 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8175 var index_parts_exports = {};
8176 __export(index_parts_exports, {
8177 Arrow: () => TooltipArrow,
8178 Handle: () => TooltipHandle,
8179 Popup: () => TooltipPopup,
8180 Portal: () => TooltipPortal,
8181 Positioner: () => TooltipPositioner,
8182 Provider: () => TooltipProvider,
8183 Root: () => TooltipRoot,
8184 Trigger: () => TooltipTrigger,
8185 Viewport: () => TooltipViewport,
8186 createHandle: () => createTooltipHandle
8187 });
8188
8189 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8190 var React36 = __toESM(require_react(), 1);
8191
8192 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8193 var React34 = __toESM(require_react(), 1);
8194 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8195 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8196 function useTooltipRootContext(optional) {
8197 const context = React34.useContext(TooltipRootContext);
8198 if (context === void 0 && !optional) {
8199 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8200 }
8201 return context;
8202 }
8203
8204 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8205 var React35 = __toESM(require_react(), 1);
8206 var ReactDOM7 = __toESM(require_react_dom(), 1);
8207 var selectors2 = {
8208 ...popupStoreSelectors,
8209 disabled: createSelector((state) => state.disabled),
8210 instantType: createSelector((state) => state.instantType),
8211 isInstantPhase: createSelector((state) => state.isInstantPhase),
8212 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8213 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8214 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8215 closeOnClick: createSelector((state) => state.closeOnClick),
8216 closeDelay: createSelector((state) => state.closeDelay),
8217 hasViewport: createSelector((state) => state.hasViewport)
8218 };
8219 var TooltipStore = class _TooltipStore extends ReactStore {
8220 constructor(initialState, floatingId, nested = false) {
8221 const triggerElements = new PopupTriggerMap();
8222 const state = {
8223 ...createInitialState(),
8224 ...initialState
8225 };
8226 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8227 super(state, {
8228 popupRef: /* @__PURE__ */ React35.createRef(),
8229 onOpenChange: void 0,
8230 onOpenChangeComplete: void 0,
8231 triggerElements
8232 }, selectors2);
8233 }
8234 setOpen = (nextOpen, eventDetails) => {
8235 const reason = eventDetails.reason;
8236 const isHover = reason === reason_parts_exports.triggerHover;
8237 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8238 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8239 eventDetails.preventUnmountOnClose = () => {
8240 this.set("preventUnmountingOnClose", true);
8241 };
8242 this.context.onOpenChange?.(nextOpen, eventDetails);
8243 if (eventDetails.isCanceled) {
8244 return;
8245 }
8246 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8247 const changeState = () => {
8248 const updatedState = {
8249 open: nextOpen,
8250 openChangeReason: reason
8251 };
8252 if (isFocusOpen) {
8253 updatedState.instantType = "focus";
8254 } else if (isDismissClose) {
8255 updatedState.instantType = "dismiss";
8256 } else if (reason === reason_parts_exports.triggerHover) {
8257 updatedState.instantType = void 0;
8258 }
8259 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8260 this.update(updatedState);
8261 };
8262 if (isHover) {
8263 ReactDOM7.flushSync(changeState);
8264 } else {
8265 changeState();
8266 }
8267 };
8268 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8269 cancelPendingOpen(event) {
8270 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8271 }
8272 static useStore(externalStore, initialState) {
8273 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8274 return store;
8275 }
8276 };
8277 function createInitialState() {
8278 return {
8279 ...createInitialPopupStoreState(),
8280 disabled: false,
8281 instantType: void 0,
8282 isInstantPhase: false,
8283 trackCursorAxis: "none",
8284 disableHoverablePopup: false,
8285 openChangeReason: null,
8286 closeOnClick: true,
8287 closeDelay: 0,
8288 hasViewport: false
8289 };
8290 }
8291
8292 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8293 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8294 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8295 const {
8296 disabled: disabled2 = false,
8297 defaultOpen = false,
8298 open: openProp,
8299 disableHoverablePopup = false,
8300 trackCursorAxis = "none",
8301 actionsRef,
8302 onOpenChange,
8303 onOpenChangeComplete,
8304 handle,
8305 triggerId: triggerIdProp,
8306 defaultTriggerId: defaultTriggerIdProp = null,
8307 children
8308 } = props;
8309 const store = TooltipStore.useStore(handle?.store, {
8310 open: defaultOpen,
8311 openProp,
8312 activeTriggerId: defaultTriggerIdProp,
8313 triggerIdProp
8314 });
8315 useOnFirstRender(() => {
8316 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8317 store.update({
8318 open: true,
8319 activeTriggerId: defaultTriggerIdProp
8320 });
8321 }
8322 });
8323 store.useControlledProp("openProp", openProp);
8324 store.useControlledProp("triggerIdProp", triggerIdProp);
8325 store.useContextCallback("onOpenChange", onOpenChange);
8326 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8327 const openState = store.useState("open");
8328 const open = !disabled2 && openState;
8329 const activeTriggerId = store.useState("activeTriggerId");
8330 const mounted = store.useState("mounted");
8331 const payload = store.useState("payload");
8332 store.useSyncedValues({
8333 trackCursorAxis,
8334 disableHoverablePopup
8335 });
8336 store.useSyncedValue("disabled", disabled2);
8337 useImplicitActiveTrigger(store);
8338 const {
8339 forceUnmount,
8340 transitionStatus
8341 } = useOpenStateTransitions(open, store);
8342 const isInstantPhase = store.useState("isInstantPhase");
8343 const instantType = store.useState("instantType");
8344 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8345 const previousInstantTypeRef = React36.useRef(null);
8346 useIsoLayoutEffect(() => {
8347 if (openState && disabled2) {
8348 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8349 }
8350 }, [openState, disabled2, store]);
8351 useIsoLayoutEffect(() => {
8352 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8353 if (instantType !== "delay") {
8354 previousInstantTypeRef.current = instantType;
8355 }
8356 store.set("instantType", "delay");
8357 } else if (previousInstantTypeRef.current !== null) {
8358 store.set("instantType", previousInstantTypeRef.current);
8359 previousInstantTypeRef.current = null;
8360 }
8361 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8362 useIsoLayoutEffect(() => {
8363 if (open) {
8364 if (activeTriggerId == null) {
8365 store.set("payload", void 0);
8366 }
8367 }
8368 }, [store, activeTriggerId, open]);
8369 const handleImperativeClose = React36.useCallback(() => {
8370 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8371 }, [store]);
8372 React36.useImperativeHandle(actionsRef, () => ({
8373 unmount: forceUnmount,
8374 close: handleImperativeClose
8375 }), [forceUnmount, handleImperativeClose]);
8376 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8377 return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(TooltipRootContext.Provider, {
8378 value: store,
8379 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipInteractions, {
8380 store,
8381 disabled: disabled2,
8382 trackCursorAxis
8383 }), typeof children === "function" ? children({
8384 payload
8385 }) : children]
8386 });
8387 });
8388 if (true) TooltipRoot.displayName = "TooltipRoot";
8389 function TooltipInteractions({
8390 store,
8391 disabled: disabled2,
8392 trackCursorAxis
8393 }) {
8394 const floatingRootContext = store.useState("floatingRootContext");
8395 const dismiss = useDismiss(floatingRootContext, {
8396 enabled: !disabled2,
8397 referencePress: () => store.select("closeOnClick")
8398 });
8399 const clientPoint = useClientPoint(floatingRootContext, {
8400 enabled: !disabled2 && trackCursorAxis !== "none",
8401 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8402 });
8403 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8404 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8405 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8406 usePopupInteractionProps(store, {
8407 activeTriggerProps,
8408 inactiveTriggerProps,
8409 popupProps
8410 });
8411 return null;
8412 }
8413
8414 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8415 var React38 = __toESM(require_react(), 1);
8416
8417 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8418 var React37 = __toESM(require_react(), 1);
8419 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8420 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8421 function useTooltipProviderContext() {
8422 return React37.useContext(TooltipProviderContext);
8423 }
8424
8425 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8426 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8427 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8428 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8429 return TooltipTriggerDataAttributes2;
8430 })({});
8431
8432 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8433 var OPEN_DELAY = 600;
8434
8435 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8436 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8437 function getTargetElement(event) {
8438 if ("composedPath" in event) {
8439 const path = event.composedPath();
8440 for (let i2 = 0; i2 < path.length; i2 += 1) {
8441 const element = path[i2];
8442 if (isElement(element)) {
8443 return element;
8444 }
8445 }
8446 }
8447 const target = event.target;
8448 if (isElement(target)) {
8449 return target;
8450 }
8451 return null;
8452 }
8453 function closestEnabledTooltipTrigger(element) {
8454 let current = element;
8455 while (current) {
8456 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8457 return current;
8458 }
8459 const parentElement = current.parentElement;
8460 if (parentElement) {
8461 current = parentElement;
8462 continue;
8463 }
8464 const root = current.getRootNode();
8465 current = "host" in root && isElement(root.host) ? root.host : null;
8466 }
8467 return null;
8468 }
8469 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8470 const {
8471 render: render4,
8472 className,
8473 style,
8474 handle,
8475 payload,
8476 disabled: disabledProp,
8477 delay,
8478 closeOnClick = true,
8479 closeDelay,
8480 id: idProp,
8481 ...elementProps
8482 } = componentProps;
8483 const rootContext = useTooltipRootContext(true);
8484 const store = handle?.store ?? rootContext;
8485 if (!store) {
8486 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82));
8487 }
8488 const thisTriggerId = useBaseUiId(idProp);
8489 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8490 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8491 const floatingRootContext = store.useState("floatingRootContext");
8492 const triggerElementRef = React38.useRef(null);
8493 const delayWithDefault = delay ?? OPEN_DELAY;
8494 const closeDelayWithDefault = closeDelay ?? 0;
8495 const {
8496 registerTrigger,
8497 isMountedByThisTrigger
8498 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8499 payload,
8500 closeOnClick,
8501 closeDelay: closeDelayWithDefault
8502 });
8503 const providerContext = useTooltipProviderContext();
8504 const {
8505 delayRef,
8506 isInstantPhase,
8507 hasProvider
8508 } = useDelayGroup(floatingRootContext, {
8509 open: isOpenedByThisTrigger
8510 });
8511 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8512 store.useSyncedValue("isInstantPhase", isInstantPhase);
8513 const rootDisabled = store.useState("disabled");
8514 const disabled2 = disabledProp ?? rootDisabled;
8515 const disabledRef = useValueAsRef(disabled2);
8516 const trackCursorAxis = store.useState("trackCursorAxis");
8517 const disableHoverablePopup = store.useState("disableHoverablePopup");
8518 const isNestedTriggerHoveredRef = React38.useRef(false);
8519 const nestedTriggerOpenTimeout = useTimeout();
8520 const pointerTypeRef = React38.useRef(void 0);
8521 function getOpenDelay() {
8522 const providerDelay = providerContext?.delay;
8523 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8524 let computedOpenDelay = delayWithDefault;
8525 if (hasProvider) {
8526 if (groupOpenValue !== 0) {
8527 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8528 } else {
8529 computedOpenDelay = 0;
8530 }
8531 }
8532 return computedOpenDelay;
8533 }
8534 function isEnabledNestedTriggerTarget(target) {
8535 const triggerEl = triggerElementRef.current;
8536 if (!triggerEl || !target) {
8537 return false;
8538 }
8539 const nearestTrigger = closestEnabledTooltipTrigger(target);
8540 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8541 }
8542 function detectNestedTriggerHover(target) {
8543 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8544 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8545 if (nestedTriggerHovered) {
8546 hoverInteraction.openChangeTimeout.clear();
8547 hoverInteraction.restTimeout.clear();
8548 hoverInteraction.restTimeoutPending = false;
8549 nestedTriggerOpenTimeout.clear();
8550 }
8551 return nestedTriggerHovered;
8552 }
8553 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8554 enabled: !disabled2,
8555 mouseOnly: true,
8556 move: false,
8557 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8558 restMs: getOpenDelay,
8559 delay() {
8560 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8561 let computedCloseDelay = closeDelayWithDefault;
8562 if (closeDelay == null && hasProvider) {
8563 computedCloseDelay = closeValue;
8564 }
8565 return {
8566 close: computedCloseDelay
8567 };
8568 },
8569 triggerElementRef,
8570 isActiveTrigger: isTriggerActive,
8571 isClosing: () => store.select("transitionStatus") === "ending",
8572 shouldOpen() {
8573 return !isNestedTriggerHoveredRef.current;
8574 }
8575 });
8576 const focusProps = useFocus(floatingRootContext, {
8577 enabled: !disabled2
8578 }).reference;
8579 const handleNestedTriggerHover = (event) => {
8580 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8581 const target = getTargetElement(event);
8582 const nestedTriggerHovered = detectNestedTriggerHover(target);
8583 const triggerEl = triggerElementRef.current;
8584 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8585 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8586 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8587 return;
8588 }
8589 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8590 isMouseLikePointerType(pointerTypeRef.current)) {
8591 const open = () => {
8592 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8593 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8594 }
8595 };
8596 const openDelay = getOpenDelay();
8597 if (openDelay === 0) {
8598 nestedTriggerOpenTimeout.clear();
8599 open();
8600 } else {
8601 nestedTriggerOpenTimeout.start(openDelay, open);
8602 }
8603 }
8604 };
8605 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8606 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8607 const state = {
8608 open: isOpenedByThisTrigger
8609 };
8610 const element = useRenderElement("button", componentProps, {
8611 state,
8612 ref: [forwardedRef, registerTrigger, triggerElementRef],
8613 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8614 onMouseOver(event) {
8615 handleNestedTriggerHover(event.nativeEvent);
8616 },
8617 onFocus(event) {
8618 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8619 event.preventBaseUIHandler();
8620 }
8621 },
8622 onMouseLeave() {
8623 isNestedTriggerHoveredRef.current = false;
8624 nestedTriggerOpenTimeout.clear();
8625 pointerTypeRef.current = void 0;
8626 },
8627 onPointerEnter(event) {
8628 pointerTypeRef.current = event.pointerType;
8629 },
8630 onPointerDown(event) {
8631 pointerTypeRef.current = event.pointerType;
8632 store.set("closeOnClick", closeOnClick);
8633 if (closeOnClick && !store.select("open")) {
8634 store.cancelPendingOpen(event.nativeEvent);
8635 }
8636 },
8637 onClick(event) {
8638 if (closeOnClick && !store.select("open")) {
8639 store.cancelPendingOpen(event.nativeEvent);
8640 }
8641 },
8642 id: thisTriggerId,
8643 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8644 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8645 }, elementProps],
8646 stateAttributesMapping: triggerOpenStateMapping
8647 });
8648 return element;
8649 });
8650 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8651
8652 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8653 var React40 = __toESM(require_react(), 1);
8654
8655 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8656 var React39 = __toESM(require_react(), 1);
8657 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8658 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8659 function useTooltipPortalContext() {
8660 const value = React39.useContext(TooltipPortalContext);
8661 if (value === void 0) {
8662 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8663 }
8664 return value;
8665 }
8666
8667 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8668 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8669 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8670 const {
8671 keepMounted = false,
8672 ...portalProps
8673 } = props;
8674 const store = useTooltipRootContext();
8675 const mounted = store.useState("mounted");
8676 const shouldRender = mounted || keepMounted;
8677 if (!shouldRender) {
8678 return null;
8679 }
8680 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TooltipPortalContext.Provider, {
8681 value: keepMounted,
8682 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FloatingPortalLite, {
8683 ref: forwardedRef,
8684 ...portalProps
8685 })
8686 });
8687 });
8688 if (true) TooltipPortal.displayName = "TooltipPortal";
8689
8690 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8691 var React42 = __toESM(require_react(), 1);
8692
8693 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8694 var React41 = __toESM(require_react(), 1);
8695 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8696 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8697 function useTooltipPositionerContext() {
8698 const context = React41.useContext(TooltipPositionerContext);
8699 if (context === void 0) {
8700 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8701 }
8702 return context;
8703 }
8704
8705 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8706 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8707 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8708 const {
8709 render: render4,
8710 className,
8711 anchor,
8712 positionMethod = "absolute",
8713 side = "top",
8714 align = "center",
8715 sideOffset = 0,
8716 alignOffset = 0,
8717 collisionBoundary = "clipping-ancestors",
8718 collisionPadding = 5,
8719 arrowPadding = 5,
8720 sticky = false,
8721 disableAnchorTracking = false,
8722 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8723 style,
8724 ...elementProps
8725 } = componentProps;
8726 const store = useTooltipRootContext();
8727 const keepMounted = useTooltipPortalContext();
8728 const open = store.useState("open");
8729 const mounted = store.useState("mounted");
8730 const trackCursorAxis = store.useState("trackCursorAxis");
8731 const disableHoverablePopup = store.useState("disableHoverablePopup");
8732 const floatingRootContext = store.useState("floatingRootContext");
8733 const instantType = store.useState("instantType");
8734 const transitionStatus = store.useState("transitionStatus");
8735 const hasViewport = store.useState("hasViewport");
8736 const positioning = useAnchorPositioning({
8737 anchor,
8738 positionMethod,
8739 floatingRootContext,
8740 mounted,
8741 side,
8742 sideOffset,
8743 align,
8744 alignOffset,
8745 collisionBoundary,
8746 collisionPadding,
8747 sticky,
8748 arrowPadding,
8749 disableAnchorTracking,
8750 keepMounted,
8751 collisionAvoidance,
8752 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8753 });
8754 const state = React42.useMemo(() => ({
8755 open,
8756 side: positioning.side,
8757 align: positioning.align,
8758 anchorHidden: positioning.anchorHidden,
8759 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8760 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8761 const element = usePositioner(componentProps, state, {
8762 styles: positioning.positionerStyles,
8763 transitionStatus,
8764 props: elementProps,
8765 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8766 hidden: !mounted,
8767 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8768 });
8769 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(TooltipPositionerContext.Provider, {
8770 value: positioning,
8771 children: element
8772 });
8773 });
8774 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8775
8776 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8777 var React43 = __toESM(require_react(), 1);
8778 var stateAttributesMapping = {
8779 ...popupStateMapping,
8780 ...transitionStatusMapping
8781 };
8782 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8783 const {
8784 render: render4,
8785 className,
8786 style,
8787 ...elementProps
8788 } = componentProps;
8789 const store = useTooltipRootContext();
8790 const {
8791 side,
8792 align
8793 } = useTooltipPositionerContext();
8794 const open = store.useState("open");
8795 const instantType = store.useState("instantType");
8796 const transitionStatus = store.useState("transitionStatus");
8797 const popupProps = store.useState("popupProps");
8798 const floatingContext = store.useState("floatingRootContext");
8799 const disabled2 = store.useState("disabled");
8800 const closeDelay = store.useState("closeDelay");
8801 useOpenChangeComplete({
8802 open,
8803 ref: store.context.popupRef,
8804 onComplete() {
8805 if (open) {
8806 store.context.onOpenChangeComplete?.(true);
8807 }
8808 }
8809 });
8810 useHoverFloatingInteraction(floatingContext, {
8811 enabled: !disabled2,
8812 closeDelay
8813 });
8814 const setPopupElement = store.useStateSetter("popupElement");
8815 const state = {
8816 open,
8817 side,
8818 align,
8819 instant: instantType,
8820 transitionStatus
8821 };
8822 const element = useRenderElement("div", componentProps, {
8823 state,
8824 ref: [forwardedRef, store.context.popupRef, setPopupElement],
8825 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8826 stateAttributesMapping
8827 });
8828 return element;
8829 });
8830 if (true) TooltipPopup.displayName = "TooltipPopup";
8831
8832 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8833 var React44 = __toESM(require_react(), 1);
8834 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8835 const {
8836 render: render4,
8837 className,
8838 style,
8839 ...elementProps
8840 } = componentProps;
8841 const store = useTooltipRootContext();
8842 const {
8843 arrowRef,
8844 side,
8845 align,
8846 arrowUncentered,
8847 arrowStyles
8848 } = useTooltipPositionerContext();
8849 const open = store.useState("open");
8850 const instantType = store.useState("instantType");
8851 const state = {
8852 open,
8853 side,
8854 align,
8855 uncentered: arrowUncentered,
8856 instant: instantType
8857 };
8858 const element = useRenderElement("div", componentProps, {
8859 state,
8860 ref: [forwardedRef, arrowRef],
8861 props: [{
8862 style: arrowStyles,
8863 "aria-hidden": true
8864 }, elementProps],
8865 stateAttributesMapping: popupStateMapping
8866 });
8867 return element;
8868 });
8869 if (true) TooltipArrow.displayName = "TooltipArrow";
8870
8871 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8872 var React45 = __toESM(require_react(), 1);
8873 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8874 var TooltipProvider = function TooltipProvider2(props) {
8875 const {
8876 delay,
8877 closeDelay,
8878 timeout = 400
8879 } = props;
8880 const contextValue = React45.useMemo(() => ({
8881 delay,
8882 closeDelay
8883 }), [delay, closeDelay]);
8884 const delayValue = React45.useMemo(() => ({
8885 open: delay,
8886 close: closeDelay
8887 }), [delay, closeDelay]);
8888 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipProviderContext.Provider, {
8889 value: contextValue,
8890 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FloatingDelayGroup, {
8891 delay: delayValue,
8892 timeoutMs: timeout,
8893 children: props.children
8894 })
8895 });
8896 };
8897 if (true) TooltipProvider.displayName = "TooltipProvider";
8898
8899 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8900 var React46 = __toESM(require_react(), 1);
8901
8902 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8903 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8904 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8905 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8906 return TooltipViewportCssVars2;
8907 })({});
8908
8909 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8910 var stateAttributesMapping2 = {
8911 activationDirection: (value) => value ? {
8912 "data-activation-direction": value
8913 } : null
8914 };
8915 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8916 const {
8917 render: render4,
8918 className,
8919 style,
8920 children,
8921 ...elementProps
8922 } = componentProps;
8923 const store = useTooltipRootContext();
8924 const positioner = useTooltipPositionerContext();
8925 const instantType = store.useState("instantType");
8926 const {
8927 children: childrenToRender,
8928 state: viewportState
8929 } = usePopupViewport({
8930 store,
8931 side: positioner.side,
8932 cssVars: TooltipViewportCssVars,
8933 children
8934 });
8935 const state = {
8936 activationDirection: viewportState.activationDirection,
8937 transitioning: viewportState.transitioning,
8938 instant: instantType
8939 };
8940 return useRenderElement("div", componentProps, {
8941 state,
8942 ref: forwardedRef,
8943 props: [elementProps, {
8944 children: childrenToRender
8945 }],
8946 stateAttributesMapping: stateAttributesMapping2
8947 });
8948 });
8949 if (true) TooltipViewport.displayName = "TooltipViewport";
8950
8951 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8952 var TooltipHandle = class {
8953 /**
8954 * Internal store holding the tooltip state.
8955 * @internal
8956 */
8957 constructor() {
8958 this.store = new TooltipStore();
8959 }
8960 /**
8961 * Opens the tooltip and associates it with the trigger with the given ID.
8962 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8963 *
8964 * This method should only be called in an event handler or an effect (not during rendering).
8965 *
8966 * @param triggerId ID of the trigger to associate with the tooltip.
8967 */
8968 open(triggerId) {
8969 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8970 if (triggerId && !triggerElement) {
8971 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8972 }
8973 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8974 }
8975 /**
8976 * Closes the tooltip.
8977 */
8978 close() {
8979 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8980 }
8981 /**
8982 * Indicates whether the tooltip is currently open.
8983 */
8984 get isOpen() {
8985 return this.store.select("open");
8986 }
8987 };
8988 function createTooltipHandle() {
8989 return new TooltipHandle();
8990 }
8991
8992 // node_modules/@base-ui/react/esm/use-render/useRender.js
8993 function useRender(params) {
8994 return useRenderElement(params.defaultTagName ?? "div", params, params);
8995 }
8996
8997 // packages/ui/build-module/text/text.mjs
8998 var import_element11 = __toESM(require_element(), 1);
8999 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9000 function getRuntime() {
9001 const globalScope = globalThis;
9002 if (globalScope.__wpStyleRuntime) {
9003 return globalScope.__wpStyleRuntime;
9004 }
9005 globalScope.__wpStyleRuntime = {
9006 documents: /* @__PURE__ */ new Map(),
9007 styles: /* @__PURE__ */ new Map(),
9008 injectedStyles: /* @__PURE__ */ new WeakMap()
9009 };
9010 if (typeof document !== "undefined") {
9011 registerDocument(document);
9012 }
9013 return globalScope.__wpStyleRuntime;
9014 }
9015 function documentContainsStyleHash(targetDocument, hash) {
9016 if (!targetDocument.head) {
9017 return false;
9018 }
9019 for (const style of targetDocument.head.querySelectorAll(
9020 `style[${STYLE_HASH_ATTRIBUTE}]`
9021 )) {
9022 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9023 return true;
9024 }
9025 }
9026 return false;
9027 }
9028 function injectStyle(targetDocument, hash, css) {
9029 if (!targetDocument.head) {
9030 return;
9031 }
9032 const runtime = getRuntime();
9033 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9034 if (!injectedStyles) {
9035 injectedStyles = /* @__PURE__ */ new Set();
9036 runtime.injectedStyles.set(targetDocument, injectedStyles);
9037 }
9038 if (injectedStyles.has(hash)) {
9039 return;
9040 }
9041 if (documentContainsStyleHash(targetDocument, hash)) {
9042 injectedStyles.add(hash);
9043 return;
9044 }
9045 const style = targetDocument.createElement("style");
9046 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9047 style.appendChild(targetDocument.createTextNode(css));
9048 targetDocument.head.appendChild(style);
9049 injectedStyles.add(hash);
9050 }
9051 function registerDocument(targetDocument) {
9052 const runtime = getRuntime();
9053 runtime.documents.set(
9054 targetDocument,
9055 (runtime.documents.get(targetDocument) ?? 0) + 1
9056 );
9057 for (const [hash, css] of runtime.styles) {
9058 injectStyle(targetDocument, hash, css);
9059 }
9060 return () => {
9061 const count = runtime.documents.get(targetDocument);
9062 if (count === void 0) {
9063 return;
9064 }
9065 if (count <= 1) {
9066 runtime.documents.delete(targetDocument);
9067 return;
9068 }
9069 runtime.documents.set(targetDocument, count - 1);
9070 };
9071 }
9072 function registerStyle(hash, css) {
9073 const runtime = getRuntime();
9074 runtime.styles.set(hash, css);
9075 for (const targetDocument of runtime.documents.keys()) {
9076 injectStyle(targetDocument, hash, css);
9077 }
9078 }
9079 if (typeof process === "undefined" || true) {
9080 registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
9081 }
9082 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
9083 if (typeof process === "undefined" || true) {
9084 registerStyle("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
9085 }
9086 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
9087 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9088 const element = useRender({
9089 render: render4,
9090 defaultTagName: "span",
9091 ref,
9092 props: mergeProps(props, {
9093 className: clsx_default(
9094 style_default.text,
9095 global_css_defense_default.heading,
9096 global_css_defense_default.p,
9097 style_default[variant],
9098 className
9099 )
9100 })
9101 });
9102 return element;
9103 });
9104
9105 // packages/ui/build-module/icon/icon.mjs
9106 var import_element12 = __toESM(require_element(), 1);
9107 var import_primitives26 = __toESM(require_primitives(), 1);
9108 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9109 var Icon = (0, import_element12.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
9110 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9111 import_primitives26.SVG,
9112 {
9113 ref,
9114 ...icon.props,
9115 ...restProps,
9116 width: size4,
9117 height: size4
9118 }
9119 );
9120 });
9121
9122 // packages/ui/build-module/utils/render-slot-with-children.mjs
9123 var import_element13 = __toESM(require_element(), 1);
9124 function renderSlotWithChildren(slot, defaultSlot, children) {
9125 return (0, import_element13.cloneElement)(slot ?? defaultSlot, { children });
9126 }
9127
9128 // packages/ui/build-module/utils/theme-provider.mjs
9129 var theme = __toESM(require_theme(), 1);
9130
9131 // packages/ui/build-module/lock-unlock.mjs
9132 var import_private_apis = __toESM(require_private_apis(), 1);
9133 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9134 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9135 "@wordpress/ui"
9136 );
9137
9138 // packages/ui/build-module/utils/theme-provider.mjs
9139 function getThemeProvider() {
9140 const themePackage = theme;
9141 if (themePackage.ThemeProvider) {
9142 return themePackage.ThemeProvider;
9143 }
9144 if (!themePackage.privateApis) {
9145 throw new Error(
9146 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9147 );
9148 }
9149 return unlock(
9150 themePackage.privateApis
9151 ).ThemeProvider;
9152 }
9153 var ThemeProvider = getThemeProvider();
9154
9155 // packages/ui/build-module/stack/stack.mjs
9156 var import_element14 = __toESM(require_element(), 1);
9157 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9158 function getRuntime2() {
9159 const globalScope = globalThis;
9160 if (globalScope.__wpStyleRuntime) {
9161 return globalScope.__wpStyleRuntime;
9162 }
9163 globalScope.__wpStyleRuntime = {
9164 documents: /* @__PURE__ */ new Map(),
9165 styles: /* @__PURE__ */ new Map(),
9166 injectedStyles: /* @__PURE__ */ new WeakMap()
9167 };
9168 if (typeof document !== "undefined") {
9169 registerDocument2(document);
9170 }
9171 return globalScope.__wpStyleRuntime;
9172 }
9173 function documentContainsStyleHash2(targetDocument, hash) {
9174 if (!targetDocument.head) {
9175 return false;
9176 }
9177 for (const style of targetDocument.head.querySelectorAll(
9178 `style[${STYLE_HASH_ATTRIBUTE2}]`
9179 )) {
9180 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9181 return true;
9182 }
9183 }
9184 return false;
9185 }
9186 function injectStyle2(targetDocument, hash, css) {
9187 if (!targetDocument.head) {
9188 return;
9189 }
9190 const runtime = getRuntime2();
9191 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9192 if (!injectedStyles) {
9193 injectedStyles = /* @__PURE__ */ new Set();
9194 runtime.injectedStyles.set(targetDocument, injectedStyles);
9195 }
9196 if (injectedStyles.has(hash)) {
9197 return;
9198 }
9199 if (documentContainsStyleHash2(targetDocument, hash)) {
9200 injectedStyles.add(hash);
9201 return;
9202 }
9203 const style = targetDocument.createElement("style");
9204 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9205 style.appendChild(targetDocument.createTextNode(css));
9206 targetDocument.head.appendChild(style);
9207 injectedStyles.add(hash);
9208 }
9209 function registerDocument2(targetDocument) {
9210 const runtime = getRuntime2();
9211 runtime.documents.set(
9212 targetDocument,
9213 (runtime.documents.get(targetDocument) ?? 0) + 1
9214 );
9215 for (const [hash, css] of runtime.styles) {
9216 injectStyle2(targetDocument, hash, css);
9217 }
9218 return () => {
9219 const count = runtime.documents.get(targetDocument);
9220 if (count === void 0) {
9221 return;
9222 }
9223 if (count <= 1) {
9224 runtime.documents.delete(targetDocument);
9225 return;
9226 }
9227 runtime.documents.set(targetDocument, count - 1);
9228 };
9229 }
9230 function registerStyle2(hash, css) {
9231 const runtime = getRuntime2();
9232 runtime.styles.set(hash, css);
9233 for (const targetDocument of runtime.documents.keys()) {
9234 injectStyle2(targetDocument, hash, css);
9235 }
9236 }
9237 if (typeof process === "undefined" || true) {
9238 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9239 }
9240 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9241 var gapTokens = {
9242 xs: "var(--wpds-dimension-gap-xs, 4px)",
9243 sm: "var(--wpds-dimension-gap-sm, 8px)",
9244 md: "var(--wpds-dimension-gap-md, 12px)",
9245 lg: "var(--wpds-dimension-gap-lg, 16px)",
9246 xl: "var(--wpds-dimension-gap-xl, 24px)",
9247 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9248 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9249 };
9250 var Stack = (0, import_element14.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9251 const style = {
9252 gap: gap && gapTokens[gap],
9253 alignItems: align,
9254 justifyContent: justify,
9255 flexDirection: direction,
9256 flexWrap: wrap
9257 };
9258 const element = useRender({
9259 render: render4,
9260 ref,
9261 props: mergeProps(props, { style, className: style_default2.stack })
9262 });
9263 return element;
9264 });
9265
9266 // packages/ui/build-module/tooltip/index.mjs
9267 var tooltip_exports = {};
9268 __export(tooltip_exports, {
9269 Popup: () => Popup,
9270 Portal: () => Portal,
9271 Positioner: () => Positioner,
9272 Provider: () => Provider,
9273 Root: () => Root,
9274 Trigger: () => Trigger
9275 });
9276
9277 // packages/ui/build-module/tooltip/popup.mjs
9278 var import_element17 = __toESM(require_element(), 1);
9279
9280 // packages/ui/build-module/tooltip/portal.mjs
9281 var import_element15 = __toESM(require_element(), 1);
9282
9283 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9284 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9285 function getRuntime3() {
9286 const globalScope = globalThis;
9287 if (globalScope.__wpStyleRuntime) {
9288 return globalScope.__wpStyleRuntime;
9289 }
9290 globalScope.__wpStyleRuntime = {
9291 documents: /* @__PURE__ */ new Map(),
9292 styles: /* @__PURE__ */ new Map(),
9293 injectedStyles: /* @__PURE__ */ new WeakMap()
9294 };
9295 if (typeof document !== "undefined") {
9296 registerDocument3(document);
9297 }
9298 return globalScope.__wpStyleRuntime;
9299 }
9300 function documentContainsStyleHash3(targetDocument, hash) {
9301 if (!targetDocument.head) {
9302 return false;
9303 }
9304 for (const style of targetDocument.head.querySelectorAll(
9305 `style[${STYLE_HASH_ATTRIBUTE3}]`
9306 )) {
9307 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9308 return true;
9309 }
9310 }
9311 return false;
9312 }
9313 function injectStyle3(targetDocument, hash, css) {
9314 if (!targetDocument.head) {
9315 return;
9316 }
9317 const runtime = getRuntime3();
9318 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9319 if (!injectedStyles) {
9320 injectedStyles = /* @__PURE__ */ new Set();
9321 runtime.injectedStyles.set(targetDocument, injectedStyles);
9322 }
9323 if (injectedStyles.has(hash)) {
9324 return;
9325 }
9326 if (documentContainsStyleHash3(targetDocument, hash)) {
9327 injectedStyles.add(hash);
9328 return;
9329 }
9330 const style = targetDocument.createElement("style");
9331 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9332 style.appendChild(targetDocument.createTextNode(css));
9333 targetDocument.head.appendChild(style);
9334 injectedStyles.add(hash);
9335 }
9336 function registerDocument3(targetDocument) {
9337 const runtime = getRuntime3();
9338 runtime.documents.set(
9339 targetDocument,
9340 (runtime.documents.get(targetDocument) ?? 0) + 1
9341 );
9342 for (const [hash, css] of runtime.styles) {
9343 injectStyle3(targetDocument, hash, css);
9344 }
9345 return () => {
9346 const count = runtime.documents.get(targetDocument);
9347 if (count === void 0) {
9348 return;
9349 }
9350 if (count <= 1) {
9351 runtime.documents.delete(targetDocument);
9352 return;
9353 }
9354 runtime.documents.set(targetDocument, count - 1);
9355 };
9356 }
9357 function registerStyle3(hash, css) {
9358 const runtime = getRuntime3();
9359 runtime.styles.set(hash, css);
9360 for (const targetDocument of runtime.documents.keys()) {
9361 injectStyle3(targetDocument, hash, css);
9362 }
9363 }
9364 if (typeof process === "undefined" || true) {
9365 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}}}");
9366 }
9367 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9368 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9369 function resolveOwnerDocument() {
9370 return typeof document === "undefined" ? null : document;
9371 }
9372 function isInWordPressEnvironment() {
9373 let topWp;
9374 try {
9375 topWp = window.top?.wp;
9376 } catch {
9377 }
9378 const wp = topWp ?? window.wp;
9379 return typeof wp?.components === "object" && wp.components !== null;
9380 }
9381 var cachedSlot = null;
9382 function createSlot(ownerDocument2) {
9383 const element = ownerDocument2.createElement("div");
9384 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9385 if (wp_compat_overlay_slot_default.slot) {
9386 element.classList.add(wp_compat_overlay_slot_default.slot);
9387 }
9388 ownerDocument2.body.appendChild(element);
9389 return element;
9390 }
9391 function getWpCompatOverlaySlot() {
9392 if (typeof window === "undefined") {
9393 return void 0;
9394 }
9395 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9396 return void 0;
9397 }
9398 const ownerDocument2 = resolveOwnerDocument();
9399 if (!ownerDocument2 || !ownerDocument2.body) {
9400 return void 0;
9401 }
9402 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9403 return cachedSlot;
9404 }
9405 const existing = ownerDocument2.querySelector(
9406 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9407 );
9408 if (existing instanceof HTMLDivElement) {
9409 cachedSlot = existing;
9410 return existing;
9411 }
9412 if (cachedSlot?.isConnected) {
9413 cachedSlot.remove();
9414 }
9415 cachedSlot = createSlot(ownerDocument2);
9416 return cachedSlot;
9417 }
9418
9419 // packages/ui/build-module/tooltip/portal.mjs
9420 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9421 var Portal = (0, import_element15.forwardRef)(
9422 function TooltipPortal3({ container, ...restProps }, ref) {
9423 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9424 index_parts_exports.Portal,
9425 {
9426 container: container ?? getWpCompatOverlaySlot(),
9427 ...restProps,
9428 ref
9429 }
9430 );
9431 }
9432 );
9433
9434 // packages/ui/build-module/tooltip/positioner.mjs
9435 var import_element16 = __toESM(require_element(), 1);
9436 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9437 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9438 function getRuntime4() {
9439 const globalScope = globalThis;
9440 if (globalScope.__wpStyleRuntime) {
9441 return globalScope.__wpStyleRuntime;
9442 }
9443 globalScope.__wpStyleRuntime = {
9444 documents: /* @__PURE__ */ new Map(),
9445 styles: /* @__PURE__ */ new Map(),
9446 injectedStyles: /* @__PURE__ */ new WeakMap()
9447 };
9448 if (typeof document !== "undefined") {
9449 registerDocument4(document);
9450 }
9451 return globalScope.__wpStyleRuntime;
9452 }
9453 function documentContainsStyleHash4(targetDocument, hash) {
9454 if (!targetDocument.head) {
9455 return false;
9456 }
9457 for (const style of targetDocument.head.querySelectorAll(
9458 `style[${STYLE_HASH_ATTRIBUTE4}]`
9459 )) {
9460 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9461 return true;
9462 }
9463 }
9464 return false;
9465 }
9466 function injectStyle4(targetDocument, hash, css) {
9467 if (!targetDocument.head) {
9468 return;
9469 }
9470 const runtime = getRuntime4();
9471 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9472 if (!injectedStyles) {
9473 injectedStyles = /* @__PURE__ */ new Set();
9474 runtime.injectedStyles.set(targetDocument, injectedStyles);
9475 }
9476 if (injectedStyles.has(hash)) {
9477 return;
9478 }
9479 if (documentContainsStyleHash4(targetDocument, hash)) {
9480 injectedStyles.add(hash);
9481 return;
9482 }
9483 const style = targetDocument.createElement("style");
9484 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9485 style.appendChild(targetDocument.createTextNode(css));
9486 targetDocument.head.appendChild(style);
9487 injectedStyles.add(hash);
9488 }
9489 function registerDocument4(targetDocument) {
9490 const runtime = getRuntime4();
9491 runtime.documents.set(
9492 targetDocument,
9493 (runtime.documents.get(targetDocument) ?? 0) + 1
9494 );
9495 for (const [hash, css] of runtime.styles) {
9496 injectStyle4(targetDocument, hash, css);
9497 }
9498 return () => {
9499 const count = runtime.documents.get(targetDocument);
9500 if (count === void 0) {
9501 return;
9502 }
9503 if (count <= 1) {
9504 runtime.documents.delete(targetDocument);
9505 return;
9506 }
9507 runtime.documents.set(targetDocument, count - 1);
9508 };
9509 }
9510 function registerStyle4(hash, css) {
9511 const runtime = getRuntime4();
9512 runtime.styles.set(hash, css);
9513 for (const targetDocument of runtime.documents.keys()) {
9514 injectStyle4(targetDocument, hash, css);
9515 }
9516 }
9517 if (typeof process === "undefined" || true) {
9518 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9519 }
9520 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9521 if (typeof process === "undefined" || true) {
9522 registerStyle4("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
9523 }
9524 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9525 var Positioner = (0, import_element16.forwardRef)(
9526 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9527 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9528 index_parts_exports.Positioner,
9529 {
9530 ref,
9531 align,
9532 side,
9533 sideOffset,
9534 ...props,
9535 className: clsx_default(
9536 resets_default["box-sizing"],
9537 style_default3.positioner,
9538 className
9539 )
9540 }
9541 );
9542 }
9543 );
9544
9545 // packages/ui/build-module/tooltip/popup.mjs
9546 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9547 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9548 function getRuntime5() {
9549 const globalScope = globalThis;
9550 if (globalScope.__wpStyleRuntime) {
9551 return globalScope.__wpStyleRuntime;
9552 }
9553 globalScope.__wpStyleRuntime = {
9554 documents: /* @__PURE__ */ new Map(),
9555 styles: /* @__PURE__ */ new Map(),
9556 injectedStyles: /* @__PURE__ */ new WeakMap()
9557 };
9558 if (typeof document !== "undefined") {
9559 registerDocument5(document);
9560 }
9561 return globalScope.__wpStyleRuntime;
9562 }
9563 function documentContainsStyleHash5(targetDocument, hash) {
9564 if (!targetDocument.head) {
9565 return false;
9566 }
9567 for (const style of targetDocument.head.querySelectorAll(
9568 `style[${STYLE_HASH_ATTRIBUTE5}]`
9569 )) {
9570 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9571 return true;
9572 }
9573 }
9574 return false;
9575 }
9576 function injectStyle5(targetDocument, hash, css) {
9577 if (!targetDocument.head) {
9578 return;
9579 }
9580 const runtime = getRuntime5();
9581 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9582 if (!injectedStyles) {
9583 injectedStyles = /* @__PURE__ */ new Set();
9584 runtime.injectedStyles.set(targetDocument, injectedStyles);
9585 }
9586 if (injectedStyles.has(hash)) {
9587 return;
9588 }
9589 if (documentContainsStyleHash5(targetDocument, hash)) {
9590 injectedStyles.add(hash);
9591 return;
9592 }
9593 const style = targetDocument.createElement("style");
9594 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9595 style.appendChild(targetDocument.createTextNode(css));
9596 targetDocument.head.appendChild(style);
9597 injectedStyles.add(hash);
9598 }
9599 function registerDocument5(targetDocument) {
9600 const runtime = getRuntime5();
9601 runtime.documents.set(
9602 targetDocument,
9603 (runtime.documents.get(targetDocument) ?? 0) + 1
9604 );
9605 for (const [hash, css] of runtime.styles) {
9606 injectStyle5(targetDocument, hash, css);
9607 }
9608 return () => {
9609 const count = runtime.documents.get(targetDocument);
9610 if (count === void 0) {
9611 return;
9612 }
9613 if (count <= 1) {
9614 runtime.documents.delete(targetDocument);
9615 return;
9616 }
9617 runtime.documents.set(targetDocument, count - 1);
9618 };
9619 }
9620 function registerStyle5(hash, css) {
9621 const runtime = getRuntime5();
9622 runtime.styles.set(hash, css);
9623 for (const targetDocument of runtime.documents.keys()) {
9624 injectStyle5(targetDocument, hash, css);
9625 }
9626 }
9627 if (typeof process === "undefined" || true) {
9628 registerStyle5("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
9629 }
9630 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9631 var POPUP_COLOR = { background: "#1e1e1e" };
9632 var Popup = (0, import_element17.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9633 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9634 index_parts_exports.Popup,
9635 {
9636 ref,
9637 className: clsx_default(style_default4.popup, className),
9638 ...props,
9639 children
9640 }
9641 ) });
9642 const positionedPopup = renderSlotWithChildren(
9643 positioner,
9644 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Positioner, {}),
9645 popupContent
9646 );
9647 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Portal, {}), positionedPopup);
9648 });
9649
9650 // packages/ui/build-module/tooltip/trigger.mjs
9651 var import_element18 = __toESM(require_element(), 1);
9652 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9653 var Trigger = (0, import_element18.forwardRef)(
9654 function TooltipTrigger3(props, ref) {
9655 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(index_parts_exports.Trigger, { ref, ...props });
9656 }
9657 );
9658
9659 // packages/ui/build-module/tooltip/root.mjs
9660 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9661 function Root(props) {
9662 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Root, { ...props });
9663 }
9664
9665 // packages/ui/build-module/tooltip/provider.mjs
9666 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9667 function Provider({ ...props }) {
9668 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Provider, { ...props });
9669 }
9670
9671 // packages/ui/build-module/empty-state/index.mjs
9672 var empty_state_exports = {};
9673 __export(empty_state_exports, {
9674 Actions: () => Actions,
9675 Description: () => Description,
9676 Icon: () => Icon3,
9677 Root: () => Root2,
9678 Title: () => Title,
9679 Visual: () => Visual
9680 });
9681
9682 // packages/ui/build-module/empty-state/root.mjs
9683 var import_element19 = __toESM(require_element(), 1);
9684 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9685 function getRuntime6() {
9686 const globalScope = globalThis;
9687 if (globalScope.__wpStyleRuntime) {
9688 return globalScope.__wpStyleRuntime;
9689 }
9690 globalScope.__wpStyleRuntime = {
9691 documents: /* @__PURE__ */ new Map(),
9692 styles: /* @__PURE__ */ new Map(),
9693 injectedStyles: /* @__PURE__ */ new WeakMap()
9694 };
9695 if (typeof document !== "undefined") {
9696 registerDocument6(document);
9697 }
9698 return globalScope.__wpStyleRuntime;
9699 }
9700 function documentContainsStyleHash6(targetDocument, hash) {
9701 if (!targetDocument.head) {
9702 return false;
9703 }
9704 for (const style of targetDocument.head.querySelectorAll(
9705 `style[${STYLE_HASH_ATTRIBUTE6}]`
9706 )) {
9707 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9708 return true;
9709 }
9710 }
9711 return false;
9712 }
9713 function injectStyle6(targetDocument, hash, css) {
9714 if (!targetDocument.head) {
9715 return;
9716 }
9717 const runtime = getRuntime6();
9718 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9719 if (!injectedStyles) {
9720 injectedStyles = /* @__PURE__ */ new Set();
9721 runtime.injectedStyles.set(targetDocument, injectedStyles);
9722 }
9723 if (injectedStyles.has(hash)) {
9724 return;
9725 }
9726 if (documentContainsStyleHash6(targetDocument, hash)) {
9727 injectedStyles.add(hash);
9728 return;
9729 }
9730 const style = targetDocument.createElement("style");
9731 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9732 style.appendChild(targetDocument.createTextNode(css));
9733 targetDocument.head.appendChild(style);
9734 injectedStyles.add(hash);
9735 }
9736 function registerDocument6(targetDocument) {
9737 const runtime = getRuntime6();
9738 runtime.documents.set(
9739 targetDocument,
9740 (runtime.documents.get(targetDocument) ?? 0) + 1
9741 );
9742 for (const [hash, css] of runtime.styles) {
9743 injectStyle6(targetDocument, hash, css);
9744 }
9745 return () => {
9746 const count = runtime.documents.get(targetDocument);
9747 if (count === void 0) {
9748 return;
9749 }
9750 if (count <= 1) {
9751 runtime.documents.delete(targetDocument);
9752 return;
9753 }
9754 runtime.documents.set(targetDocument, count - 1);
9755 };
9756 }
9757 function registerStyle6(hash, css) {
9758 const runtime = getRuntime6();
9759 runtime.styles.set(hash, css);
9760 for (const targetDocument of runtime.documents.keys()) {
9761 injectStyle6(targetDocument, hash, css);
9762 }
9763 }
9764 if (typeof process === "undefined" || true) {
9765 registerStyle6("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
9766 }
9767 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9768 var Root2 = (0, import_element19.forwardRef)(
9769 function EmptyStateRoot({ render: render4, ...props }, ref) {
9770 const className = clsx_default(style_default5.root);
9771 const element = useRender({
9772 defaultTagName: "div",
9773 render: render4,
9774 ref,
9775 props: mergeProps({ className }, props)
9776 });
9777 return element;
9778 }
9779 );
9780
9781 // packages/ui/build-module/empty-state/visual.mjs
9782 var import_element20 = __toESM(require_element(), 1);
9783 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9784 function getRuntime7() {
9785 const globalScope = globalThis;
9786 if (globalScope.__wpStyleRuntime) {
9787 return globalScope.__wpStyleRuntime;
9788 }
9789 globalScope.__wpStyleRuntime = {
9790 documents: /* @__PURE__ */ new Map(),
9791 styles: /* @__PURE__ */ new Map(),
9792 injectedStyles: /* @__PURE__ */ new WeakMap()
9793 };
9794 if (typeof document !== "undefined") {
9795 registerDocument7(document);
9796 }
9797 return globalScope.__wpStyleRuntime;
9798 }
9799 function documentContainsStyleHash7(targetDocument, hash) {
9800 if (!targetDocument.head) {
9801 return false;
9802 }
9803 for (const style of targetDocument.head.querySelectorAll(
9804 `style[${STYLE_HASH_ATTRIBUTE7}]`
9805 )) {
9806 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9807 return true;
9808 }
9809 }
9810 return false;
9811 }
9812 function injectStyle7(targetDocument, hash, css) {
9813 if (!targetDocument.head) {
9814 return;
9815 }
9816 const runtime = getRuntime7();
9817 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9818 if (!injectedStyles) {
9819 injectedStyles = /* @__PURE__ */ new Set();
9820 runtime.injectedStyles.set(targetDocument, injectedStyles);
9821 }
9822 if (injectedStyles.has(hash)) {
9823 return;
9824 }
9825 if (documentContainsStyleHash7(targetDocument, hash)) {
9826 injectedStyles.add(hash);
9827 return;
9828 }
9829 const style = targetDocument.createElement("style");
9830 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9831 style.appendChild(targetDocument.createTextNode(css));
9832 targetDocument.head.appendChild(style);
9833 injectedStyles.add(hash);
9834 }
9835 function registerDocument7(targetDocument) {
9836 const runtime = getRuntime7();
9837 runtime.documents.set(
9838 targetDocument,
9839 (runtime.documents.get(targetDocument) ?? 0) + 1
9840 );
9841 for (const [hash, css] of runtime.styles) {
9842 injectStyle7(targetDocument, hash, css);
9843 }
9844 return () => {
9845 const count = runtime.documents.get(targetDocument);
9846 if (count === void 0) {
9847 return;
9848 }
9849 if (count <= 1) {
9850 runtime.documents.delete(targetDocument);
9851 return;
9852 }
9853 runtime.documents.set(targetDocument, count - 1);
9854 };
9855 }
9856 function registerStyle7(hash, css) {
9857 const runtime = getRuntime7();
9858 runtime.styles.set(hash, css);
9859 for (const targetDocument of runtime.documents.keys()) {
9860 injectStyle7(targetDocument, hash, css);
9861 }
9862 }
9863 if (typeof process === "undefined" || true) {
9864 registerStyle7("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
9865 }
9866 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9867 var Visual = (0, import_element20.forwardRef)(
9868 function EmptyStateVisual({ render: render4, ...props }, ref) {
9869 const className = clsx_default(style_default6.visual);
9870 const element = useRender({
9871 defaultTagName: "div",
9872 render: render4,
9873 ref,
9874 props: mergeProps({ className }, props)
9875 });
9876 return element;
9877 }
9878 );
9879
9880 // packages/ui/build-module/empty-state/icon.mjs
9881 var import_element21 = __toESM(require_element(), 1);
9882 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9883 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9884 function getRuntime8() {
9885 const globalScope = globalThis;
9886 if (globalScope.__wpStyleRuntime) {
9887 return globalScope.__wpStyleRuntime;
9888 }
9889 globalScope.__wpStyleRuntime = {
9890 documents: /* @__PURE__ */ new Map(),
9891 styles: /* @__PURE__ */ new Map(),
9892 injectedStyles: /* @__PURE__ */ new WeakMap()
9893 };
9894 if (typeof document !== "undefined") {
9895 registerDocument8(document);
9896 }
9897 return globalScope.__wpStyleRuntime;
9898 }
9899 function documentContainsStyleHash8(targetDocument, hash) {
9900 if (!targetDocument.head) {
9901 return false;
9902 }
9903 for (const style of targetDocument.head.querySelectorAll(
9904 `style[${STYLE_HASH_ATTRIBUTE8}]`
9905 )) {
9906 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9907 return true;
9908 }
9909 }
9910 return false;
9911 }
9912 function injectStyle8(targetDocument, hash, css) {
9913 if (!targetDocument.head) {
9914 return;
9915 }
9916 const runtime = getRuntime8();
9917 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9918 if (!injectedStyles) {
9919 injectedStyles = /* @__PURE__ */ new Set();
9920 runtime.injectedStyles.set(targetDocument, injectedStyles);
9921 }
9922 if (injectedStyles.has(hash)) {
9923 return;
9924 }
9925 if (documentContainsStyleHash8(targetDocument, hash)) {
9926 injectedStyles.add(hash);
9927 return;
9928 }
9929 const style = targetDocument.createElement("style");
9930 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9931 style.appendChild(targetDocument.createTextNode(css));
9932 targetDocument.head.appendChild(style);
9933 injectedStyles.add(hash);
9934 }
9935 function registerDocument8(targetDocument) {
9936 const runtime = getRuntime8();
9937 runtime.documents.set(
9938 targetDocument,
9939 (runtime.documents.get(targetDocument) ?? 0) + 1
9940 );
9941 for (const [hash, css] of runtime.styles) {
9942 injectStyle8(targetDocument, hash, css);
9943 }
9944 return () => {
9945 const count = runtime.documents.get(targetDocument);
9946 if (count === void 0) {
9947 return;
9948 }
9949 if (count <= 1) {
9950 runtime.documents.delete(targetDocument);
9951 return;
9952 }
9953 runtime.documents.set(targetDocument, count - 1);
9954 };
9955 }
9956 function registerStyle8(hash, css) {
9957 const runtime = getRuntime8();
9958 runtime.styles.set(hash, css);
9959 for (const targetDocument of runtime.documents.keys()) {
9960 injectStyle8(targetDocument, hash, css);
9961 }
9962 }
9963 if (typeof process === "undefined" || true) {
9964 registerStyle8("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
9965 }
9966 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9967 var Icon3 = (0, import_element21.forwardRef)(
9968 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9969 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9970 Visual,
9971 {
9972 ref,
9973 className: clsx_default(style_default7.icon, className),
9974 ...restProps,
9975 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon })
9976 }
9977 );
9978 }
9979 );
9980
9981 // packages/ui/build-module/empty-state/title.mjs
9982 var import_element22 = __toESM(require_element(), 1);
9983 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9984 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9985 function getRuntime9() {
9986 const globalScope = globalThis;
9987 if (globalScope.__wpStyleRuntime) {
9988 return globalScope.__wpStyleRuntime;
9989 }
9990 globalScope.__wpStyleRuntime = {
9991 documents: /* @__PURE__ */ new Map(),
9992 styles: /* @__PURE__ */ new Map(),
9993 injectedStyles: /* @__PURE__ */ new WeakMap()
9994 };
9995 if (typeof document !== "undefined") {
9996 registerDocument9(document);
9997 }
9998 return globalScope.__wpStyleRuntime;
9999 }
10000 function documentContainsStyleHash9(targetDocument, hash) {
10001 if (!targetDocument.head) {
10002 return false;
10003 }
10004 for (const style of targetDocument.head.querySelectorAll(
10005 `style[${STYLE_HASH_ATTRIBUTE9}]`
10006 )) {
10007 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
10008 return true;
10009 }
10010 }
10011 return false;
10012 }
10013 function injectStyle9(targetDocument, hash, css) {
10014 if (!targetDocument.head) {
10015 return;
10016 }
10017 const runtime = getRuntime9();
10018 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10019 if (!injectedStyles) {
10020 injectedStyles = /* @__PURE__ */ new Set();
10021 runtime.injectedStyles.set(targetDocument, injectedStyles);
10022 }
10023 if (injectedStyles.has(hash)) {
10024 return;
10025 }
10026 if (documentContainsStyleHash9(targetDocument, hash)) {
10027 injectedStyles.add(hash);
10028 return;
10029 }
10030 const style = targetDocument.createElement("style");
10031 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
10032 style.appendChild(targetDocument.createTextNode(css));
10033 targetDocument.head.appendChild(style);
10034 injectedStyles.add(hash);
10035 }
10036 function registerDocument9(targetDocument) {
10037 const runtime = getRuntime9();
10038 runtime.documents.set(
10039 targetDocument,
10040 (runtime.documents.get(targetDocument) ?? 0) + 1
10041 );
10042 for (const [hash, css] of runtime.styles) {
10043 injectStyle9(targetDocument, hash, css);
10044 }
10045 return () => {
10046 const count = runtime.documents.get(targetDocument);
10047 if (count === void 0) {
10048 return;
10049 }
10050 if (count <= 1) {
10051 runtime.documents.delete(targetDocument);
10052 return;
10053 }
10054 runtime.documents.set(targetDocument, count - 1);
10055 };
10056 }
10057 function registerStyle9(hash, css) {
10058 const runtime = getRuntime9();
10059 runtime.styles.set(hash, css);
10060 for (const targetDocument of runtime.documents.keys()) {
10061 injectStyle9(targetDocument, hash, css);
10062 }
10063 }
10064 if (typeof process === "undefined" || true) {
10065 registerStyle9("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
10066 }
10067 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10068 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h2", {});
10069 var Title = (0, import_element22.forwardRef)(
10070 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
10071 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
10072 Text,
10073 {
10074 ref,
10075 variant: "heading-lg",
10076 render: render4,
10077 className: clsx_default(style_default8.title, className),
10078 ...props,
10079 children
10080 }
10081 );
10082 }
10083 );
10084
10085 // packages/ui/build-module/empty-state/description.mjs
10086 var import_element23 = __toESM(require_element(), 1);
10087 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10088 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
10089 function getRuntime10() {
10090 const globalScope = globalThis;
10091 if (globalScope.__wpStyleRuntime) {
10092 return globalScope.__wpStyleRuntime;
10093 }
10094 globalScope.__wpStyleRuntime = {
10095 documents: /* @__PURE__ */ new Map(),
10096 styles: /* @__PURE__ */ new Map(),
10097 injectedStyles: /* @__PURE__ */ new WeakMap()
10098 };
10099 if (typeof document !== "undefined") {
10100 registerDocument10(document);
10101 }
10102 return globalScope.__wpStyleRuntime;
10103 }
10104 function documentContainsStyleHash10(targetDocument, hash) {
10105 if (!targetDocument.head) {
10106 return false;
10107 }
10108 for (const style of targetDocument.head.querySelectorAll(
10109 `style[${STYLE_HASH_ATTRIBUTE10}]`
10110 )) {
10111 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
10112 return true;
10113 }
10114 }
10115 return false;
10116 }
10117 function injectStyle10(targetDocument, hash, css) {
10118 if (!targetDocument.head) {
10119 return;
10120 }
10121 const runtime = getRuntime10();
10122 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10123 if (!injectedStyles) {
10124 injectedStyles = /* @__PURE__ */ new Set();
10125 runtime.injectedStyles.set(targetDocument, injectedStyles);
10126 }
10127 if (injectedStyles.has(hash)) {
10128 return;
10129 }
10130 if (documentContainsStyleHash10(targetDocument, hash)) {
10131 injectedStyles.add(hash);
10132 return;
10133 }
10134 const style = targetDocument.createElement("style");
10135 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
10136 style.appendChild(targetDocument.createTextNode(css));
10137 targetDocument.head.appendChild(style);
10138 injectedStyles.add(hash);
10139 }
10140 function registerDocument10(targetDocument) {
10141 const runtime = getRuntime10();
10142 runtime.documents.set(
10143 targetDocument,
10144 (runtime.documents.get(targetDocument) ?? 0) + 1
10145 );
10146 for (const [hash, css] of runtime.styles) {
10147 injectStyle10(targetDocument, hash, css);
10148 }
10149 return () => {
10150 const count = runtime.documents.get(targetDocument);
10151 if (count === void 0) {
10152 return;
10153 }
10154 if (count <= 1) {
10155 runtime.documents.delete(targetDocument);
10156 return;
10157 }
10158 runtime.documents.set(targetDocument, count - 1);
10159 };
10160 }
10161 function registerStyle10(hash, css) {
10162 const runtime = getRuntime10();
10163 runtime.styles.set(hash, css);
10164 for (const targetDocument of runtime.documents.keys()) {
10165 injectStyle10(targetDocument, hash, css);
10166 }
10167 }
10168 if (typeof process === "undefined" || true) {
10169 registerStyle10("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
10170 }
10171 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10172 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", {});
10173 var Description = (0, import_element23.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10174 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10175 Text,
10176 {
10177 ref,
10178 variant: "body-md",
10179 render: render4,
10180 className: clsx_default(style_default9.description, className),
10181 ...props,
10182 children
10183 }
10184 );
10185 });
10186
10187 // packages/ui/build-module/empty-state/actions.mjs
10188 var import_element24 = __toESM(require_element(), 1);
10189 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10190 function getRuntime11() {
10191 const globalScope = globalThis;
10192 if (globalScope.__wpStyleRuntime) {
10193 return globalScope.__wpStyleRuntime;
10194 }
10195 globalScope.__wpStyleRuntime = {
10196 documents: /* @__PURE__ */ new Map(),
10197 styles: /* @__PURE__ */ new Map(),
10198 injectedStyles: /* @__PURE__ */ new WeakMap()
10199 };
10200 if (typeof document !== "undefined") {
10201 registerDocument11(document);
10202 }
10203 return globalScope.__wpStyleRuntime;
10204 }
10205 function documentContainsStyleHash11(targetDocument, hash) {
10206 if (!targetDocument.head) {
10207 return false;
10208 }
10209 for (const style of targetDocument.head.querySelectorAll(
10210 `style[${STYLE_HASH_ATTRIBUTE11}]`
10211 )) {
10212 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10213 return true;
10214 }
10215 }
10216 return false;
10217 }
10218 function injectStyle11(targetDocument, hash, css) {
10219 if (!targetDocument.head) {
10220 return;
10221 }
10222 const runtime = getRuntime11();
10223 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10224 if (!injectedStyles) {
10225 injectedStyles = /* @__PURE__ */ new Set();
10226 runtime.injectedStyles.set(targetDocument, injectedStyles);
10227 }
10228 if (injectedStyles.has(hash)) {
10229 return;
10230 }
10231 if (documentContainsStyleHash11(targetDocument, hash)) {
10232 injectedStyles.add(hash);
10233 return;
10234 }
10235 const style = targetDocument.createElement("style");
10236 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10237 style.appendChild(targetDocument.createTextNode(css));
10238 targetDocument.head.appendChild(style);
10239 injectedStyles.add(hash);
10240 }
10241 function registerDocument11(targetDocument) {
10242 const runtime = getRuntime11();
10243 runtime.documents.set(
10244 targetDocument,
10245 (runtime.documents.get(targetDocument) ?? 0) + 1
10246 );
10247 for (const [hash, css] of runtime.styles) {
10248 injectStyle11(targetDocument, hash, css);
10249 }
10250 return () => {
10251 const count = runtime.documents.get(targetDocument);
10252 if (count === void 0) {
10253 return;
10254 }
10255 if (count <= 1) {
10256 runtime.documents.delete(targetDocument);
10257 return;
10258 }
10259 runtime.documents.set(targetDocument, count - 1);
10260 };
10261 }
10262 function registerStyle11(hash, css) {
10263 const runtime = getRuntime11();
10264 runtime.styles.set(hash, css);
10265 for (const targetDocument of runtime.documents.keys()) {
10266 injectStyle11(targetDocument, hash, css);
10267 }
10268 }
10269 if (typeof process === "undefined" || true) {
10270 registerStyle11("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
10271 }
10272 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10273 var Actions = (0, import_element24.forwardRef)(
10274 function EmptyStateActions({ render: render4, ...props }, ref) {
10275 const className = clsx_default(style_default10.actions);
10276 const element = useRender({
10277 defaultTagName: "div",
10278 render: render4,
10279 ref,
10280 props: mergeProps({ className }, props)
10281 });
10282 return element;
10283 }
10284 );
10285
10286 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10287 var import_element25 = __toESM(require_element(), 1);
10288 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10289 function getRuntime12() {
10290 const globalScope = globalThis;
10291 if (globalScope.__wpStyleRuntime) {
10292 return globalScope.__wpStyleRuntime;
10293 }
10294 globalScope.__wpStyleRuntime = {
10295 documents: /* @__PURE__ */ new Map(),
10296 styles: /* @__PURE__ */ new Map(),
10297 injectedStyles: /* @__PURE__ */ new WeakMap()
10298 };
10299 if (typeof document !== "undefined") {
10300 registerDocument12(document);
10301 }
10302 return globalScope.__wpStyleRuntime;
10303 }
10304 function documentContainsStyleHash12(targetDocument, hash) {
10305 if (!targetDocument.head) {
10306 return false;
10307 }
10308 for (const style of targetDocument.head.querySelectorAll(
10309 `style[${STYLE_HASH_ATTRIBUTE12}]`
10310 )) {
10311 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10312 return true;
10313 }
10314 }
10315 return false;
10316 }
10317 function injectStyle12(targetDocument, hash, css) {
10318 if (!targetDocument.head) {
10319 return;
10320 }
10321 const runtime = getRuntime12();
10322 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10323 if (!injectedStyles) {
10324 injectedStyles = /* @__PURE__ */ new Set();
10325 runtime.injectedStyles.set(targetDocument, injectedStyles);
10326 }
10327 if (injectedStyles.has(hash)) {
10328 return;
10329 }
10330 if (documentContainsStyleHash12(targetDocument, hash)) {
10331 injectedStyles.add(hash);
10332 return;
10333 }
10334 const style = targetDocument.createElement("style");
10335 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10336 style.appendChild(targetDocument.createTextNode(css));
10337 targetDocument.head.appendChild(style);
10338 injectedStyles.add(hash);
10339 }
10340 function registerDocument12(targetDocument) {
10341 const runtime = getRuntime12();
10342 runtime.documents.set(
10343 targetDocument,
10344 (runtime.documents.get(targetDocument) ?? 0) + 1
10345 );
10346 for (const [hash, css] of runtime.styles) {
10347 injectStyle12(targetDocument, hash, css);
10348 }
10349 return () => {
10350 const count = runtime.documents.get(targetDocument);
10351 if (count === void 0) {
10352 return;
10353 }
10354 if (count <= 1) {
10355 runtime.documents.delete(targetDocument);
10356 return;
10357 }
10358 runtime.documents.set(targetDocument, count - 1);
10359 };
10360 }
10361 function registerStyle12(hash, css) {
10362 const runtime = getRuntime12();
10363 runtime.styles.set(hash, css);
10364 for (const targetDocument of runtime.documents.keys()) {
10365 injectStyle12(targetDocument, hash, css);
10366 }
10367 }
10368 if (typeof process === "undefined" || true) {
10369 registerStyle12("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
10370 }
10371 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10372 var VisuallyHidden = (0, import_element25.forwardRef)(
10373 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10374 const element = useRender({
10375 render: render4,
10376 ref,
10377 props: mergeProps(
10378 { className: style_default11["visually-hidden"] },
10379 restProps,
10380 {
10381 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10382 "data-visually-hidden": ""
10383 }
10384 )
10385 });
10386 return element;
10387 }
10388 );
10389
10390 // packages/ui/build-module/link/link.mjs
10391 var import_element26 = __toESM(require_element(), 1);
10392 var import_i18n = __toESM(require_i18n(), 1);
10393 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10394 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10395 function getRuntime13() {
10396 const globalScope = globalThis;
10397 if (globalScope.__wpStyleRuntime) {
10398 return globalScope.__wpStyleRuntime;
10399 }
10400 globalScope.__wpStyleRuntime = {
10401 documents: /* @__PURE__ */ new Map(),
10402 styles: /* @__PURE__ */ new Map(),
10403 injectedStyles: /* @__PURE__ */ new WeakMap()
10404 };
10405 if (typeof document !== "undefined") {
10406 registerDocument13(document);
10407 }
10408 return globalScope.__wpStyleRuntime;
10409 }
10410 function documentContainsStyleHash13(targetDocument, hash) {
10411 if (!targetDocument.head) {
10412 return false;
10413 }
10414 for (const style of targetDocument.head.querySelectorAll(
10415 `style[${STYLE_HASH_ATTRIBUTE13}]`
10416 )) {
10417 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10418 return true;
10419 }
10420 }
10421 return false;
10422 }
10423 function injectStyle13(targetDocument, hash, css) {
10424 if (!targetDocument.head) {
10425 return;
10426 }
10427 const runtime = getRuntime13();
10428 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10429 if (!injectedStyles) {
10430 injectedStyles = /* @__PURE__ */ new Set();
10431 runtime.injectedStyles.set(targetDocument, injectedStyles);
10432 }
10433 if (injectedStyles.has(hash)) {
10434 return;
10435 }
10436 if (documentContainsStyleHash13(targetDocument, hash)) {
10437 injectedStyles.add(hash);
10438 return;
10439 }
10440 const style = targetDocument.createElement("style");
10441 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10442 style.appendChild(targetDocument.createTextNode(css));
10443 targetDocument.head.appendChild(style);
10444 injectedStyles.add(hash);
10445 }
10446 function registerDocument13(targetDocument) {
10447 const runtime = getRuntime13();
10448 runtime.documents.set(
10449 targetDocument,
10450 (runtime.documents.get(targetDocument) ?? 0) + 1
10451 );
10452 for (const [hash, css] of runtime.styles) {
10453 injectStyle13(targetDocument, hash, css);
10454 }
10455 return () => {
10456 const count = runtime.documents.get(targetDocument);
10457 if (count === void 0) {
10458 return;
10459 }
10460 if (count <= 1) {
10461 runtime.documents.delete(targetDocument);
10462 return;
10463 }
10464 runtime.documents.set(targetDocument, count - 1);
10465 };
10466 }
10467 function registerStyle13(hash, css) {
10468 const runtime = getRuntime13();
10469 runtime.styles.set(hash, css);
10470 for (const targetDocument of runtime.documents.keys()) {
10471 injectStyle13(targetDocument, hash, css);
10472 }
10473 }
10474 if (typeof process === "undefined" || true) {
10475 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10476 }
10477 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10478 if (typeof process === "undefined" || true) {
10479 registerStyle13("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
10480 }
10481 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
10482 if (typeof process === "undefined" || true) {
10483 registerStyle13("7e0119b657", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
10484 }
10485 var style_default12 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10486 if (typeof process === "undefined" || true) {
10487 registerStyle13("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10488 }
10489 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
10490 var Link = (0, import_element26.forwardRef)(function Link2({
10491 children,
10492 variant = "default",
10493 tone = "brand",
10494 openInNewTab = false,
10495 render: render4,
10496 className,
10497 ...props
10498 }, ref) {
10499 const element = useRender({
10500 render: render4,
10501 defaultTagName: "a",
10502 ref,
10503 props: mergeProps(props, {
10504 className: clsx_default(
10505 global_css_defense_default2.a,
10506 resets_default2["box-sizing"],
10507 focus_default["outset-ring--focus"],
10508 variant !== "unstyled" && style_default12.link,
10509 variant !== "unstyled" && style_default12[`is-${tone}`],
10510 variant === "unstyled" && style_default12["is-unstyled"],
10511 className
10512 ),
10513 target: openInNewTab ? "_blank" : void 0,
10514 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
10515 children,
10516 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10517 "span",
10518 {
10519 className: style_default12["link-icon"],
10520 role: "img",
10521 "aria-label": (
10522 /* translators: accessibility text appended to link text */
10523 (0, import_i18n.__)("(opens in a new tab)")
10524 )
10525 }
10526 )
10527 ] })
10528 })
10529 });
10530 return element;
10531 });
10532
10533 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10534 var import_element27 = __toESM(require_element(), 1);
10535
10536 // packages/dataviews/build-module/constants.mjs
10537 var import_i18n2 = __toESM(require_i18n(), 1);
10538 var OPERATOR_IS_ANY = "isAny";
10539 var OPERATOR_IS_NONE = "isNone";
10540 var OPERATOR_IS_ALL = "isAll";
10541 var OPERATOR_IS_NOT_ALL = "isNotAll";
10542 var OPERATOR_BETWEEN = "between";
10543 var OPERATOR_IN_THE_PAST = "inThePast";
10544 var OPERATOR_OVER = "over";
10545 var OPERATOR_IS = "is";
10546 var OPERATOR_IS_NOT = "isNot";
10547 var OPERATOR_LESS_THAN = "lessThan";
10548 var OPERATOR_GREATER_THAN = "greaterThan";
10549 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10550 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10551 var OPERATOR_BEFORE = "before";
10552 var OPERATOR_AFTER = "after";
10553 var OPERATOR_BEFORE_INC = "beforeInc";
10554 var OPERATOR_AFTER_INC = "afterInc";
10555 var OPERATOR_CONTAINS = "contains";
10556 var OPERATOR_NOT_CONTAINS = "notContains";
10557 var OPERATOR_STARTS_WITH = "startsWith";
10558 var OPERATOR_ON = "on";
10559 var OPERATOR_NOT_ON = "notOn";
10560 var SORTING_DIRECTIONS = ["asc", "desc"];
10561 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10562 var sortValues = { asc: "ascending", desc: "descending" };
10563 var sortLabels = {
10564 asc: (0, import_i18n2.__)("Sort ascending"),
10565 desc: (0, import_i18n2.__)("Sort descending")
10566 };
10567 var sortIcons = {
10568 asc: arrow_up_default,
10569 desc: arrow_down_default
10570 };
10571 var LAYOUT_TABLE = "table";
10572 var LAYOUT_GRID = "grid";
10573 var LAYOUT_LIST = "list";
10574 var LAYOUT_ACTIVITY = "activity";
10575 var LAYOUT_PICKER_GRID = "pickerGrid";
10576 var LAYOUT_PICKER_TABLE = "pickerTable";
10577 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10578
10579 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10580 var DataViewsContext = (0, import_element27.createContext)({
10581 view: { type: LAYOUT_TABLE },
10582 onChangeView: () => {
10583 },
10584 fields: [],
10585 data: [],
10586 paginationInfo: {
10587 totalItems: 0,
10588 totalPages: 0
10589 },
10590 selection: [],
10591 onChangeSelection: () => {
10592 },
10593 setOpenedFilter: () => {
10594 },
10595 openedFilter: null,
10596 getItemId: (item) => item.id,
10597 isItemClickable: () => true,
10598 renderItemLink: void 0,
10599 containerWidth: 0,
10600 containerRef: (0, import_element27.createRef)(),
10601 resizeObserverRef: () => {
10602 },
10603 defaultLayouts: { list: {}, grid: {}, table: {} },
10604 filters: [],
10605 isShowingFilter: false,
10606 setIsShowingFilter: () => {
10607 },
10608 hasInitiallyLoaded: false,
10609 config: {
10610 perPageSizes: []
10611 },
10612 intersectionObserver: null
10613 });
10614 DataViewsContext.displayName = "DataViewsContext";
10615 var dataviews_context_default = DataViewsContext;
10616
10617 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10618 var import_i18n23 = __toESM(require_i18n(), 1);
10619
10620 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10621 var import_i18n10 = __toESM(require_i18n(), 1);
10622 var import_components6 = __toESM(require_components(), 1);
10623 var import_element35 = __toESM(require_element(), 1);
10624 var import_keycodes = __toESM(require_keycodes(), 1);
10625
10626 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10627 var import_components = __toESM(require_components(), 1);
10628 var import_i18n3 = __toESM(require_i18n(), 1);
10629 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10630 function DataViewsSelectionCheckbox({
10631 selection,
10632 onChangeSelection,
10633 item,
10634 getItemId,
10635 titleField,
10636 disabled: disabled2,
10637 ...extraProps
10638 }) {
10639 const id = getItemId(item);
10640 const isInSelectionArray = selection.includes(id);
10641 const checked = !disabled2 && isInSelectionArray;
10642 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10643 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10644 import_components.CheckboxControl,
10645 {
10646 className: "dataviews-selection-checkbox",
10647 "aria-label": selectionLabel,
10648 "aria-disabled": disabled2,
10649 checked,
10650 onChange: () => {
10651 if (disabled2) {
10652 return;
10653 }
10654 onChangeSelection(
10655 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10656 );
10657 },
10658 ...extraProps
10659 }
10660 );
10661 }
10662
10663 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10664 var import_components2 = __toESM(require_components(), 1);
10665 var import_i18n4 = __toESM(require_i18n(), 1);
10666 var import_element28 = __toESM(require_element(), 1);
10667 var import_data = __toESM(require_data(), 1);
10668 var import_compose = __toESM(require_compose(), 1);
10669
10670 // packages/dataviews/build-module/lock-unlock.mjs
10671 var import_private_apis2 = __toESM(require_private_apis(), 1);
10672 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10673 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10674 "@wordpress/dataviews"
10675 );
10676
10677 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10678 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10679 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10680 function ButtonTrigger({
10681 action,
10682 onClick,
10683 items,
10684 variant
10685 }) {
10686 const label = typeof action.label === "string" ? action.label : action.label(items);
10687 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10688 import_components2.Button,
10689 {
10690 disabled: !!action.disabled,
10691 accessibleWhenDisabled: true,
10692 size: "compact",
10693 variant,
10694 onClick,
10695 children: label
10696 }
10697 );
10698 }
10699 function MenuItemTrigger({
10700 action,
10701 onClick,
10702 items
10703 }) {
10704 const label = typeof action.label === "string" ? action.label : action.label(items);
10705 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) });
10706 }
10707 function ActionModal({
10708 action,
10709 items,
10710 closeModal
10711 }) {
10712 const label = typeof action.label === "string" ? action.label : action.label(items);
10713 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10714 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10715 import_components2.Modal,
10716 {
10717 title: modalHeader || label,
10718 __experimentalHideHeader: !!action.hideModalHeader,
10719 onRequestClose: closeModal,
10720 focusOnMount: action.modalFocusOnMount ?? true,
10721 size: action.modalSize || "medium",
10722 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10723 action.id
10724 )}`,
10725 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal })
10726 }
10727 );
10728 }
10729 function ActionsMenuGroup({
10730 actions,
10731 item,
10732 registry,
10733 setActiveModalAction
10734 }) {
10735 const { primaryActions, regularActions } = (0, import_element28.useMemo)(() => {
10736 return actions.reduce(
10737 (acc, action) => {
10738 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10739 return acc;
10740 },
10741 {
10742 primaryActions: [],
10743 regularActions: []
10744 }
10745 );
10746 }, [actions]);
10747 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10748 MenuItemTrigger,
10749 {
10750 action,
10751 onClick: () => {
10752 if ("RenderModal" in action) {
10753 setActiveModalAction(action);
10754 return;
10755 }
10756 action.callback([item], { registry });
10757 },
10758 items: [item]
10759 },
10760 action.id
10761 ));
10762 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [
10763 renderActionGroup(primaryActions),
10764 renderActionGroup(regularActions)
10765 ] });
10766 }
10767 function ItemActions({
10768 item,
10769 actions,
10770 isCompact
10771 }) {
10772 const registry = (0, import_data.useRegistry)();
10773 const { primaryActions, eligibleActions } = (0, import_element28.useMemo)(() => {
10774 const _eligibleActions = actions.filter(
10775 (action) => !action.isEligible || action.isEligible(item)
10776 );
10777 const _primaryActions = _eligibleActions.filter(
10778 (action) => action.isPrimary
10779 );
10780 return {
10781 primaryActions: _primaryActions,
10782 eligibleActions: _eligibleActions
10783 };
10784 }, [actions, item]);
10785 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10786 if (isCompact) {
10787 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10788 CompactItemActions,
10789 {
10790 item,
10791 actions: eligibleActions,
10792 isSmall: true,
10793 registry
10794 }
10795 );
10796 }
10797 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
10798 Stack,
10799 {
10800 direction: "row",
10801 justify: "flex-end",
10802 className: "dataviews-item-actions",
10803 style: {
10804 flexShrink: 0,
10805 width: "auto"
10806 },
10807 children: [
10808 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10809 PrimaryActions,
10810 {
10811 item,
10812 actions: primaryActions,
10813 registry
10814 }
10815 ),
10816 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10817 // there if there are any actions at all.
10818 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10819 CompactItemActions,
10820 {
10821 item,
10822 actions: eligibleActions,
10823 registry
10824 }
10825 )
10826 ]
10827 }
10828 );
10829 }
10830 function CompactItemActions({
10831 item,
10832 actions,
10833 isSmall,
10834 registry
10835 }) {
10836 const [activeModalAction, setActiveModalAction] = (0, import_element28.useState)(
10837 null
10838 );
10839 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10840 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [
10841 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10842 Menu.TriggerButton,
10843 {
10844 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10845 import_components2.Button,
10846 {
10847 size: isSmall ? "small" : "compact",
10848 icon: more_vertical_default,
10849 label: (0, import_i18n4.__)("Actions"),
10850 accessibleWhenDisabled: true,
10851 disabled: !actions.length,
10852 className: "dataviews-all-actions-button"
10853 }
10854 )
10855 }
10856 ),
10857 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10858 ActionsMenuGroup,
10859 {
10860 actions,
10861 item,
10862 registry,
10863 setActiveModalAction
10864 }
10865 ) })
10866 ] }),
10867 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10868 ActionModal,
10869 {
10870 action: activeModalAction,
10871 items: [item],
10872 closeModal: () => setActiveModalAction(null)
10873 }
10874 )
10875 ] });
10876 }
10877 function PrimaryActions({
10878 item,
10879 actions,
10880 registry,
10881 buttonVariant
10882 }) {
10883 const [activeModalAction, setActiveModalAction] = (0, import_element28.useState)(null);
10884 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10885 if (isMobileViewport) {
10886 return null;
10887 }
10888 if (!Array.isArray(actions) || actions.length === 0) {
10889 return null;
10890 }
10891 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10892 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10893 ButtonTrigger,
10894 {
10895 action,
10896 onClick: () => {
10897 if ("RenderModal" in action) {
10898 setActiveModalAction(action);
10899 return;
10900 }
10901 action.callback([item], { registry });
10902 },
10903 items: [item],
10904 variant: buttonVariant
10905 },
10906 action.id
10907 )),
10908 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10909 ActionModal,
10910 {
10911 action: activeModalAction,
10912 items: [item],
10913 closeModal: () => setActiveModalAction(null)
10914 }
10915 )
10916 ] });
10917 }
10918
10919 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10920 var import_components3 = __toESM(require_components(), 1);
10921 var import_i18n6 = __toESM(require_i18n(), 1);
10922 var import_element29 = __toESM(require_element(), 1);
10923 var import_data2 = __toESM(require_data(), 1);
10924 var import_compose2 = __toESM(require_compose(), 1);
10925
10926 // packages/dataviews/build-module/utils/get-footer-message.mjs
10927 var import_i18n5 = __toESM(require_i18n(), 1);
10928 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10929 if (selectionCount > 0) {
10930 return (0, import_i18n5.sprintf)(
10931 /* translators: %d: number of items. */
10932 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10933 selectionCount
10934 );
10935 }
10936 if (onlyTotalCount || totalItems <= itemsCount) {
10937 return (0, import_i18n5.sprintf)(
10938 /* translators: %d: number of items. */
10939 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10940 totalItems
10941 );
10942 }
10943 return (0, import_i18n5.sprintf)(
10944 /* translators: %1$d: number of items. %2$d: total number of items. */
10945 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10946 itemsCount,
10947 totalItems
10948 );
10949 }
10950
10951 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10952 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10953 function ActionWithModal({
10954 action,
10955 items,
10956 ActionTriggerComponent
10957 }) {
10958 const [isModalOpen, setIsModalOpen] = (0, import_element29.useState)(false);
10959 const actionTriggerProps = {
10960 action,
10961 onClick: () => {
10962 setIsModalOpen(true);
10963 },
10964 items
10965 };
10966 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10967 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10968 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10969 ActionModal,
10970 {
10971 action,
10972 items,
10973 closeModal: () => setIsModalOpen(false)
10974 }
10975 )
10976 ] });
10977 }
10978 function useHasAPossibleBulkAction(actions, item) {
10979 return (0, import_element29.useMemo)(() => {
10980 return actions.some((action) => {
10981 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10982 });
10983 }, [actions, item]);
10984 }
10985 function useSomeItemHasAPossibleBulkAction(actions, data) {
10986 return (0, import_element29.useMemo)(() => {
10987 return data.some((item) => {
10988 return actions.some((action) => {
10989 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10990 });
10991 });
10992 }, [actions, data]);
10993 }
10994 function BulkSelectionCheckbox({
10995 selection,
10996 onChangeSelection,
10997 data,
10998 actions,
10999 getItemId,
11000 disableSelectAll = false
11001 }) {
11002 const selectableItems = (0, import_element29.useMemo)(() => {
11003 return data.filter((item) => {
11004 return actions.some(
11005 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11006 );
11007 });
11008 }, [data, actions]);
11009 const selectedItems = data.filter(
11010 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11011 );
11012 const hasSelection = selection.length > 0;
11013 const areAllSelected = selectedItems.length === selectableItems.length;
11014 if (disableSelectAll) {
11015 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11016 import_components3.CheckboxControl,
11017 {
11018 className: "dataviews-view-table-selection-checkbox",
11019 checked: hasSelection,
11020 disabled: !hasSelection,
11021 onChange: () => {
11022 onChangeSelection([]);
11023 },
11024 "aria-label": (0, import_i18n6.__)("Deselect all")
11025 }
11026 );
11027 }
11028 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11029 import_components3.CheckboxControl,
11030 {
11031 className: "dataviews-view-table-selection-checkbox",
11032 checked: areAllSelected,
11033 indeterminate: !areAllSelected && !!selectedItems.length,
11034 onChange: () => {
11035 if (areAllSelected) {
11036 onChangeSelection([]);
11037 } else {
11038 onChangeSelection(
11039 selectableItems.map((item) => getItemId(item))
11040 );
11041 }
11042 },
11043 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
11044 }
11045 );
11046 }
11047 function ActionTrigger({
11048 action,
11049 onClick,
11050 isBusy,
11051 items
11052 }) {
11053 const label = typeof action.label === "string" ? action.label : action.label(items);
11054 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11055 if (isMobile) {
11056 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11057 import_components3.Button,
11058 {
11059 disabled: isBusy,
11060 accessibleWhenDisabled: true,
11061 label,
11062 icon: action.icon,
11063 size: "compact",
11064 onClick,
11065 isBusy
11066 }
11067 );
11068 }
11069 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11070 import_components3.Button,
11071 {
11072 disabled: isBusy,
11073 accessibleWhenDisabled: true,
11074 size: "compact",
11075 onClick,
11076 isBusy,
11077 children: label
11078 }
11079 );
11080 }
11081 var EMPTY_ARRAY2 = [];
11082 function ActionButton({
11083 action,
11084 selectedItems,
11085 actionInProgress,
11086 setActionInProgress
11087 }) {
11088 const registry = (0, import_data2.useRegistry)();
11089 const selectedEligibleItems = (0, import_element29.useMemo)(() => {
11090 return selectedItems.filter((item) => {
11091 return !action.isEligible || action.isEligible(item);
11092 });
11093 }, [action, selectedItems]);
11094 if ("RenderModal" in action) {
11095 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11096 ActionWithModal,
11097 {
11098 action,
11099 items: selectedEligibleItems,
11100 ActionTriggerComponent: ActionTrigger
11101 },
11102 action.id
11103 );
11104 }
11105 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11106 ActionTrigger,
11107 {
11108 action,
11109 onClick: async () => {
11110 setActionInProgress(action.id);
11111 await action.callback(selectedItems, {
11112 registry
11113 });
11114 setActionInProgress(null);
11115 },
11116 items: selectedEligibleItems,
11117 isBusy: actionInProgress === action.id
11118 },
11119 action.id
11120 );
11121 }
11122 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
11123 const message2 = getFooterMessage(
11124 selection.length,
11125 data.length,
11126 paginationInfo.totalItems,
11127 isInfiniteScroll
11128 );
11129 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
11130 Stack,
11131 {
11132 direction: "row",
11133 className: "dataviews-bulk-actions-footer__container",
11134 gap: "md",
11135 align: "center",
11136 children: [
11137 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11138 BulkSelectionCheckbox,
11139 {
11140 selection,
11141 onChangeSelection,
11142 data,
11143 actions,
11144 getItemId,
11145 disableSelectAll: isInfiniteScroll
11146 }
11147 ),
11148 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
11149 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
11150 Stack,
11151 {
11152 direction: "row",
11153 className: "dataviews-bulk-actions-footer__action-buttons",
11154 gap: "xs",
11155 children: [
11156 actionsToShow.map((action) => {
11157 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11158 ActionButton,
11159 {
11160 action,
11161 selectedItems,
11162 actionInProgress,
11163 setActionInProgress
11164 },
11165 action.id
11166 );
11167 }),
11168 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11169 import_components3.Button,
11170 {
11171 icon: close_small_default,
11172 showTooltip: true,
11173 tooltipPosition: "top",
11174 size: "compact",
11175 label: (0, import_i18n6.__)("Cancel"),
11176 disabled: !!actionInProgress,
11177 accessibleWhenDisabled: false,
11178 onClick: () => {
11179 onChangeSelection(EMPTY_ARRAY2);
11180 }
11181 }
11182 )
11183 ]
11184 }
11185 )
11186 ]
11187 }
11188 );
11189 }
11190 function FooterContent({
11191 selection,
11192 actions,
11193 onChangeSelection,
11194 data,
11195 getItemId,
11196 isInfiniteScroll,
11197 paginationInfo
11198 }) {
11199 const [actionInProgress, setActionInProgress] = (0, import_element29.useState)(
11200 null
11201 );
11202 const footerContentRef = (0, import_element29.useRef)(void 0);
11203 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11204 const bulkActions = (0, import_element29.useMemo)(
11205 () => actions.filter((action) => action.supportsBulk),
11206 [actions]
11207 );
11208 const selectableItems = (0, import_element29.useMemo)(() => {
11209 return data.filter((item) => {
11210 return bulkActions.some(
11211 (action) => !action.isEligible || action.isEligible(item)
11212 );
11213 });
11214 }, [data, bulkActions]);
11215 const selectedItems = (0, import_element29.useMemo)(() => {
11216 return data.filter(
11217 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11218 );
11219 }, [selection, data, getItemId, selectableItems]);
11220 const actionsToShow = (0, import_element29.useMemo)(
11221 () => actions.filter((action) => {
11222 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11223 (item) => !action.isEligible || action.isEligible(item)
11224 );
11225 }),
11226 [actions, selectedItems, isMobile]
11227 );
11228 if (!actionInProgress) {
11229 if (footerContentRef.current) {
11230 footerContentRef.current = void 0;
11231 }
11232 return renderFooterContent(
11233 data,
11234 actions,
11235 getItemId,
11236 isInfiniteScroll,
11237 selection,
11238 actionsToShow,
11239 selectedItems,
11240 actionInProgress,
11241 setActionInProgress,
11242 onChangeSelection,
11243 paginationInfo
11244 );
11245 } else if (!footerContentRef.current) {
11246 footerContentRef.current = renderFooterContent(
11247 data,
11248 actions,
11249 getItemId,
11250 isInfiniteScroll,
11251 selection,
11252 actionsToShow,
11253 selectedItems,
11254 actionInProgress,
11255 setActionInProgress,
11256 onChangeSelection,
11257 paginationInfo
11258 );
11259 }
11260 return footerContentRef.current;
11261 }
11262 function BulkActionsFooter() {
11263 const {
11264 data,
11265 selection,
11266 actions = EMPTY_ARRAY2,
11267 onChangeSelection,
11268 getItemId,
11269 paginationInfo,
11270 view
11271 } = (0, import_element29.useContext)(dataviews_context_default);
11272 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11273 FooterContent,
11274 {
11275 selection,
11276 onChangeSelection,
11277 data,
11278 actions,
11279 getItemId,
11280 isInfiniteScroll: !!view.infiniteScrollEnabled,
11281 paginationInfo
11282 }
11283 );
11284 }
11285
11286 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11287 var import_i18n7 = __toESM(require_i18n(), 1);
11288 var import_components4 = __toESM(require_components(), 1);
11289 var import_element30 = __toESM(require_element(), 1);
11290
11291 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11292 function getHideableFields(view, fields) {
11293 const togglableFields = [
11294 view?.titleField,
11295 view?.mediaField,
11296 view?.descriptionField
11297 ].filter(Boolean);
11298 return fields.filter(
11299 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11300 );
11301 }
11302
11303 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11304 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11305 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11306 function WithMenuSeparators({ children }) {
11307 return import_element30.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element30.Fragment, { children: [
11308 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}),
11309 child
11310 ] }, i2));
11311 }
11312 var _HeaderMenu = (0, import_element30.forwardRef)(function HeaderMenu({
11313 fieldId,
11314 view,
11315 fields,
11316 onChangeView,
11317 onHide,
11318 setOpenedFilter,
11319 canMove = true,
11320 canInsertLeft = true,
11321 canInsertRight = true
11322 }, ref) {
11323 const visibleFieldIds = view.fields ?? [];
11324 const index2 = visibleFieldIds?.indexOf(fieldId);
11325 const isSorted = view.sort?.field === fieldId;
11326 let isHidable = false;
11327 let isSortable = false;
11328 let canAddFilter = false;
11329 let operators = [];
11330 const field = fields.find((f2) => f2.id === fieldId);
11331 const { setIsShowingFilter } = (0, import_element30.useContext)(dataviews_context_default);
11332 if (!field) {
11333 return null;
11334 }
11335 isHidable = field.enableHiding !== false;
11336 isSortable = field.enableSorting !== false;
11337 const header = field.header;
11338 operators = !!field.filterBy && field.filterBy?.operators || [];
11339 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11340 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11341 return header;
11342 }
11343 const hiddenFields = getHideableFields(view, fields).filter(
11344 (f2) => !visibleFieldIds.includes(f2.id)
11345 );
11346 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11347 const isRtl = (0, import_i18n7.isRTL)();
11348 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11349 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11350 Menu2.TriggerButton,
11351 {
11352 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11353 import_components4.Button,
11354 {
11355 size: "compact",
11356 className: "dataviews-view-table-header-button",
11357 ref,
11358 variant: "tertiary"
11359 }
11360 ),
11361 children: [
11362 header,
11363 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11364 ]
11365 }
11366 ),
11367 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [
11368 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11369 (direction) => {
11370 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11371 const value = `${fieldId}-${direction}`;
11372 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11373 Menu2.RadioItem,
11374 {
11375 name: "view-table-sorting",
11376 value,
11377 checked: isChecked,
11378 onChange: () => {
11379 onChangeView({
11380 ...view,
11381 sort: {
11382 field: fieldId,
11383 direction
11384 },
11385 showLevels: false
11386 });
11387 },
11388 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11389 },
11390 value
11391 );
11392 }
11393 ) }),
11394 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11395 Menu2.Item,
11396 {
11397 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }),
11398 onClick: () => {
11399 setOpenedFilter(fieldId);
11400 setIsShowingFilter(true);
11401 onChangeView({
11402 ...view,
11403 page: 1,
11404 filters: [
11405 ...view.filters || [],
11406 {
11407 field: fieldId,
11408 value: void 0,
11409 operator: operators[0]
11410 }
11411 ]
11412 });
11413 },
11414 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11415 }
11416 ) }),
11417 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [
11418 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11419 Menu2.Item,
11420 {
11421 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11422 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11423 onClick: () => {
11424 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11425 const newFields = [
11426 ...visibleFieldIds
11427 ];
11428 newFields.splice(index2, 1);
11429 newFields.splice(
11430 targetIndex,
11431 0,
11432 fieldId
11433 );
11434 onChangeView({
11435 ...view,
11436 fields: newFields
11437 });
11438 },
11439 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11440 }
11441 ),
11442 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11443 Menu2.Item,
11444 {
11445 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11446 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11447 onClick: () => {
11448 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11449 const newFields = [
11450 ...visibleFieldIds
11451 ];
11452 newFields.splice(index2, 1);
11453 newFields.splice(
11454 targetIndex,
11455 0,
11456 fieldId
11457 );
11458 onChangeView({
11459 ...view,
11460 fields: newFields
11461 });
11462 },
11463 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11464 }
11465 ),
11466 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11467 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11468 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11469 const insertIndex = isRtl ? index2 + 1 : index2;
11470 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11471 Menu2.Item,
11472 {
11473 onClick: () => {
11474 onChangeView({
11475 ...view,
11476 fields: [
11477 ...visibleFieldIds.slice(
11478 0,
11479 insertIndex
11480 ),
11481 hiddenField.id,
11482 ...visibleFieldIds.slice(
11483 insertIndex
11484 )
11485 ]
11486 });
11487 },
11488 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11489 },
11490 hiddenField.id
11491 );
11492 }) })
11493 ] }),
11494 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11495 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11496 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11497 const insertIndex = isRtl ? index2 : index2 + 1;
11498 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11499 Menu2.Item,
11500 {
11501 onClick: () => {
11502 onChangeView({
11503 ...view,
11504 fields: [
11505 ...visibleFieldIds.slice(
11506 0,
11507 insertIndex
11508 ),
11509 hiddenField.id,
11510 ...visibleFieldIds.slice(
11511 insertIndex
11512 )
11513 ]
11514 });
11515 },
11516 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11517 },
11518 hiddenField.id
11519 );
11520 }) })
11521 ] }),
11522 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11523 Menu2.Item,
11524 {
11525 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }),
11526 onClick: () => {
11527 onHide(field);
11528 onChangeView({
11529 ...view,
11530 fields: visibleFieldIds.filter(
11531 (id) => id !== fieldId
11532 )
11533 });
11534 },
11535 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11536 }
11537 )
11538 ] })
11539 ] }) })
11540 ] });
11541 });
11542 var ColumnHeaderMenu = _HeaderMenu;
11543 var column_header_menu_default = ColumnHeaderMenu;
11544
11545 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11546 var import_element31 = __toESM(require_element(), 1);
11547 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11548 function getClickableItemProps({
11549 item,
11550 isItemClickable,
11551 onClickItem,
11552 className
11553 }) {
11554 if (!isItemClickable(item) || !onClickItem) {
11555 return { className };
11556 }
11557 return {
11558 className: className ? `${className} ${className}--clickable` : void 0,
11559 role: "button",
11560 tabIndex: 0,
11561 onClick: (event) => {
11562 event.stopPropagation();
11563 onClickItem(item);
11564 },
11565 onKeyDown: (event) => {
11566 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11567 event.stopPropagation();
11568 onClickItem(item);
11569 }
11570 }
11571 };
11572 }
11573 function ItemClickWrapper({
11574 item,
11575 isItemClickable,
11576 onClickItem,
11577 renderItemLink,
11578 className,
11579 children,
11580 ...extraProps
11581 }) {
11582 if (!isItemClickable(item)) {
11583 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children });
11584 }
11585 if (renderItemLink) {
11586 const renderedElement = renderItemLink({
11587 item,
11588 className: `${className} ${className}--clickable`,
11589 ...extraProps,
11590 children
11591 });
11592 return (0, import_element31.cloneElement)(renderedElement, {
11593 onClick: (event) => {
11594 event.stopPropagation();
11595 if (renderedElement.props.onClick) {
11596 renderedElement.props.onClick(event);
11597 }
11598 },
11599 onKeyDown: (event) => {
11600 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11601 event.stopPropagation();
11602 if (renderedElement.props.onKeyDown) {
11603 renderedElement.props.onKeyDown(event);
11604 }
11605 }
11606 }
11607 });
11608 }
11609 const clickProps = getClickableItemProps({
11610 item,
11611 isItemClickable,
11612 onClickItem,
11613 className
11614 });
11615 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children });
11616 }
11617
11618 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11619 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11620 function ColumnPrimary({
11621 item,
11622 level,
11623 titleField,
11624 mediaField,
11625 descriptionField,
11626 onClickItem,
11627 renderItemLink,
11628 isItemClickable
11629 }) {
11630 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11631 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11632 ItemClickWrapper,
11633 {
11634 item,
11635 isItemClickable,
11636 onClickItem,
11637 renderItemLink,
11638 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11639 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11640 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11641 mediaField.render,
11642 {
11643 item,
11644 field: mediaField,
11645 config: { sizes: "32px" }
11646 }
11647 )
11648 }
11649 ),
11650 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11651 Stack,
11652 {
11653 direction: "column",
11654 align: "flex-start",
11655 className: "dataviews-view-table__primary-column-content",
11656 children: [
11657 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11658 ItemClickWrapper,
11659 {
11660 item,
11661 isItemClickable,
11662 onClickItem,
11663 renderItemLink,
11664 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11665 children: [
11666 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [
11667 Array(level).fill("\u2014").join(" "),
11668 "\xA0"
11669 ] }),
11670 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField })
11671 ]
11672 }
11673 ),
11674 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11675 descriptionField.render,
11676 {
11677 item,
11678 field: descriptionField
11679 }
11680 )
11681 ]
11682 }
11683 )
11684 ] });
11685 }
11686 var column_primary_default = ColumnPrimary;
11687
11688 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11689 var import_element32 = __toESM(require_element(), 1);
11690 var import_i18n8 = __toESM(require_i18n(), 1);
11691 var isScrolledToEnd = (element) => {
11692 if ((0, import_i18n8.isRTL)()) {
11693 const scrollLeft = Math.abs(element.scrollLeft);
11694 return scrollLeft <= 1;
11695 }
11696 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11697 };
11698 function useScrollState({
11699 scrollContainerRef,
11700 enabledHorizontal = false
11701 }) {
11702 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element32.useState)(false);
11703 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element32.useState)(false);
11704 const handleScroll = (0, import_element32.useCallback)(() => {
11705 const scrollContainer = scrollContainerRef.current;
11706 if (!scrollContainer) {
11707 return;
11708 }
11709 if (enabledHorizontal) {
11710 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11711 }
11712 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11713 }, [scrollContainerRef, enabledHorizontal]);
11714 (0, import_element32.useEffect)(() => {
11715 if (typeof window === "undefined" || !scrollContainerRef.current) {
11716 return () => {
11717 };
11718 }
11719 const scrollContainer = scrollContainerRef.current;
11720 handleScroll();
11721 scrollContainer.addEventListener("scroll", handleScroll);
11722 window.addEventListener("resize", handleScroll);
11723 return () => {
11724 scrollContainer.removeEventListener("scroll", handleScroll);
11725 window.removeEventListener("resize", handleScroll);
11726 };
11727 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11728 return { isHorizontalScrollEnd, isVerticallyScrolled };
11729 }
11730
11731 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11732 function getDataByGroup(data, groupByField) {
11733 return data.reduce((groups, item) => {
11734 const groupName = groupByField.getValue({ item });
11735 if (!groups.has(groupName)) {
11736 groups.set(groupName, []);
11737 }
11738 groups.get(groupName)?.push(item);
11739 return groups;
11740 }, /* @__PURE__ */ new Map());
11741 }
11742
11743 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11744 var import_components5 = __toESM(require_components(), 1);
11745 var import_i18n9 = __toESM(require_i18n(), 1);
11746 var import_element33 = __toESM(require_element(), 1);
11747 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11748 function FieldItem({
11749 field,
11750 isVisible: isVisible2,
11751 onToggleVisibility
11752 }) {
11753 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11754 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.Icon, { icon: check_default }) }),
11755 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11756 ] }) });
11757 }
11758 function isDefined(item) {
11759 return !!item;
11760 }
11761 function PropertiesSection({
11762 showLabel = true
11763 }) {
11764 const { view, fields, onChangeView } = (0, import_element33.useContext)(dataviews_context_default);
11765 const regularFields = getHideableFields(view, fields);
11766 if (!regularFields?.length) {
11767 return null;
11768 }
11769 const titleField = fields.find((f2) => f2.id === view.titleField);
11770 const previewField = fields.find((f2) => f2.id === view.mediaField);
11771 const descriptionField = fields.find(
11772 (f2) => f2.id === view.descriptionField
11773 );
11774 const lockedFields = [
11775 {
11776 field: titleField,
11777 isVisibleFlag: "showTitle"
11778 },
11779 {
11780 field: previewField,
11781 isVisibleFlag: "showMedia"
11782 },
11783 {
11784 field: descriptionField,
11785 isVisibleFlag: "showDescription"
11786 }
11787 ].filter(({ field }) => isDefined(field));
11788 const visibleFieldIds = view.fields ?? [];
11789 const visibleRegularFieldsCount = regularFields.filter(
11790 (f2) => visibleFieldIds.includes(f2.id)
11791 ).length;
11792 const visibleLockedFields = lockedFields.filter(
11793 ({ isVisibleFlag }) => (
11794 // @ts-expect-error
11795 view[isVisibleFlag] ?? true
11796 )
11797 );
11798 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11799 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11800 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11801 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11802 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11803 Stack,
11804 {
11805 direction: "column",
11806 className: "dataviews-view-config__properties",
11807 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11808 lockedFields.map(({ field, isVisibleFlag }) => {
11809 const isVisible2 = view[isVisibleFlag] ?? true;
11810 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11811 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11812 FieldItem,
11813 {
11814 field: fieldToRender,
11815 isVisible: isVisible2,
11816 onToggleVisibility: () => {
11817 onChangeView({
11818 ...view,
11819 [isVisibleFlag]: !isVisible2
11820 });
11821 }
11822 },
11823 field.id
11824 );
11825 }),
11826 regularFields.map((field) => {
11827 const isVisible2 = visibleFieldIds.includes(field.id);
11828 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11829 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11830 FieldItem,
11831 {
11832 field: fieldToRender,
11833 isVisible: isVisible2,
11834 onToggleVisibility: () => {
11835 onChangeView({
11836 ...view,
11837 fields: isVisible2 ? visibleFieldIds.filter(
11838 (fieldId) => fieldId !== field.id
11839 ) : [...visibleFieldIds, field.id]
11840 });
11841 }
11842 },
11843 field.id
11844 );
11845 })
11846 ] })
11847 }
11848 )
11849 ] });
11850 }
11851
11852 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11853 var import_element34 = __toESM(require_element(), 1);
11854 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11855 const [showLoader, setShowLoader] = (0, import_element34.useState)(false);
11856 (0, import_element34.useEffect)(() => {
11857 if (!isLoading) {
11858 return;
11859 }
11860 const timeout = setTimeout(() => {
11861 setShowLoader(true);
11862 }, options.delay);
11863 return () => {
11864 clearTimeout(timeout);
11865 setShowLoader(false);
11866 };
11867 }, [isLoading, options.delay]);
11868 return showLoader;
11869 }
11870
11871 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11872 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11873 function getEffectiveAlign(explicitAlign, fieldType) {
11874 if (explicitAlign) {
11875 return explicitAlign;
11876 }
11877 if (fieldType === "integer" || fieldType === "number") {
11878 return "end";
11879 }
11880 return void 0;
11881 }
11882 function TableColumnField({
11883 item,
11884 fields,
11885 column,
11886 align
11887 }) {
11888 const field = fields.find((f2) => f2.id === column);
11889 if (!field) {
11890 return null;
11891 }
11892 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11893 "dataviews-view-table__cell-align-end": align === "end",
11894 "dataviews-view-table__cell-align-center": align === "center"
11895 });
11896 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) });
11897 }
11898 function TableRow({
11899 hasBulkActions,
11900 item,
11901 level,
11902 actions,
11903 fields,
11904 id,
11905 view,
11906 titleField,
11907 mediaField,
11908 descriptionField,
11909 selection,
11910 getItemId,
11911 isItemClickable,
11912 onClickItem,
11913 renderItemLink,
11914 onChangeSelection,
11915 isActionsColumnSticky,
11916 posinset
11917 }) {
11918 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
11919 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11920 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11921 const {
11922 showTitle = true,
11923 showMedia = true,
11924 showDescription = true,
11925 infiniteScrollEnabled
11926 } = view;
11927 const isTouchDeviceRef = (0, import_element35.useRef)(false);
11928 const columns = view.fields ?? [];
11929 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11930 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11931 "tr",
11932 {
11933 className: clsx_default("dataviews-view-table__row", {
11934 "is-selected": hasPossibleBulkAction && isSelected2,
11935 "has-bulk-actions": hasPossibleBulkAction
11936 }),
11937 onTouchStart: () => {
11938 isTouchDeviceRef.current = true;
11939 },
11940 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11941 "aria-posinset": posinset,
11942 role: infiniteScrollEnabled ? "article" : void 0,
11943 onMouseDown: (event) => {
11944 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11945 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11946 event?.preventDefault();
11947 }
11948 },
11949 onClick: (event) => {
11950 if (!hasPossibleBulkAction) {
11951 return;
11952 }
11953 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11954 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11955 onChangeSelection(
11956 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11957 );
11958 }
11959 },
11960 children: [
11961 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11962 DataViewsSelectionCheckbox,
11963 {
11964 item,
11965 selection,
11966 onChangeSelection,
11967 getItemId,
11968 titleField,
11969 disabled: !hasPossibleBulkAction
11970 }
11971 ) }) }),
11972 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11973 column_primary_default,
11974 {
11975 item,
11976 level,
11977 titleField: showTitle ? titleField : void 0,
11978 mediaField: showMedia ? mediaField : void 0,
11979 descriptionField: showDescription ? descriptionField : void 0,
11980 isItemClickable,
11981 onClickItem,
11982 renderItemLink
11983 }
11984 ) }),
11985 columns.map((column) => {
11986 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11987 const field = fields.find((f2) => f2.id === column);
11988 const effectiveAlign = getEffectiveAlign(align, field?.type);
11989 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11990 "td",
11991 {
11992 style: {
11993 width,
11994 maxWidth,
11995 minWidth
11996 },
11997 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11998 TableColumnField,
11999 {
12000 fields,
12001 item,
12002 column,
12003 align: effectiveAlign
12004 }
12005 )
12006 },
12007 column
12008 );
12009 }),
12010 !!actions?.length && // Disable reason: we are not making the element interactive,
12011 // but preventing any click events from bubbling up to the
12012 // table row. This allows us to add a click handler to the row
12013 // itself (to toggle row selection) without erroneously
12014 // intercepting click events from ItemActions.
12015 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12016 "td",
12017 {
12018 className: clsx_default("dataviews-view-table__actions-column", {
12019 "dataviews-view-table__actions-column--sticky": true,
12020 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12021 }),
12022 onClick: (e2) => e2.stopPropagation(),
12023 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions })
12024 }
12025 )
12026 ]
12027 }
12028 );
12029 }
12030 function ViewTable({
12031 actions,
12032 data,
12033 fields,
12034 getItemId,
12035 getItemLevel,
12036 isLoading = false,
12037 onChangeView,
12038 onChangeSelection,
12039 selection,
12040 setOpenedFilter,
12041 onClickItem,
12042 isItemClickable,
12043 renderItemLink,
12044 view,
12045 className,
12046 empty
12047 }) {
12048 const { containerRef } = (0, import_element35.useContext)(dataviews_context_default);
12049 const isDelayedLoading = useDelayedLoading(isLoading);
12050 const headerMenuRefs = (0, import_element35.useRef)(/* @__PURE__ */ new Map());
12051 const headerMenuToFocusRef = (0, import_element35.useRef)(void 0);
12052 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element35.useState)();
12053 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element35.useState)(null);
12054 (0, import_element35.useEffect)(() => {
12055 if (headerMenuToFocusRef.current) {
12056 headerMenuToFocusRef.current.focus();
12057 headerMenuToFocusRef.current = void 0;
12058 }
12059 });
12060 const tableNoticeId = (0, import_element35.useId)();
12061 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12062 scrollContainerRef: containerRef,
12063 enabledHorizontal: !!actions?.length
12064 });
12065 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12066 if (nextHeaderMenuToFocus) {
12067 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12068 setNextHeaderMenuToFocus(void 0);
12069 return;
12070 }
12071 const onHide = (field) => {
12072 const hidden = headerMenuRefs.current.get(field.id);
12073 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12074 setNextHeaderMenuToFocus(fallback?.node);
12075 };
12076 const handleHeaderContextMenu = (event) => {
12077 event.preventDefault();
12078 event.stopPropagation();
12079 const virtualAnchor = {
12080 getBoundingClientRect: () => ({
12081 x: event.clientX,
12082 y: event.clientY,
12083 top: event.clientY,
12084 left: event.clientX,
12085 right: event.clientX,
12086 bottom: event.clientY,
12087 width: 0,
12088 height: 0,
12089 toJSON: () => ({})
12090 })
12091 };
12092 window.requestAnimationFrame(() => {
12093 setContextMenuAnchor(virtualAnchor);
12094 });
12095 };
12096 const hasData = !!data?.length;
12097 const titleField = fields.find((field) => field.id === view.titleField);
12098 const mediaField = fields.find((field) => field.id === view.mediaField);
12099 const descriptionField = fields.find(
12100 (field) => field.id === view.descriptionField
12101 );
12102 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12103 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12104 const { showTitle = true, showMedia = true, showDescription = true } = view;
12105 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12106 const columns = view.fields ?? [];
12107 const headerMenuRef = (column, index2) => (node) => {
12108 if (node) {
12109 headerMenuRefs.current.set(column, {
12110 node,
12111 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12112 });
12113 } else {
12114 headerMenuRefs.current.delete(column);
12115 }
12116 };
12117 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12118 const isRtl = (0, import_i18n10.isRTL)();
12119 if (!hasData) {
12120 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12121 "div",
12122 {
12123 className: clsx_default("dataviews-no-results", {
12124 "is-refreshing": isDelayedLoading
12125 }),
12126 id: tableNoticeId,
12127 children: empty
12128 }
12129 );
12130 }
12131 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
12132 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
12133 "table",
12134 {
12135 className: clsx_default("dataviews-view-table", className, {
12136 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12137 view.layout.density
12138 ),
12139 "has-bulk-actions": hasBulkActions,
12140 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12141 }),
12142 "aria-busy": isLoading,
12143 "aria-describedby": tableNoticeId,
12144 role: isInfiniteScroll ? "feed" : void 0,
12145 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12146 children: [
12147 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [
12148 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12149 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12150 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12151 "col",
12152 {
12153 className: clsx_default(
12154 `dataviews-view-table__col-${column}`,
12155 {
12156 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12157 }
12158 )
12159 },
12160 `col-${column}`
12161 )),
12162 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" })
12163 ] }),
12164 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12165 import_components6.Popover,
12166 {
12167 anchor: contextMenuAnchor,
12168 onClose: () => setContextMenuAnchor(null),
12169 placement: "bottom-start",
12170 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false })
12171 }
12172 ),
12173 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12174 "thead",
12175 {
12176 className: clsx_default({
12177 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12178 }),
12179 onContextMenu: handleHeaderContextMenu,
12180 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12181 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12182 "th",
12183 {
12184 className: "dataviews-view-table__checkbox-column",
12185 scope: "col",
12186 onContextMenu: handleHeaderContextMenu,
12187 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12188 BulkSelectionCheckbox,
12189 {
12190 selection,
12191 onChangeSelection,
12192 data,
12193 actions,
12194 getItemId
12195 }
12196 )
12197 }
12198 ),
12199 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12200 column_header_menu_default,
12201 {
12202 ref: headerMenuRef(
12203 titleField.id,
12204 0
12205 ),
12206 fieldId: titleField.id,
12207 view,
12208 fields,
12209 onChangeView,
12210 onHide,
12211 setOpenedFilter,
12212 canMove: false,
12213 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12214 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12215 }
12216 ) }),
12217 columns.map((column, index2) => {
12218 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12219 const field = fields.find(
12220 (f2) => f2.id === column
12221 );
12222 const effectiveAlign = getEffectiveAlign(
12223 align,
12224 field?.type
12225 );
12226 const canInsertOrMove = view.layout?.enableMoving ?? true;
12227 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12228 "th",
12229 {
12230 style: {
12231 width,
12232 maxWidth,
12233 minWidth,
12234 textAlign: effectiveAlign
12235 },
12236 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12237 scope: "col",
12238 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12239 column_header_menu_default,
12240 {
12241 ref: headerMenuRef(column, index2),
12242 fieldId: column,
12243 view,
12244 fields,
12245 onChangeView,
12246 onHide,
12247 setOpenedFilter,
12248 canMove: canInsertOrMove,
12249 canInsertLeft: canInsertOrMove,
12250 canInsertRight: canInsertOrMove
12251 }
12252 )
12253 },
12254 column
12255 );
12256 }),
12257 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12258 "th",
12259 {
12260 className: clsx_default(
12261 "dataviews-view-table__actions-column",
12262 {
12263 "dataviews-view-table__actions-column--sticky": true,
12264 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12265 }
12266 ),
12267 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12268 }
12269 )
12270 ] })
12271 }
12272 ),
12273 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12274 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [
12275 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12276 "td",
12277 {
12278 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12279 className: "dataviews-view-table__group-header-cell",
12280 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12281 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12282 (0, import_i18n10.__)("%1$s: %2$s"),
12283 groupField.label,
12284 groupName
12285 )
12286 }
12287 ) }),
12288 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12289 TableRow,
12290 {
12291 item,
12292 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12293 hasBulkActions,
12294 actions,
12295 fields,
12296 id: getItemId(item) || index2.toString(),
12297 view,
12298 titleField,
12299 mediaField,
12300 descriptionField,
12301 selection,
12302 getItemId,
12303 onChangeSelection,
12304 onClickItem,
12305 renderItemLink,
12306 isItemClickable,
12307 isActionsColumnSticky: !isHorizontalScrollEnd
12308 },
12309 getItemId(item)
12310 ))
12311 ] }, `group-${groupName}`)
12312 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12313 TableRow,
12314 {
12315 item,
12316 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12317 hasBulkActions,
12318 actions,
12319 fields,
12320 id: getItemId(item) || index2.toString(),
12321 view,
12322 titleField,
12323 mediaField,
12324 descriptionField,
12325 selection,
12326 getItemId,
12327 onChangeSelection,
12328 onClickItem,
12329 renderItemLink,
12330 isItemClickable,
12331 isActionsColumnSticky: !isHorizontalScrollEnd,
12332 posinset: isInfiniteScroll ? index2 + 1 : void 0
12333 },
12334 getItemId(item)
12335 )) })
12336 ]
12337 }
12338 ),
12339 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components6.Spinner, {}) }) })
12340 ] });
12341 }
12342 var table_default = ViewTable;
12343
12344 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12345 var import_components9 = __toESM(require_components(), 1);
12346 var import_i18n13 = __toESM(require_i18n(), 1);
12347
12348 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12349 var import_components8 = __toESM(require_components(), 1);
12350 var import_i18n12 = __toESM(require_i18n(), 1);
12351 var import_compose3 = __toESM(require_compose(), 1);
12352 var import_keycodes2 = __toESM(require_keycodes(), 1);
12353 var import_element39 = __toESM(require_element(), 1);
12354
12355 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12356 var import_components7 = __toESM(require_components(), 1);
12357 var import_i18n11 = __toESM(require_i18n(), 1);
12358 var import_element36 = __toESM(require_element(), 1);
12359 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12360 var imageSizes = [
12361 {
12362 value: 120,
12363 breakpoint: 1
12364 },
12365 {
12366 value: 170,
12367 breakpoint: 1
12368 },
12369 {
12370 value: 230,
12371 breakpoint: 1
12372 },
12373 {
12374 value: 290,
12375 breakpoint: 1112
12376 // at minimum image width, 4 images display at this container size
12377 },
12378 {
12379 value: 350,
12380 breakpoint: 1636
12381 // at minimum image width, 6 images display at this container size
12382 },
12383 {
12384 value: 430,
12385 breakpoint: 588
12386 // at minimum image width, 2 images display at this container size
12387 }
12388 ];
12389 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12390 function useGridColumns() {
12391 const context = (0, import_element36.useContext)(dataviews_context_default);
12392 const view = context.view;
12393 return (0, import_element36.useMemo)(() => {
12394 const containerWidth = context.containerWidth;
12395 const gap = 32;
12396 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12397 const columns = Math.floor(
12398 (containerWidth + gap) / (previewSize + gap)
12399 );
12400 return Math.max(1, columns);
12401 }, [context.containerWidth, view.layout?.previewSize]);
12402 }
12403
12404 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12405 var import_element37 = __toESM(require_element(), 1);
12406 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12407 var GridItems = (0, import_element37.forwardRef)(({ className, previewSize, ...props }, ref) => {
12408 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12409 "div",
12410 {
12411 ref,
12412 className: clsx_default("dataviews-view-grid-items", className),
12413 style: {
12414 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12415 },
12416 ...props
12417 }
12418 );
12419 });
12420
12421 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12422 var import_element38 = __toESM(require_element(), 1);
12423 function useIntersectionObserver(elementRef, posinset) {
12424 const { intersectionObserver } = (0, import_element38.useContext)(dataviews_context_default);
12425 (0, import_element38.useEffect)(() => {
12426 const element = elementRef.current;
12427 if (!element || posinset === void 0 || !intersectionObserver) {
12428 return;
12429 }
12430 intersectionObserver.observe(element);
12431 return () => {
12432 intersectionObserver.unobserve(element);
12433 };
12434 }, [elementRef, intersectionObserver, posinset]);
12435 }
12436 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12437 const hasData = !!data?.length;
12438 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12439 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12440 }
12441
12442 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12443 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12444 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12445 function chunk(array, size4) {
12446 const chunks = [];
12447 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12448 chunks.push(array.slice(i2, i2 + size4));
12449 }
12450 return chunks;
12451 }
12452 var GridItem = (0, import_element39.forwardRef)(
12453 function GridItem2({
12454 view,
12455 selection,
12456 onChangeSelection,
12457 onClickItem,
12458 isItemClickable,
12459 renderItemLink,
12460 getItemId,
12461 item,
12462 actions,
12463 mediaField,
12464 titleField,
12465 descriptionField,
12466 regularFields,
12467 badgeFields,
12468 hasBulkActions,
12469 config,
12470 posinset,
12471 setsize,
12472 ...props
12473 }, forwardedRef) {
12474 const {
12475 showTitle = true,
12476 showMedia = true,
12477 showDescription = true
12478 } = view;
12479 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12480 const id = getItemId(item);
12481 const elementRef = (0, import_element39.useRef)(null);
12482 const setRefs = (0, import_element39.useCallback)(
12483 (node) => {
12484 elementRef.current = node;
12485 if (typeof forwardedRef === "function") {
12486 forwardedRef(node);
12487 } else if (forwardedRef) {
12488 forwardedRef.current = node;
12489 }
12490 },
12491 [forwardedRef]
12492 );
12493 useIntersectionObserver(elementRef, posinset);
12494 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12495 const isSelected2 = selection.includes(id);
12496 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12497 const rendersMediaField = showMedia && mediaField?.render;
12498 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12499 mediaField.render,
12500 {
12501 item,
12502 field: mediaField,
12503 config
12504 }
12505 ) : mediaPlaceholder;
12506 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
12507 let mediaA11yProps;
12508 let titleA11yProps;
12509 if (isItemClickable(item) && onClickItem) {
12510 if (renderedTitleField) {
12511 mediaA11yProps = {
12512 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12513 };
12514 titleA11yProps = {
12515 id: `dataviews-view-grid__title-field-${instanceId}`
12516 };
12517 } else {
12518 mediaA11yProps = {
12519 "aria-label": (0, import_i18n12.__)("Navigate to item")
12520 };
12521 }
12522 }
12523 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12524 Stack,
12525 {
12526 direction: "column",
12527 ...props,
12528 ref: setRefs,
12529 "aria-setsize": setsize,
12530 "aria-posinset": posinset,
12531 className: clsx_default(
12532 props.className,
12533 "dataviews-view-grid__row__gridcell",
12534 "dataviews-view-grid__card",
12535 {
12536 "is-selected": hasBulkAction && isSelected2
12537 }
12538 ),
12539 onClickCapture: (event) => {
12540 props.onClickCapture?.(event);
12541 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12542 event.stopPropagation();
12543 event.preventDefault();
12544 if (!hasBulkAction) {
12545 return;
12546 }
12547 onChangeSelection(
12548 isSelected2 ? selection.filter(
12549 (itemId) => id !== itemId
12550 ) : [...selection, id]
12551 );
12552 }
12553 },
12554 children: [
12555 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12556 ItemClickWrapper,
12557 {
12558 item,
12559 isItemClickable,
12560 onClickItem,
12561 renderItemLink,
12562 className: clsx_default("dataviews-view-grid__media", {
12563 "dataviews-view-grid__media--placeholder": !rendersMediaField
12564 }),
12565 ...mediaA11yProps,
12566 children: renderedMediaField
12567 }
12568 ),
12569 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12570 DataViewsSelectionCheckbox,
12571 {
12572 item,
12573 selection,
12574 onChangeSelection,
12575 getItemId,
12576 titleField,
12577 disabled: !hasBulkAction
12578 }
12579 ),
12580 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12581 ItemActions,
12582 {
12583 item,
12584 actions,
12585 isCompact: true
12586 }
12587 ) }),
12588 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12589 ItemClickWrapper,
12590 {
12591 item,
12592 isItemClickable,
12593 onClickItem,
12594 renderItemLink,
12595 className: "dataviews-view-grid__title-field dataviews-title-field",
12596 ...titleA11yProps,
12597 title: titleField?.getValueFormatted({
12598 item,
12599 field: titleField
12600 }) || void 0,
12601 children: renderedTitleField
12602 }
12603 ) }),
12604 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12605 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12606 descriptionField.render,
12607 {
12608 item,
12609 field: descriptionField
12610 }
12611 ),
12612 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12613 Stack,
12614 {
12615 direction: "row",
12616 className: "dataviews-view-grid__badge-fields",
12617 gap: "sm",
12618 wrap: "wrap",
12619 align: "top",
12620 justify: "flex-start",
12621 children: badgeFields.map((field) => {
12622 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12623 WCBadge,
12624 {
12625 className: "dataviews-view-grid__field-value",
12626 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12627 field.render,
12628 {
12629 item,
12630 field
12631 }
12632 )
12633 },
12634 field.id
12635 );
12636 })
12637 }
12638 ),
12639 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12640 Stack,
12641 {
12642 direction: "column",
12643 className: "dataviews-view-grid__fields",
12644 gap: "xs",
12645 children: regularFields.map((field) => {
12646 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12647 import_components8.Flex,
12648 {
12649 className: "dataviews-view-grid__field",
12650 gap: 1,
12651 justify: "flex-start",
12652 expanded: true,
12653 style: { height: "auto" },
12654 direction: "row",
12655 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
12656 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [
12657 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12658 tooltip_exports.Trigger,
12659 {
12660 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12661 }
12662 ),
12663 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label })
12664 ] }),
12665 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12666 import_components8.FlexItem,
12667 {
12668 className: "dataviews-view-grid__field-value",
12669 style: { maxHeight: "none" },
12670 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12671 field.render,
12672 {
12673 item,
12674 field
12675 }
12676 )
12677 }
12678 )
12679 ] })
12680 },
12681 field.id
12682 );
12683 })
12684 }
12685 )
12686 ] })
12687 ]
12688 }
12689 );
12690 }
12691 );
12692 function CompositeGrid({
12693 data,
12694 isInfiniteScroll,
12695 className,
12696 inert,
12697 isLoading,
12698 view,
12699 fields,
12700 selection,
12701 onChangeSelection,
12702 onClickItem,
12703 isItemClickable,
12704 renderItemLink,
12705 getItemId,
12706 actions
12707 }) {
12708 const { paginationInfo, resizeObserverRef } = (0, import_element39.useContext)(dataviews_context_default);
12709 const gridColumns = useGridColumns();
12710 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12711 const titleField = fields.find(
12712 (field) => field.id === view?.titleField
12713 );
12714 const mediaField = fields.find(
12715 (field) => field.id === view?.mediaField
12716 );
12717 const descriptionField = fields.find(
12718 (field) => field.id === view?.descriptionField
12719 );
12720 const otherFields = view.fields ?? [];
12721 const { regularFields, badgeFields } = otherFields.reduce(
12722 (accumulator, fieldId) => {
12723 const field = fields.find((f2) => f2.id === fieldId);
12724 if (!field) {
12725 return accumulator;
12726 }
12727 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12728 accumulator[key].push(field);
12729 return accumulator;
12730 },
12731 { regularFields: [], badgeFields: [] }
12732 );
12733 const size4 = "900px";
12734 const totalRows = Math.ceil(data.length / gridColumns);
12735 const placeholdersNeeded = usePlaceholdersNeeded(
12736 data,
12737 isInfiniteScroll,
12738 gridColumns
12739 );
12740 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, {
12741 // Render infinite scroll layout (no rows, feed semantics)
12742 children: [
12743 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12744 import_components8.Composite,
12745 {
12746 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12747 GridItems,
12748 {
12749 className: clsx_default(
12750 "dataviews-view-grid-infinite-scroll",
12751 className,
12752 {
12753 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12754 "compact",
12755 "comfortable"
12756 ].includes(view.layout.density)
12757 }
12758 ),
12759 previewSize: view.layout?.previewSize,
12760 "aria-busy": isLoading,
12761 ref: resizeObserverRef
12762 }
12763 ),
12764 role: "feed",
12765 focusWrap: true,
12766 inert,
12767 children: [
12768 Array.from({ length: placeholdersNeeded }).map(
12769 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12770 import_components8.Composite.Item,
12771 {
12772 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12773 Stack,
12774 {
12775 ...props,
12776 direction: "column",
12777 role: "article",
12778 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12779 }
12780 ),
12781 "aria-hidden": true,
12782 tabIndex: -1
12783 },
12784 `placeholder-${index2}`
12785 )
12786 ),
12787 data.map((item) => {
12788 const itemId = getItemId(item);
12789 const stablePosition = item.position;
12790 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12791 import_components8.Composite.Item,
12792 {
12793 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12794 GridItem,
12795 {
12796 ...props,
12797 id: itemId,
12798 role: "article",
12799 view,
12800 selection,
12801 onChangeSelection,
12802 onClickItem,
12803 isItemClickable,
12804 renderItemLink,
12805 getItemId,
12806 item,
12807 actions,
12808 mediaField,
12809 titleField,
12810 descriptionField,
12811 regularFields,
12812 badgeFields,
12813 hasBulkActions,
12814 posinset: stablePosition,
12815 setsize: paginationInfo.totalItems,
12816 config: {
12817 sizes: size4
12818 }
12819 }
12820 )
12821 },
12822 itemId
12823 );
12824 })
12825 ]
12826 }
12827 ),
12828 // Render standard grid layout (with rows, grid semantics)
12829 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12830 import_components8.Composite,
12831 {
12832 role: "grid",
12833 className: clsx_default("dataviews-view-grid", className, {
12834 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12835 view.layout.density
12836 )
12837 }),
12838 focusWrap: true,
12839 "aria-busy": isLoading,
12840 "aria-rowcount": totalRows,
12841 ref: resizeObserverRef,
12842 inert,
12843 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12844 import_components8.Composite.Row,
12845 {
12846 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12847 "div",
12848 {
12849 role: "row",
12850 "aria-rowindex": i2 + 1,
12851 "aria-label": (0, import_i18n12.sprintf)(
12852 /* translators: %d: The row number in the grid */
12853 (0, import_i18n12.__)("Row %d"),
12854 i2 + 1
12855 ),
12856 className: "dataviews-view-grid__row",
12857 style: {
12858 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12859 }
12860 }
12861 ),
12862 children: row.map((item) => {
12863 const itemId = getItemId(item);
12864 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12865 import_components8.Composite.Item,
12866 {
12867 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12868 GridItem,
12869 {
12870 ...props,
12871 id: itemId,
12872 role: "gridcell",
12873 view,
12874 selection,
12875 onChangeSelection,
12876 onClickItem,
12877 isItemClickable,
12878 renderItemLink,
12879 getItemId,
12880 item,
12881 actions,
12882 mediaField,
12883 titleField,
12884 descriptionField,
12885 regularFields,
12886 badgeFields,
12887 hasBulkActions,
12888 config: {
12889 sizes: size4
12890 }
12891 }
12892 )
12893 },
12894 itemId
12895 );
12896 })
12897 },
12898 i2
12899 ))
12900 }
12901 )
12902 ]
12903 });
12904 }
12905
12906 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12907 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12908 function ViewGrid({
12909 actions,
12910 data,
12911 fields,
12912 getItemId,
12913 isLoading,
12914 onChangeSelection,
12915 onClickItem,
12916 isItemClickable,
12917 renderItemLink,
12918 selection,
12919 view,
12920 className,
12921 empty
12922 }) {
12923 const isDelayedLoading = useDelayedLoading(!!isLoading);
12924 const hasData = !!data?.length;
12925 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12926 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12927 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12928 if (!hasData) {
12929 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12930 "div",
12931 {
12932 className: clsx_default("dataviews-no-results", {
12933 "is-refreshing": isDelayedLoading
12934 }),
12935 children: empty
12936 }
12937 );
12938 }
12939 const gridProps = {
12940 className: clsx_default(className, {
12941 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12942 }),
12943 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12944 isLoading,
12945 view,
12946 fields,
12947 selection,
12948 onChangeSelection,
12949 onClickItem,
12950 isItemClickable,
12951 renderItemLink,
12952 getItemId,
12953 actions
12954 };
12955 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12956 // Render multiple groups.
12957 children: [
12958 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12959 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12960 Stack,
12961 {
12962 direction: "column",
12963 gap: "sm",
12964 children: [
12965 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12966 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12967 (0, import_i18n13.__)("%1$s: %2$s"),
12968 groupField.label,
12969 groupName
12970 ) }),
12971 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12972 CompositeGrid,
12973 {
12974 ...gridProps,
12975 data: groupItems,
12976 isInfiniteScroll: false
12977 }
12978 )
12979 ]
12980 },
12981 groupName
12982 )
12983 ) }),
12984 // Render a single grid with all data.
12985 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12986 CompositeGrid,
12987 {
12988 ...gridProps,
12989 data,
12990 isInfiniteScroll: !!isInfiniteScroll
12991 }
12992 ),
12993 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) })
12994 ]
12995 });
12996 }
12997 var grid_default = ViewGrid;
12998
12999 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
13000 var import_compose4 = __toESM(require_compose(), 1);
13001 var import_components10 = __toESM(require_components(), 1);
13002 var import_element40 = __toESM(require_element(), 1);
13003 var import_i18n14 = __toESM(require_i18n(), 1);
13004 var import_data3 = __toESM(require_data(), 1);
13005 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13006 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
13007 function generateItemWrapperCompositeId(idPrefix) {
13008 return `${idPrefix}-item-wrapper`;
13009 }
13010 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
13011 return `${idPrefix}-primary-action-${primaryActionId}`;
13012 }
13013 function generateDropdownTriggerCompositeId(idPrefix) {
13014 return `${idPrefix}-dropdown`;
13015 }
13016 function PrimaryActionGridCell({
13017 idPrefix,
13018 primaryAction,
13019 item
13020 }) {
13021 const registry = (0, import_data3.useRegistry)();
13022 const [isModalOpen, setIsModalOpen] = (0, import_element40.useState)(false);
13023 const compositeItemId = generatePrimaryActionCompositeId(
13024 idPrefix,
13025 primaryAction.id
13026 );
13027 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13028 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13029 import_components10.Composite.Item,
13030 {
13031 id: compositeItemId,
13032 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13033 import_components10.Button,
13034 {
13035 disabled: !!primaryAction.disabled,
13036 accessibleWhenDisabled: true,
13037 text: label,
13038 size: "small",
13039 onClick: () => setIsModalOpen(true)
13040 }
13041 ),
13042 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13043 ActionModal,
13044 {
13045 action: primaryAction,
13046 items: [item],
13047 closeModal: () => setIsModalOpen(false)
13048 }
13049 )
13050 }
13051 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13052 import_components10.Composite.Item,
13053 {
13054 id: compositeItemId,
13055 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13056 import_components10.Button,
13057 {
13058 disabled: !!primaryAction.disabled,
13059 accessibleWhenDisabled: true,
13060 size: "small",
13061 onClick: () => {
13062 primaryAction.callback([item], { registry });
13063 },
13064 children: label
13065 }
13066 )
13067 }
13068 ) }, primaryAction.id);
13069 }
13070 function ListItem({
13071 view,
13072 actions,
13073 idPrefix,
13074 isSelected: isSelected2,
13075 item,
13076 titleField,
13077 mediaField,
13078 descriptionField,
13079 onSelect,
13080 otherFields,
13081 onDropdownTriggerKeyDown,
13082 posinset
13083 }) {
13084 const {
13085 showTitle = true,
13086 showMedia = true,
13087 showDescription = true,
13088 infiniteScrollEnabled
13089 } = view;
13090 const itemRef = (0, import_element40.useRef)(null);
13091 const labelId = `${idPrefix}-label`;
13092 const descriptionId = `${idPrefix}-description`;
13093 const registry = (0, import_data3.useRegistry)();
13094 const [isHovered, setIsHovered] = (0, import_element40.useState)(false);
13095 const [activeModalAction, setActiveModalAction] = (0, import_element40.useState)(
13096 null
13097 );
13098 const handleHover = ({ type }) => {
13099 const isHover = type === "mouseenter";
13100 setIsHovered(isHover);
13101 };
13102 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13103 (0, import_element40.useEffect)(() => {
13104 if (isSelected2) {
13105 itemRef.current?.scrollIntoView({
13106 behavior: "auto",
13107 block: "nearest",
13108 inline: "nearest"
13109 });
13110 }
13111 }, [isSelected2]);
13112 const { primaryAction, eligibleActions } = (0, import_element40.useMemo)(() => {
13113 const _eligibleActions = actions.filter(
13114 (action) => !action.isEligible || action.isEligible(item)
13115 );
13116 const _primaryActions = _eligibleActions.filter(
13117 (action) => action.isPrimary
13118 );
13119 return {
13120 primaryAction: _primaryActions[0],
13121 eligibleActions: _eligibleActions
13122 };
13123 }, [actions, item]);
13124 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13125 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13126 mediaField.render,
13127 {
13128 item,
13129 field: mediaField,
13130 config: { sizes: "52px" }
13131 }
13132 ) }) : null;
13133 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null;
13134 const renderDescription = showDescription && descriptionField?.render;
13135 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13136 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13137 Stack,
13138 {
13139 direction: "row",
13140 gap: "md",
13141 className: "dataviews-view-list__item-actions",
13142 children: [
13143 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13144 PrimaryActionGridCell,
13145 {
13146 idPrefix,
13147 primaryAction,
13148 item
13149 }
13150 ),
13151 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [
13152 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [
13153 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13154 Menu3.TriggerButton,
13155 {
13156 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13157 import_components10.Composite.Item,
13158 {
13159 id: generateDropdownTriggerCompositeId(
13160 idPrefix
13161 ),
13162 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13163 import_components10.Button,
13164 {
13165 size: "small",
13166 icon: more_vertical_default,
13167 label: (0, import_i18n14.__)("Actions"),
13168 accessibleWhenDisabled: true,
13169 disabled: !actions.length,
13170 onKeyDown: onDropdownTriggerKeyDown
13171 }
13172 )
13173 }
13174 )
13175 }
13176 ),
13177 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13178 ActionsMenuGroup,
13179 {
13180 actions: eligibleActions,
13181 item,
13182 registry,
13183 setActiveModalAction
13184 }
13185 ) })
13186 ] }),
13187 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13188 ActionModal,
13189 {
13190 action: activeModalAction,
13191 items: [item],
13192 closeModal: () => setActiveModalAction(null)
13193 }
13194 )
13195 ] })
13196 ]
13197 }
13198 );
13199 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13200 import_components10.Composite.Row,
13201 {
13202 ref: itemRef,
13203 render: (
13204 /* aria-posinset breaks Composite.Row if passed to it directly. */
13205 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13206 "div",
13207 {
13208 "aria-posinset": posinset,
13209 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13210 }
13211 )
13212 ),
13213 role: infiniteScrollEnabled ? "article" : "row",
13214 className: clsx_default({
13215 "is-selected": isSelected2,
13216 "is-hovered": isHovered
13217 }),
13218 onMouseEnter: handleHover,
13219 onMouseLeave: handleHover,
13220 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13221 Stack,
13222 {
13223 direction: "row",
13224 className: "dataviews-view-list__item-wrapper",
13225 children: [
13226 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13227 import_components10.Composite.Item,
13228 {
13229 id: generateItemWrapperCompositeId(idPrefix),
13230 "aria-pressed": isSelected2,
13231 "aria-labelledby": labelId,
13232 "aria-describedby": descriptionId,
13233 className: "dataviews-view-list__item",
13234 onClick: () => onSelect(item)
13235 }
13236 ) }),
13237 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13238 Stack,
13239 {
13240 direction: "row",
13241 gap: "md",
13242 justify: "start",
13243 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13244 style: { flex: 1, minWidth: 0 },
13245 children: [
13246 renderedMediaField,
13247 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13248 Stack,
13249 {
13250 direction: "column",
13251 gap: "xs",
13252 className: "dataviews-view-list__field-wrapper",
13253 children: [
13254 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [
13255 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13256 "div",
13257 {
13258 className: "dataviews-title-field dataviews-view-list__title-field",
13259 id: labelId,
13260 children: renderedTitleField
13261 }
13262 ),
13263 usedActions
13264 ] }),
13265 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13266 descriptionField.render,
13267 {
13268 item,
13269 field: descriptionField
13270 }
13271 ) }),
13272 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13273 "div",
13274 {
13275 className: "dataviews-view-list__fields",
13276 id: descriptionId,
13277 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13278 "div",
13279 {
13280 className: "dataviews-view-list__field",
13281 children: [
13282 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13283 VisuallyHidden,
13284 {
13285 className: "dataviews-view-list__field-label",
13286 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}),
13287 children: field.label
13288 }
13289 ),
13290 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13291 field.render,
13292 {
13293 item,
13294 field
13295 }
13296 ) })
13297 ]
13298 },
13299 field.id
13300 ))
13301 }
13302 )
13303 ]
13304 }
13305 )
13306 ]
13307 }
13308 )
13309 ]
13310 }
13311 )
13312 }
13313 );
13314 }
13315 function isDefined2(item) {
13316 return !!item;
13317 }
13318 function ViewList(props) {
13319 const {
13320 actions,
13321 data,
13322 fields,
13323 getItemId,
13324 isLoading,
13325 onChangeSelection,
13326 selection,
13327 view,
13328 className,
13329 empty
13330 } = props;
13331 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13332 const isDelayedLoading = useDelayedLoading(!!isLoading);
13333 const selectedItem = data?.findLast(
13334 (item) => selection.includes(getItemId(item))
13335 );
13336 const titleField = fields.find((field) => field.id === view.titleField);
13337 const mediaField = fields.find((field) => field.id === view.mediaField);
13338 const descriptionField = fields.find(
13339 (field) => field.id === view.descriptionField
13340 );
13341 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13342 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13343 const generateCompositeItemIdPrefix = (0, import_element40.useCallback)(
13344 (item) => `${baseId}-${getItemId(item)}`,
13345 [baseId, getItemId]
13346 );
13347 const isActiveCompositeItem = (0, import_element40.useCallback)(
13348 (item, idToCheck) => {
13349 return idToCheck.startsWith(
13350 generateCompositeItemIdPrefix(item)
13351 );
13352 },
13353 [generateCompositeItemIdPrefix]
13354 );
13355 const [activeCompositeId, setActiveCompositeId] = (0, import_element40.useState)(void 0);
13356 const compositeRef = (0, import_element40.useRef)(null);
13357 (0, import_element40.useEffect)(() => {
13358 if (selectedItem) {
13359 setActiveCompositeId(
13360 generateItemWrapperCompositeId(
13361 generateCompositeItemIdPrefix(selectedItem)
13362 )
13363 );
13364 }
13365 }, [selectedItem, generateCompositeItemIdPrefix]);
13366 const activeItemIndex = data.findIndex(
13367 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13368 );
13369 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13370 const isActiveIdInList = activeItemIndex !== -1;
13371 const selectCompositeItem = (0, import_element40.useCallback)(
13372 (targetIndex, generateCompositeId) => {
13373 const clampedIndex = Math.min(
13374 data.length - 1,
13375 Math.max(0, targetIndex)
13376 );
13377 if (!data[clampedIndex]) {
13378 return;
13379 }
13380 const itemIdPrefix = generateCompositeItemIdPrefix(
13381 data[clampedIndex]
13382 );
13383 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13384 setActiveCompositeId(targetCompositeItemId);
13385 if (compositeRef.current?.contains(
13386 compositeRef.current.ownerDocument.activeElement
13387 )) {
13388 document.getElementById(targetCompositeItemId)?.focus();
13389 }
13390 },
13391 [data, generateCompositeItemIdPrefix]
13392 );
13393 (0, import_element40.useEffect)(() => {
13394 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13395 if (!isActiveIdInList && wasActiveIdInList) {
13396 selectCompositeItem(
13397 previousActiveItemIndex,
13398 generateItemWrapperCompositeId
13399 );
13400 }
13401 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13402 const onDropdownTriggerKeyDown = (0, import_element40.useCallback)(
13403 (event) => {
13404 if (event.key === "ArrowDown") {
13405 event.preventDefault();
13406 selectCompositeItem(
13407 activeItemIndex + 1,
13408 generateDropdownTriggerCompositeId
13409 );
13410 }
13411 if (event.key === "ArrowUp") {
13412 event.preventDefault();
13413 selectCompositeItem(
13414 activeItemIndex - 1,
13415 generateDropdownTriggerCompositeId
13416 );
13417 }
13418 },
13419 [selectCompositeItem, activeItemIndex]
13420 );
13421 const hasData = !!data?.length;
13422 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13423 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13424 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13425 if (!hasData) {
13426 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13427 "div",
13428 {
13429 className: clsx_default("dataviews-no-results", {
13430 "is-refreshing": isDelayedLoading
13431 }),
13432 children: empty
13433 }
13434 );
13435 }
13436 if (hasData && groupField && dataByGroup) {
13437 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13438 import_components10.Composite,
13439 {
13440 ref: compositeRef,
13441 id: `${baseId}`,
13442 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13443 className: "dataviews-view-list__group",
13444 role: "grid",
13445 activeId: activeCompositeId,
13446 setActiveId: setActiveCompositeId,
13447 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13448 Stack,
13449 {
13450 direction: "column",
13451 gap: "lg",
13452 className: clsx_default("dataviews-view-list", className),
13453 children: Array.from(dataByGroup.entries()).map(
13454 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13455 Stack,
13456 {
13457 direction: "column",
13458 gap: "sm",
13459 children: [
13460 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13461 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13462 (0, import_i18n14.__)("%1$s: %2$s"),
13463 groupField.label,
13464 groupName
13465 ) }),
13466 groupItems.map((item) => {
13467 const id = generateCompositeItemIdPrefix(item);
13468 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13469 ListItem,
13470 {
13471 view,
13472 idPrefix: id,
13473 actions,
13474 item,
13475 isSelected: item === selectedItem,
13476 onSelect,
13477 mediaField,
13478 titleField,
13479 descriptionField,
13480 otherFields,
13481 onDropdownTriggerKeyDown
13482 },
13483 id
13484 );
13485 })
13486 ]
13487 },
13488 groupName
13489 )
13490 )
13491 }
13492 )
13493 }
13494 );
13495 }
13496 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13497 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13498 import_components10.Composite,
13499 {
13500 ref: compositeRef,
13501 id: baseId,
13502 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13503 className: clsx_default("dataviews-view-list", className, {
13504 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13505 view.layout.density
13506 ),
13507 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13508 }),
13509 role: view.infiniteScrollEnabled ? "feed" : "grid",
13510 activeId: activeCompositeId,
13511 setActiveId: setActiveCompositeId,
13512 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13513 children: data.map((item, index2) => {
13514 const id = generateCompositeItemIdPrefix(item);
13515 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13516 ListItem,
13517 {
13518 view,
13519 idPrefix: id,
13520 actions,
13521 item,
13522 isSelected: item === selectedItem,
13523 onSelect,
13524 mediaField,
13525 titleField,
13526 descriptionField,
13527 otherFields,
13528 onDropdownTriggerKeyDown,
13529 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13530 },
13531 id
13532 );
13533 })
13534 }
13535 ),
13536 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) })
13537 ] });
13538 }
13539
13540 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13541 var import_components11 = __toESM(require_components(), 1);
13542
13543 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13544 var import_i18n15 = __toESM(require_i18n(), 1);
13545 var import_element41 = __toESM(require_element(), 1);
13546 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13547 function ActivityGroup({
13548 groupName,
13549 groupData,
13550 groupField,
13551 showLabel = true,
13552 children
13553 }) {
13554 const groupHeader = showLabel ? (0, import_element41.createInterpolateElement)(
13555 // translators: %s: The label of the field e.g. "Status".
13556 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13557 {
13558 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13559 groupField.render,
13560 {
13561 item: groupData[0],
13562 field: groupField
13563 }
13564 )
13565 }
13566 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField });
13567 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13568 Stack,
13569 {
13570 direction: "column",
13571 className: "dataviews-view-activity__group",
13572 children: [
13573 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13574 children
13575 ]
13576 },
13577 groupName
13578 );
13579 }
13580
13581 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13582 var import_element42 = __toESM(require_element(), 1);
13583 var import_data4 = __toESM(require_data(), 1);
13584 var import_compose5 = __toESM(require_compose(), 1);
13585 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13586 function ActivityItem(props) {
13587 const {
13588 view,
13589 actions,
13590 item,
13591 titleField,
13592 mediaField,
13593 descriptionField,
13594 otherFields,
13595 posinset,
13596 onClickItem,
13597 renderItemLink,
13598 isItemClickable
13599 } = props;
13600 const {
13601 showTitle = true,
13602 showMedia = true,
13603 showDescription = true,
13604 infiniteScrollEnabled
13605 } = view;
13606 const itemRef = (0, import_element42.useRef)(null);
13607 const registry = (0, import_data4.useRegistry)();
13608 const { paginationInfo } = (0, import_element42.useContext)(dataviews_context_default);
13609 const { primaryActions, eligibleActions } = (0, import_element42.useMemo)(() => {
13610 const _eligibleActions = actions.filter(
13611 (action) => !action.isEligible || action.isEligible(item)
13612 );
13613 const _primaryActions = _eligibleActions.filter(
13614 (action) => action.isPrimary
13615 );
13616 return {
13617 primaryActions: _primaryActions,
13618 eligibleActions: _eligibleActions
13619 };
13620 }, [actions, item]);
13621 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13622 const density = view.layout?.density ?? "balanced";
13623 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13624 mediaField.render,
13625 {
13626 item,
13627 field: mediaField,
13628 config: {
13629 sizes: density === "comfortable" ? "32px" : "24px"
13630 }
13631 }
13632 ) : null;
13633 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13634 "span",
13635 {
13636 className: "dataviews-view-activity__item-bullet",
13637 "aria-hidden": "true"
13638 }
13639 ) });
13640 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
13641 const verticalGap = (0, import_element42.useMemo)(() => {
13642 switch (density) {
13643 case "comfortable":
13644 return "md";
13645 default:
13646 return "sm";
13647 }
13648 }, [density]);
13649 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13650 "div",
13651 {
13652 ref: itemRef,
13653 role: infiniteScrollEnabled ? "article" : void 0,
13654 "aria-posinset": posinset,
13655 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13656 className: clsx_default(
13657 "dataviews-view-activity__item",
13658 density === "compact" && "is-compact",
13659 density === "balanced" && "is-balanced",
13660 density === "comfortable" && "is-comfortable"
13661 ),
13662 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13663 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13664 Stack,
13665 {
13666 direction: "column",
13667 gap: "xs",
13668 align: "center",
13669 className: "dataviews-view-activity__item-type",
13670 children: renderedMediaField
13671 }
13672 ),
13673 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13674 Stack,
13675 {
13676 direction: "column",
13677 gap: verticalGap,
13678 align: "flex-start",
13679 className: "dataviews-view-activity__item-content",
13680 children: [
13681 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13682 ItemClickWrapper,
13683 {
13684 item,
13685 isItemClickable,
13686 onClickItem,
13687 renderItemLink,
13688 className: "dataviews-view-activity__item-title",
13689 children: renderedTitleField
13690 }
13691 ),
13692 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13693 descriptionField.render,
13694 {
13695 item,
13696 field: descriptionField
13697 }
13698 ) }),
13699 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13700 "div",
13701 {
13702 className: "dataviews-view-activity__item-field",
13703 children: [
13704 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13705 VisuallyHidden,
13706 {
13707 className: "dataviews-view-activity__item-field-label",
13708 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}),
13709 children: field.label
13710 }
13711 ),
13712 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13713 field.render,
13714 {
13715 item,
13716 field
13717 }
13718 ) })
13719 ]
13720 },
13721 field.id
13722 )) }),
13723 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13724 PrimaryActions,
13725 {
13726 item,
13727 actions: primaryActions,
13728 registry,
13729 buttonVariant: "secondary"
13730 }
13731 )
13732 ]
13733 }
13734 ),
13735 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13736 // there if there are any actions at all.
13737 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13738 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13739 ItemActions,
13740 {
13741 item,
13742 actions: eligibleActions,
13743 isCompact: true
13744 }
13745 ) })
13746 ] })
13747 }
13748 );
13749 }
13750 var activity_item_default = ActivityItem;
13751
13752 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13753 var import_react10 = __toESM(require_react(), 1);
13754 function isDefined3(item) {
13755 return !!item;
13756 }
13757 function ActivityItems(props) {
13758 const { data, fields, getItemId, view } = props;
13759 const titleField = fields.find((field) => field.id === view.titleField);
13760 const mediaField = fields.find((field) => field.id === view.mediaField);
13761 const descriptionField = fields.find(
13762 (field) => field.id === view.descriptionField
13763 );
13764 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13765 return data.map((item, index2) => {
13766 return /* @__PURE__ */ (0, import_react10.createElement)(
13767 activity_item_default,
13768 {
13769 ...props,
13770 key: getItemId(item),
13771 item,
13772 mediaField,
13773 titleField,
13774 descriptionField,
13775 otherFields,
13776 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13777 }
13778 );
13779 });
13780 }
13781
13782 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13783 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13784 function ViewActivity(props) {
13785 const { empty, data, fields, isLoading, view, className } = props;
13786 const isDelayedLoading = useDelayedLoading(!!isLoading);
13787 const hasData = !!data?.length;
13788 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13789 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13790 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13791 if (!hasData) {
13792 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13793 "div",
13794 {
13795 className: clsx_default("dataviews-no-results", {
13796 "is-refreshing": isDelayedLoading
13797 }),
13798 children: empty
13799 }
13800 );
13801 }
13802 const isInert = !isInfiniteScroll && !!isLoading;
13803 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13804 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13805 });
13806 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13807 if (hasData && groupField && dataByGroup) {
13808 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13809 Stack,
13810 {
13811 direction: "column",
13812 gap: "sm",
13813 className: wrapperClassName,
13814 inert: isInert ? "true" : void 0,
13815 children: groupedEntries.map(
13816 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13817 ActivityGroup,
13818 {
13819 groupName,
13820 groupData,
13821 groupField,
13822 showLabel: view.groupBy?.showLabel !== false,
13823 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13824 ActivityItems,
13825 {
13826 ...props,
13827 data: groupData
13828 }
13829 )
13830 },
13831 groupName
13832 )
13833 )
13834 }
13835 );
13836 }
13837 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13838 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13839 "div",
13840 {
13841 className: wrapperClassName,
13842 role: view.infiniteScrollEnabled ? "feed" : void 0,
13843 inert: isInert ? "true" : void 0,
13844 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props })
13845 }
13846 ),
13847 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) })
13848 ] });
13849 }
13850
13851 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13852 var import_components14 = __toESM(require_components(), 1);
13853 var import_i18n18 = __toESM(require_i18n(), 1);
13854 var import_compose6 = __toESM(require_compose(), 1);
13855 var import_element45 = __toESM(require_element(), 1);
13856
13857 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13858 var import_components13 = __toESM(require_components(), 1);
13859 var import_data5 = __toESM(require_data(), 1);
13860 var import_element44 = __toESM(require_element(), 1);
13861 var import_i18n17 = __toESM(require_i18n(), 1);
13862
13863 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13864 var import_components12 = __toESM(require_components(), 1);
13865 var import_element43 = __toESM(require_element(), 1);
13866 var import_i18n16 = __toESM(require_i18n(), 1);
13867 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13868 function DataViewsPagination() {
13869 const {
13870 view,
13871 onChangeView,
13872 paginationInfo: { totalItems = 0, totalPages }
13873 } = (0, import_element43.useContext)(dataviews_context_default);
13874 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13875 return null;
13876 }
13877 const currentPage = view.page ?? 1;
13878 const pageSelectOptions = Array.from(Array(totalPages)).map(
13879 (_, i2) => {
13880 const page = i2 + 1;
13881 return {
13882 value: page.toString(),
13883 label: page.toString(),
13884 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13885 // translators: 1: current page number. 2: total number of pages.
13886 (0, import_i18n16.__)("Page %1$d of %2$d"),
13887 currentPage,
13888 totalPages
13889 ) : page.toString()
13890 };
13891 }
13892 );
13893 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
13894 Stack,
13895 {
13896 direction: "row",
13897 className: "dataviews-pagination",
13898 justify: "end",
13899 align: "center",
13900 gap: "xl",
13901 children: [
13902 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13903 Stack,
13904 {
13905 direction: "row",
13906 justify: "flex-start",
13907 align: "center",
13908 gap: "xs",
13909 className: "dataviews-pagination__page-select",
13910 children: (0, import_element43.createInterpolateElement)(
13911 (0, import_i18n16.sprintf)(
13912 // translators: 1: Current page number, 2: Total number of pages.
13913 (0, import_i18n16._x)(
13914 "<div>Page</div>%1$s<div>of %2$d</div>",
13915 "paging"
13916 ),
13917 "<CurrentPage />",
13918 totalPages
13919 ),
13920 {
13921 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }),
13922 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13923 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13924 import_components12.SelectControl,
13925 {
13926 "aria-label": (0, import_i18n16.__)("Current page"),
13927 value: currentPage.toString(),
13928 options: pageSelectOptions,
13929 onChange: (newValue) => {
13930 onChangeView({
13931 ...view,
13932 page: +newValue
13933 });
13934 },
13935 size: "small",
13936 variant: "minimal"
13937 }
13938 )
13939 }
13940 )
13941 }
13942 ),
13943 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13944 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13945 import_components12.Button,
13946 {
13947 onClick: () => onChangeView({
13948 ...view,
13949 page: currentPage - 1
13950 }),
13951 disabled: currentPage === 1,
13952 accessibleWhenDisabled: true,
13953 label: (0, import_i18n16.__)("Previous page"),
13954 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13955 showTooltip: true,
13956 size: "compact",
13957 tooltipPosition: "top"
13958 }
13959 ),
13960 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13961 import_components12.Button,
13962 {
13963 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13964 disabled: currentPage >= totalPages,
13965 accessibleWhenDisabled: true,
13966 label: (0, import_i18n16.__)("Next page"),
13967 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13968 showTooltip: true,
13969 size: "compact",
13970 tooltipPosition: "top"
13971 }
13972 )
13973 ] })
13974 ]
13975 }
13976 );
13977 }
13978 var dataviews_pagination_default = (0, import_element43.memo)(DataViewsPagination);
13979
13980 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13981 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13982 function useIsMultiselectPicker(actions) {
13983 return (0, import_element44.useMemo)(() => {
13984 return !!actions?.length && actions?.every((action) => action.supportsBulk);
13985 }, [actions]);
13986 }
13987
13988 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13989 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13990 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13991 function GridItem3({
13992 view,
13993 multiselect,
13994 selection,
13995 onChangeSelection,
13996 getItemId,
13997 item,
13998 mediaField,
13999 titleField,
14000 descriptionField,
14001 regularFields,
14002 badgeFields,
14003 config,
14004 posinset,
14005 setsize
14006 }) {
14007 const { showTitle = true, showMedia = true, showDescription = true } = view;
14008 const id = getItemId(item);
14009 const elementRef = (0, import_element45.useRef)(null);
14010 const isSelected2 = selection.includes(id);
14011 useIntersectionObserver(elementRef, posinset);
14012 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14013 mediaField.render,
14014 {
14015 item,
14016 field: mediaField,
14017 config
14018 }
14019 ) : null;
14020 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null;
14021 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14022 import_components14.Composite.Item,
14023 {
14024 ref: elementRef,
14025 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
14026 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }),
14027 role: "option",
14028 "aria-posinset": posinset,
14029 "aria-setsize": setsize,
14030 className: clsx_default("dataviews-view-picker-grid__card", {
14031 "is-selected": isSelected2
14032 }),
14033 "aria-selected": isSelected2,
14034 onClick: () => {
14035 if (isSelected2) {
14036 onChangeSelection(
14037 selection.filter((itemId) => id !== itemId)
14038 );
14039 } else {
14040 const newSelection = multiselect ? [...selection, id] : [id];
14041 onChangeSelection(newSelection);
14042 }
14043 },
14044 children: [
14045 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14046 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14047 DataViewsSelectionCheckbox,
14048 {
14049 item,
14050 selection,
14051 onChangeSelection,
14052 getItemId,
14053 titleField,
14054 disabled: false,
14055 "aria-hidden": true,
14056 tabIndex: -1
14057 }
14058 ),
14059 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14060 Stack,
14061 {
14062 direction: "row",
14063 justify: "space-between",
14064 className: "dataviews-view-picker-grid__title-actions",
14065 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14066 }
14067 ),
14068 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14069 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14070 descriptionField.render,
14071 {
14072 item,
14073 field: descriptionField
14074 }
14075 ),
14076 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14077 Stack,
14078 {
14079 direction: "row",
14080 className: "dataviews-view-picker-grid__badge-fields",
14081 gap: "sm",
14082 wrap: "wrap",
14083 align: "top",
14084 justify: "flex-start",
14085 children: badgeFields.map((field) => {
14086 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14087 WCBadge2,
14088 {
14089 className: "dataviews-view-picker-grid__field-value",
14090 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14091 field.render,
14092 {
14093 item,
14094 field
14095 }
14096 )
14097 },
14098 field.id
14099 );
14100 })
14101 }
14102 ),
14103 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14104 Stack,
14105 {
14106 direction: "column",
14107 className: "dataviews-view-picker-grid__fields",
14108 gap: "xs",
14109 children: regularFields.map((field) => {
14110 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14111 import_components14.Flex,
14112 {
14113 className: "dataviews-view-picker-grid__field",
14114 gap: 1,
14115 justify: "flex-start",
14116 expanded: true,
14117 style: { height: "auto" },
14118 direction: "row",
14119 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
14120 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14121 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14122 import_components14.FlexItem,
14123 {
14124 className: "dataviews-view-picker-grid__field-value",
14125 style: { maxHeight: "none" },
14126 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14127 field.render,
14128 {
14129 item,
14130 field
14131 }
14132 )
14133 }
14134 )
14135 ] })
14136 },
14137 field.id
14138 );
14139 })
14140 }
14141 )
14142 ] })
14143 ]
14144 },
14145 id
14146 );
14147 }
14148 function GridGroup({
14149 groupName,
14150 groupField,
14151 showLabel = true,
14152 children
14153 }) {
14154 const headerId = (0, import_compose6.useInstanceId)(
14155 GridGroup,
14156 "dataviews-view-picker-grid-group__header"
14157 );
14158 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14159 Stack,
14160 {
14161 direction: "column",
14162 gap: "sm",
14163 role: "group",
14164 "aria-labelledby": headerId,
14165 children: [
14166 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14167 "h3",
14168 {
14169 className: "dataviews-view-picker-grid-group__header",
14170 id: headerId,
14171 children: showLabel ? (0, import_i18n18.sprintf)(
14172 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14173 (0, import_i18n18.__)("%1$s: %2$s"),
14174 groupField.label,
14175 groupName
14176 ) : groupName
14177 }
14178 ),
14179 children
14180 ]
14181 },
14182 groupName
14183 );
14184 }
14185 function ViewPickerGrid({
14186 actions,
14187 data,
14188 fields,
14189 getItemId,
14190 isLoading,
14191 onChangeSelection,
14192 selection,
14193 view,
14194 className,
14195 empty
14196 }) {
14197 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element45.useContext)(dataviews_context_default);
14198 const titleField = fields.find(
14199 (field) => field.id === view?.titleField
14200 );
14201 const mediaField = fields.find(
14202 (field) => field.id === view?.mediaField
14203 );
14204 const descriptionField = fields.find(
14205 (field) => field.id === view?.descriptionField
14206 );
14207 const otherFields = view.fields ?? [];
14208 const { regularFields, badgeFields } = otherFields.reduce(
14209 (accumulator, fieldId) => {
14210 const field = fields.find((f2) => f2.id === fieldId);
14211 if (!field) {
14212 return accumulator;
14213 }
14214 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14215 accumulator[key].push(field);
14216 return accumulator;
14217 },
14218 { regularFields: [], badgeFields: [] }
14219 );
14220 const hasData = !!data?.length;
14221 const usedPreviewSize = view.layout?.previewSize;
14222 const isMultiselect = useIsMultiselectPicker(actions);
14223 const size4 = "900px";
14224 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14225 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14226 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14227 const currentPage = view?.page ?? 1;
14228 const perPage = view?.perPage ?? 0;
14229 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14230 const gridColumns = useGridColumns();
14231 const placeholdersNeeded = usePlaceholdersNeeded(
14232 data,
14233 isInfiniteScroll,
14234 gridColumns
14235 );
14236 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, {
14237 // Render multiple groups.
14238 children: [
14239 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14240 import_components14.Composite,
14241 {
14242 virtualFocus: true,
14243 orientation: "horizontal",
14244 role: "listbox",
14245 "aria-multiselectable": isMultiselect,
14246 className: clsx_default(
14247 "dataviews-view-picker-grid",
14248 className,
14249 {
14250 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14251 view.layout.density
14252 )
14253 }
14254 ),
14255 "aria-label": itemListLabel,
14256 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14257 Stack,
14258 {
14259 direction: "column",
14260 gap: "lg",
14261 children,
14262 ...props
14263 }
14264 ),
14265 children: Array.from(dataByGroup.entries()).map(
14266 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14267 GridGroup,
14268 {
14269 groupName,
14270 groupField,
14271 showLabel: view.groupBy?.showLabel !== false,
14272 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14273 GridItems,
14274 {
14275 previewSize: usedPreviewSize,
14276 style: {
14277 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14278 },
14279 "aria-busy": isLoading,
14280 ref: resizeObserverRef,
14281 children: groupItems.map((item) => {
14282 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14283 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14284 GridItem3,
14285 {
14286 view,
14287 multiselect: isMultiselect,
14288 selection,
14289 onChangeSelection,
14290 getItemId,
14291 item,
14292 mediaField,
14293 titleField,
14294 descriptionField,
14295 regularFields,
14296 badgeFields,
14297 config: {
14298 sizes: size4
14299 },
14300 posinset: posInSet,
14301 setsize: setSize
14302 },
14303 getItemId(item)
14304 );
14305 })
14306 }
14307 )
14308 },
14309 groupName
14310 )
14311 )
14312 }
14313 ),
14314 // Render a single grid with all data.
14315 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14316 import_components14.Composite,
14317 {
14318 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14319 GridItems,
14320 {
14321 className: clsx_default(
14322 "dataviews-view-picker-grid",
14323 className,
14324 {
14325 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14326 "compact",
14327 "comfortable"
14328 ].includes(view.layout.density)
14329 }
14330 ),
14331 previewSize: usedPreviewSize,
14332 "aria-busy": isLoading,
14333 ref: resizeObserverRef
14334 }
14335 ),
14336 virtualFocus: true,
14337 orientation: "horizontal",
14338 role: "listbox",
14339 "aria-multiselectable": isMultiselect,
14340 "aria-label": itemListLabel,
14341 children: [
14342 Array.from({ length: placeholdersNeeded }).map(
14343 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14344 import_components14.Composite.Item,
14345 {
14346 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14347 Stack,
14348 {
14349 direction: "column",
14350 children,
14351 ...props
14352 }
14353 ),
14354 role: "option",
14355 "aria-hidden": true,
14356 tabIndex: -1,
14357 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14358 },
14359 `placeholder-${index2}`
14360 )
14361 ),
14362 data.map((item) => {
14363 const posinset = item.position;
14364 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14365 GridItem3,
14366 {
14367 view,
14368 multiselect: isMultiselect,
14369 selection,
14370 onChangeSelection,
14371 getItemId,
14372 item,
14373 mediaField,
14374 titleField,
14375 descriptionField,
14376 regularFields,
14377 badgeFields,
14378 config: {
14379 sizes: size4
14380 },
14381 posinset,
14382 setsize: setSize
14383 },
14384 getItemId(item)
14385 );
14386 })
14387 ]
14388 }
14389 ),
14390 // Render empty state.
14391 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14392 "div",
14393 {
14394 className: clsx_default({
14395 "dataviews-loading": isLoading,
14396 "dataviews-no-results": !isLoading
14397 }),
14398 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty
14399 }
14400 ),
14401 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) })
14402 ]
14403 });
14404 }
14405 var picker_grid_default = ViewPickerGrid;
14406
14407 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14408 var import_i18n19 = __toESM(require_i18n(), 1);
14409 var import_components15 = __toESM(require_components(), 1);
14410 var import_element46 = __toESM(require_element(), 1);
14411 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14412 function TableColumnField2({
14413 item,
14414 fields,
14415 column,
14416 align
14417 }) {
14418 const field = fields.find((f2) => f2.id === column);
14419 if (!field) {
14420 return null;
14421 }
14422 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14423 "dataviews-view-table__cell-align-end": align === "end",
14424 "dataviews-view-table__cell-align-center": align === "center"
14425 });
14426 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) });
14427 }
14428 function TableRow2({
14429 item,
14430 fields,
14431 id,
14432 view,
14433 titleField,
14434 mediaField,
14435 descriptionField,
14436 selection,
14437 getItemId,
14438 onChangeSelection,
14439 multiselect,
14440 posinset
14441 }) {
14442 const { paginationInfo } = (0, import_element46.useContext)(dataviews_context_default);
14443 const isSelected2 = selection.includes(id);
14444 const [isHovered, setIsHovered] = (0, import_element46.useState)(false);
14445 const elementRef = (0, import_element46.useRef)(null);
14446 useIntersectionObserver(elementRef, posinset);
14447 const {
14448 showTitle = true,
14449 showMedia = true,
14450 showDescription = true,
14451 infiniteScrollEnabled
14452 } = view;
14453 const handleMouseEnter = () => {
14454 setIsHovered(true);
14455 };
14456 const handleMouseLeave = () => {
14457 setIsHovered(false);
14458 };
14459 const columns = view.fields ?? [];
14460 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14461 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14462 import_components15.Composite.Item,
14463 {
14464 ref: elementRef,
14465 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14466 "tr",
14467 {
14468 className: clsx_default("dataviews-view-table__row", {
14469 "is-selected": isSelected2,
14470 "is-hovered": isHovered
14471 }),
14472 onMouseEnter: handleMouseEnter,
14473 onMouseLeave: handleMouseLeave,
14474 children,
14475 ...props
14476 }
14477 ),
14478 "aria-selected": isSelected2,
14479 "aria-setsize": paginationInfo.totalItems || void 0,
14480 "aria-posinset": posinset,
14481 role: infiniteScrollEnabled ? "article" : "option",
14482 onMouseDown: (event) => {
14483 if (event.button !== 0) {
14484 return;
14485 }
14486 event.currentTarget.parentElement?.focus({
14487 preventScroll: true
14488 });
14489 },
14490 onClick: () => {
14491 if (isSelected2) {
14492 onChangeSelection(
14493 selection.filter((itemId) => id !== itemId)
14494 );
14495 } else {
14496 const newSelection = multiselect ? [...selection, id] : [id];
14497 onChangeSelection(newSelection);
14498 }
14499 },
14500 children: [
14501 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14502 "td",
14503 {
14504 className: "dataviews-view-table__checkbox-column",
14505 role: "presentation",
14506 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14507 DataViewsSelectionCheckbox,
14508 {
14509 item,
14510 selection,
14511 onChangeSelection,
14512 getItemId,
14513 titleField,
14514 disabled: false,
14515 "aria-hidden": true,
14516 tabIndex: -1
14517 }
14518 ) })
14519 }
14520 ),
14521 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14522 "td",
14523 {
14524 role: "presentation",
14525 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14526 column_primary_default,
14527 {
14528 item,
14529 titleField: showTitle ? titleField : void 0,
14530 mediaField: showMedia ? mediaField : void 0,
14531 descriptionField: showDescription ? descriptionField : void 0,
14532 isItemClickable: () => false
14533 }
14534 )
14535 }
14536 ),
14537 columns.map((column) => {
14538 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14539 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14540 "td",
14541 {
14542 style: {
14543 width,
14544 maxWidth,
14545 minWidth
14546 },
14547 role: "presentation",
14548 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14549 TableColumnField2,
14550 {
14551 fields,
14552 item,
14553 column,
14554 align
14555 }
14556 )
14557 },
14558 column
14559 );
14560 })
14561 ]
14562 },
14563 id
14564 );
14565 }
14566 function ViewPickerTable({
14567 actions,
14568 data,
14569 fields,
14570 getItemId,
14571 isLoading = false,
14572 onChangeView,
14573 onChangeSelection,
14574 selection,
14575 setOpenedFilter,
14576 view,
14577 className,
14578 empty
14579 }) {
14580 const headerMenuRefs = (0, import_element46.useRef)(/* @__PURE__ */ new Map());
14581 const headerMenuToFocusRef = (0, import_element46.useRef)(void 0);
14582 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element46.useState)();
14583 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14584 (0, import_element46.useEffect)(() => {
14585 if (headerMenuToFocusRef.current) {
14586 headerMenuToFocusRef.current.focus();
14587 headerMenuToFocusRef.current = void 0;
14588 }
14589 });
14590 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14591 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14592 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14593 const tableNoticeId = (0, import_element46.useId)();
14594 if (nextHeaderMenuToFocus) {
14595 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14596 setNextHeaderMenuToFocus(void 0);
14597 return;
14598 }
14599 const onHide = (field) => {
14600 const hidden = headerMenuRefs.current.get(field.id);
14601 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14602 setNextHeaderMenuToFocus(fallback?.node);
14603 };
14604 const hasData = !!data?.length;
14605 const titleField = fields.find((field) => field.id === view.titleField);
14606 const mediaField = fields.find((field) => field.id === view.mediaField);
14607 const descriptionField = fields.find(
14608 (field) => field.id === view.descriptionField
14609 );
14610 const { showTitle = true, showMedia = true, showDescription = true } = view;
14611 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14612 const columns = view.fields ?? [];
14613 const headerMenuRef = (column, index2) => (node) => {
14614 if (node) {
14615 headerMenuRefs.current.set(column, {
14616 node,
14617 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14618 });
14619 } else {
14620 headerMenuRefs.current.delete(column);
14621 }
14622 };
14623 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14624 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14625 "table",
14626 {
14627 className: clsx_default(
14628 "dataviews-view-table",
14629 "dataviews-view-picker-table",
14630 className,
14631 {
14632 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14633 view.layout.density
14634 )
14635 }
14636 ),
14637 "aria-busy": isLoading,
14638 "aria-describedby": tableNoticeId,
14639 role: isInfiniteScroll ? "feed" : "listbox",
14640 children: [
14641 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14642 "tr",
14643 {
14644 className: "dataviews-view-table__row",
14645 role: "presentation",
14646 children: [
14647 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14648 BulkSelectionCheckbox,
14649 {
14650 selection,
14651 onChangeSelection,
14652 data,
14653 actions,
14654 getItemId,
14655 disableSelectAll: isInfiniteScroll
14656 }
14657 ) }),
14658 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14659 column_header_menu_default,
14660 {
14661 ref: headerMenuRef(
14662 titleField.id,
14663 0
14664 ),
14665 fieldId: titleField.id,
14666 view,
14667 fields,
14668 onChangeView,
14669 onHide,
14670 setOpenedFilter,
14671 canMove: false
14672 }
14673 ) }),
14674 columns.map((column, index2) => {
14675 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14676 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14677 "th",
14678 {
14679 style: {
14680 width,
14681 maxWidth,
14682 minWidth,
14683 textAlign: align
14684 },
14685 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14686 scope: "col",
14687 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14688 column_header_menu_default,
14689 {
14690 ref: headerMenuRef(column, index2),
14691 fieldId: column,
14692 view,
14693 fields,
14694 onChangeView,
14695 onHide,
14696 setOpenedFilter,
14697 canMove: view.layout?.enableMoving ?? true
14698 }
14699 )
14700 },
14701 column
14702 );
14703 })
14704 ]
14705 }
14706 ) }),
14707 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14708 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14709 import_components15.Composite,
14710 {
14711 virtualFocus: true,
14712 orientation: "vertical",
14713 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }),
14714 children: [
14715 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14716 "tr",
14717 {
14718 className: "dataviews-view-table__group-header-row",
14719 role: "presentation",
14720 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14721 "td",
14722 {
14723 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14724 className: "dataviews-view-table__group-header-cell",
14725 role: "presentation",
14726 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14727 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14728 (0, import_i18n19.__)("%1$s: %2$s"),
14729 groupField.label,
14730 groupName
14731 )
14732 }
14733 )
14734 }
14735 ),
14736 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14737 TableRow2,
14738 {
14739 item,
14740 fields,
14741 id: getItemId(item) || index2.toString(),
14742 view,
14743 titleField,
14744 mediaField,
14745 descriptionField,
14746 selection,
14747 getItemId,
14748 onChangeSelection,
14749 multiselect: isMultiselect
14750 },
14751 getItemId(item)
14752 ))
14753 ]
14754 },
14755 `group-${groupName}`
14756 )
14757 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14758 import_components15.Composite,
14759 {
14760 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }),
14761 virtualFocus: true,
14762 orientation: "vertical",
14763 children: hasData && data.map((item, index2) => {
14764 const itemId = getItemId(item);
14765 const posinset = item.position;
14766 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14767 TableRow2,
14768 {
14769 item,
14770 fields,
14771 id: itemId || index2.toString(),
14772 view,
14773 titleField,
14774 mediaField,
14775 descriptionField,
14776 selection,
14777 getItemId,
14778 onChangeSelection,
14779 multiselect: isMultiselect,
14780 posinset
14781 },
14782 itemId
14783 );
14784 })
14785 }
14786 )
14787 ]
14788 }
14789 ),
14790 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14791 "div",
14792 {
14793 className: clsx_default({
14794 "dataviews-loading": isLoading,
14795 "dataviews-no-results": !hasData && !isLoading
14796 }),
14797 id: tableNoticeId,
14798 children: [
14799 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty),
14800 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) })
14801 ]
14802 }
14803 )
14804 ] });
14805 }
14806 var picker_table_default = ViewPickerTable;
14807
14808 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14809 var import_components16 = __toESM(require_components(), 1);
14810 var import_element47 = __toESM(require_element(), 1);
14811 var import_compose7 = __toESM(require_compose(), 1);
14812 var import_i18n20 = __toESM(require_i18n(), 1);
14813 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14814 function isDefined4(item) {
14815 return !!item;
14816 }
14817 function PickerActivityItem({
14818 view,
14819 multiselect,
14820 selection,
14821 onChangeSelection,
14822 getItemId,
14823 item,
14824 titleField,
14825 mediaField,
14826 descriptionField,
14827 otherFields,
14828 posinset,
14829 setsize
14830 }) {
14831 const elementRef = (0, import_element47.useRef)(null);
14832 useIntersectionObserver(elementRef, posinset);
14833 const { showTitle = true, showMedia = true, showDescription = true } = view;
14834 const id = getItemId(item);
14835 const isSelected2 = selection.includes(id);
14836 const density = view.layout?.density ?? "balanced";
14837 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14838 mediaField.render,
14839 {
14840 item,
14841 field: mediaField,
14842 config: {
14843 sizes: density === "comfortable" ? "32px" : "24px"
14844 }
14845 }
14846 ) : null;
14847 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14848 "span",
14849 {
14850 className: "dataviews-view-picker-activity__item-bullet",
14851 "aria-hidden": "true"
14852 }
14853 ) });
14854 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(titleField.render, { item, field: titleField }) : null;
14855 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14856 const verticalGap = (0, import_element47.useMemo)(() => {
14857 switch (density) {
14858 case "comfortable":
14859 return "md";
14860 default:
14861 return "sm";
14862 }
14863 }, [density]);
14864 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14865 import_components16.Composite.Item,
14866 {
14867 ref: elementRef,
14868 role: "option",
14869 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14870 "aria-posinset": posinset,
14871 "aria-setsize": setsize,
14872 "aria-selected": isSelected2,
14873 className: clsx_default(
14874 "dataviews-view-picker-activity__item",
14875 density === "compact" && "is-compact",
14876 density === "balanced" && "is-balanced",
14877 density === "comfortable" && "is-comfortable",
14878 isSelected2 && "is-selected"
14879 ),
14880 onClick: () => {
14881 if (isSelected2) {
14882 onChangeSelection(
14883 selection.filter((itemId) => id !== itemId)
14884 );
14885 } else {
14886 const newSelection = multiselect ? [...selection, id] : [id];
14887 onChangeSelection(newSelection);
14888 }
14889 },
14890 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", {}),
14891 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14892 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14893 Stack,
14894 {
14895 direction: "column",
14896 gap: "xs",
14897 align: "center",
14898 className: "dataviews-view-picker-activity__item-type",
14899 children: renderedMediaField
14900 }
14901 ),
14902 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14903 Stack,
14904 {
14905 direction: "column",
14906 gap: verticalGap,
14907 align: "flex-start",
14908 className: "dataviews-view-picker-activity__item-content",
14909 children: [
14910 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14911 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14912 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14913 "div",
14914 {
14915 className: "dataviews-view-picker-activity__item-field",
14916 children: [
14917 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14918 VisuallyHidden,
14919 {
14920 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", {}),
14921 className: "dataviews-view-picker-activity__item-field-label",
14922 children: field.label
14923 }
14924 ),
14925 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14926 field.render,
14927 {
14928 item,
14929 field
14930 }
14931 ) })
14932 ]
14933 },
14934 field.id
14935 )) })
14936 ]
14937 }
14938 )
14939 ] })
14940 }
14941 );
14942 }
14943 function PickerActivityGroup({
14944 groupName,
14945 groupField,
14946 showLabel = true,
14947 children
14948 }) {
14949 const headerId = (0, import_compose7.useInstanceId)(
14950 PickerActivityGroup,
14951 "dataviews-view-picker-activity-group__header"
14952 );
14953 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14954 Stack,
14955 {
14956 direction: "column",
14957 role: "group",
14958 "aria-labelledby": headerId,
14959 className: "dataviews-view-picker-activity-group",
14960 children: [
14961 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14962 "h3",
14963 {
14964 className: "dataviews-view-picker-activity-group__header",
14965 id: headerId,
14966 children: showLabel ? (0, import_i18n20.sprintf)(
14967 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14968 (0, import_i18n20.__)("%1$s: %2$s"),
14969 groupField.label,
14970 groupName
14971 ) : groupName
14972 }
14973 ),
14974 children
14975 ]
14976 }
14977 );
14978 }
14979 function ViewPickerActivity({
14980 data,
14981 fields,
14982 getItemId,
14983 isLoading,
14984 onChangeSelection,
14985 selection,
14986 view,
14987 actions,
14988 className,
14989 empty
14990 }) {
14991 const { itemListLabel, paginationInfo } = (0, import_element47.useContext)(dataviews_context_default);
14992 const isMultiselect = useIsMultiselectPicker(actions);
14993 const titleField = fields.find(
14994 (field) => field.id === view?.titleField
14995 );
14996 const mediaField = fields.find(
14997 (field) => field.id === view?.mediaField
14998 );
14999 const descriptionField = fields.find(
15000 (field) => field.id === view?.descriptionField
15001 );
15002 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
15003 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15004 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15005 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15006 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15007 const hasData = !!data?.length;
15008 const isGrouped = !!(groupField && dataByGroup);
15009 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15010 PickerActivityItem,
15011 {
15012 view,
15013 multiselect: isMultiselect,
15014 selection,
15015 onChangeSelection,
15016 getItemId,
15017 item,
15018 titleField,
15019 mediaField,
15020 descriptionField,
15021 otherFields,
15022 posinset: item.position,
15023 setsize
15024 },
15025 getItemId(item)
15026 );
15027 if (!hasData) {
15028 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15029 "div",
15030 {
15031 className: clsx_default({
15032 "dataviews-loading": isLoading,
15033 "dataviews-no-results": !isLoading
15034 }),
15035 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) }) : empty
15036 }
15037 );
15038 }
15039 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
15040 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15041 import_components16.Composite,
15042 {
15043 virtualFocus: true,
15044 orientation: "vertical",
15045 role: "listbox",
15046 "aria-multiselectable": isMultiselect,
15047 "aria-label": itemListLabel,
15048 "aria-busy": isLoading,
15049 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15050 className: clsx_default(
15051 "dataviews-view-picker-activity",
15052 className
15053 ),
15054 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15055 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15056 PickerActivityGroup,
15057 {
15058 groupName,
15059 groupField,
15060 showLabel: view.groupBy?.showLabel !== false,
15061 children: groupItems.map(renderItem)
15062 },
15063 groupName
15064 )
15065 ) : data.map(renderItem)
15066 }
15067 ),
15068 isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) })
15069 ] });
15070 }
15071
15072 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15073 var import_components17 = __toESM(require_components(), 1);
15074 var import_i18n21 = __toESM(require_i18n(), 1);
15075 var import_element48 = __toESM(require_element(), 1);
15076 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15077 function DensityPicker() {
15078 const context = (0, import_element48.useContext)(dataviews_context_default);
15079 const view = context.view;
15080 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15081 import_components17.__experimentalToggleGroupControl,
15082 {
15083 size: "__unstable-large",
15084 label: (0, import_i18n21.__)("Density"),
15085 value: view.layout?.density || "balanced",
15086 onChange: (value) => {
15087 context.onChangeView({
15088 ...view,
15089 layout: {
15090 ...view.layout,
15091 density: value
15092 }
15093 });
15094 },
15095 isBlock: true,
15096 children: [
15097 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15098 import_components17.__experimentalToggleGroupControlOption,
15099 {
15100 value: "comfortable",
15101 label: (0, import_i18n21._x)(
15102 "Comfortable",
15103 "Density option for DataView layout"
15104 )
15105 },
15106 "comfortable"
15107 ),
15108 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15109 import_components17.__experimentalToggleGroupControlOption,
15110 {
15111 value: "balanced",
15112 label: (0, import_i18n21._x)("Balanced", "Density option for DataView layout")
15113 },
15114 "balanced"
15115 ),
15116 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15117 import_components17.__experimentalToggleGroupControlOption,
15118 {
15119 value: "compact",
15120 label: (0, import_i18n21._x)("Compact", "Density option for DataView layout")
15121 },
15122 "compact"
15123 )
15124 ]
15125 }
15126 );
15127 }
15128
15129 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15130 var import_components18 = __toESM(require_components(), 1);
15131 var import_i18n22 = __toESM(require_i18n(), 1);
15132 var import_element49 = __toESM(require_element(), 1);
15133 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15134 var imageSizes2 = [
15135 {
15136 value: 120,
15137 breakpoint: 1
15138 },
15139 {
15140 value: 170,
15141 breakpoint: 1
15142 },
15143 {
15144 value: 230,
15145 breakpoint: 1
15146 },
15147 {
15148 value: 290,
15149 breakpoint: 1112
15150 // at minimum image width, 4 images display at this container size
15151 },
15152 {
15153 value: 350,
15154 breakpoint: 1636
15155 // at minimum image width, 6 images display at this container size
15156 },
15157 {
15158 value: 430,
15159 breakpoint: 588
15160 // at minimum image width, 2 images display at this container size
15161 }
15162 ];
15163 function PreviewSizePicker() {
15164 const context = (0, import_element49.useContext)(dataviews_context_default);
15165 const view = context.view;
15166 const breakValues = imageSizes2.filter((size4) => {
15167 return context.containerWidth >= size4.breakpoint;
15168 });
15169 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15170 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15171 const marks = breakValues.map((size4, index2) => {
15172 return {
15173 value: index2
15174 };
15175 });
15176 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15177 import_components18.RangeControl,
15178 {
15179 __next40pxDefaultSize: true,
15180 showTooltip: false,
15181 label: (0, import_i18n22.__)("Preview size"),
15182 value: previewSizeToUse,
15183 min: 0,
15184 max: breakValues.length - 1,
15185 withInputField: false,
15186 onChange: (value = 0) => {
15187 context.onChangeView({
15188 ...view,
15189 layout: {
15190 ...view.layout,
15191 previewSize: breakValues[value].value
15192 }
15193 });
15194 },
15195 step: 1,
15196 marks
15197 }
15198 );
15199 }
15200
15201 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15202 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15203 function GridConfigOptions() {
15204 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
15205 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DensityPicker, {}),
15206 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(PreviewSizePicker, {})
15207 ] });
15208 }
15209
15210 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15211 var VIEW_LAYOUTS = [
15212 {
15213 type: LAYOUT_TABLE,
15214 label: (0, import_i18n23.__)("Table"),
15215 component: table_default,
15216 icon: block_table_default,
15217 viewConfigOptions: DensityPicker
15218 },
15219 {
15220 type: LAYOUT_GRID,
15221 label: (0, import_i18n23.__)("Grid"),
15222 component: grid_default,
15223 icon: category_default,
15224 viewConfigOptions: GridConfigOptions
15225 },
15226 {
15227 type: LAYOUT_LIST,
15228 label: (0, import_i18n23.__)("List"),
15229 component: ViewList,
15230 icon: (0, import_i18n23.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15231 viewConfigOptions: DensityPicker
15232 },
15233 {
15234 type: LAYOUT_ACTIVITY,
15235 label: (0, import_i18n23.__)("Activity"),
15236 component: ViewActivity,
15237 icon: scheduled_default,
15238 viewConfigOptions: DensityPicker
15239 },
15240 {
15241 type: LAYOUT_PICKER_GRID,
15242 label: (0, import_i18n23.__)("Grid"),
15243 component: picker_grid_default,
15244 icon: category_default,
15245 viewConfigOptions: GridConfigOptions,
15246 isPicker: true
15247 },
15248 {
15249 type: LAYOUT_PICKER_TABLE,
15250 label: (0, import_i18n23.__)("Table"),
15251 component: picker_table_default,
15252 icon: block_table_default,
15253 viewConfigOptions: DensityPicker,
15254 isPicker: true
15255 },
15256 {
15257 type: LAYOUT_PICKER_ACTIVITY,
15258 label: (0, import_i18n23.__)("Activity"),
15259 component: ViewPickerActivity,
15260 icon: scheduled_default,
15261 viewConfigOptions: DensityPicker,
15262 isPicker: true
15263 }
15264 ];
15265
15266 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15267 var import_element57 = __toESM(require_element(), 1);
15268
15269 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15270 var import_components21 = __toESM(require_components(), 1);
15271 var import_i18n26 = __toESM(require_i18n(), 1);
15272 var import_element54 = __toESM(require_element(), 1);
15273
15274 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15275 var import_react11 = __toESM(require_react(), 1);
15276 var FocusableContext = (0, import_react11.createContext)(true);
15277
15278 // node_modules/@ariakit/utils/dist/index.js
15279 function toArray(arg) {
15280 if (Array.isArray(arg)) return arg;
15281 return typeof arg !== "undefined" ? [arg] : [];
15282 }
15283 function flatten2DArray(array) {
15284 const flattened = [];
15285 for (const row of array) flattened.push(...row);
15286 return flattened;
15287 }
15288 function reverseArray(array) {
15289 return array.slice().reverse();
15290 }
15291 var canUseDOM = checkIsBrowser();
15292 function checkIsBrowser() {
15293 return typeof window !== "undefined" && !!window.document?.createElement;
15294 }
15295 function getDocument(node) {
15296 if (!node) return document;
15297 if ("self" in node) return node.document;
15298 return node.ownerDocument || document;
15299 }
15300 function getActiveElement(node, activeDescendant = false) {
15301 const { activeElement: activeElement2 } = getDocument(node);
15302 if (!activeElement2?.nodeName) return null;
15303 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15304 if (activeDescendant) {
15305 const id = activeElement2.getAttribute("aria-activedescendant");
15306 if (id) {
15307 const element = getDocument(activeElement2).getElementById(id);
15308 if (element) return element;
15309 }
15310 }
15311 return activeElement2;
15312 }
15313 function contains2(parent, child) {
15314 return parent === child || parent.contains(child);
15315 }
15316 function isElement2(target) {
15317 return target?.nodeType === 1;
15318 }
15319 function isNode2(target) {
15320 return typeof target?.nodeType === "number";
15321 }
15322 function isFrame(element) {
15323 return element.tagName === "IFRAME";
15324 }
15325 function isButton(element) {
15326 const tagName = element.tagName.toLowerCase();
15327 if (tagName === "button") return true;
15328 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15329 return false;
15330 }
15331 var buttonInputTypes = [
15332 "button",
15333 "color",
15334 "file",
15335 "image",
15336 "reset",
15337 "submit"
15338 ];
15339 function isVisible(element) {
15340 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15341 const htmlElement = element;
15342 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15343 }
15344 function isTextField(element) {
15345 try {
15346 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15347 const isTextArea = element.tagName === "TEXTAREA";
15348 return isTextInput || isTextArea || false;
15349 } catch (_error) {
15350 return false;
15351 }
15352 }
15353 function isTextbox(element) {
15354 return element.isContentEditable || isTextField(element);
15355 }
15356 function getTextboxValue(element) {
15357 if (isTextField(element)) return element.value;
15358 if (element.isContentEditable) {
15359 const range = getDocument(element).createRange();
15360 range.selectNodeContents(element);
15361 return range.toString();
15362 }
15363 return "";
15364 }
15365 function getTextboxSelection(element) {
15366 let start = 0;
15367 let end = 0;
15368 if (isTextField(element)) {
15369 start = element.selectionStart || 0;
15370 end = element.selectionEnd || 0;
15371 } else if (element.isContentEditable) {
15372 const selection = getDocument(element).getSelection();
15373 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15374 const range = selection.getRangeAt(0);
15375 const nextRange = range.cloneRange();
15376 nextRange.selectNodeContents(element);
15377 nextRange.setEnd(range.startContainer, range.startOffset);
15378 start = nextRange.toString().length;
15379 nextRange.setEnd(range.endContainer, range.endOffset);
15380 end = nextRange.toString().length;
15381 }
15382 }
15383 return {
15384 start,
15385 end
15386 };
15387 }
15388 function getPopupRole(element, fallback) {
15389 const allowedPopupRoles = [
15390 "dialog",
15391 "menu",
15392 "listbox",
15393 "tree",
15394 "grid"
15395 ];
15396 const role = element?.getAttribute("role");
15397 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15398 return fallback;
15399 }
15400 function getScrollingElement(element) {
15401 if (!element) return null;
15402 const isScrollableOverflow = (overflow) => {
15403 if (overflow === "auto") return true;
15404 if (overflow === "scroll") return true;
15405 return false;
15406 };
15407 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15408 const { overflowY } = getComputedStyle(element);
15409 if (isScrollableOverflow(overflowY)) return element;
15410 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15411 const { overflowX } = getComputedStyle(element);
15412 if (isScrollableOverflow(overflowX)) return element;
15413 }
15414 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15415 }
15416 function setSelectionRange(element, ...args) {
15417 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15418 }
15419 function sortBasedOnDOMPosition(items, getElement) {
15420 const pairs = items.map((item, index2) => [index2, item]);
15421 let isOrderDifferent = false;
15422 pairs.sort(([indexA, a2], [indexB, b2]) => {
15423 const elementA = getElement(a2);
15424 const elementB = getElement(b2);
15425 if (elementA === elementB) return 0;
15426 if (!elementA || !elementB) return 0;
15427 if (isElementPreceding(elementA, elementB)) {
15428 if (indexA > indexB) isOrderDifferent = true;
15429 return -1;
15430 }
15431 if (indexA < indexB) isOrderDifferent = true;
15432 return 1;
15433 });
15434 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15435 return items;
15436 }
15437 function isElementPreceding(a2, b2) {
15438 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15439 }
15440 function isTouchDevice() {
15441 return canUseDOM && !!navigator.maxTouchPoints;
15442 }
15443 function isApple() {
15444 if (!canUseDOM) return false;
15445 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15446 }
15447 function isSafari2() {
15448 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15449 }
15450 function isFirefox2() {
15451 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15452 }
15453 function isPortalEvent(event) {
15454 const { currentTarget, target } = event;
15455 if (!currentTarget) return false;
15456 if (!isNode2(target)) return true;
15457 return !contains2(currentTarget, target);
15458 }
15459 function isSelfTarget(event) {
15460 return event.target === event.currentTarget;
15461 }
15462 function isOpeningInNewTab(event) {
15463 const element = event.currentTarget;
15464 if (!element) return false;
15465 const isAppleDevice = isApple();
15466 if (isAppleDevice && !event.metaKey) return false;
15467 if (!isAppleDevice && !event.ctrlKey) return false;
15468 const tagName = element.tagName.toLowerCase();
15469 if (tagName === "a") return true;
15470 if (tagName === "button" && element.type === "submit") return true;
15471 if (tagName === "input" && element.type === "submit") return true;
15472 return false;
15473 }
15474 function isDownloading(event) {
15475 const element = event.currentTarget;
15476 if (!element) return false;
15477 const tagName = element.tagName.toLowerCase();
15478 if (!event.altKey) return false;
15479 if (tagName === "a") return true;
15480 if (tagName === "button" && element.type === "submit") return true;
15481 if (tagName === "input" && element.type === "submit") return true;
15482 return false;
15483 }
15484 function fireBlurEvent(element, eventInit) {
15485 const event = new FocusEvent("blur", eventInit);
15486 const defaultAllowed = element.dispatchEvent(event);
15487 const bubbleInit = {
15488 ...eventInit,
15489 bubbles: true
15490 };
15491 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15492 return defaultAllowed;
15493 }
15494 function fireKeyboardEvent(element, type, eventInit) {
15495 const event = new KeyboardEvent(type, eventInit);
15496 return element.dispatchEvent(event);
15497 }
15498 function fireClickEvent(element, eventInit) {
15499 const event = new MouseEvent("click", eventInit);
15500 return element.dispatchEvent(event);
15501 }
15502 function isFocusEventOutside(event, container) {
15503 const containerElement = container || event.currentTarget;
15504 const relatedTarget = event.relatedTarget;
15505 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15506 }
15507 function queueBeforeEvent(element, type, callback, timeout) {
15508 const createTimer = (callback2) => {
15509 if (timeout) {
15510 const timerId2 = setTimeout(callback2, timeout);
15511 return () => clearTimeout(timerId2);
15512 }
15513 const timerId = requestAnimationFrame(callback2);
15514 return () => cancelAnimationFrame(timerId);
15515 };
15516 const cancelTimer = createTimer(() => {
15517 element.removeEventListener(type, callSync, true);
15518 callback();
15519 });
15520 const callSync = () => {
15521 cancelTimer();
15522 callback();
15523 };
15524 element.addEventListener(type, callSync, {
15525 once: true,
15526 capture: true
15527 });
15528 return cancelTimer;
15529 }
15530 function addGlobalEventListener(type, listener, options, scope = window) {
15531 const children = [];
15532 try {
15533 scope.document.addEventListener(type, listener, options);
15534 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15535 } catch {
15536 }
15537 const removeEventListener = () => {
15538 try {
15539 scope.document.removeEventListener(type, listener, options);
15540 } catch {
15541 }
15542 for (const remove of children) remove();
15543 };
15544 return removeEventListener;
15545 }
15546 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'])";
15547 function isFocusable(element) {
15548 if (!element.matches(selector)) return false;
15549 if (!isVisible(element)) return false;
15550 if (element.closest("[inert]")) return false;
15551 return true;
15552 }
15553 function hasFocus(element) {
15554 const activeElement2 = getActiveElement(element);
15555 if (!activeElement2) return false;
15556 if (activeElement2 === element) return true;
15557 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15558 if (!activeDescendant) return false;
15559 return activeDescendant === element.id;
15560 }
15561 function hasFocusWithin(element) {
15562 const activeElement2 = getActiveElement(element);
15563 if (!activeElement2) return false;
15564 if (contains2(element, activeElement2)) return true;
15565 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15566 if (!activeDescendant) return false;
15567 if (!("id" in element)) return false;
15568 if (activeDescendant === element.id) return true;
15569 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15570 }
15571 function focusIntoView(element, options) {
15572 if (!("scrollIntoView" in element)) element.focus();
15573 else {
15574 element.focus({ preventScroll: true });
15575 element.scrollIntoView({
15576 block: "nearest",
15577 inline: "nearest",
15578 ...options
15579 });
15580 }
15581 }
15582 function noop4(..._) {
15583 }
15584 function hasOwnProperty(object, prop) {
15585 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15586 return Object.prototype.hasOwnProperty.call(object, prop);
15587 }
15588 function chain(...fns) {
15589 return (...args) => {
15590 for (const fn of fns) if (typeof fn === "function") fn(...args);
15591 };
15592 }
15593 function normalizeString(str) {
15594 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15595 }
15596 function omit(object, keys) {
15597 const result = { ...object };
15598 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15599 return result;
15600 }
15601 function pick(object, paths) {
15602 const result = {};
15603 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15604 return result;
15605 }
15606 function identity(value) {
15607 return value;
15608 }
15609 function invariant(condition, message2) {
15610 if (condition) return;
15611 if (typeof message2 !== "string") throw new Error("Invariant failed");
15612 throw new Error(message2);
15613 }
15614 function getKeys(obj) {
15615 return Object.keys(obj);
15616 }
15617 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15618 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15619 if (result == null) return false;
15620 return !result;
15621 }
15622 function disabledFromProps(props) {
15623 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15624 }
15625 function removeUndefinedValues(obj) {
15626 const result = {};
15627 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15628 return result;
15629 }
15630 function defaultValue(...values) {
15631 for (const value of values) if (value !== void 0) return value;
15632 }
15633 function createUndoCallback(callback) {
15634 return async () => {
15635 const redo = await callback?.();
15636 return createUndoCallback(async () => {
15637 await redo?.();
15638 return callback;
15639 });
15640 };
15641 }
15642 var UndoManager = createUndoManager();
15643 function createUndoManager({ limit = 100 } = {}) {
15644 const undoStack = [];
15645 let redoStack = [];
15646 let currentGroup = null;
15647 const canUndo = () => undoStack.length > 0;
15648 const canRedo = () => redoStack.length > 0;
15649 const undo = async () => {
15650 if (!canUndo()) return;
15651 currentGroup = null;
15652 redoStack.push(await undoStack.pop()?.());
15653 };
15654 const redo = async () => {
15655 if (!canRedo()) return;
15656 currentGroup = null;
15657 undoStack.push(await redoStack.pop()?.());
15658 };
15659 const execute = async (callback, group) => {
15660 if (!callback) return;
15661 while (undoStack.length > limit) undoStack.shift();
15662 const sameGroup = group === currentGroup;
15663 currentGroup = group ?? null;
15664 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15665 const undoCallback = await callback();
15666 if (!undoCallback) return;
15667 redoStack = [];
15668 const currentUndo = undoStack[nextIndex];
15669 undoStack[nextIndex] = createUndoCallback(async () => {
15670 await undoCallback?.();
15671 const currentRedo = await currentUndo?.();
15672 return async () => {
15673 await currentRedo?.();
15674 await callback?.();
15675 };
15676 });
15677 };
15678 return {
15679 canUndo,
15680 canRedo,
15681 undo,
15682 redo,
15683 execute
15684 };
15685 }
15686
15687 // node_modules/@ariakit/react-utils/dist/index.js
15688 var React47 = __toESM(require_react(), 1);
15689 var import_react12 = __toESM(require_react(), 1);
15690 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15691 function setRef(ref, value) {
15692 if (typeof ref === "function") ref(value);
15693 else if (ref) ref.current = value;
15694 }
15695 function isValidElementWithRef(element) {
15696 if (!element) return false;
15697 if (!(0, import_react12.isValidElement)(element)) return false;
15698 if ("ref" in element.props) return true;
15699 if ("ref" in element) return true;
15700 return false;
15701 }
15702 function getRefProperty(element) {
15703 if (!isValidElementWithRef(element)) return null;
15704 return { ...element.props }.ref || element.ref;
15705 }
15706 function mergeProps2(base, overrides) {
15707 const props = { ...base };
15708 for (const key in overrides) {
15709 if (!hasOwnProperty(overrides, key)) continue;
15710 if (key === "className") {
15711 const prop = "className";
15712 const baseClass = base[prop];
15713 const overrideClass = overrides[prop];
15714 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15715 else props[prop] = overrideClass || baseClass;
15716 continue;
15717 }
15718 if (key === "style") {
15719 const prop = "style";
15720 props[prop] = base[prop] ? {
15721 ...base[prop],
15722 ...overrides[prop]
15723 } : overrides[prop];
15724 continue;
15725 }
15726 const overrideValue = overrides[key];
15727 if (key.startsWith("on")) {
15728 if (typeof overrideValue !== "function") continue;
15729 const baseValue = base[key];
15730 if (typeof baseValue === "function") {
15731 props[key] = (...args) => {
15732 overrideValue(...args);
15733 baseValue(...args);
15734 };
15735 continue;
15736 }
15737 }
15738 props[key] = overrideValue;
15739 }
15740 return props;
15741 }
15742 var _React = { ...React47 };
15743 var useReactId = _React.useId;
15744 var useReactDeferredValue = _React.useDeferredValue;
15745 var useReactInsertionEffect = _React.useInsertionEffect;
15746 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15747 function useInitialValue(value) {
15748 const [initialValue] = (0, import_react12.useState)(value);
15749 return initialValue;
15750 }
15751 function useLiveRef(value) {
15752 const ref = (0, import_react12.useRef)(value);
15753 useSafeLayoutEffect(() => {
15754 ref.current = value;
15755 });
15756 return ref;
15757 }
15758 function useEvent(callback) {
15759 const ref = (0, import_react12.useRef)(() => {
15760 throw new Error("Cannot call an event handler while rendering.");
15761 });
15762 if (useReactInsertionEffect) useReactInsertionEffect(() => {
15763 ref.current = callback;
15764 });
15765 else ref.current = callback;
15766 return (0, import_react12.useCallback)((...args) => ref.current?.(...args), []);
15767 }
15768 function useTransactionState(callback) {
15769 const [state, setState] = (0, import_react12.useState)(null);
15770 useSafeLayoutEffect(() => {
15771 if (state == null) return;
15772 if (!callback) return;
15773 let prevState = null;
15774 callback((prev) => {
15775 prevState = prev;
15776 return state;
15777 });
15778 return () => {
15779 callback(prevState);
15780 };
15781 }, [state, callback]);
15782 return [state, setState];
15783 }
15784 function useMergeRefs(...refs) {
15785 return (0, import_react12.useMemo)(() => {
15786 if (!refs.some(Boolean)) return;
15787 return (value) => {
15788 for (const ref of refs) setRef(ref, value);
15789 };
15790 }, refs);
15791 }
15792 function useId4(defaultId) {
15793 if (useReactId) {
15794 const reactId = useReactId();
15795 if (defaultId) return defaultId;
15796 return reactId;
15797 }
15798 const [id, setId] = (0, import_react12.useState)(defaultId);
15799 useSafeLayoutEffect(() => {
15800 if (defaultId || id) return;
15801 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
15802 }, [defaultId, id]);
15803 return defaultId || id;
15804 }
15805 function useTagName(refOrElement, type) {
15806 const stringOrUndefined = (type2) => {
15807 if (typeof type2 !== "string") return;
15808 return type2;
15809 };
15810 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15811 useSafeLayoutEffect(() => {
15812 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
15813 }, [refOrElement, type]);
15814 return tagName;
15815 }
15816 function useAttribute(refOrElement, attributeName, defaultValue2) {
15817 const initialValue = useInitialValue(defaultValue2);
15818 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15819 (0, import_react12.useEffect)(() => {
15820 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15821 if (!element) return;
15822 const callback = () => {
15823 const value = element.getAttribute(attributeName);
15824 setAttribute(value == null ? initialValue : value);
15825 };
15826 const observer = new MutationObserver(callback);
15827 observer.observe(element, { attributeFilter: [attributeName] });
15828 callback();
15829 return () => observer.disconnect();
15830 }, [
15831 refOrElement,
15832 attributeName,
15833 initialValue
15834 ]);
15835 return attribute;
15836 }
15837 function useUpdateEffect(effect, deps) {
15838 const mounted = (0, import_react12.useRef)(false);
15839 (0, import_react12.useEffect)(() => {
15840 if (mounted.current) return effect();
15841 mounted.current = true;
15842 }, deps);
15843 (0, import_react12.useEffect)(() => () => {
15844 mounted.current = false;
15845 }, []);
15846 }
15847 function useUpdateLayoutEffect(effect, deps) {
15848 const mounted = (0, import_react12.useRef)(false);
15849 useSafeLayoutEffect(() => {
15850 if (mounted.current) return effect();
15851 mounted.current = true;
15852 }, deps);
15853 useSafeLayoutEffect(() => () => {
15854 mounted.current = false;
15855 }, []);
15856 }
15857 function useForceUpdate() {
15858 return (0, import_react12.useReducer)(() => [], []);
15859 }
15860 function useBooleanEvent(booleanOrCallback) {
15861 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
15862 }
15863 function useWrapElement(props, callback, deps = []) {
15864 const wrapElement = (0, import_react12.useCallback)((element) => {
15865 if (props.wrapElement) element = props.wrapElement(element);
15866 return callback(element);
15867 }, [...deps, props.wrapElement]);
15868 return {
15869 ...props,
15870 wrapElement
15871 };
15872 }
15873 function useMetadataProps(props, key, value) {
15874 const parent = props.onLoadedMetadataCapture;
15875 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15876 return Object.assign(() => {
15877 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
15878 }, [
15879 parent,
15880 key,
15881 value
15882 ]);
15883 return [parent?.[key], { onLoadedMetadataCapture }];
15884 }
15885 var hasInstalledGlobalEventListeners = false;
15886 function useIsMouseMoving() {
15887 (0, import_react12.useEffect)(() => {
15888 if (hasInstalledGlobalEventListeners) return;
15889 addGlobalEventListener("mousemove", setMouseMoving, true);
15890 addGlobalEventListener("mousedown", resetMouseMoving, true);
15891 addGlobalEventListener("mouseup", resetMouseMoving, true);
15892 addGlobalEventListener("keydown", resetMouseMoving, true);
15893 addGlobalEventListener("scroll", resetMouseMoving, true);
15894 hasInstalledGlobalEventListeners = true;
15895 }, []);
15896 return useEvent(() => mouseMoving);
15897 }
15898 var mouseMoving = false;
15899 var previousScreenX = 0;
15900 var previousScreenY = 0;
15901 function hasMouseMovement(event) {
15902 const movementX = event.movementX || event.screenX - previousScreenX;
15903 const movementY = event.movementY || event.screenY - previousScreenY;
15904 previousScreenX = event.screenX;
15905 previousScreenY = event.screenY;
15906 return movementX || movementY || false;
15907 }
15908 function setMouseMoving(event) {
15909 if (!hasMouseMovement(event)) return;
15910 mouseMoving = true;
15911 }
15912 function resetMouseMoving() {
15913 mouseMoving = false;
15914 }
15915 function forwardRef30(render4) {
15916 const Role = React47.forwardRef((props, ref) => render4({
15917 ...props,
15918 ref
15919 }));
15920 Role.displayName = render4.displayName || render4.name;
15921 return Role;
15922 }
15923 function memo3(Component, propsAreEqual) {
15924 return React47.memo(Component, propsAreEqual);
15925 }
15926 function createElement3(Type, props) {
15927 const { wrapElement, render: render4, ...rest } = props;
15928 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15929 let element;
15930 if (React47.isValidElement(render4)) {
15931 const renderProps = {
15932 ...render4.props,
15933 ref: mergedRef
15934 };
15935 element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
15936 } else if (render4) element = render4(rest);
15937 else element = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Type, { ...rest });
15938 if (wrapElement) return wrapElement(element);
15939 return element;
15940 }
15941 function createHook(useProps) {
15942 const useRole = (props = {}) => {
15943 return useProps(props);
15944 };
15945 useRole.displayName = useProps.name;
15946 return useRole;
15947 }
15948 function createStoreContext(providers = [], scopedProviders = []) {
15949 const context = React47.createContext(void 0);
15950 const scopedContext = React47.createContext(void 0);
15951 const useContext38 = () => React47.useContext(context);
15952 const useScopedContext = (onlyScoped = false) => {
15953 const scoped = React47.useContext(scopedContext);
15954 const store = useContext38();
15955 if (onlyScoped) return scoped;
15956 return scoped || store;
15957 };
15958 const useProviderContext = () => {
15959 const scoped = React47.useContext(scopedContext);
15960 const store = useContext38();
15961 if (scoped && scoped === store) return;
15962 return store;
15963 };
15964 const ContextProvider = (props) => {
15965 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, {
15966 ...props,
15967 children
15968 }), /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(context.Provider, { ...props }));
15969 };
15970 const ScopedContextProvider = (props) => {
15971 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContextProvider, {
15972 ...props,
15973 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, {
15974 ...props,
15975 children
15976 }), /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(scopedContext.Provider, { ...props }))
15977 });
15978 };
15979 return {
15980 context,
15981 scopedContext,
15982 useContext: useContext38,
15983 useScopedContext,
15984 useProviderContext,
15985 ContextProvider,
15986 ScopedContextProvider
15987 };
15988 }
15989
15990 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
15991 var import_react13 = __toESM(require_react(), 1);
15992 var TagName = "div";
15993 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
15994 var isSafariBrowser = isSafari2();
15995 var alwaysFocusVisibleInputTypes = [
15996 "text",
15997 "search",
15998 "url",
15999 "tel",
16000 "email",
16001 "password",
16002 "number",
16003 "date",
16004 "month",
16005 "week",
16006 "time",
16007 "datetime",
16008 "datetime-local"
16009 ];
16010 function isAlwaysFocusVisible(element) {
16011 const { tagName, readOnly, type } = element;
16012 if (tagName === "TEXTAREA" && !readOnly) return true;
16013 if (tagName === "SELECT" && !readOnly) return true;
16014 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
16015 if (element.isContentEditable) return true;
16016 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
16017 return false;
16018 }
16019 function isNativeTabbable(tagName) {
16020 if (!tagName) return true;
16021 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16022 }
16023 function supportsDisabledAttribute(tagName) {
16024 if (!tagName) return true;
16025 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16026 }
16027 var buttonInputTypes2 = [
16028 "button",
16029 "color",
16030 "file",
16031 "image",
16032 "reset",
16033 "submit"
16034 ];
16035 function needsSafariTabIndex(tagName, inputType) {
16036 if (tagName === "button") return true;
16037 if (tagName === "input" && inputType) {
16038 if (inputType === "checkbox" || inputType === "radio") return true;
16039 return buttonInputTypes2.includes(inputType);
16040 }
16041 return false;
16042 }
16043 function isNativeSubmitControl(element) {
16044 if (element.tagName === "BUTTON") {
16045 const { type } = element;
16046 return type === "submit";
16047 }
16048 if (element.tagName === "INPUT") {
16049 const { type } = element;
16050 return type === "submit" || type === "image";
16051 }
16052 return false;
16053 }
16054 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16055 if (!focusable2) return tabIndexProp;
16056 if (trulyDisabled) {
16057 if (nativeTabbable && !supportsDisabled) return -1;
16058 return;
16059 }
16060 if (nativeTabbable) {
16061 if (safariTabIndex && tabIndexProp == null) return 0;
16062 return tabIndexProp;
16063 }
16064 return tabIndexProp ?? 0;
16065 }
16066 function useDisableEvent(onEvent, disabled2) {
16067 return useEvent((event) => {
16068 onEvent?.(event);
16069 if (event.defaultPrevented) return;
16070 if (disabled2) {
16071 event.stopPropagation();
16072 event.preventDefault();
16073 }
16074 });
16075 }
16076 var hasInstalledGlobalEventListeners2 = false;
16077 var isKeyboardModality = true;
16078 function onGlobalMouseDown(event) {
16079 const target = event.target;
16080 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16081 }
16082 function onGlobalKeyDown(event) {
16083 if (event.metaKey) return;
16084 if (event.ctrlKey) return;
16085 if (event.altKey) return;
16086 isKeyboardModality = true;
16087 }
16088 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16089 const ref = (0, import_react13.useRef)(null);
16090 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16091 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16092 (0, import_react13.useEffect)(() => {
16093 if (!focusable2) return;
16094 if (hasInstalledGlobalEventListeners2) return;
16095 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16096 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16097 hasInstalledGlobalEventListeners2 = true;
16098 }, [focusable2]);
16099 const disabled2 = focusable2 && disabledFromProps(props);
16100 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16101 const [focusVisible, setFocusVisible] = (0, import_react13.useState)(false);
16102 const focusVisibleRef = (0, import_react13.useRef)(false);
16103 const nativeSubmitObserverCleanupRef = (0, import_react13.useRef)(null);
16104 const cleanupFocusVisible = useEvent((element) => {
16105 nativeSubmitObserverCleanupRef.current?.();
16106 nativeSubmitObserverCleanupRef.current = null;
16107 focusVisibleRef.current = false;
16108 element?.removeAttribute("data-focus-visible");
16109 });
16110 (0, import_react13.useEffect)(() => {
16111 if (!focusable2) return;
16112 if (!trulyDisabled) return;
16113 cleanupFocusVisible(ref.current);
16114 if (focusVisible) setFocusVisible(false);
16115 }, [
16116 focusable2,
16117 trulyDisabled,
16118 focusVisible,
16119 cleanupFocusVisible
16120 ]);
16121 (0, import_react13.useEffect)(() => {
16122 if (!focusable2) return;
16123 if (!focusVisible) return;
16124 const element = ref.current;
16125 if (!element) return;
16126 if (typeof IntersectionObserver === "undefined") return;
16127 const observer = new IntersectionObserver(() => {
16128 if (!isFocusable(element)) {
16129 focusVisibleRef.current = false;
16130 setFocusVisible(false);
16131 }
16132 });
16133 observer.observe(element);
16134 return () => observer.disconnect();
16135 }, [focusable2, focusVisible]);
16136 (0, import_react13.useEffect)(() => {
16137 return () => nativeSubmitObserverCleanupRef.current?.();
16138 }, []);
16139 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16140 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16141 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16142 const handleFocusVisible = (event, currentTarget) => {
16143 if (currentTarget) event.currentTarget = currentTarget;
16144 if (!focusable2) return;
16145 const element = event.currentTarget;
16146 if (!element) return;
16147 if (!hasFocus(element)) return;
16148 onFocusVisible?.(event);
16149 if (event.defaultPrevented) return;
16150 element.dataset.focusVisible = "true";
16151 focusVisibleRef.current = true;
16152 if (isNativeSubmitControl(element)) {
16153 nativeSubmitObserverCleanupRef.current?.();
16154 nativeSubmitObserverCleanupRef.current = null;
16155 if (typeof IntersectionObserver !== "undefined") {
16156 const observer = new IntersectionObserver(() => {
16157 if (isFocusable(element)) return;
16158 cleanupFocusVisible(element);
16159 });
16160 observer.observe(element);
16161 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16162 }
16163 return;
16164 }
16165 setFocusVisible(true);
16166 };
16167 const onKeyDownCaptureProp = props.onKeyDownCapture;
16168 const onKeyDownCapture = useEvent((event) => {
16169 onKeyDownCaptureProp?.(event);
16170 if (event.defaultPrevented) return;
16171 if (!focusable2) return;
16172 if (focusVisible) return;
16173 if (focusVisibleRef.current) return;
16174 if (event.metaKey) return;
16175 if (event.altKey) return;
16176 if (event.ctrlKey) return;
16177 if (!isSelfTarget(event)) return;
16178 const element = event.currentTarget;
16179 const applyFocusVisible = () => handleFocusVisible(event, element);
16180 queueBeforeEvent(element, "focusout", applyFocusVisible);
16181 });
16182 const onFocusCaptureProp = props.onFocusCapture;
16183 const onFocusCapture = useEvent((event) => {
16184 onFocusCaptureProp?.(event);
16185 if (event.defaultPrevented) return;
16186 if (!focusable2) return;
16187 if (!isSelfTarget(event)) {
16188 setFocusVisible(false);
16189 return;
16190 }
16191 const element = event.currentTarget;
16192 const applyFocusVisible = () => handleFocusVisible(event, element);
16193 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16194 else setFocusVisible(false);
16195 });
16196 const onBlurProp = props.onBlur;
16197 const onBlur = useEvent((event) => {
16198 onBlurProp?.(event);
16199 if (!focusable2) return;
16200 if (!isFocusEventOutside(event)) return;
16201 cleanupFocusVisible(event.currentTarget);
16202 setFocusVisible(false);
16203 });
16204 const autoFocusOnShow = (0, import_react13.useContext)(FocusableContext);
16205 const autoFocusRef = useEvent((element) => {
16206 if (!focusable2) return;
16207 if (!autoFocus) return;
16208 if (!element) return;
16209 if (!autoFocusOnShow) return;
16210 queueMicrotask(() => {
16211 if (hasFocus(element)) return;
16212 if (!isFocusable(element)) return;
16213 element.focus();
16214 });
16215 });
16216 const tagName = useTagName(ref);
16217 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16218 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16219 const [safariTabIndex, setSafariTabIndex] = (0, import_react13.useState)(false);
16220 if (isSafariBrowser) (0, import_react13.useEffect)(() => {
16221 if (!focusable2) return;
16222 const element = ref.current;
16223 if (!element) return;
16224 const tag = element.tagName.toLowerCase();
16225 const type = element.type;
16226 setSafariTabIndex(needsSafariTabIndex(tag, type));
16227 }, [focusable2]);
16228 const styleProp = props.style;
16229 const style = (0, import_react13.useMemo)(() => {
16230 if (trulyDisabled) return {
16231 pointerEvents: "none",
16232 ...styleProp
16233 };
16234 return styleProp;
16235 }, [trulyDisabled, styleProp]);
16236 props = {
16237 "data-focus-visible": focusable2 && focusVisible || void 0,
16238 "data-autofocus": autoFocus || void 0,
16239 "aria-disabled": disabled2 || void 0,
16240 ...props,
16241 ...metadataProps,
16242 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16243 style,
16244 tabIndex: getTabIndex2({
16245 focusable: focusable2,
16246 trulyDisabled,
16247 nativeTabbable,
16248 supportsDisabled,
16249 safariTabIndex,
16250 tabIndexProp: props.tabIndex
16251 }),
16252 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16253 contentEditable: disabled2 ? void 0 : props.contentEditable,
16254 onKeyPressCapture,
16255 onClickCapture,
16256 onMouseDownCapture,
16257 onKeyDownCapture,
16258 onFocusCapture,
16259 onBlur
16260 };
16261 return removeUndefinedValues(props);
16262 });
16263 var Focusable = forwardRef30(function Focusable2(props) {
16264 return createElement3(TagName, useFocusable(props));
16265 });
16266
16267 // node_modules/@ariakit/react-components/dist/command/command.js
16268 var import_react14 = __toESM(require_react(), 1);
16269 var TagName2 = "button";
16270 function isNativeClick(event) {
16271 if (!event.isTrusted) return false;
16272 const element = event.currentTarget;
16273 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16274 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16275 return false;
16276 }
16277 var symbol = /* @__PURE__ */ Symbol("command");
16278 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16279 const ref = (0, import_react14.useRef)(null);
16280 const [isNativeButton, setIsNativeButton] = (0, import_react14.useState)(false);
16281 (0, import_react14.useEffect)(() => {
16282 if (!ref.current) return;
16283 setIsNativeButton(isButton(ref.current));
16284 }, []);
16285 const [active, setActive] = (0, import_react14.useState)(false);
16286 const activeRef = (0, import_react14.useRef)(false);
16287 const disabled2 = disabledFromProps(props);
16288 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16289 const onKeyDownProp = props.onKeyDown;
16290 const onKeyDown = useEvent((event) => {
16291 onKeyDownProp?.(event);
16292 const element = event.currentTarget;
16293 if (event.defaultPrevented) return;
16294 if (isDuplicate) return;
16295 if (disabled2) return;
16296 if (!isSelfTarget(event)) return;
16297 if (isTextField(element)) return;
16298 if (element.isContentEditable) return;
16299 const isEnter = clickOnEnter && event.key === "Enter";
16300 const isSpace = clickOnSpace && event.key === " ";
16301 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16302 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16303 if (shouldPreventEnter || shouldPreventSpace) {
16304 event.preventDefault();
16305 return;
16306 }
16307 if (isEnter || isSpace) {
16308 const nativeClick = isNativeClick(event);
16309 if (isEnter) {
16310 if (!nativeClick) {
16311 event.preventDefault();
16312 const { view, ...eventInit } = event;
16313 const click = () => fireClickEvent(element, eventInit);
16314 if (isFirefox2()) queueBeforeEvent(element, "keyup", click);
16315 else queueMicrotask(click);
16316 }
16317 } else if (isSpace) {
16318 activeRef.current = true;
16319 if (!nativeClick) {
16320 event.preventDefault();
16321 setActive(true);
16322 }
16323 }
16324 }
16325 });
16326 const onKeyUpProp = props.onKeyUp;
16327 const onKeyUp = useEvent((event) => {
16328 onKeyUpProp?.(event);
16329 if (event.defaultPrevented) return;
16330 if (isDuplicate) return;
16331 if (disabled2) return;
16332 if (event.metaKey) return;
16333 const isSpace = clickOnSpace && event.key === " ";
16334 if (activeRef.current && isSpace) {
16335 activeRef.current = false;
16336 if (!isNativeClick(event)) {
16337 event.preventDefault();
16338 setActive(false);
16339 const element = event.currentTarget;
16340 const { view, ...eventInit } = event;
16341 queueMicrotask(() => fireClickEvent(element, eventInit));
16342 }
16343 }
16344 });
16345 props = {
16346 "data-active": active || void 0,
16347 type: isNativeButton ? "button" : void 0,
16348 ...metadataProps,
16349 ...props,
16350 ref: useMergeRefs(ref, props.ref),
16351 onKeyDown,
16352 onKeyUp
16353 };
16354 props = useFocusable(props);
16355 return props;
16356 });
16357 var Command = forwardRef30(function Command2(props) {
16358 return createElement3(TagName2, useCommand(props));
16359 });
16360
16361 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16362 var ctx = createStoreContext();
16363 var useCollectionContext = ctx.useContext;
16364 var useCollectionScopedContext = ctx.useScopedContext;
16365 var useCollectionProviderContext = ctx.useProviderContext;
16366 var CollectionContextProvider = ctx.ContextProvider;
16367 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16368
16369 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16370 var import_react15 = __toESM(require_react(), 1);
16371 var TagName3 = "div";
16372 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16373 const context = useCollectionContext();
16374 store = store || context;
16375 const id = useId4(props.id);
16376 const ref = (0, import_react15.useRef)(element);
16377 (0, import_react15.useEffect)(() => {
16378 const element2 = ref.current;
16379 if (!id) return;
16380 if (!element2) return;
16381 if (!shouldRegisterItem) return;
16382 const item = getItem({
16383 id,
16384 element: element2
16385 });
16386 return store?.renderItem(item);
16387 }, [
16388 id,
16389 shouldRegisterItem,
16390 getItem,
16391 store
16392 ]);
16393 props = {
16394 ...props,
16395 ref: useMergeRefs(ref, props.ref)
16396 };
16397 return removeUndefinedValues(props);
16398 });
16399 var CollectionItem = forwardRef30(function CollectionItem2(props) {
16400 return createElement3(TagName3, useCollectionItem(props));
16401 });
16402
16403 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16404 var import_react16 = __toESM(require_react(), 1);
16405 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16406 var useCompositeContext = ctx2.useContext;
16407 var useCompositeScopedContext = ctx2.useScopedContext;
16408 var useCompositeProviderContext = ctx2.useProviderContext;
16409 var CompositeContextProvider = ctx2.ContextProvider;
16410 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16411 var CompositeItemContext = (0, import_react16.createContext)(void 0);
16412 var CompositeRowContext = (0, import_react16.createContext)(void 0);
16413
16414 // node_modules/@ariakit/react-components/dist/composite/utils.js
16415 function findFirstEnabledItem(items, excludeId) {
16416 return items.find((item) => {
16417 if (excludeId) return !item.disabled && item.id !== excludeId;
16418 return !item.disabled;
16419 });
16420 }
16421 function getEnabledItem(store, id) {
16422 if (!id) return null;
16423 return store.item(id) || null;
16424 }
16425 function groupItemsByRows(items) {
16426 const rows = [];
16427 for (const item of items) {
16428 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
16429 if (row) row.push(item);
16430 else rows.push([item]);
16431 }
16432 return rows;
16433 }
16434 function selectTextField(element, collapseToEnd = false) {
16435 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
16436 else if (element.isContentEditable) {
16437 const selection = getDocument(element).getSelection();
16438 selection?.selectAllChildren(element);
16439 if (collapseToEnd) selection?.collapseToEnd();
16440 }
16441 }
16442 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
16443 function focusSilently(element) {
16444 element[FOCUS_SILENTLY] = true;
16445 element.focus({ preventScroll: true });
16446 }
16447 function silentlyFocused(element) {
16448 const isSilentlyFocused = element[FOCUS_SILENTLY];
16449 delete element[FOCUS_SILENTLY];
16450 return isSilentlyFocused;
16451 }
16452 function isItem(store, element, exclude) {
16453 if (!element) return false;
16454 if (element === exclude) return false;
16455 const item = store.item(element.id);
16456 if (!item) return false;
16457 if (exclude && item.element === exclude) return false;
16458 return true;
16459 }
16460
16461 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
16462 var import_react17 = __toESM(require_react(), 1);
16463 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16464
16465 // node_modules/@ariakit/store/dist/index.js
16466 function getInternal(store, key) {
16467 const internals = store.__unstableInternals;
16468 invariant(internals, "Invalid store");
16469 return internals[key];
16470 }
16471 function hasUpdatedKey(keys, updatedKey) {
16472 if (!keys) return true;
16473 for (const currentKey of keys) if (updatedKey instanceof Set) {
16474 if (updatedKey.has(currentKey)) return true;
16475 } else if (currentKey === updatedKey) return true;
16476 return false;
16477 }
16478 function addKeyedListener(map, keys, listener) {
16479 if (!keys) return;
16480 for (const key of keys) {
16481 let listeners = map.get(key);
16482 if (!listeners) {
16483 listeners = /* @__PURE__ */ new Set();
16484 map.set(key, listeners);
16485 }
16486 listeners.add(listener);
16487 }
16488 }
16489 function deleteKeyedListener(map, keys, listener) {
16490 if (!map) return;
16491 if (!keys) return;
16492 for (const key of keys) {
16493 const listeners = map.get(key);
16494 if (!listeners) continue;
16495 listeners.delete(listener);
16496 if (!listeners.size) map.delete(key);
16497 }
16498 }
16499 function createStore(initialState, ...stores) {
16500 let state = initialState;
16501 let prevStateBatch = state;
16502 let destroy = noop4;
16503 let batchPending = false;
16504 let inDispatch = false;
16505 let updatedKeys = /* @__PURE__ */ new Set();
16506 const instances = /* @__PURE__ */ new Set();
16507 const setups = /* @__PURE__ */ new Set();
16508 const syncListenerGroup = {
16509 listeners: /* @__PURE__ */ new Set(),
16510 disposables: /* @__PURE__ */ new Map(),
16511 listenerKeys: /* @__PURE__ */ new WeakMap()
16512 };
16513 const batchListenerGroup = {
16514 listeners: /* @__PURE__ */ new Set(),
16515 disposables: /* @__PURE__ */ new Map(),
16516 listenerKeys: /* @__PURE__ */ new WeakMap()
16517 };
16518 const storeSetup = (callback) => {
16519 setups.add(callback);
16520 return () => setups.delete(callback);
16521 };
16522 const storeInit = () => {
16523 const initializedInstances = instances.size;
16524 const instance = /* @__PURE__ */ Symbol();
16525 instances.add(instance);
16526 const maybeDestroy = () => {
16527 instances.delete(instance);
16528 if (instances.size) return;
16529 destroy();
16530 };
16531 if (initializedInstances) return maybeDestroy;
16532 const stateKeys = getKeys(state);
16533 const desyncs = [];
16534 for (const store of stores) {
16535 const storeState = store?.getState?.();
16536 if (!storeState) continue;
16537 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16538 if (!keys.length) continue;
16539 if (stores.length === 1 || keys.length === stateKeys.length) {
16540 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16541 setState(key, state2[key], true);
16542 }));
16543 continue;
16544 }
16545 let didSyncInitialState = false;
16546 desyncs.push(sync(store, keys, (state2, prevState) => {
16547 for (const key of keys) {
16548 if (didSyncInitialState && state2[key] === prevState[key]) continue;
16549 setState(key, state2[key], true);
16550 }
16551 didSyncInitialState = true;
16552 }));
16553 }
16554 const teardowns = [];
16555 for (const setup2 of setups) teardowns.push(setup2());
16556 const cleanups = stores.map(init);
16557 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16558 return maybeDestroy;
16559 };
16560 const deleteListenerIndexes = (group, listener, keys) => {
16561 if (keys === void 0) return;
16562 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16563 else group.allKeysListeners?.delete(listener);
16564 };
16565 const registerListener = (keys, listener, group = syncListenerGroup) => {
16566 const listenerKeysValue = keys ? [...keys] : null;
16567 if (group.listeners.has(listener)) deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16568 group.listeners.add(listener);
16569 if (listenerKeysValue) {
16570 group.listenersByKey ??= /* @__PURE__ */ new Map();
16571 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16572 } else {
16573 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16574 group.allKeysListeners.add(listener);
16575 }
16576 group.listenerKeys.set(listener, listenerKeysValue);
16577 return () => {
16578 group.disposables.get(listener)?.();
16579 group.disposables.delete(listener);
16580 const currentKeys = group.listenerKeys.get(listener);
16581 deleteListenerIndexes(group, listener, listenerKeysValue);
16582 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16583 group.listenerKeys.delete(listener);
16584 group.listeners.delete(listener);
16585 };
16586 };
16587 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16588 const reconcileInitialCleanup = (group, listener, cleanup) => {
16589 if (cleanup) group.disposables.set(listener, cleanup);
16590 else group.disposables.delete(listener);
16591 };
16592 const storeSync = (keys, listener) => {
16593 reconcileInitialCleanup(syncListenerGroup, listener, listener(state, state));
16594 return registerListener(keys, listener);
16595 };
16596 const storeBatch = (keys, listener) => {
16597 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
16598 reconcileInitialCleanup(batchListenerGroup, listener, listener(state, prevStateBatch));
16599 return registerListener(keys, listener, batchListenerGroup);
16600 };
16601 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16602 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16603 const getState = () => state;
16604 const runListeners = (group, prevState, updatedKey) => {
16605 const { disposables } = group;
16606 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
16607 const keyedListeners = group.listenersByKey?.get(updatedKey);
16608 if (!keyedListeners) return;
16609 for (const listener of keyedListeners) {
16610 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16611 if (cleanup) cleanup();
16612 const result = listener(state, prevState);
16613 if (result) disposables.set(listener, result);
16614 else if (cleanup) disposables.delete(listener);
16615 }
16616 return;
16617 }
16618 const allKeysListeners = group.allKeysListeners;
16619 for (const listener of group.listeners) {
16620 if (!allKeysListeners?.has(listener)) {
16621 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16622 }
16623 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16624 if (cleanup) cleanup();
16625 const result = listener(state, prevState);
16626 if (result) disposables.set(listener, result);
16627 else if (cleanup) disposables.delete(listener);
16628 }
16629 };
16630 const setState = (key, value, fromStores = false) => {
16631 if (!hasOwnProperty(state, key)) return;
16632 const currentValue = state[key];
16633 const nextValue = typeof value === "function" ? value(currentValue) : value;
16634 if (nextValue === currentValue) return;
16635 if (!fromStores && stores.length) for (const store of stores) store?.setState?.(key, nextValue);
16636 const prevState = state;
16637 state = {
16638 ...state,
16639 [key]: nextValue
16640 };
16641 const wasInDispatch = inDispatch;
16642 inDispatch = true;
16643 try {
16644 runListeners(syncListenerGroup, prevState, key);
16645 } finally {
16646 inDispatch = wasInDispatch;
16647 }
16648 if (!batchListenerGroup.listeners.size) {
16649 if (!inDispatch) prevStateBatch = state;
16650 return;
16651 }
16652 updatedKeys.add(key);
16653 if (batchPending) return;
16654 batchPending = true;
16655 queueMicrotask(() => {
16656 batchPending = false;
16657 const snapshot = state;
16658 const updatedKeysSnapshot = updatedKeys;
16659 updatedKeys = /* @__PURE__ */ new Set();
16660 const prevStateBatchBefore = prevStateBatch;
16661 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
16662 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
16663 });
16664 };
16665 const finalStore = {
16666 getState,
16667 setState,
16668 __unstableInternals: {
16669 setup: storeSetup,
16670 init: storeInit,
16671 subscribe: storeSubscribe,
16672 sync: storeSync,
16673 batch: storeBatch,
16674 pick: storePick,
16675 omit: storeOmit
16676 }
16677 };
16678 return finalStore;
16679 }
16680 function setup(store, ...args) {
16681 if (!store) return;
16682 return getInternal(store, "setup")(...args);
16683 }
16684 function init(store, ...args) {
16685 if (!store) return;
16686 return getInternal(store, "init")(...args);
16687 }
16688 function subscribe(store, ...args) {
16689 if (!store) return;
16690 return getInternal(store, "subscribe")(...args);
16691 }
16692 function sync(store, ...args) {
16693 if (!store) return;
16694 return getInternal(store, "sync")(...args);
16695 }
16696 function batch(store, ...args) {
16697 if (!store) return;
16698 return getInternal(store, "batch")(...args);
16699 }
16700 function omit2(store, ...args) {
16701 if (!store) return;
16702 return getInternal(store, "omit")(...args);
16703 }
16704 function pick2(store, ...args) {
16705 if (!store) return;
16706 return getInternal(store, "pick")(...args);
16707 }
16708 function mergeStore(...stores) {
16709 const initialState = {};
16710 for (const store2 of stores) {
16711 const nextState = store2?.getState?.();
16712 if (nextState) Object.assign(initialState, nextState);
16713 }
16714 const store = createStore(initialState, ...stores);
16715 return Object.assign({}, ...stores, store);
16716 }
16717 function throwOnConflictingProps(props, store) {
16718 if (false) return;
16719 if (!store) return;
16720 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16721 const stateKey = key.replace("default", "");
16722 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
16723 });
16724 if (!defaultKeys.length) return;
16725 const storeState = store.getState();
16726 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
16727 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
16728
16729 const store = useSelectStore();
16730 <SelectProvider store={store} defaultValue="Apple" />
16731 ^ ^
16732
16733 Instead, pass the default state to the topmost store:
16734
16735 const store = useSelectStore({ defaultValue: "Apple" });
16736 <SelectProvider store={store} />
16737
16738 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16739
16740 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16741 `);
16742 }
16743
16744 // node_modules/@ariakit/react-store/dist/index.js
16745 var React48 = __toESM(require_react(), 1);
16746 var import_shim2 = __toESM(require_shim(), 1);
16747 var noopSubscribe = () => () => {
16748 };
16749 function useStoreState(store, keyOrSelector = identity) {
16750 const storeSubscribe = React48.useCallback((callback) => {
16751 if (!store) return noopSubscribe();
16752 return subscribe(store, null, callback);
16753 }, [store]);
16754 const getSnapshot = () => {
16755 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16756 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16757 const state = store?.getState();
16758 if (selector2) return selector2(state);
16759 if (!state) return;
16760 if (!key) return;
16761 if (!hasOwnProperty(state, key)) return;
16762 return state[key];
16763 };
16764 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16765 }
16766 function useStoreStateObject(store, object) {
16767 const objRef = React48.useRef({});
16768 const storeSubscribe = React48.useCallback((callback) => {
16769 if (!store) return noopSubscribe();
16770 return subscribe(store, null, callback);
16771 }, [store]);
16772 const getSnapshot = () => {
16773 const state = store?.getState();
16774 let updated = false;
16775 const obj = objRef.current;
16776 for (const prop in object) {
16777 const keyOrSelector = object[prop];
16778 if (typeof keyOrSelector === "function") {
16779 const value = keyOrSelector(state);
16780 if (value !== obj[prop]) {
16781 obj[prop] = value;
16782 updated = true;
16783 }
16784 }
16785 if (typeof keyOrSelector === "string") {
16786 if (!state) continue;
16787 if (!hasOwnProperty(state, keyOrSelector)) continue;
16788 const value = state[keyOrSelector];
16789 if (value !== obj[prop]) {
16790 obj[prop] = value;
16791 updated = true;
16792 }
16793 }
16794 }
16795 if (updated) objRef.current = { ...obj };
16796 return objRef.current;
16797 };
16798 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16799 }
16800 function useStoreProps(store, props, key, setKey) {
16801 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16802 const propsRef = useLiveRef({
16803 value,
16804 setValue: setKey ? props[setKey] : void 0
16805 });
16806 useSafeLayoutEffect(() => {
16807 return sync(store, [key], (state, prev) => {
16808 const { value: value2, setValue } = propsRef.current;
16809 if (!setValue) return;
16810 if (state[key] === prev[key]) return;
16811 if (state[key] === value2) return;
16812 setValue(state[key]);
16813 });
16814 }, [store, key]);
16815 useSafeLayoutEffect(() => {
16816 if (value === void 0) return;
16817 store.setState(key, value);
16818 return batch(store, [key], () => {
16819 if (value === void 0) return;
16820 store.setState(key, value);
16821 });
16822 });
16823 }
16824 function useStore2(createStore2, props) {
16825 const [store, setStore] = React48.useState(() => createStore2(props));
16826 useSafeLayoutEffect(() => init(store), [store]);
16827 const useState36 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
16828 return [React48.useMemo(() => ({
16829 ...store,
16830 useState: useState36
16831 }), [store, useState36]), useEvent(() => {
16832 setStore((store2) => createStore2({
16833 ...props,
16834 ...store2.getState()
16835 }));
16836 })];
16837 }
16838
16839 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
16840 var TagName4 = "button";
16841 function isEditableElement(element) {
16842 if (isTextbox(element)) return true;
16843 return element.tagName === "INPUT" && !isButton(element);
16844 }
16845 function getNextPageOffset(scrollingElement, pageUp = false) {
16846 const height = scrollingElement.clientHeight;
16847 const { top } = scrollingElement.getBoundingClientRect();
16848 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16849 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16850 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
16851 return pageOffset;
16852 }
16853 function getItemOffset(itemElement, pageUp = false) {
16854 const { top } = itemElement.getBoundingClientRect();
16855 if (pageUp) return top + itemElement.clientHeight;
16856 return top;
16857 }
16858 function findNextPageItemId(element, store, next, pageUp = false) {
16859 if (!store) return;
16860 if (!next) return;
16861 const { renderedItems } = store.getState();
16862 const scrollingElement = getScrollingElement(element);
16863 if (!scrollingElement) return;
16864 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16865 let id;
16866 let prevDifference;
16867 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16868 const previousId = id;
16869 id = next(i2);
16870 if (!id) break;
16871 if (id === previousId) continue;
16872 const itemElement = getEnabledItem(store, id)?.element;
16873 if (!itemElement) continue;
16874 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
16875 const absDifference = Math.abs(difference);
16876 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16877 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
16878 break;
16879 }
16880 prevDifference = absDifference;
16881 }
16882 return id;
16883 }
16884 function targetIsAnotherItem(event, store) {
16885 if (isSelfTarget(event)) return false;
16886 return isItem(store, event.target);
16887 }
16888 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
16889 const context = useCompositeScopedContext();
16890 store = store || context;
16891 const id = useId4(props.id);
16892 const ref = (0, import_react17.useRef)(null);
16893 const row = (0, import_react17.useContext)(CompositeRowContext);
16894 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
16895 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
16896 rowId(state) {
16897 if (rowIdProp) return rowIdProp;
16898 if (!state) return;
16899 if (!row?.baseElement) return;
16900 if (row.baseElement !== state.baseElement) return;
16901 return row.id;
16902 },
16903 baseElement(state) {
16904 return state?.baseElement || void 0;
16905 },
16906 isActiveItem(state) {
16907 return !!state && state.activeId === id;
16908 },
16909 ariaSetSize(state) {
16910 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16911 if (!state) return;
16912 if (!row?.ariaSetSize) return;
16913 if (row.baseElement !== state.baseElement) return;
16914 return row.ariaSetSize;
16915 },
16916 ariaPosInSet(state) {
16917 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16918 if (!state) return;
16919 if (!row?.ariaPosInSet) return;
16920 if (row.baseElement !== state.baseElement) return;
16921 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId);
16922 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16923 },
16924 isTabbable(state) {
16925 if (!state?.renderedItems.length) return true;
16926 if (state.virtualFocus) return false;
16927 if (tabbable2) return true;
16928 if (state.activeId === null) return false;
16929 const item = store?.item(state.activeId);
16930 if (item?.disabled) return true;
16931 if (!item?.element) return true;
16932 return state.activeId === id;
16933 }
16934 });
16935 const getItem = (0, import_react17.useCallback)((item) => {
16936 const nextItem = {
16937 ...item,
16938 id: id || item.id,
16939 rowId,
16940 disabled: trulyDisabled,
16941 children: item.element?.textContent
16942 };
16943 if (getItemProp) return getItemProp(nextItem);
16944 return nextItem;
16945 }, [
16946 id,
16947 rowId,
16948 trulyDisabled,
16949 getItemProp
16950 ]);
16951 const onFocusProp = props.onFocus;
16952 const hasFocusedComposite = (0, import_react17.useRef)(false);
16953 const onFocus = useEvent((event) => {
16954 onFocusProp?.(event);
16955 if (event.defaultPrevented) return;
16956 if (isPortalEvent(event)) return;
16957 if (!id) return;
16958 if (!store) return;
16959 if (targetIsAnotherItem(event, store)) return;
16960 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16961 store.setActiveId(id);
16962 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
16963 if (!virtualFocus) return;
16964 if (!isSelfTarget(event)) return;
16965 if (isEditableElement(event.currentTarget)) return;
16966 if (!baseElement2?.isConnected) return;
16967 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) event.currentTarget.scrollIntoView({
16968 block: "nearest",
16969 inline: "nearest"
16970 });
16971 hasFocusedComposite.current = true;
16972 if (event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget)) focusSilently(baseElement2);
16973 else baseElement2.focus();
16974 });
16975 const onBlurCaptureProp = props.onBlurCapture;
16976 const onBlurCapture = useEvent((event) => {
16977 onBlurCaptureProp?.(event);
16978 if (event.defaultPrevented) return;
16979 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
16980 hasFocusedComposite.current = false;
16981 event.preventDefault();
16982 event.stopPropagation();
16983 }
16984 });
16985 const onKeyDownProp = props.onKeyDown;
16986 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16987 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16988 const onKeyDown = useEvent((event) => {
16989 onKeyDownProp?.(event);
16990 if (event.defaultPrevented) return;
16991 if (!isSelfTarget(event)) return;
16992 if (!store) return;
16993 const { currentTarget } = event;
16994 const state = store.getState();
16995 const isGrid2 = !!store.item(id)?.rowId;
16996 const isVertical = state.orientation !== "horizontal";
16997 const isHorizontal = state.orientation !== "vertical";
16998 const canHomeEnd = () => {
16999 if (isGrid2) return true;
17000 if (isHorizontal) return true;
17001 if (!state.baseElement) return true;
17002 if (!isTextField(state.baseElement)) return true;
17003 return false;
17004 };
17005 const action = {
17006 ArrowUp: (isGrid2 || isVertical) && store.up,
17007 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17008 ArrowDown: (isGrid2 || isVertical) && store.down,
17009 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17010 Home: () => {
17011 if (!canHomeEnd()) return;
17012 if (!isGrid2 || event.ctrlKey) return store?.first();
17013 return store?.previous(-1);
17014 },
17015 End: () => {
17016 if (!canHomeEnd()) return;
17017 if (!isGrid2 || event.ctrlKey) return store?.last();
17018 return store?.next(-1);
17019 },
17020 PageUp: () => {
17021 return findNextPageItemId(currentTarget, store, store?.up, true);
17022 },
17023 PageDown: () => {
17024 return findNextPageItemId(currentTarget, store, store?.down);
17025 }
17026 }[event.key];
17027 if (action) {
17028 if (isTextbox(currentTarget)) {
17029 const selection = getTextboxSelection(currentTarget);
17030 const isLeft = isHorizontal && event.key === "ArrowLeft";
17031 const isRight = isHorizontal && event.key === "ArrowRight";
17032 const isUp = isVertical && event.key === "ArrowUp";
17033 const isDown = isVertical && event.key === "ArrowDown";
17034 if (isRight || isDown) {
17035 const { length: valueLength } = getTextboxValue(currentTarget);
17036 if (selection.end !== valueLength) return;
17037 } else if ((isLeft || isUp) && selection.start !== 0) return;
17038 }
17039 const nextId = action();
17040 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17041 if (!moveOnKeyPressProp(event)) return;
17042 event.preventDefault();
17043 store.move(nextId);
17044 }
17045 }
17046 });
17047 const providerValue = (0, import_react17.useMemo)(() => ({
17048 id,
17049 baseElement
17050 }), [id, baseElement]);
17051 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeItemContext.Provider, {
17052 value: providerValue,
17053 children: element
17054 }), [providerValue]);
17055 props = {
17056 "data-active-item": isActiveItem || void 0,
17057 ...props,
17058 id,
17059 ref: useMergeRefs(ref, props.ref),
17060 tabIndex: isTabbable ? props.tabIndex : -1,
17061 onFocus,
17062 onBlurCapture,
17063 onKeyDown
17064 };
17065 props = useCommand(props);
17066 props = useCollectionItem({
17067 store,
17068 ...props,
17069 getItem,
17070 shouldRegisterItem: id ? props.shouldRegisterItem : false
17071 });
17072 return removeUndefinedValues({
17073 ...props,
17074 "aria-setsize": ariaSetSize,
17075 "aria-posinset": ariaPosInSet
17076 });
17077 });
17078 var CompositeItem = memo3(forwardRef30(function CompositeItem2(props) {
17079 return createElement3(TagName4, useCompositeItem(props));
17080 }));
17081
17082 // node_modules/@ariakit/react-components/dist/composite/composite.js
17083 var import_react18 = __toESM(require_react(), 1);
17084 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17085 var TagName5 = "div";
17086 function isGrid(items) {
17087 return items.some((item) => !!item.rowId);
17088 }
17089 function isPrintableKey(event) {
17090 const target = event.target;
17091 if (target && !isTextField(target)) return false;
17092 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17093 }
17094 function isModifierKey(event) {
17095 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17096 }
17097 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17098 return useEvent((event) => {
17099 onKeyboardEvent?.(event);
17100 if (event.defaultPrevented) return;
17101 if (event.isPropagationStopped()) return;
17102 if (!isSelfTarget(event)) return;
17103 if (isModifierKey(event)) return;
17104 if (isPrintableKey(event)) return;
17105 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17106 if (!activeElement2) return;
17107 const { view, ...eventInit } = event;
17108 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17109 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17110 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17111 });
17112 }
17113 function findFirstEnabledItemInTheLastRow(items) {
17114 return findFirstEnabledItem(flatten2DArray(reverseArray(groupItemsByRows(items))));
17115 }
17116 function withBaseScrollPreserved(store, callback) {
17117 const { virtualFocus, baseElement } = store.getState();
17118 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17119 callback();
17120 return;
17121 }
17122 const savedScrollLeft = baseElement.scrollLeft;
17123 const savedScrollTop = baseElement.scrollTop;
17124 callback();
17125 baseElement.scrollLeft = savedScrollLeft;
17126 baseElement.scrollTop = savedScrollTop;
17127 }
17128 function useScheduleFocus(store) {
17129 const [scheduled, setScheduled] = (0, import_react18.useState)(false);
17130 const schedule = (0, import_react18.useCallback)(() => setScheduled(true), []);
17131 const activeItem = useStoreState(store, (state) => getEnabledItem(store, state.activeId));
17132 (0, import_react18.useEffect)(() => {
17133 const activeElement2 = activeItem?.element;
17134 if (!scheduled) return;
17135 if (!activeElement2) return;
17136 setScheduled(false);
17137 withBaseScrollPreserved(store, () => {
17138 activeElement2.focus({ preventScroll: true });
17139 });
17140 }, [
17141 store,
17142 activeItem,
17143 scheduled
17144 ]);
17145 return schedule;
17146 }
17147 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
17148 const context = useCompositeProviderContext();
17149 store = store || context;
17150 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
17151 const ref = (0, import_react18.useRef)(null);
17152 const previousElementRef = (0, import_react18.useRef)(null);
17153 const scheduleFocus = useScheduleFocus(store);
17154 const moves = useStoreState(store, "moves");
17155 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
17156 (0, import_react18.useEffect)(() => {
17157 if (!store) return;
17158 if (!moves) return;
17159 if (!composite) return;
17160 if (!focusOnMove) return;
17161 const { activeId: activeId2 } = store.getState();
17162 const itemElement = getEnabledItem(store, activeId2)?.element;
17163 if (!itemElement) return;
17164 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
17165 }, [
17166 store,
17167 moves,
17168 composite,
17169 focusOnMove
17170 ]);
17171 useSafeLayoutEffect(() => {
17172 if (!store) return;
17173 if (!moves) return;
17174 if (!composite) return;
17175 const { baseElement, activeId: activeId2 } = store.getState();
17176 if (!(activeId2 === null)) return;
17177 if (!baseElement) return;
17178 const previousElement = previousElementRef.current;
17179 previousElementRef.current = null;
17180 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
17181 if (!hasFocus(baseElement)) baseElement.focus();
17182 }, [
17183 store,
17184 moves,
17185 composite
17186 ]);
17187 const activeId = useStoreState(store, "activeId");
17188 const virtualFocus = useStoreState(store, "virtualFocus");
17189 useSafeLayoutEffect(() => {
17190 if (!store) return;
17191 if (!composite) return;
17192 if (!virtualFocus) return;
17193 const previousElement = previousElementRef.current;
17194 previousElementRef.current = null;
17195 if (!previousElement) return;
17196 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
17197 if (relatedTarget === previousElement) return;
17198 fireBlurEvent(previousElement, { relatedTarget });
17199 }, [
17200 store,
17201 activeId,
17202 virtualFocus,
17203 composite
17204 ]);
17205 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
17206 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
17207 const onFocusCaptureProp = props.onFocusCapture;
17208 const onFocusCapture = useEvent((event) => {
17209 onFocusCaptureProp?.(event);
17210 if (event.defaultPrevented) return;
17211 if (!store) return;
17212 const { virtualFocus: virtualFocus2 } = store.getState();
17213 if (!virtualFocus2) return;
17214 const previousActiveElement = event.relatedTarget;
17215 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17216 if (isSelfTarget(event) && isSilentlyFocused) {
17217 event.stopPropagation();
17218 previousElementRef.current = previousActiveElement;
17219 }
17220 });
17221 const onFocusProp = props.onFocus;
17222 const onFocus = useEvent((event) => {
17223 onFocusProp?.(event);
17224 if (event.defaultPrevented) return;
17225 if (!composite) return;
17226 if (!store) return;
17227 const { relatedTarget } = event;
17228 const { virtualFocus: virtualFocus2 } = store.getState();
17229 if (virtualFocus2) {
17230 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
17231 } else if (isSelfTarget(event)) store.setActiveId(null);
17232 });
17233 const onBlurCaptureProp = props.onBlurCapture;
17234 const onBlurCapture = useEvent((event) => {
17235 onBlurCaptureProp?.(event);
17236 if (event.defaultPrevented) return;
17237 if (!store) return;
17238 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17239 if (!virtualFocus2) return;
17240 const activeElement2 = getEnabledItem(store, activeId2)?.element;
17241 const nextActiveElement = event.relatedTarget;
17242 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17243 const previousElement = previousElementRef.current;
17244 previousElementRef.current = null;
17245 if (isSelfTarget(event) && nextActiveElementIsItem) {
17246 if (nextActiveElement === activeElement2) {
17247 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
17248 } else if (activeElement2) fireBlurEvent(activeElement2, event);
17249 else if (previousElement) fireBlurEvent(previousElement, event);
17250 event.stopPropagation();
17251 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
17252 });
17253 const onKeyDownProp = props.onKeyDown;
17254 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17255 const onKeyDown = useEvent((event) => {
17256 onKeyDownProp?.(event);
17257 if (event.nativeEvent.isComposing) return;
17258 if (event.defaultPrevented) return;
17259 if (!store) return;
17260 if (!isSelfTarget(event)) return;
17261 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
17262 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
17263 const isVertical = orientation !== "horizontal";
17264 const isHorizontal = orientation !== "vertical";
17265 const grid = isGrid(renderedItems);
17266 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
17267 const up = () => {
17268 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
17269 return store?.last();
17270 };
17271 const action = {
17272 ArrowUp: (grid || isVertical) && up,
17273 ArrowRight: (grid || isHorizontal) && store.first,
17274 ArrowDown: (grid || isVertical) && store.first,
17275 ArrowLeft: (grid || isHorizontal) && store.last,
17276 Home: store.first,
17277 End: store.last,
17278 PageUp: store.first,
17279 PageDown: store.last
17280 }[event.key];
17281 if (action) {
17282 const id = action();
17283 if (id !== void 0) {
17284 if (!moveOnKeyPressProp(event)) return;
17285 event.preventDefault();
17286 store.move(id);
17287 }
17288 }
17289 });
17290 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeScopedContextProvider, {
17291 value: store,
17292 children: element
17293 }), [store]);
17294 props = {
17295 "aria-activedescendant": useStoreState(store, (state) => {
17296 if (!store) return;
17297 if (!composite) return;
17298 if (!state.virtualFocus) return;
17299 return getEnabledItem(store, state.activeId)?.id;
17300 }),
17301 ...props,
17302 ref: useMergeRefs(ref, setBaseElement, props.ref),
17303 onKeyDownCapture,
17304 onKeyUpCapture,
17305 onFocusCapture,
17306 onFocus,
17307 onBlurCapture,
17308 onKeyDown
17309 };
17310 props = useFocusable({
17311 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
17312 ...props
17313 });
17314 return props;
17315 });
17316 var Composite6 = forwardRef30(function Composite7(props) {
17317 return createElement3(TagName5, useComposite(props));
17318 });
17319
17320 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
17321 var ctx3 = createStoreContext();
17322 var useDisclosureContext = ctx3.useContext;
17323 var useDisclosureScopedContext = ctx3.useScopedContext;
17324 var useDisclosureProviderContext = ctx3.useProviderContext;
17325 var DisclosureContextProvider = ctx3.ContextProvider;
17326 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17327
17328 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
17329 var import_react19 = __toESM(require_react(), 1);
17330 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
17331 var useDialogContext = ctx4.useContext;
17332 var useDialogScopedContext = ctx4.useScopedContext;
17333 var useDialogProviderContext = ctx4.useProviderContext;
17334 var DialogContextProvider = ctx4.ContextProvider;
17335 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17336 var DialogHeadingContext = (0, import_react19.createContext)(void 0);
17337 var DialogDescriptionContext = (0, import_react19.createContext)(void 0);
17338
17339 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
17340 var import_react20 = __toESM(require_react(), 1);
17341 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17342 var import_react_dom4 = __toESM(require_react_dom(), 1);
17343 var TagName6 = "div";
17344 function afterTimeout(timeoutMs, cb) {
17345 const timeoutId = setTimeout(cb, timeoutMs);
17346 return () => clearTimeout(timeoutId);
17347 }
17348 function afterPaint(cb) {
17349 let raf = requestAnimationFrame(() => {
17350 raf = requestAnimationFrame(cb);
17351 });
17352 return () => cancelAnimationFrame(raf);
17353 }
17354 function parseCSSTime(...times) {
17355 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17356 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17357 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17358 if (currentTime > longestTime) return currentTime;
17359 return longestTime;
17360 }, 0);
17361 }
17362 function isHidden(mounted, hidden, alwaysVisible) {
17363 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17364 }
17365 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17366 const context = useDisclosureProviderContext();
17367 store = store || context;
17368 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
17369 const ref = (0, import_react20.useRef)(null);
17370 const id = useId4(props.id);
17371 const [transition, setTransition] = (0, import_react20.useState)(null);
17372 const open = useStoreState(store, "open");
17373 const mounted = useStoreState(store, "mounted");
17374 const animated = useStoreState(store, "animated");
17375 const contentElement = useStoreState(store, "contentElement");
17376 const otherElement = useStoreState(store.disclosure, "contentElement");
17377 const hasClosedRef = (0, import_react20.useRef)(false);
17378 useSafeLayoutEffect(() => {
17379 if (!ref.current) return;
17380 store?.setContentElement(ref.current);
17381 }, [store]);
17382 useSafeLayoutEffect(() => {
17383 let previousAnimated;
17384 store?.setState("animated", (animated2) => {
17385 previousAnimated = animated2;
17386 return true;
17387 });
17388 return () => {
17389 if (previousAnimated === void 0) return;
17390 store?.setState("animated", previousAnimated);
17391 };
17392 }, [store]);
17393 useSafeLayoutEffect(() => {
17394 if (!animated) {
17395 if (!open) {
17396 hasClosedRef.current = true;
17397 setTransition(null);
17398 } else if (hasClosedRef.current) {
17399 hasClosedRef.current = false;
17400 setTransition("enter");
17401 }
17402 return;
17403 }
17404 if (!contentElement?.isConnected) {
17405 setTransition(null);
17406 return;
17407 }
17408 return afterPaint(() => {
17409 setTransition(open ? "enter" : mounted ? "leave" : null);
17410 });
17411 }, [
17412 animated,
17413 contentElement,
17414 open,
17415 mounted
17416 ]);
17417 useSafeLayoutEffect(() => {
17418 if (!store) return;
17419 if (!animated) return;
17420 if (!transition) return;
17421 if (!contentElement) return;
17422 const stopAnimation = () => store?.setState("animating", false);
17423 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17424 if (transition === "leave" && open) return;
17425 if (transition === "enter" && !open) return;
17426 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
17427 const { transitionDuration, animationDuration, transitionDelay, animationDelay } = getComputedStyle(contentElement);
17428 const { transitionDuration: transitionDuration2 = "0", animationDuration: animationDuration2 = "0", transitionDelay: transitionDelay2 = "0", animationDelay: animationDelay2 = "0" } = otherElement ? getComputedStyle(otherElement) : {};
17429 const timeout = parseCSSTime(transitionDelay, animationDelay, transitionDelay2, animationDelay2) + parseCSSTime(transitionDuration, animationDuration, transitionDuration2, animationDuration2);
17430 if (!timeout) {
17431 if (transition === "enter") store.setState("animated", false);
17432 stopAnimation();
17433 return;
17434 }
17435 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
17436 }, [
17437 store,
17438 animated,
17439 contentElement,
17440 otherElement,
17441 open,
17442 transition
17443 ]);
17444 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogScopedContextProvider, {
17445 value: store,
17446 children: element
17447 }), [store]);
17448 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17449 const styleProp = props.style;
17450 const style = (0, import_react20.useMemo)(() => {
17451 if (hidden) return {
17452 ...styleProp,
17453 display: "none"
17454 };
17455 return styleProp;
17456 }, [hidden, styleProp]);
17457 props = {
17458 "data-open": open || void 0,
17459 "data-enter": transition === "enter" || void 0,
17460 "data-leave": transition === "leave" || void 0,
17461 hidden,
17462 ...props,
17463 id,
17464 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17465 style
17466 };
17467 return removeUndefinedValues(props);
17468 });
17469 var DisclosureContentImpl = forwardRef30(function DisclosureContentImpl2(props) {
17470 return createElement3(TagName6, useDisclosureContent(props));
17471 });
17472 var DisclosureContent = forwardRef30(function DisclosureContent2({ unmountOnHide, ...props }) {
17473 const context = useDisclosureProviderContext();
17474 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
17475 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DisclosureContentImpl, { ...props });
17476 });
17477
17478 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
17479 function createDisclosureStore(props = {}) {
17480 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
17481 throwOnConflictingProps(props, store);
17482 const syncState = store?.getState();
17483 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
17484 const animated = defaultValue(props.animated, syncState?.animated, false);
17485 const disclosure = createStore({
17486 open,
17487 animated,
17488 animating: !!animated && open,
17489 mounted: open,
17490 contentElement: defaultValue(syncState?.contentElement, null),
17491 disclosureElement: defaultValue(syncState?.disclosureElement, null)
17492 }, store);
17493 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
17494 if (state.animated) return;
17495 disclosure.setState("animating", false);
17496 }));
17497 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
17498 if (!disclosure.getState().animated) return;
17499 disclosure.setState("animating", true);
17500 }));
17501 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
17502 disclosure.setState("mounted", state.open || state.animating);
17503 }));
17504 return {
17505 ...disclosure,
17506 disclosure: props.disclosure,
17507 setOpen: (value) => disclosure.setState("open", value),
17508 show: () => disclosure.setState("open", true),
17509 hide: () => disclosure.setState("open", false),
17510 toggle: () => disclosure.setState("open", (open2) => !open2),
17511 stopAnimation: () => disclosure.setState("animating", false),
17512 setContentElement: (value) => disclosure.setState("contentElement", value),
17513 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17514 };
17515 }
17516
17517 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
17518 function useDisclosureStoreProps(store, update2, props) {
17519 useUpdateEffect(update2, [props.store, props.disclosure]);
17520 useStoreProps(store, props, "open", "setOpen");
17521 useStoreProps(store, props, "mounted", "setMounted");
17522 useStoreProps(store, props, "animated");
17523 return Object.assign(store, { disclosure: props.disclosure });
17524 }
17525
17526 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
17527 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
17528 var usePopoverContext = ctx5.useContext;
17529 var usePopoverScopedContext = ctx5.useScopedContext;
17530 var usePopoverProviderContext = ctx5.useProviderContext;
17531 var PopoverContextProvider = ctx5.ContextProvider;
17532 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17533
17534 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
17535 var import_react21 = __toESM(require_react(), 1);
17536 var ComboboxListRoleContext = (0, import_react21.createContext)(void 0);
17537 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
17538 var useComboboxContext = ctx6.useContext;
17539 var useComboboxScopedContext = ctx6.useScopedContext;
17540 var useComboboxProviderContext = ctx6.useProviderContext;
17541 var ComboboxContextProvider = ctx6.ContextProvider;
17542 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17543 var ComboboxItemValueContext = (0, import_react21.createContext)(void 0);
17544 var ComboboxItemCheckedContext = (0, import_react21.createContext)(false);
17545
17546 // node_modules/@ariakit/components/dist/collection/collection-store.js
17547 function getCommonParent(items) {
17548 const firstItem = items.find((item) => !!item.element);
17549 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17550 let parentElement = firstItem?.element?.parentElement;
17551 if (!lastElement) return getDocument(parentElement).body;
17552 while (parentElement) {
17553 if (parentElement.contains(lastElement)) return parentElement;
17554 parentElement = parentElement.parentElement;
17555 }
17556 return getDocument(parentElement).body;
17557 }
17558 function getPrivateStore(store) {
17559 return store?.__unstablePrivateStore;
17560 }
17561 function createCollectionStore(props = {}) {
17562 throwOnConflictingProps(props, props.store);
17563 const syncState = props.store?.getState();
17564 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17565 const itemsMap = new Map(items.map((item) => [item.id, item]));
17566 const initialState = {
17567 items,
17568 renderedItems: defaultValue(syncState?.renderedItems, [])
17569 };
17570 const syncPrivateStore = getPrivateStore(props.store);
17571 const privateStore = createStore({
17572 items,
17573 renderedItems: initialState.renderedItems
17574 }, syncPrivateStore);
17575 const collection = createStore(initialState, props.store);
17576 const sortItems = (renderedItems) => {
17577 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17578 privateStore.setState("renderedItems", sortedItems);
17579 collection.setState("renderedItems", sortedItems);
17580 };
17581 setup(collection, () => init(privateStore));
17582 setup(privateStore, () => {
17583 return batch(privateStore, ["items"], (state) => {
17584 collection.setState("items", state.items);
17585 });
17586 });
17587 setup(privateStore, () => {
17588 return batch(privateStore, ["renderedItems"], (state) => {
17589 let firstRun = true;
17590 let raf = requestAnimationFrame(() => {
17591 const { renderedItems } = collection.getState();
17592 if (state.renderedItems === renderedItems) return;
17593 sortItems(state.renderedItems);
17594 });
17595 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17596 const ioCallback = () => {
17597 if (firstRun) {
17598 firstRun = false;
17599 return;
17600 }
17601 cancelAnimationFrame(raf);
17602 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17603 };
17604 const root = getCommonParent(state.renderedItems);
17605 const observer = new IntersectionObserver(ioCallback, { root });
17606 for (const item of state.renderedItems) {
17607 if (!item.element) continue;
17608 observer.observe(item.element);
17609 }
17610 return () => {
17611 cancelAnimationFrame(raf);
17612 observer.disconnect();
17613 };
17614 });
17615 });
17616 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17617 let prevItem;
17618 setItems((items2) => {
17619 const index2 = items2.findIndex(({ id }) => id === item.id);
17620 const nextItems = items2.slice();
17621 if (index2 !== -1) {
17622 prevItem = items2[index2];
17623 const nextItem = {
17624 ...prevItem,
17625 ...item
17626 };
17627 nextItems[index2] = nextItem;
17628 itemsMap.set(item.id, nextItem);
17629 } else {
17630 nextItems.push(item);
17631 itemsMap.set(item.id, item);
17632 }
17633 return nextItems;
17634 });
17635 const unmergeItem = () => {
17636 setItems((items2) => {
17637 if (!prevItem) {
17638 if (canDeleteFromMap) itemsMap.delete(item.id);
17639 return items2.filter(({ id }) => id !== item.id);
17640 }
17641 const index2 = items2.findIndex(({ id }) => id === item.id);
17642 if (index2 === -1) return items2;
17643 const nextItems = items2.slice();
17644 nextItems[index2] = prevItem;
17645 itemsMap.set(item.id, prevItem);
17646 return nextItems;
17647 });
17648 };
17649 return unmergeItem;
17650 };
17651 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17652 return {
17653 ...collection,
17654 registerItem,
17655 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17656 item: (id) => {
17657 if (!id) return null;
17658 let item = itemsMap.get(id);
17659 if (!item) {
17660 const { items: items2 } = privateStore.getState();
17661 item = items2.find((item2) => item2.id === id);
17662 if (item) itemsMap.set(id, item);
17663 }
17664 return item || null;
17665 },
17666 __unstablePrivateStore: privateStore
17667 };
17668 }
17669
17670 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
17671 function useCollectionStoreProps(store, update2, props) {
17672 useUpdateEffect(update2, [props.store]);
17673 useStoreProps(store, props, "items", "setItems");
17674 return store;
17675 }
17676
17677 // node_modules/@ariakit/components/dist/composite/composite-store.js
17678 var NULL_ITEM = { id: null };
17679 function findFirstEnabledItem2(items, excludeId) {
17680 return items.find((item) => {
17681 if (excludeId) return !item.disabled && item.id !== excludeId;
17682 return !item.disabled;
17683 });
17684 }
17685 function getEnabledItems(items, excludeId) {
17686 return items.filter((item) => {
17687 if (excludeId) return !item.disabled && item.id !== excludeId;
17688 return !item.disabled;
17689 });
17690 }
17691 function getItemsInRow(items, rowId) {
17692 return items.filter((item) => item.rowId === rowId);
17693 }
17694 function flipItems(items, activeId, shouldInsertNullItem = false) {
17695 const index2 = items.findIndex((item) => item.id === activeId);
17696 return [
17697 ...items.slice(index2 + 1),
17698 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17699 ...items.slice(0, index2)
17700 ];
17701 }
17702 function groupItemsByRows2(items) {
17703 const rows = [];
17704 for (const item of items) {
17705 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17706 if (row) row.push(item);
17707 else rows.push([item]);
17708 }
17709 return rows;
17710 }
17711 function getMaxRowLength(array) {
17712 let maxLength = 0;
17713 for (const { length } of array) if (length > maxLength) maxLength = length;
17714 return maxLength;
17715 }
17716 function createEmptyItem(rowId) {
17717 return {
17718 id: "__EMPTY_ITEM__",
17719 disabled: true,
17720 rowId
17721 };
17722 }
17723 function normalizeRows(rows, activeId, focusShift) {
17724 const maxLength = getMaxRowLength(rows);
17725 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17726 const item = row[i2];
17727 if (!item || focusShift && item.disabled) {
17728 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17729 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17730 }
17731 }
17732 return rows;
17733 }
17734 function verticalizeItems(items) {
17735 const rows = groupItemsByRows2(items);
17736 const maxLength = getMaxRowLength(rows);
17737 const verticalized = [];
17738 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17739 const item = row[i2];
17740 if (item) verticalized.push({
17741 ...item,
17742 rowId: item.rowId ? `${i2}` : void 0
17743 });
17744 }
17745 return verticalized;
17746 }
17747 function createCompositeStore(props = {}) {
17748 const syncState = props.store?.getState();
17749 const collection = createCollectionStore(props);
17750 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17751 const composite = createStore({
17752 ...collection.getState(),
17753 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17754 activeId,
17755 baseElement: defaultValue(syncState?.baseElement, null),
17756 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17757 moves: defaultValue(syncState?.moves, 0),
17758 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17759 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17760 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17761 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17762 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17763 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17764 }, collection, props.store);
17765 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17766 composite.setState("activeId", (activeId2) => {
17767 if (activeId2 !== void 0) return activeId2;
17768 return findFirstEnabledItem2(state.renderedItems)?.id;
17769 });
17770 }));
17771 const getNextId = (direction = "next", options = {}) => {
17772 const defaultState = composite.getState();
17773 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;
17774 const isVerticalDirection = direction === "up" || direction === "down";
17775 const isNextDirection = direction === "next" || direction === "down";
17776 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17777 const canShift = focusShift && !skip;
17778 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift));
17779 items = canReverse ? reverseArray(items) : items;
17780 items = isVerticalDirection ? verticalizeItems(items) : items;
17781 if (activeId2 == null) return findFirstEnabledItem2(items)?.id;
17782 const activeItem = items.find((item) => item.id === activeId2);
17783 if (!activeItem) return findFirstEnabledItem2(items)?.id;
17784 const isGrid2 = items.some((item) => item.rowId);
17785 const activeIndex = items.indexOf(activeItem);
17786 const nextItems = items.slice(activeIndex + 1);
17787 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17788 if (skip) {
17789 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17790 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17791 }
17792 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17793 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17794 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17795 if (canLoop) return findFirstEnabledItem2(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17796 if (canWrap) {
17797 const nextItem2 = findFirstEnabledItem2(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17798 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17799 }
17800 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17801 if (!nextItem && hasNullItem) return null;
17802 return nextItem?.id;
17803 };
17804 return {
17805 ...collection,
17806 ...composite,
17807 setBaseElement: (element) => composite.setState("baseElement", element),
17808 setActiveId: (id) => composite.setState("activeId", id),
17809 move: (id) => {
17810 if (id === void 0) return;
17811 composite.setState("activeId", id);
17812 composite.setState("moves", (moves) => moves + 1);
17813 },
17814 first: () => findFirstEnabledItem2(composite.getState().renderedItems)?.id,
17815 last: () => findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))?.id,
17816 next: (options) => {
17817 if (options !== void 0 && typeof options === "number") options = { skip: options };
17818 return getNextId("next", options);
17819 },
17820 previous: (options) => {
17821 if (options !== void 0 && typeof options === "number") options = { skip: options };
17822 return getNextId("previous", options);
17823 },
17824 down: (options) => {
17825 if (options !== void 0 && typeof options === "number") options = { skip: options };
17826 return getNextId("down", options);
17827 },
17828 up: (options) => {
17829 if (options !== void 0 && typeof options === "number") options = { skip: options };
17830 return getNextId("up", options);
17831 }
17832 };
17833 }
17834
17835 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
17836 function useCompositeStoreOptions(props) {
17837 return {
17838 id: useId4(props.id),
17839 ...props
17840 };
17841 }
17842 function useCompositeStoreProps(store, update2, props) {
17843 store = useCollectionStoreProps(store, update2, props);
17844 useStoreProps(store, props, "activeId", "setActiveId");
17845 useStoreProps(store, props, "includesBaseElement");
17846 useStoreProps(store, props, "virtualFocus");
17847 useStoreProps(store, props, "orientation");
17848 useStoreProps(store, props, "rtl");
17849 useStoreProps(store, props, "focusLoop");
17850 useStoreProps(store, props, "focusWrap");
17851 useStoreProps(store, props, "focusShift");
17852 return store;
17853 }
17854
17855 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
17856 function createDialogStore(props = {}) {
17857 return createDisclosureStore(props);
17858 }
17859
17860 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
17861 function useDialogStoreProps(store, update2, props) {
17862 return useDisclosureStoreProps(store, update2, props);
17863 }
17864
17865 // node_modules/@ariakit/components/dist/popover/popover-store.js
17866 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
17867 const store = mergeStore(props.store, omit2(otherPopover, [
17868 "arrowElement",
17869 "anchorElement",
17870 "contentElement",
17871 "popoverElement",
17872 "disclosureElement"
17873 ]));
17874 throwOnConflictingProps(props, store);
17875 const syncState = store?.getState();
17876 const dialog = createDialogStore({
17877 ...props,
17878 store
17879 });
17880 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
17881 const popover = createStore({
17882 ...dialog.getState(),
17883 placement,
17884 currentPlacement: placement,
17885 anchorElement: defaultValue(syncState?.anchorElement, null),
17886 popoverElement: defaultValue(syncState?.popoverElement, null),
17887 arrowElement: defaultValue(syncState?.arrowElement, null),
17888 rendered: /* @__PURE__ */ Symbol("rendered")
17889 }, dialog, store);
17890 return {
17891 ...dialog,
17892 ...popover,
17893 setAnchorElement: (element) => popover.setState("anchorElement", element),
17894 setPopoverElement: (element) => popover.setState("popoverElement", element),
17895 setArrowElement: (element) => popover.setState("arrowElement", element),
17896 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17897 };
17898 }
17899
17900 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
17901 function usePopoverStoreProps(store, update2, props) {
17902 useUpdateEffect(update2, [props.popover]);
17903 useStoreProps(store, props, "placement");
17904 return useDialogStoreProps(store, update2, props);
17905 }
17906
17907 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
17908 var TagName7 = "div";
17909 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
17910 const context = usePopoverProviderContext();
17911 store = store || context;
17912 props = {
17913 ...props,
17914 ref: useMergeRefs(store?.setAnchorElement, props.ref)
17915 };
17916 return props;
17917 });
17918 var PopoverAnchor = forwardRef30(function PopoverAnchor2(props) {
17919 return createElement3(TagName7, usePopoverAnchor(props));
17920 });
17921
17922 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
17923 var import_react22 = __toESM(require_react(), 1);
17924 var TagName8 = "div";
17925 function hoveringInside(event) {
17926 const nextElement = event.relatedTarget;
17927 if (!isElement2(nextElement)) return false;
17928 return contains2(event.currentTarget, nextElement);
17929 }
17930 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17931 function movingToAnotherItem(event) {
17932 const { relatedTarget } = event;
17933 if (!isElement2(relatedTarget)) return false;
17934 let dest = relatedTarget;
17935 do {
17936 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17937 dest = dest.parentElement;
17938 } while (dest);
17939 return false;
17940 }
17941 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
17942 const context = useCompositeScopedContext();
17943 store = store || context;
17944 invariant(store, "CompositeHover must be wrapped in a Composite component.");
17945 const isMouseMoving = useIsMouseMoving();
17946 const onMouseMoveProp = props.onMouseMove;
17947 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17948 const onMouseMove = useEvent((event) => {
17949 onMouseMoveProp?.(event);
17950 if (event.defaultPrevented) return;
17951 if (!isMouseMoving()) return;
17952 if (!focusOnHoverProp(event)) return;
17953 if (!hasFocusWithin(event.currentTarget)) {
17954 const baseElement = store?.getState().baseElement;
17955 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
17956 }
17957 store?.setActiveId(event.currentTarget.id);
17958 });
17959 const onMouseLeaveProp = props.onMouseLeave;
17960 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17961 const onMouseLeave = useEvent((event) => {
17962 onMouseLeaveProp?.(event);
17963 if (event.defaultPrevented) return;
17964 if (!isMouseMoving()) return;
17965 if (hoveringInside(event)) return;
17966 if (movingToAnotherItem(event)) return;
17967 if (!focusOnHoverProp(event)) return;
17968 if (!blurOnHoverEndProp(event)) return;
17969 store?.setActiveId(null);
17970 store?.getState().baseElement?.focus();
17971 });
17972 const ref = (0, import_react22.useCallback)((element) => {
17973 if (!element) return;
17974 element[symbol2] = true;
17975 }, []);
17976 props = {
17977 ...props,
17978 ref: useMergeRefs(ref, props.ref),
17979 onMouseMove,
17980 onMouseLeave
17981 };
17982 return removeUndefinedValues(props);
17983 });
17984 var CompositeHover = memo3(forwardRef30(function CompositeHover2(props) {
17985 return createElement3(TagName8, useCompositeHover(props));
17986 }));
17987
17988 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
17989 var import_react23 = __toESM(require_react(), 1);
17990 var TagName9 = "input";
17991 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17992 if (!autoSelect) return false;
17993 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
17994 }
17995 function hasCompletionString(value, activeValue) {
17996 if (!activeValue) return false;
17997 if (value == null) return false;
17998 value = normalizeString(value);
17999 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
18000 }
18001 function isInputEvent(event) {
18002 return event.type === "input";
18003 }
18004 function isAriaAutoCompleteValue(value) {
18005 return value === "inline" || value === "list" || value === "both" || value === "none";
18006 }
18007 function getDefaultAutoSelectId(items) {
18008 return items.find((item) => {
18009 if (item.disabled) return false;
18010 return item.element?.getAttribute("role") !== "tab";
18011 })?.id;
18012 }
18013 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 }) {
18014 const context = useComboboxProviderContext();
18015 store = store || context;
18016 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18017 const ref = (0, import_react23.useRef)(null);
18018 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18019 const canAutoSelectRef = (0, import_react23.useRef)(false);
18020 const composingRef = (0, import_react23.useRef)(false);
18021 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18022 const inline4 = autoComplete === "inline" || autoComplete === "both";
18023 const [canInline, setCanInline] = (0, import_react23.useState)(inline4);
18024 useUpdateLayoutEffect(() => {
18025 if (!inline4) return;
18026 setCanInline(true);
18027 }, [inline4]);
18028 const storeValue = useStoreState(store, "value");
18029 const prevSelectedValueRef = (0, import_react23.useRef)(void 0);
18030 (0, import_react23.useEffect)(() => {
18031 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18032 prevSelectedValueRef.current = prev.selectedValue;
18033 });
18034 }, [store]);
18035 const inlineActiveValue = useStoreState(store, (state) => {
18036 if (!inline4) return;
18037 if (!canInline) return;
18038 if (state.activeValue && Array.isArray(state.selectedValue)) {
18039 if (state.selectedValue.includes(state.activeValue)) return;
18040 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18041 }
18042 return state.activeValue;
18043 });
18044 const items = useStoreState(store, "renderedItems");
18045 const open = useStoreState(store, "open");
18046 const contentElement = useStoreState(store, "contentElement");
18047 const value = (0, import_react23.useMemo)(() => {
18048 if (!inline4) return storeValue;
18049 if (!canInline) return storeValue;
18050 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18051 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18052 return storeValue;
18053 }
18054 return inlineActiveValue || storeValue;
18055 }, [
18056 inline4,
18057 canInline,
18058 items,
18059 inlineActiveValue,
18060 autoSelect,
18061 storeValue
18062 ]);
18063 (0, import_react23.useEffect)(() => {
18064 const element = ref.current;
18065 if (!element) return;
18066 const onCompositeItemMove = () => setCanInline(true);
18067 element.addEventListener("combobox-item-move", onCompositeItemMove);
18068 return () => {
18069 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18070 };
18071 }, []);
18072 (0, import_react23.useEffect)(() => {
18073 if (!inline4) return;
18074 if (!canInline) return;
18075 if (!inlineActiveValue) return;
18076 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18077 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18078 let cleanup = noop4;
18079 queueMicrotask(() => {
18080 const element = ref.current;
18081 if (!element) return;
18082 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18083 const nextStart = storeValue.length;
18084 const nextEnd = inlineActiveValue.length;
18085 setSelectionRange(element, nextStart, nextEnd);
18086 cleanup = () => {
18087 if (!hasFocus(element)) return;
18088 const { start, end } = getTextboxSelection(element);
18089 if (start !== nextStart) return;
18090 if (end !== nextEnd) return;
18091 setSelectionRange(element, prevStart, prevEnd);
18092 };
18093 });
18094 return () => cleanup();
18095 }, [
18096 valueUpdated,
18097 inline4,
18098 canInline,
18099 inlineActiveValue,
18100 items,
18101 autoSelect,
18102 storeValue
18103 ]);
18104 const scrollingElementRef = (0, import_react23.useRef)(null);
18105 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18106 const autoSelectIdRef = (0, import_react23.useRef)(null);
18107 const autoSelectMovedRef = (0, import_react23.useRef)(void 0);
18108 const userScrolledRef = (0, import_react23.useRef)(false);
18109 const isAutoScrollingRef = (0, import_react23.useRef)(false);
18110 (0, import_react23.useEffect)(() => {
18111 if (!open) return;
18112 if (!contentElement) return;
18113 const scrollingElement = getScrollingElement(contentElement);
18114 if (!scrollingElement) return;
18115 scrollingElementRef.current = scrollingElement;
18116 const onUserScroll = () => {
18117 canAutoSelectRef.current = false;
18118 userScrolledRef.current = true;
18119 };
18120 const onScroll = () => {
18121 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18122 if (!store) return;
18123 if (!canAutoSelectRef.current) return;
18124 const { activeId } = store.getState();
18125 if (activeId === null) return;
18126 if (activeId === autoSelectIdRef.current) return;
18127 canAutoSelectRef.current = false;
18128 };
18129 const options = {
18130 passive: true,
18131 capture: true
18132 };
18133 scrollingElement.addEventListener("wheel", onUserScroll, options);
18134 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18135 scrollingElement.addEventListener("scroll", onScroll, options);
18136 return () => {
18137 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18138 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18139 scrollingElement.removeEventListener("scroll", onScroll, true);
18140 };
18141 }, [
18142 open,
18143 contentElement,
18144 store
18145 ]);
18146 useSafeLayoutEffect(() => {
18147 userScrolledRef.current = false;
18148 if (!storeValue) return;
18149 if (composingRef.current) return;
18150 canAutoSelectRef.current = true;
18151 }, [storeValue]);
18152 useSafeLayoutEffect(() => {
18153 if (autoSelect !== "always" && open) return;
18154 canAutoSelectRef.current = open;
18155 }, [autoSelect, open]);
18156 useSafeLayoutEffect(() => {
18157 if (open) return;
18158 autoSelectMovedRef.current = void 0;
18159 }, [open]);
18160 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18161 useUpdateEffect(() => {
18162 const canAutoSelect = canAutoSelectRef.current;
18163 if (!store) return;
18164 if (!open) return;
18165 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18166 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18167 if (baseElement && !hasFocus(baseElement)) return;
18168 if (contentElement2?.hasAttribute("data-placing")) {
18169 const observer = new MutationObserver(forceValueUpdate);
18170 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18171 return () => observer.disconnect();
18172 }
18173 if (autoSelect && canAutoSelect) {
18174 const userAutoSelectId = getAutoSelectIdProp(items);
18175 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18176 autoSelectIdRef.current = autoSelectId;
18177 const nextActiveId = autoSelectId ?? null;
18178 const nextActiveValue = store.item(nextActiveId)?.value;
18179 const moved = autoSelectMovedRef.current;
18180 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18181 autoSelectMovedRef.current = {
18182 id: nextActiveId,
18183 value: nextActiveValue
18184 };
18185 store.move(nextActiveId);
18186 } else store.setState("activeValue", nextActiveValue);
18187 } else {
18188 const element = store.item(activeId || store.first())?.element;
18189 if (element && "scrollIntoView" in element) {
18190 isAutoScrollingRef.current = true;
18191 element.scrollIntoView({
18192 block: "nearest",
18193 inline: "nearest"
18194 });
18195 requestAnimationFrame(() => {
18196 isAutoScrollingRef.current = false;
18197 });
18198 }
18199 }
18200 }, [
18201 store,
18202 open,
18203 valueUpdated,
18204 storeValue,
18205 autoSelect,
18206 resetValueOnSelect,
18207 getAutoSelectIdProp,
18208 items
18209 ]);
18210 (0, import_react23.useEffect)(() => {
18211 if (!inline4) return;
18212 const combobox = ref.current;
18213 if (!combobox) return;
18214 const elements = [combobox, contentElement].filter((value2) => !!value2);
18215 const onBlur2 = (event) => {
18216 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18217 };
18218 for (const element of elements) element.addEventListener("focusout", onBlur2);
18219 return () => {
18220 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18221 };
18222 }, [
18223 inline4,
18224 contentElement,
18225 store,
18226 value
18227 ]);
18228 const canShow = (event) => {
18229 return event.currentTarget.value.length >= showMinLength;
18230 };
18231 const onChangeProp = props.onChange;
18232 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18233 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18234 const onChange = useEvent((event) => {
18235 onChangeProp?.(event);
18236 if (event.defaultPrevented) return;
18237 if (!store) return;
18238 const currentTarget = event.currentTarget;
18239 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18240 const nativeEvent = event.nativeEvent;
18241 canAutoSelectRef.current = true;
18242 if (isInputEvent(nativeEvent)) {
18243 if (nativeEvent.isComposing) {
18244 canAutoSelectRef.current = false;
18245 composingRef.current = true;
18246 }
18247 if (inline4) {
18248 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18249 const caretAtEnd = selectionStart === value2.length;
18250 setCanInline(textInserted && caretAtEnd);
18251 }
18252 }
18253 if (setValueOnChangeProp(event)) {
18254 const isSameValue = value2 === store.getState().value;
18255 store.setValue(value2);
18256 queueMicrotask(() => {
18257 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18258 });
18259 if (inline4 && autoSelect && isSameValue) forceValueUpdate();
18260 }
18261 if (showOnChangeProp(event)) store.show();
18262 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18263 });
18264 const onCompositionEndProp = props.onCompositionEnd;
18265 const onCompositionEnd = useEvent((event) => {
18266 canAutoSelectRef.current = true;
18267 composingRef.current = false;
18268 onCompositionEndProp?.(event);
18269 if (event.defaultPrevented) return;
18270 if (!autoSelect) return;
18271 forceValueUpdate();
18272 });
18273 const onMouseDownProp = props.onMouseDown;
18274 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18275 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18276 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18277 const onMouseDown = useEvent((event) => {
18278 onMouseDownProp?.(event);
18279 if (event.defaultPrevented) return;
18280 if (event.button) return;
18281 if (event.ctrlKey) return;
18282 if (!store) return;
18283 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18284 if (setValueOnClickProp(event)) store.setValue(value);
18285 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18286 });
18287 const onKeyDownProp = props.onKeyDown;
18288 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18289 const onKeyDown = useEvent((event) => {
18290 onKeyDownProp?.(event);
18291 if (!event.repeat) canAutoSelectRef.current = false;
18292 if (event.defaultPrevented) return;
18293 if (!store) return;
18294 const { open: open2 } = store.getState();
18295 if (open2 && event.key === "Enter") {
18296 event.preventDefault();
18297 return;
18298 }
18299 if (event.ctrlKey) return;
18300 if (event.altKey) return;
18301 if (event.shiftKey) return;
18302 if (event.metaKey) return;
18303 if (open2) return;
18304 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18305 if (showOnKeyPressProp(event)) {
18306 event.preventDefault();
18307 store.show();
18308 }
18309 }
18310 });
18311 const onBlurProp = props.onBlur;
18312 const onBlur = useEvent((event) => {
18313 canAutoSelectRef.current = false;
18314 onBlurProp?.(event);
18315 if (event.defaultPrevented) return;
18316 });
18317 const id = useId4(props.id);
18318 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18319 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18320 props = {
18321 role: "combobox",
18322 "aria-autocomplete": ariaAutoComplete,
18323 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18324 "aria-expanded": open,
18325 "aria-controls": contentElement?.id,
18326 "data-active-item": isActiveItem || void 0,
18327 value,
18328 ...props,
18329 id,
18330 ref: useMergeRefs(ref, props.ref),
18331 onChange,
18332 onCompositionEnd,
18333 onMouseDown,
18334 onKeyDown,
18335 onBlur
18336 };
18337 props = useComposite({
18338 store,
18339 focusable: focusable2,
18340 ...props,
18341 moveOnKeyPress: (event) => {
18342 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18343 if (inline4) setCanInline(true);
18344 return true;
18345 }
18346 });
18347 props = usePopoverAnchor({
18348 store,
18349 ...props
18350 });
18351 return {
18352 autoComplete: "off",
18353 ...props
18354 };
18355 });
18356 var Combobox = forwardRef30(function Combobox2(props) {
18357 return createElement3(TagName9, useCombobox(props));
18358 });
18359
18360 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18361 var import_react24 = __toESM(require_react(), 1);
18362 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18363 var TagName10 = "div";
18364 function isSelected(storeValue, itemValue) {
18365 if (itemValue == null) return;
18366 if (storeValue == null) return false;
18367 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18368 return storeValue === itemValue;
18369 }
18370 function getItemRole(popupRole) {
18371 return {
18372 menu: "menuitem",
18373 listbox: "option",
18374 tree: "treeitem"
18375 }[popupRole] ?? "option";
18376 }
18377 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18378 const context = useComboboxScopedContext();
18379 store = store || context;
18380 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18381 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18382 resetValueOnSelectState: "resetValueOnSelect",
18383 multiSelectable(state) {
18384 return Array.isArray(state.selectedValue);
18385 },
18386 selected(state) {
18387 return isSelected(state.selectedValue, value);
18388 }
18389 });
18390 const getItem = (0, import_react24.useCallback)((item) => {
18391 const nextItem = {
18392 ...item,
18393 value
18394 };
18395 if (getItemProp) return getItemProp(nextItem);
18396 return nextItem;
18397 }, [value, getItemProp]);
18398 setValueOnClick = setValueOnClick ?? !multiSelectable;
18399 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18400 const onClickProp = props.onClick;
18401 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18402 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18403 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18404 const hideOnClickProp = useBooleanEvent(hideOnClick);
18405 const onClick = useEvent((event) => {
18406 onClickProp?.(event);
18407 if (event.defaultPrevented) return;
18408 if (isDownloading(event)) return;
18409 if (isOpeningInNewTab(event)) return;
18410 if (value != null) {
18411 if (selectValueOnClickProp(event)) {
18412 if (resetValueOnSelectProp(event)) store?.resetValue();
18413 store?.setSelectedValue((prevValue) => {
18414 if (!Array.isArray(prevValue)) return value;
18415 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18416 return [...prevValue, value];
18417 });
18418 }
18419 if (setValueOnClickProp(event)) store?.setValue(value);
18420 }
18421 if (hideOnClickProp(event)) store?.hide();
18422 });
18423 const onKeyDownProp = props.onKeyDown;
18424 const onKeyDown = useEvent((event) => {
18425 onKeyDownProp?.(event);
18426 if (event.defaultPrevented) return;
18427 const baseElement = store?.getState().baseElement;
18428 if (!baseElement) return;
18429 if (hasFocus(baseElement)) return;
18430 if (event.key.length === 1 || event.key === "Backspace" || event.key === "Delete") {
18431 queueMicrotask(() => baseElement.focus());
18432 if (isTextField(baseElement)) store?.setValue(baseElement.value);
18433 }
18434 });
18435 if (multiSelectable && selected != null) props = {
18436 "aria-selected": selected,
18437 ...props
18438 };
18439 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemValueContext.Provider, {
18440 value,
18441 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemCheckedContext.Provider, {
18442 value: selected ?? false,
18443 children: element
18444 })
18445 }), [value, selected]);
18446 props = {
18447 role: getItemRole((0, import_react24.useContext)(ComboboxListRoleContext)),
18448 children: value,
18449 ...props,
18450 onClick,
18451 onKeyDown
18452 };
18453 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18454 props = useCompositeItem({
18455 store,
18456 ...props,
18457 getItem,
18458 moveOnKeyPress: (event) => {
18459 if (!moveOnKeyPressProp(event)) return false;
18460 const moveEvent = new Event("combobox-item-move");
18461 store?.getState().baseElement?.dispatchEvent(moveEvent);
18462 return true;
18463 }
18464 });
18465 props = useCompositeHover({
18466 store,
18467 focusOnHover,
18468 ...props
18469 });
18470 return props;
18471 });
18472 var ComboboxItem = memo3(forwardRef30(function ComboboxItem2(props) {
18473 return createElement3(TagName10, useComboboxItem(props));
18474 }));
18475
18476 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
18477 var import_react25 = __toESM(require_react(), 1);
18478 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18479 var TagName11 = "span";
18480 function normalizeValue(value) {
18481 return normalizeString(value).toLowerCase();
18482 }
18483 function getOffsets(string, values) {
18484 const offsets = [];
18485 for (const value of values) {
18486 let pos = 0;
18487 const length = value.length;
18488 while (string.indexOf(value, pos) !== -1) {
18489 const index2 = string.indexOf(value, pos);
18490 if (index2 !== -1) offsets.push([index2, length]);
18491 pos = index2 + 1;
18492 }
18493 }
18494 return offsets;
18495 }
18496 function filterOverlappingOffsets(offsets) {
18497 return offsets.filter(([offset4, length], i2, arr) => {
18498 return !arr.some(([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length);
18499 });
18500 }
18501 function sortOffsets(offsets) {
18502 return offsets.sort(([a2], [b2]) => a2 - b2);
18503 }
18504 function splitValue(itemValue, userValue) {
18505 if (!itemValue) return itemValue;
18506 if (!userValue) return itemValue;
18507 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18508 const parts = [];
18509 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", {
18510 "data-autocomplete-value": autocomplete ? "" : void 0,
18511 "data-user-value": autocomplete ? void 0 : "",
18512 children: value
18513 }, parts.length);
18514 const offsets = sortOffsets(filterOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
18515 const firstEntry = offsets[0];
18516 if (!firstEntry) {
18517 parts.push(span(itemValue, true));
18518 return parts;
18519 }
18520 const [firstOffset] = firstEntry;
18521 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
18522 const value = itemValue.slice(offset4, offset4 + length);
18523 const nextOffset = offsets[i2 + 1]?.[0];
18524 return [value, itemValue.slice(offset4 + length, nextOffset)];
18525 })].forEach((value, i2) => {
18526 if (!value) return;
18527 parts.push(span(value, i2 % 2 === 0));
18528 });
18529 return parts;
18530 }
18531 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18532 const context = useComboboxScopedContext();
18533 store = store || context;
18534 const itemContext = (0, import_react25.useContext)(ComboboxItemValueContext);
18535 const itemValue = value ?? itemContext;
18536 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
18537 props = {
18538 children: (0, import_react25.useMemo)(() => {
18539 if (!itemValue) return;
18540 if (!inputValue) return itemValue;
18541 return splitValue(itemValue, inputValue);
18542 }, [itemValue, inputValue]),
18543 ...props
18544 };
18545 return removeUndefinedValues(props);
18546 });
18547 var ComboboxItemValue = forwardRef30(function ComboboxItemValue2(props) {
18548 return createElement3(TagName11, useComboboxItemValue(props));
18549 });
18550
18551 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
18552 var TagName12 = "label";
18553 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
18554 const context = useComboboxProviderContext();
18555 store = store || context;
18556 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18557 props = {
18558 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
18559 ...props
18560 };
18561 return removeUndefinedValues(props);
18562 });
18563 var ComboboxLabel = memo3(forwardRef30(function ComboboxLabel2(props) {
18564 return createElement3(TagName12, useComboboxLabel(props));
18565 }));
18566
18567 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
18568 var import_react26 = __toESM(require_react(), 1);
18569 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18570 var TagName13 = "div";
18571 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
18572 const scopedContext = useComboboxScopedContext(true);
18573 const context = useComboboxContext();
18574 store = store || context;
18575 const scopedContextSameStore = !!store && store === scopedContext;
18576 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18577 const ref = (0, import_react26.useRef)(null);
18578 const id = useId4(props.id);
18579 const mounted = useStoreState(store, "mounted");
18580 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18581 const style = hidden ? {
18582 ...props.style,
18583 display: "none"
18584 } : props.style;
18585 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
18586 const role = useAttribute(ref, "role", props.role);
18587 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
18588 const [hasListboxInside, setHasListboxInside] = (0, import_react26.useState)(false);
18589 const contentElement = useStoreState(store, "contentElement");
18590 useSafeLayoutEffect(() => {
18591 if (!mounted) return;
18592 const element = ref.current;
18593 if (!element) return;
18594 if (contentElement !== element) return;
18595 const callback = () => {
18596 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18597 };
18598 const observer = new MutationObserver(callback);
18599 observer.observe(element, {
18600 subtree: true,
18601 childList: true,
18602 attributeFilter: ["role"]
18603 });
18604 callback();
18605 return () => observer.disconnect();
18606 }, [mounted, contentElement]);
18607 if (!hasListboxInside) props = {
18608 role: "listbox",
18609 "aria-multiselectable": ariaMultiSelectable,
18610 ...props
18611 };
18612 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxScopedContextProvider, {
18613 value: store,
18614 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxListRoleContext.Provider, {
18615 value: role,
18616 children: element
18617 })
18618 }), [store, role]);
18619 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18620 props = {
18621 hidden,
18622 ...props,
18623 id,
18624 ref: useMergeRefs(setContentElement, ref, props.ref),
18625 style
18626 };
18627 return removeUndefinedValues(props);
18628 });
18629 var ComboboxList = forwardRef30(function ComboboxList2(props) {
18630 return createElement3(TagName13, useComboboxList(props));
18631 });
18632
18633 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
18634 var import_react27 = __toESM(require_react(), 1);
18635 var TagValueContext = (0, import_react27.createContext)(null);
18636 var TagRemoveIdContext = (0, import_react27.createContext)(null);
18637 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
18638 var useTagContext = ctx7.useContext;
18639 var useTagScopedContext = ctx7.useScopedContext;
18640 var useTagProviderContext = ctx7.useProviderContext;
18641 var TagContextProvider = ctx7.ContextProvider;
18642 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18643
18644 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
18645 var isTouchSafari = isSafari2() && isTouchDevice();
18646 function createComboboxStore({ tag, ...props } = {}) {
18647 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18648 throwOnConflictingProps(props, store);
18649 const tagState = tag?.getState();
18650 const syncState = store?.getState();
18651 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
18652 const composite = createCompositeStore({
18653 ...props,
18654 activeId,
18655 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
18656 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
18657 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
18658 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
18659 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
18660 });
18661 const popover = createPopoverStore({
18662 ...props,
18663 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
18664 });
18665 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
18666 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
18667 const multiSelectable = Array.isArray(selectedValue);
18668 const initialState = {
18669 ...composite.getState(),
18670 ...popover.getState(),
18671 value,
18672 selectedValue,
18673 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
18674 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
18675 activeValue: syncState?.activeValue
18676 };
18677 const combobox = createStore(initialState, composite, popover, store);
18678 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
18679 combobox.setState("virtualFocus", false);
18680 }));
18681 setup(combobox, () => {
18682 if (!tag) return;
18683 return chain(sync(combobox, ["selectedValue"], (state) => {
18684 if (!Array.isArray(state.selectedValue)) return;
18685 tag.setValues(state.selectedValue);
18686 }), sync(tag, ["values"], (state) => {
18687 combobox.setState("selectedValue", state.values);
18688 }));
18689 });
18690 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18691 if (!state.resetValueOnHide) return;
18692 if (state.mounted) return;
18693 combobox.setState("value", value);
18694 }));
18695 setup(combobox, () => sync(combobox, ["open"], (state) => {
18696 if (state.open) return;
18697 combobox.setState("activeId", activeId);
18698 combobox.setState("moves", 0);
18699 }));
18700 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18701 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
18702 }));
18703 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18704 if (state.moves === prev.moves) return;
18705 const { activeId: activeId2 } = combobox.getState();
18706 const activeItem = composite.item(activeId2);
18707 combobox.setState("activeValue", activeItem?.value);
18708 }));
18709 return {
18710 ...popover,
18711 ...composite,
18712 ...combobox,
18713 tag,
18714 setValue: (value2) => combobox.setState("value", value2),
18715 resetValue: () => combobox.setState("value", initialState.value),
18716 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18717 };
18718 }
18719
18720 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
18721 function useComboboxStoreOptions(props) {
18722 const tag = useTagContext();
18723 props = {
18724 ...props,
18725 tag: props.tag !== void 0 ? props.tag : tag
18726 };
18727 return useCompositeStoreOptions(props);
18728 }
18729 function useComboboxStoreProps(store, update2, props) {
18730 useUpdateEffect(update2, [props.tag]);
18731 useStoreProps(store, props, "value", "setValue");
18732 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18733 useStoreProps(store, props, "resetValueOnHide");
18734 useStoreProps(store, props, "resetValueOnSelect");
18735 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
18736 }
18737 function useComboboxStore(props = {}) {
18738 props = useComboboxStoreOptions(props);
18739 const [store, update2] = useStore2(createComboboxStore, props);
18740 return useComboboxStoreProps(store, update2, props);
18741 }
18742
18743 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
18744 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18745 function ComboboxProvider(props = {}) {
18746 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxContextProvider, {
18747 value: useComboboxStore(props),
18748 children: props.children
18749 });
18750 }
18751
18752 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18753 var import_remove_accents = __toESM(require_remove_accents(), 1);
18754 var import_compose8 = __toESM(require_compose(), 1);
18755 var import_i18n24 = __toESM(require_i18n(), 1);
18756 var import_element51 = __toESM(require_element(), 1);
18757 var import_components19 = __toESM(require_components(), 1);
18758
18759 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18760 var EMPTY_ARRAY3 = [];
18761 var getCurrentValue = (filterDefinition, currentFilter) => {
18762 if (filterDefinition.singleSelection) {
18763 return currentFilter?.value;
18764 }
18765 if (Array.isArray(currentFilter?.value)) {
18766 return currentFilter.value;
18767 }
18768 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18769 return [currentFilter.value];
18770 }
18771 return EMPTY_ARRAY3;
18772 };
18773
18774 // packages/dataviews/build-module/hooks/use-elements.mjs
18775 var import_element50 = __toESM(require_element(), 1);
18776 var EMPTY_ARRAY4 = [];
18777 function useElements({
18778 elements,
18779 getElements
18780 }) {
18781 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18782 const [records, setRecords] = (0, import_element50.useState)(staticElements);
18783 const [isLoading, setIsLoading] = (0, import_element50.useState)(false);
18784 (0, import_element50.useEffect)(() => {
18785 if (!getElements) {
18786 setRecords(staticElements);
18787 return;
18788 }
18789 let cancelled = false;
18790 setIsLoading(true);
18791 getElements().then((fetchedElements) => {
18792 if (!cancelled) {
18793 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18794 setRecords(dynamicElements);
18795 }
18796 }).catch(() => {
18797 if (!cancelled) {
18798 setRecords(staticElements);
18799 }
18800 }).finally(() => {
18801 if (!cancelled) {
18802 setIsLoading(false);
18803 }
18804 });
18805 return () => {
18806 cancelled = true;
18807 };
18808 }, [getElements, staticElements]);
18809 return {
18810 elements: records,
18811 isLoading
18812 };
18813 }
18814
18815 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18816 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
18817 function normalizeSearchInput(input = "") {
18818 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18819 }
18820 var getNewValue = (filterDefinition, currentFilter, value) => {
18821 if (filterDefinition.singleSelection) {
18822 return value;
18823 }
18824 if (Array.isArray(currentFilter?.value)) {
18825 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18826 }
18827 return [value];
18828 };
18829 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18830 return `${prefix}-${filterElementValue}`;
18831 }
18832 var MultiSelectionOption = ({ selected }) => {
18833 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18834 "span",
18835 {
18836 className: clsx_default(
18837 "dataviews-filters__search-widget-listitem-multi-selection",
18838 { "is-selected": selected }
18839 ),
18840 children: selected && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: check_default })
18841 }
18842 );
18843 };
18844 var SingleSelectionOption = ({ selected }) => {
18845 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18846 "span",
18847 {
18848 className: clsx_default(
18849 "dataviews-filters__search-widget-listitem-single-selection",
18850 { "is-selected": selected }
18851 )
18852 }
18853 );
18854 };
18855 function ListBox({ view, filter, onChangeView }) {
18856 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
18857 const [activeCompositeId, setActiveCompositeId] = (0, import_element51.useState)(
18858 // When there are one or less operators, the first item is set as active
18859 // (by setting the initial `activeId` to `undefined`).
18860 // With 2 or more operators, the focus is moved on the operators control
18861 // (by setting the initial `activeId` to `null`), meaning that there won't
18862 // be an active item initially. Focus is then managed via the
18863 // `onFocusVisible` callback.
18864 filter.operators?.length === 1 ? void 0 : null
18865 );
18866 const currentFilter = view.filters?.find(
18867 (f2) => f2.field === filter.field
18868 );
18869 const currentValue = getCurrentValue(filter, currentFilter);
18870 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18871 import_components19.Composite,
18872 {
18873 virtualFocus: true,
18874 focusLoop: true,
18875 activeId: activeCompositeId,
18876 setActiveId: setActiveCompositeId,
18877 role: "listbox",
18878 className: "dataviews-filters__search-widget-listbox",
18879 "aria-label": (0, import_i18n24.sprintf)(
18880 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18881 (0, import_i18n24.__)("List of: %1$s"),
18882 filter.name
18883 ),
18884 onFocusVisible: () => {
18885 if (!activeCompositeId && filter.elements.length) {
18886 setActiveCompositeId(
18887 generateFilterElementCompositeItemId(
18888 baseId,
18889 filter.elements[0].value
18890 )
18891 );
18892 }
18893 },
18894 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Composite.Typeahead, {}),
18895 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
18896 import_components19.Composite.Hover,
18897 {
18898 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18899 import_components19.Composite.Item,
18900 {
18901 id: generateFilterElementCompositeItemId(
18902 baseId,
18903 element.value
18904 ),
18905 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18906 "div",
18907 {
18908 "aria-label": element.label,
18909 role: "option",
18910 className: "dataviews-filters__search-widget-listitem"
18911 }
18912 ),
18913 onClick: () => {
18914 const newFilters = currentFilter ? [
18915 ...(view.filters ?? []).map(
18916 (_filter) => {
18917 if (_filter.field === filter.field) {
18918 return {
18919 ..._filter,
18920 operator: currentFilter.operator || filter.operators[0],
18921 value: getNewValue(
18922 filter,
18923 currentFilter,
18924 element.value
18925 )
18926 };
18927 }
18928 return _filter;
18929 }
18930 )
18931 ] : [
18932 ...view.filters ?? [],
18933 {
18934 field: filter.field,
18935 operator: filter.operators[0],
18936 value: getNewValue(
18937 filter,
18938 currentFilter,
18939 element.value
18940 )
18941 }
18942 ];
18943 onChangeView({
18944 ...view,
18945 page: 1,
18946 filters: newFilters
18947 });
18948 }
18949 }
18950 ),
18951 children: [
18952 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18953 SingleSelectionOption,
18954 {
18955 selected: currentValue === element.value
18956 }
18957 ),
18958 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18959 MultiSelectionOption,
18960 {
18961 selected: currentValue.includes(element.value)
18962 }
18963 ),
18964 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18965 "span",
18966 {
18967 className: "dataviews-filters__search-widget-listitem-value",
18968 title: element.label,
18969 children: element.label
18970 }
18971 )
18972 ]
18973 },
18974 element.value
18975 ))
18976 }
18977 );
18978 }
18979 function ComboboxList22({ view, filter, onChangeView }) {
18980 const [searchValue, setSearchValue] = (0, import_element51.useState)("");
18981 const deferredSearchValue = (0, import_element51.useDeferredValue)(searchValue);
18982 const currentFilter = view.filters?.find(
18983 (_filter) => _filter.field === filter.field
18984 );
18985 const currentValue = getCurrentValue(filter, currentFilter);
18986 const matches = (0, import_element51.useMemo)(() => {
18987 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18988 return filter.elements.filter(
18989 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18990 );
18991 }, [filter.elements, deferredSearchValue]);
18992 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
18993 ComboboxProvider,
18994 {
18995 selectedValue: currentValue,
18996 setSelectedValue: (value) => {
18997 const newFilters = currentFilter ? [
18998 ...(view.filters ?? []).map((_filter) => {
18999 if (_filter.field === filter.field) {
19000 return {
19001 ..._filter,
19002 operator: currentFilter.operator || filter.operators[0],
19003 value
19004 };
19005 }
19006 return _filter;
19007 })
19008 ] : [
19009 ...view.filters ?? [],
19010 {
19011 field: filter.field,
19012 operator: filter.operators[0],
19013 value
19014 }
19015 ];
19016 onChangeView({
19017 ...view,
19018 page: 1,
19019 filters: newFilters
19020 });
19021 },
19022 setValue: setSearchValue,
19023 children: [
19024 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19025 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxLabel, {}), children: (0, import_i18n24.__)("Search items") }),
19026 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19027 Combobox,
19028 {
19029 autoSelect: "always",
19030 placeholder: (0, import_i18n24.__)("Search"),
19031 className: "dataviews-filters__search-widget-filter-combobox__input"
19032 }
19033 ),
19034 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: search_default }) })
19035 ] }),
19036 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19037 ComboboxList,
19038 {
19039 className: "dataviews-filters__search-widget-filter-combobox-list",
19040 alwaysVisible: true,
19041 children: [
19042 matches.map((element) => {
19043 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19044 ComboboxItem,
19045 {
19046 resetValueOnSelect: false,
19047 value: element.value,
19048 className: "dataviews-filters__search-widget-listitem",
19049 hideOnClick: false,
19050 setValueOnClick: false,
19051 focusOnHover: true,
19052 children: [
19053 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19054 SingleSelectionOption,
19055 {
19056 selected: currentValue === element.value
19057 }
19058 ),
19059 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19060 MultiSelectionOption,
19061 {
19062 selected: currentValue.includes(
19063 element.value
19064 )
19065 }
19066 ),
19067 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19068 "span",
19069 {
19070 className: "dataviews-filters__search-widget-listitem-value",
19071 title: element.label,
19072 children: [
19073 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19074 ComboboxItemValue,
19075 {
19076 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19077 value: element.label
19078 }
19079 ),
19080 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19081 ]
19082 }
19083 )
19084 ]
19085 },
19086 element.value
19087 );
19088 }),
19089 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n24.__)("No results found") })
19090 ]
19091 }
19092 )
19093 ]
19094 }
19095 );
19096 }
19097 function SearchWidget(props) {
19098 const { elements, isLoading } = useElements({
19099 elements: props.filter.elements,
19100 getElements: props.filter.getElements
19101 });
19102 if (isLoading) {
19103 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Spinner, {}) });
19104 }
19105 if (elements.length === 0) {
19106 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n24.__)("No elements found") });
19107 }
19108 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19109 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19110 }
19111
19112 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19113 var import_es6 = __toESM(require_es6(), 1);
19114 var import_compose9 = __toESM(require_compose(), 1);
19115 var import_element52 = __toESM(require_element(), 1);
19116 var import_components20 = __toESM(require_components(), 1);
19117 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19118 function InputWidget({
19119 filter,
19120 view,
19121 onChangeView,
19122 fields
19123 }) {
19124 const currentFilter = view.filters?.find(
19125 (f2) => f2.field === filter.field
19126 );
19127 const currentValue = getCurrentValue(filter, currentFilter);
19128 const field = (0, import_element52.useMemo)(() => {
19129 const currentField = fields.find((f2) => f2.id === filter.field);
19130 if (currentField) {
19131 return {
19132 ...currentField,
19133 // Deactivate validation for filters.
19134 isValid: {},
19135 // Filter controls are always enabled.
19136 isDisabled: () => false,
19137 // Filter controls are always visible.
19138 isVisible: () => true,
19139 // Configure getValue/setValue as if Item was a plain object.
19140 getValue: ({ item }) => item[currentField.id],
19141 setValue: ({ value }) => ({
19142 [currentField.id]: value
19143 })
19144 };
19145 }
19146 return currentField;
19147 }, [fields, filter.field]);
19148 const data = (0, import_element52.useMemo)(() => {
19149 return (view.filters ?? []).reduce(
19150 (acc, activeFilter) => {
19151 acc[activeFilter.field] = activeFilter.value;
19152 return acc;
19153 },
19154 {}
19155 );
19156 }, [view.filters]);
19157 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19158 if (!field || !currentFilter) {
19159 return;
19160 }
19161 const nextValue = field.getValue({ item: updatedData });
19162 if ((0, import_es6.default)(nextValue, currentValue)) {
19163 return;
19164 }
19165 onChangeView({
19166 ...view,
19167 filters: (view.filters ?? []).map(
19168 (_filter) => _filter.field === filter.field ? {
19169 ..._filter,
19170 operator: currentFilter.operator || filter.operators[0],
19171 // Consider empty strings as undefined:
19172 //
19173 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19174 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19175 //
19176 // In practice, this means the filter will not be able to find an empty string as the value.
19177 value: nextValue === "" ? void 0 : nextValue
19178 } : _filter
19179 )
19180 });
19181 });
19182 if (!field || !field.Edit || !currentFilter) {
19183 return null;
19184 }
19185 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19186 import_components20.Flex,
19187 {
19188 className: "dataviews-filters__user-input-widget",
19189 gap: 2.5,
19190 direction: "column",
19191 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19192 field.Edit,
19193 {
19194 hideLabelFromVision: true,
19195 data,
19196 field,
19197 operator: currentFilter.operator,
19198 onChange: handleChange
19199 }
19200 )
19201 }
19202 );
19203 }
19204
19205 // node_modules/date-fns/constants.js
19206 var daysInYear = 365.2425;
19207 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19208 var minTime = -maxTime;
19209 var millisecondsInWeek = 6048e5;
19210 var millisecondsInDay = 864e5;
19211 var secondsInHour = 3600;
19212 var secondsInDay = secondsInHour * 24;
19213 var secondsInWeek = secondsInDay * 7;
19214 var secondsInYear = secondsInDay * daysInYear;
19215 var secondsInMonth = secondsInYear / 12;
19216 var secondsInQuarter = secondsInMonth * 3;
19217 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19218
19219 // node_modules/date-fns/constructFrom.js
19220 function constructFrom(date, value) {
19221 if (typeof date === "function") return date(value);
19222 if (date && typeof date === "object" && constructFromSymbol in date)
19223 return date[constructFromSymbol](value);
19224 if (date instanceof Date) return new date.constructor(value);
19225 return new Date(value);
19226 }
19227
19228 // node_modules/date-fns/toDate.js
19229 function toDate(argument, context) {
19230 return constructFrom(context || argument, argument);
19231 }
19232
19233 // node_modules/date-fns/addDays.js
19234 function addDays(date, amount, options) {
19235 const _date = toDate(date, options?.in);
19236 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19237 if (!amount) return _date;
19238 _date.setDate(_date.getDate() + amount);
19239 return _date;
19240 }
19241
19242 // node_modules/date-fns/addMonths.js
19243 function addMonths(date, amount, options) {
19244 const _date = toDate(date, options?.in);
19245 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19246 if (!amount) {
19247 return _date;
19248 }
19249 const dayOfMonth = _date.getDate();
19250 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19251 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19252 const daysInMonth = endOfDesiredMonth.getDate();
19253 if (dayOfMonth >= daysInMonth) {
19254 return endOfDesiredMonth;
19255 } else {
19256 _date.setFullYear(
19257 endOfDesiredMonth.getFullYear(),
19258 endOfDesiredMonth.getMonth(),
19259 dayOfMonth
19260 );
19261 return _date;
19262 }
19263 }
19264
19265 // node_modules/date-fns/_lib/defaultOptions.js
19266 var defaultOptions = {};
19267 function getDefaultOptions() {
19268 return defaultOptions;
19269 }
19270
19271 // node_modules/date-fns/startOfWeek.js
19272 function startOfWeek(date, options) {
19273 const defaultOptions2 = getDefaultOptions();
19274 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19275 const _date = toDate(date, options?.in);
19276 const day = _date.getDay();
19277 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19278 _date.setDate(_date.getDate() - diff);
19279 _date.setHours(0, 0, 0, 0);
19280 return _date;
19281 }
19282
19283 // node_modules/date-fns/startOfISOWeek.js
19284 function startOfISOWeek(date, options) {
19285 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19286 }
19287
19288 // node_modules/date-fns/getISOWeekYear.js
19289 function getISOWeekYear(date, options) {
19290 const _date = toDate(date, options?.in);
19291 const year = _date.getFullYear();
19292 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19293 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19294 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19295 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19296 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19297 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19298 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19299 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19300 if (_date.getTime() >= startOfNextYear.getTime()) {
19301 return year + 1;
19302 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19303 return year;
19304 } else {
19305 return year - 1;
19306 }
19307 }
19308
19309 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19310 function getTimezoneOffsetInMilliseconds(date) {
19311 const _date = toDate(date);
19312 const utcDate = new Date(
19313 Date.UTC(
19314 _date.getFullYear(),
19315 _date.getMonth(),
19316 _date.getDate(),
19317 _date.getHours(),
19318 _date.getMinutes(),
19319 _date.getSeconds(),
19320 _date.getMilliseconds()
19321 )
19322 );
19323 utcDate.setUTCFullYear(_date.getFullYear());
19324 return +date - +utcDate;
19325 }
19326
19327 // node_modules/date-fns/_lib/normalizeDates.js
19328 function normalizeDates(context, ...dates) {
19329 const normalize = constructFrom.bind(
19330 null,
19331 context || dates.find((date) => typeof date === "object")
19332 );
19333 return dates.map(normalize);
19334 }
19335
19336 // node_modules/date-fns/startOfDay.js
19337 function startOfDay(date, options) {
19338 const _date = toDate(date, options?.in);
19339 _date.setHours(0, 0, 0, 0);
19340 return _date;
19341 }
19342
19343 // node_modules/date-fns/differenceInCalendarDays.js
19344 function differenceInCalendarDays(laterDate, earlierDate, options) {
19345 const [laterDate_, earlierDate_] = normalizeDates(
19346 options?.in,
19347 laterDate,
19348 earlierDate
19349 );
19350 const laterStartOfDay = startOfDay(laterDate_);
19351 const earlierStartOfDay = startOfDay(earlierDate_);
19352 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19353 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19354 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19355 }
19356
19357 // node_modules/date-fns/startOfISOWeekYear.js
19358 function startOfISOWeekYear(date, options) {
19359 const year = getISOWeekYear(date, options);
19360 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19361 fourthOfJanuary.setFullYear(year, 0, 4);
19362 fourthOfJanuary.setHours(0, 0, 0, 0);
19363 return startOfISOWeek(fourthOfJanuary);
19364 }
19365
19366 // node_modules/date-fns/addWeeks.js
19367 function addWeeks(date, amount, options) {
19368 return addDays(date, amount * 7, options);
19369 }
19370
19371 // node_modules/date-fns/addYears.js
19372 function addYears(date, amount, options) {
19373 return addMonths(date, amount * 12, options);
19374 }
19375
19376 // node_modules/date-fns/isDate.js
19377 function isDate(value) {
19378 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19379 }
19380
19381 // node_modules/date-fns/isValid.js
19382 function isValid(date) {
19383 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19384 }
19385
19386 // node_modules/date-fns/startOfMonth.js
19387 function startOfMonth(date, options) {
19388 const _date = toDate(date, options?.in);
19389 _date.setDate(1);
19390 _date.setHours(0, 0, 0, 0);
19391 return _date;
19392 }
19393
19394 // node_modules/date-fns/startOfYear.js
19395 function startOfYear(date, options) {
19396 const date_ = toDate(date, options?.in);
19397 date_.setFullYear(date_.getFullYear(), 0, 1);
19398 date_.setHours(0, 0, 0, 0);
19399 return date_;
19400 }
19401
19402 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19403 var formatDistanceLocale = {
19404 lessThanXSeconds: {
19405 one: "less than a second",
19406 other: "less than {{count}} seconds"
19407 },
19408 xSeconds: {
19409 one: "1 second",
19410 other: "{{count}} seconds"
19411 },
19412 halfAMinute: "half a minute",
19413 lessThanXMinutes: {
19414 one: "less than a minute",
19415 other: "less than {{count}} minutes"
19416 },
19417 xMinutes: {
19418 one: "1 minute",
19419 other: "{{count}} minutes"
19420 },
19421 aboutXHours: {
19422 one: "about 1 hour",
19423 other: "about {{count}} hours"
19424 },
19425 xHours: {
19426 one: "1 hour",
19427 other: "{{count}} hours"
19428 },
19429 xDays: {
19430 one: "1 day",
19431 other: "{{count}} days"
19432 },
19433 aboutXWeeks: {
19434 one: "about 1 week",
19435 other: "about {{count}} weeks"
19436 },
19437 xWeeks: {
19438 one: "1 week",
19439 other: "{{count}} weeks"
19440 },
19441 aboutXMonths: {
19442 one: "about 1 month",
19443 other: "about {{count}} months"
19444 },
19445 xMonths: {
19446 one: "1 month",
19447 other: "{{count}} months"
19448 },
19449 aboutXYears: {
19450 one: "about 1 year",
19451 other: "about {{count}} years"
19452 },
19453 xYears: {
19454 one: "1 year",
19455 other: "{{count}} years"
19456 },
19457 overXYears: {
19458 one: "over 1 year",
19459 other: "over {{count}} years"
19460 },
19461 almostXYears: {
19462 one: "almost 1 year",
19463 other: "almost {{count}} years"
19464 }
19465 };
19466 var formatDistance = (token, count, options) => {
19467 let result;
19468 const tokenValue = formatDistanceLocale[token];
19469 if (typeof tokenValue === "string") {
19470 result = tokenValue;
19471 } else if (count === 1) {
19472 result = tokenValue.one;
19473 } else {
19474 result = tokenValue.other.replace("{{count}}", count.toString());
19475 }
19476 if (options?.addSuffix) {
19477 if (options.comparison && options.comparison > 0) {
19478 return "in " + result;
19479 } else {
19480 return result + " ago";
19481 }
19482 }
19483 return result;
19484 };
19485
19486 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19487 function buildFormatLongFn(args) {
19488 return (options = {}) => {
19489 const width = options.width ? String(options.width) : args.defaultWidth;
19490 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19491 return format6;
19492 };
19493 }
19494
19495 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19496 var dateFormats = {
19497 full: "EEEE, MMMM do, y",
19498 long: "MMMM do, y",
19499 medium: "MMM d, y",
19500 short: "MM/dd/yyyy"
19501 };
19502 var timeFormats = {
19503 full: "h:mm:ss a zzzz",
19504 long: "h:mm:ss a z",
19505 medium: "h:mm:ss a",
19506 short: "h:mm a"
19507 };
19508 var dateTimeFormats = {
19509 full: "{{date}} 'at' {{time}}",
19510 long: "{{date}} 'at' {{time}}",
19511 medium: "{{date}}, {{time}}",
19512 short: "{{date}}, {{time}}"
19513 };
19514 var formatLong = {
19515 date: buildFormatLongFn({
19516 formats: dateFormats,
19517 defaultWidth: "full"
19518 }),
19519 time: buildFormatLongFn({
19520 formats: timeFormats,
19521 defaultWidth: "full"
19522 }),
19523 dateTime: buildFormatLongFn({
19524 formats: dateTimeFormats,
19525 defaultWidth: "full"
19526 })
19527 };
19528
19529 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19530 var formatRelativeLocale = {
19531 lastWeek: "'last' eeee 'at' p",
19532 yesterday: "'yesterday at' p",
19533 today: "'today at' p",
19534 tomorrow: "'tomorrow at' p",
19535 nextWeek: "eeee 'at' p",
19536 other: "P"
19537 };
19538 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19539
19540 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19541 function buildLocalizeFn(args) {
19542 return (value, options) => {
19543 const context = options?.context ? String(options.context) : "standalone";
19544 let valuesArray;
19545 if (context === "formatting" && args.formattingValues) {
19546 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19547 const width = options?.width ? String(options.width) : defaultWidth;
19548 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19549 } else {
19550 const defaultWidth = args.defaultWidth;
19551 const width = options?.width ? String(options.width) : args.defaultWidth;
19552 valuesArray = args.values[width] || args.values[defaultWidth];
19553 }
19554 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19555 return valuesArray[index2];
19556 };
19557 }
19558
19559 // node_modules/date-fns/locale/en-US/_lib/localize.js
19560 var eraValues = {
19561 narrow: ["B", "A"],
19562 abbreviated: ["BC", "AD"],
19563 wide: ["Before Christ", "Anno Domini"]
19564 };
19565 var quarterValues = {
19566 narrow: ["1", "2", "3", "4"],
19567 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19568 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19569 };
19570 var monthValues = {
19571 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19572 abbreviated: [
19573 "Jan",
19574 "Feb",
19575 "Mar",
19576 "Apr",
19577 "May",
19578 "Jun",
19579 "Jul",
19580 "Aug",
19581 "Sep",
19582 "Oct",
19583 "Nov",
19584 "Dec"
19585 ],
19586 wide: [
19587 "January",
19588 "February",
19589 "March",
19590 "April",
19591 "May",
19592 "June",
19593 "July",
19594 "August",
19595 "September",
19596 "October",
19597 "November",
19598 "December"
19599 ]
19600 };
19601 var dayValues = {
19602 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19603 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19604 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19605 wide: [
19606 "Sunday",
19607 "Monday",
19608 "Tuesday",
19609 "Wednesday",
19610 "Thursday",
19611 "Friday",
19612 "Saturday"
19613 ]
19614 };
19615 var dayPeriodValues = {
19616 narrow: {
19617 am: "a",
19618 pm: "p",
19619 midnight: "mi",
19620 noon: "n",
19621 morning: "morning",
19622 afternoon: "afternoon",
19623 evening: "evening",
19624 night: "night"
19625 },
19626 abbreviated: {
19627 am: "AM",
19628 pm: "PM",
19629 midnight: "midnight",
19630 noon: "noon",
19631 morning: "morning",
19632 afternoon: "afternoon",
19633 evening: "evening",
19634 night: "night"
19635 },
19636 wide: {
19637 am: "a.m.",
19638 pm: "p.m.",
19639 midnight: "midnight",
19640 noon: "noon",
19641 morning: "morning",
19642 afternoon: "afternoon",
19643 evening: "evening",
19644 night: "night"
19645 }
19646 };
19647 var formattingDayPeriodValues = {
19648 narrow: {
19649 am: "a",
19650 pm: "p",
19651 midnight: "mi",
19652 noon: "n",
19653 morning: "in the morning",
19654 afternoon: "in the afternoon",
19655 evening: "in the evening",
19656 night: "at night"
19657 },
19658 abbreviated: {
19659 am: "AM",
19660 pm: "PM",
19661 midnight: "midnight",
19662 noon: "noon",
19663 morning: "in the morning",
19664 afternoon: "in the afternoon",
19665 evening: "in the evening",
19666 night: "at night"
19667 },
19668 wide: {
19669 am: "a.m.",
19670 pm: "p.m.",
19671 midnight: "midnight",
19672 noon: "noon",
19673 morning: "in the morning",
19674 afternoon: "in the afternoon",
19675 evening: "in the evening",
19676 night: "at night"
19677 }
19678 };
19679 var ordinalNumber = (dirtyNumber, _options) => {
19680 const number = Number(dirtyNumber);
19681 const rem100 = number % 100;
19682 if (rem100 > 20 || rem100 < 10) {
19683 switch (rem100 % 10) {
19684 case 1:
19685 return number + "st";
19686 case 2:
19687 return number + "nd";
19688 case 3:
19689 return number + "rd";
19690 }
19691 }
19692 return number + "th";
19693 };
19694 var localize = {
19695 ordinalNumber,
19696 era: buildLocalizeFn({
19697 values: eraValues,
19698 defaultWidth: "wide"
19699 }),
19700 quarter: buildLocalizeFn({
19701 values: quarterValues,
19702 defaultWidth: "wide",
19703 argumentCallback: (quarter) => quarter - 1
19704 }),
19705 month: buildLocalizeFn({
19706 values: monthValues,
19707 defaultWidth: "wide"
19708 }),
19709 day: buildLocalizeFn({
19710 values: dayValues,
19711 defaultWidth: "wide"
19712 }),
19713 dayPeriod: buildLocalizeFn({
19714 values: dayPeriodValues,
19715 defaultWidth: "wide",
19716 formattingValues: formattingDayPeriodValues,
19717 defaultFormattingWidth: "wide"
19718 })
19719 };
19720
19721 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19722 function buildMatchFn(args) {
19723 return (string, options = {}) => {
19724 const width = options.width;
19725 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19726 const matchResult = string.match(matchPattern);
19727 if (!matchResult) {
19728 return null;
19729 }
19730 const matchedString = matchResult[0];
19731 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19732 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19733 // [TODO] -- I challenge you to fix the type
19734 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19735 );
19736 let value;
19737 value = args.valueCallback ? args.valueCallback(key) : key;
19738 value = options.valueCallback ? (
19739 // [TODO] -- I challenge you to fix the type
19740 options.valueCallback(value)
19741 ) : value;
19742 const rest = string.slice(matchedString.length);
19743 return { value, rest };
19744 };
19745 }
19746 function findKey(object, predicate) {
19747 for (const key in object) {
19748 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19749 return key;
19750 }
19751 }
19752 return void 0;
19753 }
19754 function findIndex(array, predicate) {
19755 for (let key = 0; key < array.length; key++) {
19756 if (predicate(array[key])) {
19757 return key;
19758 }
19759 }
19760 return void 0;
19761 }
19762
19763 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19764 function buildMatchPatternFn(args) {
19765 return (string, options = {}) => {
19766 const matchResult = string.match(args.matchPattern);
19767 if (!matchResult) return null;
19768 const matchedString = matchResult[0];
19769 const parseResult = string.match(args.parsePattern);
19770 if (!parseResult) return null;
19771 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19772 value = options.valueCallback ? options.valueCallback(value) : value;
19773 const rest = string.slice(matchedString.length);
19774 return { value, rest };
19775 };
19776 }
19777
19778 // node_modules/date-fns/locale/en-US/_lib/match.js
19779 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19780 var parseOrdinalNumberPattern = /\d+/i;
19781 var matchEraPatterns = {
19782 narrow: /^(b|a)/i,
19783 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19784 wide: /^(before christ|before common era|anno domini|common era)/i
19785 };
19786 var parseEraPatterns = {
19787 any: [/^b/i, /^(a|c)/i]
19788 };
19789 var matchQuarterPatterns = {
19790 narrow: /^[1234]/i,
19791 abbreviated: /^q[1234]/i,
19792 wide: /^[1234](th|st|nd|rd)? quarter/i
19793 };
19794 var parseQuarterPatterns = {
19795 any: [/1/i, /2/i, /3/i, /4/i]
19796 };
19797 var matchMonthPatterns = {
19798 narrow: /^[jfmasond]/i,
19799 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19800 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19801 };
19802 var parseMonthPatterns = {
19803 narrow: [
19804 /^j/i,
19805 /^f/i,
19806 /^m/i,
19807 /^a/i,
19808 /^m/i,
19809 /^j/i,
19810 /^j/i,
19811 /^a/i,
19812 /^s/i,
19813 /^o/i,
19814 /^n/i,
19815 /^d/i
19816 ],
19817 any: [
19818 /^ja/i,
19819 /^f/i,
19820 /^mar/i,
19821 /^ap/i,
19822 /^may/i,
19823 /^jun/i,
19824 /^jul/i,
19825 /^au/i,
19826 /^s/i,
19827 /^o/i,
19828 /^n/i,
19829 /^d/i
19830 ]
19831 };
19832 var matchDayPatterns = {
19833 narrow: /^[smtwf]/i,
19834 short: /^(su|mo|tu|we|th|fr|sa)/i,
19835 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19836 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19837 };
19838 var parseDayPatterns = {
19839 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19840 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19841 };
19842 var matchDayPeriodPatterns = {
19843 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19844 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19845 };
19846 var parseDayPeriodPatterns = {
19847 any: {
19848 am: /^a/i,
19849 pm: /^p/i,
19850 midnight: /^mi/i,
19851 noon: /^no/i,
19852 morning: /morning/i,
19853 afternoon: /afternoon/i,
19854 evening: /evening/i,
19855 night: /night/i
19856 }
19857 };
19858 var match = {
19859 ordinalNumber: buildMatchPatternFn({
19860 matchPattern: matchOrdinalNumberPattern,
19861 parsePattern: parseOrdinalNumberPattern,
19862 valueCallback: (value) => parseInt(value, 10)
19863 }),
19864 era: buildMatchFn({
19865 matchPatterns: matchEraPatterns,
19866 defaultMatchWidth: "wide",
19867 parsePatterns: parseEraPatterns,
19868 defaultParseWidth: "any"
19869 }),
19870 quarter: buildMatchFn({
19871 matchPatterns: matchQuarterPatterns,
19872 defaultMatchWidth: "wide",
19873 parsePatterns: parseQuarterPatterns,
19874 defaultParseWidth: "any",
19875 valueCallback: (index2) => index2 + 1
19876 }),
19877 month: buildMatchFn({
19878 matchPatterns: matchMonthPatterns,
19879 defaultMatchWidth: "wide",
19880 parsePatterns: parseMonthPatterns,
19881 defaultParseWidth: "any"
19882 }),
19883 day: buildMatchFn({
19884 matchPatterns: matchDayPatterns,
19885 defaultMatchWidth: "wide",
19886 parsePatterns: parseDayPatterns,
19887 defaultParseWidth: "any"
19888 }),
19889 dayPeriod: buildMatchFn({
19890 matchPatterns: matchDayPeriodPatterns,
19891 defaultMatchWidth: "any",
19892 parsePatterns: parseDayPeriodPatterns,
19893 defaultParseWidth: "any"
19894 })
19895 };
19896
19897 // node_modules/date-fns/locale/en-US.js
19898 var enUS = {
19899 code: "en-US",
19900 formatDistance,
19901 formatLong,
19902 formatRelative,
19903 localize,
19904 match,
19905 options: {
19906 weekStartsOn: 0,
19907 firstWeekContainsDate: 1
19908 }
19909 };
19910
19911 // node_modules/date-fns/getDayOfYear.js
19912 function getDayOfYear(date, options) {
19913 const _date = toDate(date, options?.in);
19914 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19915 const dayOfYear = diff + 1;
19916 return dayOfYear;
19917 }
19918
19919 // node_modules/date-fns/getISOWeek.js
19920 function getISOWeek(date, options) {
19921 const _date = toDate(date, options?.in);
19922 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19923 return Math.round(diff / millisecondsInWeek) + 1;
19924 }
19925
19926 // node_modules/date-fns/getWeekYear.js
19927 function getWeekYear(date, options) {
19928 const _date = toDate(date, options?.in);
19929 const year = _date.getFullYear();
19930 const defaultOptions2 = getDefaultOptions();
19931 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19932 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19933 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19934 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19935 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19936 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19937 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19938 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19939 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19940 if (+_date >= +startOfNextYear) {
19941 return year + 1;
19942 } else if (+_date >= +startOfThisYear) {
19943 return year;
19944 } else {
19945 return year - 1;
19946 }
19947 }
19948
19949 // node_modules/date-fns/startOfWeekYear.js
19950 function startOfWeekYear(date, options) {
19951 const defaultOptions2 = getDefaultOptions();
19952 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19953 const year = getWeekYear(date, options);
19954 const firstWeek = constructFrom(options?.in || date, 0);
19955 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19956 firstWeek.setHours(0, 0, 0, 0);
19957 const _date = startOfWeek(firstWeek, options);
19958 return _date;
19959 }
19960
19961 // node_modules/date-fns/getWeek.js
19962 function getWeek(date, options) {
19963 const _date = toDate(date, options?.in);
19964 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19965 return Math.round(diff / millisecondsInWeek) + 1;
19966 }
19967
19968 // node_modules/date-fns/_lib/addLeadingZeros.js
19969 function addLeadingZeros(number, targetLength) {
19970 const sign = number < 0 ? "-" : "";
19971 const output = Math.abs(number).toString().padStart(targetLength, "0");
19972 return sign + output;
19973 }
19974
19975 // node_modules/date-fns/_lib/format/lightFormatters.js
19976 var lightFormatters = {
19977 // Year
19978 y(date, token) {
19979 const signedYear = date.getFullYear();
19980 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19981 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19982 },
19983 // Month
19984 M(date, token) {
19985 const month = date.getMonth();
19986 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19987 },
19988 // Day of the month
19989 d(date, token) {
19990 return addLeadingZeros(date.getDate(), token.length);
19991 },
19992 // AM or PM
19993 a(date, token) {
19994 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19995 switch (token) {
19996 case "a":
19997 case "aa":
19998 return dayPeriodEnumValue.toUpperCase();
19999 case "aaa":
20000 return dayPeriodEnumValue;
20001 case "aaaaa":
20002 return dayPeriodEnumValue[0];
20003 case "aaaa":
20004 default:
20005 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20006 }
20007 },
20008 // Hour [1-12]
20009 h(date, token) {
20010 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20011 },
20012 // Hour [0-23]
20013 H(date, token) {
20014 return addLeadingZeros(date.getHours(), token.length);
20015 },
20016 // Minute
20017 m(date, token) {
20018 return addLeadingZeros(date.getMinutes(), token.length);
20019 },
20020 // Second
20021 s(date, token) {
20022 return addLeadingZeros(date.getSeconds(), token.length);
20023 },
20024 // Fraction of second
20025 S(date, token) {
20026 const numberOfDigits = token.length;
20027 const milliseconds = date.getMilliseconds();
20028 const fractionalSeconds = Math.trunc(
20029 milliseconds * Math.pow(10, numberOfDigits - 3)
20030 );
20031 return addLeadingZeros(fractionalSeconds, token.length);
20032 }
20033 };
20034
20035 // node_modules/date-fns/_lib/format/formatters.js
20036 var dayPeriodEnum = {
20037 am: "am",
20038 pm: "pm",
20039 midnight: "midnight",
20040 noon: "noon",
20041 morning: "morning",
20042 afternoon: "afternoon",
20043 evening: "evening",
20044 night: "night"
20045 };
20046 var formatters = {
20047 // Era
20048 G: function(date, token, localize2) {
20049 const era = date.getFullYear() > 0 ? 1 : 0;
20050 switch (token) {
20051 // AD, BC
20052 case "G":
20053 case "GG":
20054 case "GGG":
20055 return localize2.era(era, { width: "abbreviated" });
20056 // A, B
20057 case "GGGGG":
20058 return localize2.era(era, { width: "narrow" });
20059 // Anno Domini, Before Christ
20060 case "GGGG":
20061 default:
20062 return localize2.era(era, { width: "wide" });
20063 }
20064 },
20065 // Year
20066 y: function(date, token, localize2) {
20067 if (token === "yo") {
20068 const signedYear = date.getFullYear();
20069 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20070 return localize2.ordinalNumber(year, { unit: "year" });
20071 }
20072 return lightFormatters.y(date, token);
20073 },
20074 // Local week-numbering year
20075 Y: function(date, token, localize2, options) {
20076 const signedWeekYear = getWeekYear(date, options);
20077 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20078 if (token === "YY") {
20079 const twoDigitYear = weekYear % 100;
20080 return addLeadingZeros(twoDigitYear, 2);
20081 }
20082 if (token === "Yo") {
20083 return localize2.ordinalNumber(weekYear, { unit: "year" });
20084 }
20085 return addLeadingZeros(weekYear, token.length);
20086 },
20087 // ISO week-numbering year
20088 R: function(date, token) {
20089 const isoWeekYear = getISOWeekYear(date);
20090 return addLeadingZeros(isoWeekYear, token.length);
20091 },
20092 // Extended year. This is a single number designating the year of this calendar system.
20093 // The main difference between `y` and `u` localizers are B.C. years:
20094 // | Year | `y` | `u` |
20095 // |------|-----|-----|
20096 // | AC 1 | 1 | 1 |
20097 // | BC 1 | 1 | 0 |
20098 // | BC 2 | 2 | -1 |
20099 // Also `yy` always returns the last two digits of a year,
20100 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20101 u: function(date, token) {
20102 const year = date.getFullYear();
20103 return addLeadingZeros(year, token.length);
20104 },
20105 // Quarter
20106 Q: function(date, token, localize2) {
20107 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20108 switch (token) {
20109 // 1, 2, 3, 4
20110 case "Q":
20111 return String(quarter);
20112 // 01, 02, 03, 04
20113 case "QQ":
20114 return addLeadingZeros(quarter, 2);
20115 // 1st, 2nd, 3rd, 4th
20116 case "Qo":
20117 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20118 // Q1, Q2, Q3, Q4
20119 case "QQQ":
20120 return localize2.quarter(quarter, {
20121 width: "abbreviated",
20122 context: "formatting"
20123 });
20124 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20125 case "QQQQQ":
20126 return localize2.quarter(quarter, {
20127 width: "narrow",
20128 context: "formatting"
20129 });
20130 // 1st quarter, 2nd quarter, ...
20131 case "QQQQ":
20132 default:
20133 return localize2.quarter(quarter, {
20134 width: "wide",
20135 context: "formatting"
20136 });
20137 }
20138 },
20139 // Stand-alone quarter
20140 q: function(date, token, localize2) {
20141 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20142 switch (token) {
20143 // 1, 2, 3, 4
20144 case "q":
20145 return String(quarter);
20146 // 01, 02, 03, 04
20147 case "qq":
20148 return addLeadingZeros(quarter, 2);
20149 // 1st, 2nd, 3rd, 4th
20150 case "qo":
20151 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20152 // Q1, Q2, Q3, Q4
20153 case "qqq":
20154 return localize2.quarter(quarter, {
20155 width: "abbreviated",
20156 context: "standalone"
20157 });
20158 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20159 case "qqqqq":
20160 return localize2.quarter(quarter, {
20161 width: "narrow",
20162 context: "standalone"
20163 });
20164 // 1st quarter, 2nd quarter, ...
20165 case "qqqq":
20166 default:
20167 return localize2.quarter(quarter, {
20168 width: "wide",
20169 context: "standalone"
20170 });
20171 }
20172 },
20173 // Month
20174 M: function(date, token, localize2) {
20175 const month = date.getMonth();
20176 switch (token) {
20177 case "M":
20178 case "MM":
20179 return lightFormatters.M(date, token);
20180 // 1st, 2nd, ..., 12th
20181 case "Mo":
20182 return localize2.ordinalNumber(month + 1, { unit: "month" });
20183 // Jan, Feb, ..., Dec
20184 case "MMM":
20185 return localize2.month(month, {
20186 width: "abbreviated",
20187 context: "formatting"
20188 });
20189 // J, F, ..., D
20190 case "MMMMM":
20191 return localize2.month(month, {
20192 width: "narrow",
20193 context: "formatting"
20194 });
20195 // January, February, ..., December
20196 case "MMMM":
20197 default:
20198 return localize2.month(month, { width: "wide", context: "formatting" });
20199 }
20200 },
20201 // Stand-alone month
20202 L: function(date, token, localize2) {
20203 const month = date.getMonth();
20204 switch (token) {
20205 // 1, 2, ..., 12
20206 case "L":
20207 return String(month + 1);
20208 // 01, 02, ..., 12
20209 case "LL":
20210 return addLeadingZeros(month + 1, 2);
20211 // 1st, 2nd, ..., 12th
20212 case "Lo":
20213 return localize2.ordinalNumber(month + 1, { unit: "month" });
20214 // Jan, Feb, ..., Dec
20215 case "LLL":
20216 return localize2.month(month, {
20217 width: "abbreviated",
20218 context: "standalone"
20219 });
20220 // J, F, ..., D
20221 case "LLLLL":
20222 return localize2.month(month, {
20223 width: "narrow",
20224 context: "standalone"
20225 });
20226 // January, February, ..., December
20227 case "LLLL":
20228 default:
20229 return localize2.month(month, { width: "wide", context: "standalone" });
20230 }
20231 },
20232 // Local week of year
20233 w: function(date, token, localize2, options) {
20234 const week = getWeek(date, options);
20235 if (token === "wo") {
20236 return localize2.ordinalNumber(week, { unit: "week" });
20237 }
20238 return addLeadingZeros(week, token.length);
20239 },
20240 // ISO week of year
20241 I: function(date, token, localize2) {
20242 const isoWeek = getISOWeek(date);
20243 if (token === "Io") {
20244 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20245 }
20246 return addLeadingZeros(isoWeek, token.length);
20247 },
20248 // Day of the month
20249 d: function(date, token, localize2) {
20250 if (token === "do") {
20251 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20252 }
20253 return lightFormatters.d(date, token);
20254 },
20255 // Day of year
20256 D: function(date, token, localize2) {
20257 const dayOfYear = getDayOfYear(date);
20258 if (token === "Do") {
20259 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20260 }
20261 return addLeadingZeros(dayOfYear, token.length);
20262 },
20263 // Day of week
20264 E: function(date, token, localize2) {
20265 const dayOfWeek = date.getDay();
20266 switch (token) {
20267 // Tue
20268 case "E":
20269 case "EE":
20270 case "EEE":
20271 return localize2.day(dayOfWeek, {
20272 width: "abbreviated",
20273 context: "formatting"
20274 });
20275 // T
20276 case "EEEEE":
20277 return localize2.day(dayOfWeek, {
20278 width: "narrow",
20279 context: "formatting"
20280 });
20281 // Tu
20282 case "EEEEEE":
20283 return localize2.day(dayOfWeek, {
20284 width: "short",
20285 context: "formatting"
20286 });
20287 // Tuesday
20288 case "EEEE":
20289 default:
20290 return localize2.day(dayOfWeek, {
20291 width: "wide",
20292 context: "formatting"
20293 });
20294 }
20295 },
20296 // Local day of week
20297 e: function(date, token, localize2, options) {
20298 const dayOfWeek = date.getDay();
20299 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20300 switch (token) {
20301 // Numerical value (Nth day of week with current locale or weekStartsOn)
20302 case "e":
20303 return String(localDayOfWeek);
20304 // Padded numerical value
20305 case "ee":
20306 return addLeadingZeros(localDayOfWeek, 2);
20307 // 1st, 2nd, ..., 7th
20308 case "eo":
20309 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20310 case "eee":
20311 return localize2.day(dayOfWeek, {
20312 width: "abbreviated",
20313 context: "formatting"
20314 });
20315 // T
20316 case "eeeee":
20317 return localize2.day(dayOfWeek, {
20318 width: "narrow",
20319 context: "formatting"
20320 });
20321 // Tu
20322 case "eeeeee":
20323 return localize2.day(dayOfWeek, {
20324 width: "short",
20325 context: "formatting"
20326 });
20327 // Tuesday
20328 case "eeee":
20329 default:
20330 return localize2.day(dayOfWeek, {
20331 width: "wide",
20332 context: "formatting"
20333 });
20334 }
20335 },
20336 // Stand-alone local day of week
20337 c: function(date, token, localize2, options) {
20338 const dayOfWeek = date.getDay();
20339 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20340 switch (token) {
20341 // Numerical value (same as in `e`)
20342 case "c":
20343 return String(localDayOfWeek);
20344 // Padded numerical value
20345 case "cc":
20346 return addLeadingZeros(localDayOfWeek, token.length);
20347 // 1st, 2nd, ..., 7th
20348 case "co":
20349 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20350 case "ccc":
20351 return localize2.day(dayOfWeek, {
20352 width: "abbreviated",
20353 context: "standalone"
20354 });
20355 // T
20356 case "ccccc":
20357 return localize2.day(dayOfWeek, {
20358 width: "narrow",
20359 context: "standalone"
20360 });
20361 // Tu
20362 case "cccccc":
20363 return localize2.day(dayOfWeek, {
20364 width: "short",
20365 context: "standalone"
20366 });
20367 // Tuesday
20368 case "cccc":
20369 default:
20370 return localize2.day(dayOfWeek, {
20371 width: "wide",
20372 context: "standalone"
20373 });
20374 }
20375 },
20376 // ISO day of week
20377 i: function(date, token, localize2) {
20378 const dayOfWeek = date.getDay();
20379 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20380 switch (token) {
20381 // 2
20382 case "i":
20383 return String(isoDayOfWeek);
20384 // 02
20385 case "ii":
20386 return addLeadingZeros(isoDayOfWeek, token.length);
20387 // 2nd
20388 case "io":
20389 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20390 // Tue
20391 case "iii":
20392 return localize2.day(dayOfWeek, {
20393 width: "abbreviated",
20394 context: "formatting"
20395 });
20396 // T
20397 case "iiiii":
20398 return localize2.day(dayOfWeek, {
20399 width: "narrow",
20400 context: "formatting"
20401 });
20402 // Tu
20403 case "iiiiii":
20404 return localize2.day(dayOfWeek, {
20405 width: "short",
20406 context: "formatting"
20407 });
20408 // Tuesday
20409 case "iiii":
20410 default:
20411 return localize2.day(dayOfWeek, {
20412 width: "wide",
20413 context: "formatting"
20414 });
20415 }
20416 },
20417 // AM or PM
20418 a: function(date, token, localize2) {
20419 const hours = date.getHours();
20420 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20421 switch (token) {
20422 case "a":
20423 case "aa":
20424 return localize2.dayPeriod(dayPeriodEnumValue, {
20425 width: "abbreviated",
20426 context: "formatting"
20427 });
20428 case "aaa":
20429 return localize2.dayPeriod(dayPeriodEnumValue, {
20430 width: "abbreviated",
20431 context: "formatting"
20432 }).toLowerCase();
20433 case "aaaaa":
20434 return localize2.dayPeriod(dayPeriodEnumValue, {
20435 width: "narrow",
20436 context: "formatting"
20437 });
20438 case "aaaa":
20439 default:
20440 return localize2.dayPeriod(dayPeriodEnumValue, {
20441 width: "wide",
20442 context: "formatting"
20443 });
20444 }
20445 },
20446 // AM, PM, midnight, noon
20447 b: function(date, token, localize2) {
20448 const hours = date.getHours();
20449 let dayPeriodEnumValue;
20450 if (hours === 12) {
20451 dayPeriodEnumValue = dayPeriodEnum.noon;
20452 } else if (hours === 0) {
20453 dayPeriodEnumValue = dayPeriodEnum.midnight;
20454 } else {
20455 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20456 }
20457 switch (token) {
20458 case "b":
20459 case "bb":
20460 return localize2.dayPeriod(dayPeriodEnumValue, {
20461 width: "abbreviated",
20462 context: "formatting"
20463 });
20464 case "bbb":
20465 return localize2.dayPeriod(dayPeriodEnumValue, {
20466 width: "abbreviated",
20467 context: "formatting"
20468 }).toLowerCase();
20469 case "bbbbb":
20470 return localize2.dayPeriod(dayPeriodEnumValue, {
20471 width: "narrow",
20472 context: "formatting"
20473 });
20474 case "bbbb":
20475 default:
20476 return localize2.dayPeriod(dayPeriodEnumValue, {
20477 width: "wide",
20478 context: "formatting"
20479 });
20480 }
20481 },
20482 // in the morning, in the afternoon, in the evening, at night
20483 B: function(date, token, localize2) {
20484 const hours = date.getHours();
20485 let dayPeriodEnumValue;
20486 if (hours >= 17) {
20487 dayPeriodEnumValue = dayPeriodEnum.evening;
20488 } else if (hours >= 12) {
20489 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20490 } else if (hours >= 4) {
20491 dayPeriodEnumValue = dayPeriodEnum.morning;
20492 } else {
20493 dayPeriodEnumValue = dayPeriodEnum.night;
20494 }
20495 switch (token) {
20496 case "B":
20497 case "BB":
20498 case "BBB":
20499 return localize2.dayPeriod(dayPeriodEnumValue, {
20500 width: "abbreviated",
20501 context: "formatting"
20502 });
20503 case "BBBBB":
20504 return localize2.dayPeriod(dayPeriodEnumValue, {
20505 width: "narrow",
20506 context: "formatting"
20507 });
20508 case "BBBB":
20509 default:
20510 return localize2.dayPeriod(dayPeriodEnumValue, {
20511 width: "wide",
20512 context: "formatting"
20513 });
20514 }
20515 },
20516 // Hour [1-12]
20517 h: function(date, token, localize2) {
20518 if (token === "ho") {
20519 let hours = date.getHours() % 12;
20520 if (hours === 0) hours = 12;
20521 return localize2.ordinalNumber(hours, { unit: "hour" });
20522 }
20523 return lightFormatters.h(date, token);
20524 },
20525 // Hour [0-23]
20526 H: function(date, token, localize2) {
20527 if (token === "Ho") {
20528 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20529 }
20530 return lightFormatters.H(date, token);
20531 },
20532 // Hour [0-11]
20533 K: function(date, token, localize2) {
20534 const hours = date.getHours() % 12;
20535 if (token === "Ko") {
20536 return localize2.ordinalNumber(hours, { unit: "hour" });
20537 }
20538 return addLeadingZeros(hours, token.length);
20539 },
20540 // Hour [1-24]
20541 k: function(date, token, localize2) {
20542 let hours = date.getHours();
20543 if (hours === 0) hours = 24;
20544 if (token === "ko") {
20545 return localize2.ordinalNumber(hours, { unit: "hour" });
20546 }
20547 return addLeadingZeros(hours, token.length);
20548 },
20549 // Minute
20550 m: function(date, token, localize2) {
20551 if (token === "mo") {
20552 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20553 }
20554 return lightFormatters.m(date, token);
20555 },
20556 // Second
20557 s: function(date, token, localize2) {
20558 if (token === "so") {
20559 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20560 }
20561 return lightFormatters.s(date, token);
20562 },
20563 // Fraction of second
20564 S: function(date, token) {
20565 return lightFormatters.S(date, token);
20566 },
20567 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20568 X: function(date, token, _localize) {
20569 const timezoneOffset = date.getTimezoneOffset();
20570 if (timezoneOffset === 0) {
20571 return "Z";
20572 }
20573 switch (token) {
20574 // Hours and optional minutes
20575 case "X":
20576 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20577 // Hours, minutes and optional seconds without `:` delimiter
20578 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20579 // so this token always has the same output as `XX`
20580 case "XXXX":
20581 case "XX":
20582 return formatTimezone(timezoneOffset);
20583 // Hours, minutes and optional seconds with `:` delimiter
20584 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20585 // so this token always has the same output as `XXX`
20586 case "XXXXX":
20587 case "XXX":
20588 // Hours and minutes with `:` delimiter
20589 default:
20590 return formatTimezone(timezoneOffset, ":");
20591 }
20592 },
20593 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20594 x: function(date, token, _localize) {
20595 const timezoneOffset = date.getTimezoneOffset();
20596 switch (token) {
20597 // Hours and optional minutes
20598 case "x":
20599 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20600 // Hours, minutes and optional seconds without `:` delimiter
20601 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20602 // so this token always has the same output as `xx`
20603 case "xxxx":
20604 case "xx":
20605 return formatTimezone(timezoneOffset);
20606 // Hours, minutes and optional seconds with `:` delimiter
20607 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20608 // so this token always has the same output as `xxx`
20609 case "xxxxx":
20610 case "xxx":
20611 // Hours and minutes with `:` delimiter
20612 default:
20613 return formatTimezone(timezoneOffset, ":");
20614 }
20615 },
20616 // Timezone (GMT)
20617 O: function(date, token, _localize) {
20618 const timezoneOffset = date.getTimezoneOffset();
20619 switch (token) {
20620 // Short
20621 case "O":
20622 case "OO":
20623 case "OOO":
20624 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20625 // Long
20626 case "OOOO":
20627 default:
20628 return "GMT" + formatTimezone(timezoneOffset, ":");
20629 }
20630 },
20631 // Timezone (specific non-location)
20632 z: function(date, token, _localize) {
20633 const timezoneOffset = date.getTimezoneOffset();
20634 switch (token) {
20635 // Short
20636 case "z":
20637 case "zz":
20638 case "zzz":
20639 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20640 // Long
20641 case "zzzz":
20642 default:
20643 return "GMT" + formatTimezone(timezoneOffset, ":");
20644 }
20645 },
20646 // Seconds timestamp
20647 t: function(date, token, _localize) {
20648 const timestamp = Math.trunc(+date / 1e3);
20649 return addLeadingZeros(timestamp, token.length);
20650 },
20651 // Milliseconds timestamp
20652 T: function(date, token, _localize) {
20653 return addLeadingZeros(+date, token.length);
20654 }
20655 };
20656 function formatTimezoneShort(offset4, delimiter = "") {
20657 const sign = offset4 > 0 ? "-" : "+";
20658 const absOffset = Math.abs(offset4);
20659 const hours = Math.trunc(absOffset / 60);
20660 const minutes = absOffset % 60;
20661 if (minutes === 0) {
20662 return sign + String(hours);
20663 }
20664 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20665 }
20666 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20667 if (offset4 % 60 === 0) {
20668 const sign = offset4 > 0 ? "-" : "+";
20669 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20670 }
20671 return formatTimezone(offset4, delimiter);
20672 }
20673 function formatTimezone(offset4, delimiter = "") {
20674 const sign = offset4 > 0 ? "-" : "+";
20675 const absOffset = Math.abs(offset4);
20676 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20677 const minutes = addLeadingZeros(absOffset % 60, 2);
20678 return sign + hours + delimiter + minutes;
20679 }
20680
20681 // node_modules/date-fns/_lib/format/longFormatters.js
20682 var dateLongFormatter = (pattern, formatLong2) => {
20683 switch (pattern) {
20684 case "P":
20685 return formatLong2.date({ width: "short" });
20686 case "PP":
20687 return formatLong2.date({ width: "medium" });
20688 case "PPP":
20689 return formatLong2.date({ width: "long" });
20690 case "PPPP":
20691 default:
20692 return formatLong2.date({ width: "full" });
20693 }
20694 };
20695 var timeLongFormatter = (pattern, formatLong2) => {
20696 switch (pattern) {
20697 case "p":
20698 return formatLong2.time({ width: "short" });
20699 case "pp":
20700 return formatLong2.time({ width: "medium" });
20701 case "ppp":
20702 return formatLong2.time({ width: "long" });
20703 case "pppp":
20704 default:
20705 return formatLong2.time({ width: "full" });
20706 }
20707 };
20708 var dateTimeLongFormatter = (pattern, formatLong2) => {
20709 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20710 const datePattern = matchResult[1];
20711 const timePattern = matchResult[2];
20712 if (!timePattern) {
20713 return dateLongFormatter(pattern, formatLong2);
20714 }
20715 let dateTimeFormat;
20716 switch (datePattern) {
20717 case "P":
20718 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20719 break;
20720 case "PP":
20721 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20722 break;
20723 case "PPP":
20724 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20725 break;
20726 case "PPPP":
20727 default:
20728 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20729 break;
20730 }
20731 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20732 };
20733 var longFormatters = {
20734 p: timeLongFormatter,
20735 P: dateTimeLongFormatter
20736 };
20737
20738 // node_modules/date-fns/_lib/protectedTokens.js
20739 var dayOfYearTokenRE = /^D+$/;
20740 var weekYearTokenRE = /^Y+$/;
20741 var throwTokens = ["D", "DD", "YY", "YYYY"];
20742 function isProtectedDayOfYearToken(token) {
20743 return dayOfYearTokenRE.test(token);
20744 }
20745 function isProtectedWeekYearToken(token) {
20746 return weekYearTokenRE.test(token);
20747 }
20748 function warnOrThrowProtectedError(token, format6, input) {
20749 const _message = message(token, format6, input);
20750 console.warn(_message);
20751 if (throwTokens.includes(token)) throw new RangeError(_message);
20752 }
20753 function message(token, format6, input) {
20754 const subject = token[0] === "Y" ? "years" : "days of the month";
20755 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`;
20756 }
20757
20758 // node_modules/date-fns/format.js
20759 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20760 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20761 var escapedStringRegExp = /^'([^]*?)'?$/;
20762 var doubleQuoteRegExp = /''/g;
20763 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20764 function format(date, formatStr, options) {
20765 const defaultOptions2 = getDefaultOptions();
20766 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20767 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20768 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20769 const originalDate = toDate(date, options?.in);
20770 if (!isValid(originalDate)) {
20771 throw new RangeError("Invalid time value");
20772 }
20773 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20774 const firstCharacter = substring[0];
20775 if (firstCharacter === "p" || firstCharacter === "P") {
20776 const longFormatter = longFormatters[firstCharacter];
20777 return longFormatter(substring, locale.formatLong);
20778 }
20779 return substring;
20780 }).join("").match(formattingTokensRegExp).map((substring) => {
20781 if (substring === "''") {
20782 return { isToken: false, value: "'" };
20783 }
20784 const firstCharacter = substring[0];
20785 if (firstCharacter === "'") {
20786 return { isToken: false, value: cleanEscapedString(substring) };
20787 }
20788 if (formatters[firstCharacter]) {
20789 return { isToken: true, value: substring };
20790 }
20791 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20792 throw new RangeError(
20793 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20794 );
20795 }
20796 return { isToken: false, value: substring };
20797 });
20798 if (locale.localize.preprocessor) {
20799 parts = locale.localize.preprocessor(originalDate, parts);
20800 }
20801 const formatterOptions = {
20802 firstWeekContainsDate,
20803 weekStartsOn,
20804 locale
20805 };
20806 return parts.map((part) => {
20807 if (!part.isToken) return part.value;
20808 const token = part.value;
20809 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20810 warnOrThrowProtectedError(token, formatStr, String(date));
20811 }
20812 const formatter = formatters[token[0]];
20813 return formatter(originalDate, token, locale.localize, formatterOptions);
20814 }).join("");
20815 }
20816 function cleanEscapedString(input) {
20817 const matched = input.match(escapedStringRegExp);
20818 if (!matched) {
20819 return input;
20820 }
20821 return matched[1].replace(doubleQuoteRegExp, "'");
20822 }
20823
20824 // node_modules/date-fns/subDays.js
20825 function subDays(date, amount, options) {
20826 return addDays(date, -amount, options);
20827 }
20828
20829 // node_modules/date-fns/subMonths.js
20830 function subMonths(date, amount, options) {
20831 return addMonths(date, -amount, options);
20832 }
20833
20834 // node_modules/date-fns/subWeeks.js
20835 function subWeeks(date, amount, options) {
20836 return addWeeks(date, -amount, options);
20837 }
20838
20839 // node_modules/date-fns/subYears.js
20840 function subYears(date, amount, options) {
20841 return addYears(date, -amount, options);
20842 }
20843
20844 // packages/dataviews/build-module/utils/operators.mjs
20845 var import_i18n25 = __toESM(require_i18n(), 1);
20846 var import_element53 = __toESM(require_element(), 1);
20847 var import_date = __toESM(require_date(), 1);
20848 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
20849 var filterTextWrappers = {
20850 Name: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20851 Value: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20852 };
20853 function getRelativeDate(value, unit) {
20854 switch (unit) {
20855 case "days":
20856 return subDays(/* @__PURE__ */ new Date(), value);
20857 case "weeks":
20858 return subWeeks(/* @__PURE__ */ new Date(), value);
20859 case "months":
20860 return subMonths(/* @__PURE__ */ new Date(), value);
20861 case "years":
20862 return subYears(/* @__PURE__ */ new Date(), value);
20863 default:
20864 return /* @__PURE__ */ new Date();
20865 }
20866 }
20867 var isNoneOperatorDefinition = {
20868 /* translators: DataViews operator name */
20869 label: (0, import_i18n25.__)("Is none of"),
20870 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
20871 (0, import_i18n25.sprintf)(
20872 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20873 (0, import_i18n25.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20874 filter.name,
20875 activeElements.map((element) => element.label).join(", ")
20876 ),
20877 filterTextWrappers
20878 ),
20879 filter: ((item, field, filterValue) => {
20880 if (!filterValue?.length) {
20881 return true;
20882 }
20883 const fieldValue = field.getValue({ item });
20884 if (Array.isArray(fieldValue)) {
20885 return !filterValue.some(
20886 (fv) => fieldValue.includes(fv)
20887 );
20888 } else if (typeof fieldValue === "string") {
20889 return !filterValue.includes(fieldValue);
20890 }
20891 return false;
20892 }),
20893 selection: "multi"
20894 };
20895 var OPERATORS = [
20896 {
20897 name: OPERATOR_IS_ANY,
20898 /* translators: DataViews operator name */
20899 label: (0, import_i18n25.__)("Includes"),
20900 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
20901 (0, import_i18n25.sprintf)(
20902 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20903 (0, import_i18n25.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20904 filter.name,
20905 activeElements.map((element) => element.label).join(", ")
20906 ),
20907 filterTextWrappers
20908 ),
20909 filter(item, field, filterValue) {
20910 if (!filterValue?.length) {
20911 return true;
20912 }
20913 const fieldValue = field.getValue({ item });
20914 if (Array.isArray(fieldValue)) {
20915 return filterValue.some(
20916 (fv) => fieldValue.includes(fv)
20917 );
20918 } else if (typeof fieldValue === "string") {
20919 return filterValue.includes(fieldValue);
20920 }
20921 return false;
20922 },
20923 selection: "multi"
20924 },
20925 {
20926 name: OPERATOR_IS_NONE,
20927 ...isNoneOperatorDefinition
20928 },
20929 {
20930 name: OPERATOR_IS_ALL,
20931 /* translators: DataViews operator name */
20932 label: (0, import_i18n25.__)("Includes all"),
20933 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
20934 (0, import_i18n25.sprintf)(
20935 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20936 (0, import_i18n25.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20937 filter.name,
20938 activeElements.map((element) => element.label).join(", ")
20939 ),
20940 filterTextWrappers
20941 ),
20942 filter(item, field, filterValue) {
20943 if (!filterValue?.length) {
20944 return true;
20945 }
20946 return filterValue.every((value) => {
20947 return field.getValue({ item })?.includes(value);
20948 });
20949 },
20950 selection: "multi"
20951 },
20952 {
20953 name: OPERATOR_IS_NOT_ALL,
20954 ...isNoneOperatorDefinition
20955 },
20956 {
20957 name: OPERATOR_BETWEEN,
20958 /* translators: DataViews operator name */
20959 label: (0, import_i18n25.__)("Between (inc)"),
20960 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
20961 (0, import_i18n25.sprintf)(
20962 /* 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". */
20963 (0, import_i18n25.__)(
20964 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20965 ),
20966 filter.name,
20967 activeElements[0].label[0],
20968 activeElements[0].label[1]
20969 ),
20970 filterTextWrappers
20971 ),
20972 filter(item, field, filterValue) {
20973 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20974 return true;
20975 }
20976 const fieldValue = field.getValue({ item });
20977 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20978 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20979 }
20980 return false;
20981 },
20982 selection: "custom"
20983 },
20984 {
20985 name: OPERATOR_IN_THE_PAST,
20986 /* translators: DataViews operator name */
20987 label: (0, import_i18n25.__)("In the past"),
20988 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
20989 (0, import_i18n25.sprintf)(
20990 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20991 (0, import_i18n25.__)(
20992 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20993 ),
20994 filter.name,
20995 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20996 ),
20997 filterTextWrappers
20998 ),
20999 filter(item, field, filterValue) {
21000 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21001 return true;
21002 }
21003 const targetDate = getRelativeDate(
21004 filterValue.value,
21005 filterValue.unit
21006 );
21007 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21008 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21009 },
21010 selection: "custom"
21011 },
21012 {
21013 name: OPERATOR_OVER,
21014 /* translators: DataViews operator name */
21015 label: (0, import_i18n25.__)("Over"),
21016 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21017 (0, import_i18n25.sprintf)(
21018 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21019 (0, import_i18n25.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21020 filter.name,
21021 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21022 ),
21023 filterTextWrappers
21024 ),
21025 filter(item, field, filterValue) {
21026 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21027 return true;
21028 }
21029 const targetDate = getRelativeDate(
21030 filterValue.value,
21031 filterValue.unit
21032 );
21033 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21034 return fieldValue < targetDate;
21035 },
21036 selection: "custom"
21037 },
21038 {
21039 name: OPERATOR_IS,
21040 /* translators: DataViews operator name */
21041 label: (0, import_i18n25.__)("Is"),
21042 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21043 (0, import_i18n25.sprintf)(
21044 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21045 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21046 filter.name,
21047 activeElements[0].label
21048 ),
21049 filterTextWrappers
21050 ),
21051 filter(item, field, filterValue) {
21052 return filterValue === field.getValue({ item }) || filterValue === void 0;
21053 },
21054 selection: "single"
21055 },
21056 {
21057 name: OPERATOR_IS_NOT,
21058 /* translators: DataViews operator name */
21059 label: (0, import_i18n25.__)("Is not"),
21060 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21061 (0, import_i18n25.sprintf)(
21062 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21063 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21064 filter.name,
21065 activeElements[0].label
21066 ),
21067 filterTextWrappers
21068 ),
21069 filter(item, field, filterValue) {
21070 return filterValue !== field.getValue({ item });
21071 },
21072 selection: "single"
21073 },
21074 {
21075 name: OPERATOR_LESS_THAN,
21076 /* translators: DataViews operator name */
21077 label: (0, import_i18n25.__)("Less than"),
21078 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21079 (0, import_i18n25.sprintf)(
21080 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21081 (0, import_i18n25.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21082 filter.name,
21083 activeElements[0].label
21084 ),
21085 filterTextWrappers
21086 ),
21087 filter(item, field, filterValue) {
21088 if (filterValue === void 0) {
21089 return true;
21090 }
21091 const fieldValue = field.getValue({ item });
21092 return fieldValue < filterValue;
21093 },
21094 selection: "single"
21095 },
21096 {
21097 name: OPERATOR_GREATER_THAN,
21098 /* translators: DataViews operator name */
21099 label: (0, import_i18n25.__)("Greater than"),
21100 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21101 (0, import_i18n25.sprintf)(
21102 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21103 (0, import_i18n25.__)(
21104 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21105 ),
21106 filter.name,
21107 activeElements[0].label
21108 ),
21109 filterTextWrappers
21110 ),
21111 filter(item, field, filterValue) {
21112 if (filterValue === void 0) {
21113 return true;
21114 }
21115 const fieldValue = field.getValue({ item });
21116 return fieldValue > filterValue;
21117 },
21118 selection: "single"
21119 },
21120 {
21121 name: OPERATOR_LESS_THAN_OR_EQUAL,
21122 /* translators: DataViews operator name */
21123 label: (0, import_i18n25.__)("Less than or equal"),
21124 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21125 (0, import_i18n25.sprintf)(
21126 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21127 (0, import_i18n25.__)(
21128 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21129 ),
21130 filter.name,
21131 activeElements[0].label
21132 ),
21133 filterTextWrappers
21134 ),
21135 filter(item, field, filterValue) {
21136 if (filterValue === void 0) {
21137 return true;
21138 }
21139 const fieldValue = field.getValue({ item });
21140 return fieldValue <= filterValue;
21141 },
21142 selection: "single"
21143 },
21144 {
21145 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21146 /* translators: DataViews operator name */
21147 label: (0, import_i18n25.__)("Greater than or equal"),
21148 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21149 (0, import_i18n25.sprintf)(
21150 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21151 (0, import_i18n25.__)(
21152 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21153 ),
21154 filter.name,
21155 activeElements[0].label
21156 ),
21157 filterTextWrappers
21158 ),
21159 filter(item, field, filterValue) {
21160 if (filterValue === void 0) {
21161 return true;
21162 }
21163 const fieldValue = field.getValue({ item });
21164 return fieldValue >= filterValue;
21165 },
21166 selection: "single"
21167 },
21168 {
21169 name: OPERATOR_BEFORE,
21170 /* translators: DataViews operator name */
21171 label: (0, import_i18n25.__)("Before"),
21172 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21173 (0, import_i18n25.sprintf)(
21174 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21175 (0, import_i18n25.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21176 filter.name,
21177 activeElements[0].label
21178 ),
21179 filterTextWrappers
21180 ),
21181 filter(item, field, filterValue) {
21182 if (filterValue === void 0) {
21183 return true;
21184 }
21185 const filterDate = (0, import_date.getDate)(filterValue);
21186 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21187 return fieldDate < filterDate;
21188 },
21189 selection: "single"
21190 },
21191 {
21192 name: OPERATOR_AFTER,
21193 /* translators: DataViews operator name */
21194 label: (0, import_i18n25.__)("After"),
21195 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21196 (0, import_i18n25.sprintf)(
21197 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21198 (0, import_i18n25.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21199 filter.name,
21200 activeElements[0].label
21201 ),
21202 filterTextWrappers
21203 ),
21204 filter(item, field, filterValue) {
21205 if (filterValue === void 0) {
21206 return true;
21207 }
21208 const filterDate = (0, import_date.getDate)(filterValue);
21209 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21210 return fieldDate > filterDate;
21211 },
21212 selection: "single"
21213 },
21214 {
21215 name: OPERATOR_BEFORE_INC,
21216 /* translators: DataViews operator name */
21217 label: (0, import_i18n25.__)("Before (inc)"),
21218 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21219 (0, import_i18n25.sprintf)(
21220 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21221 (0, import_i18n25.__)(
21222 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21223 ),
21224 filter.name,
21225 activeElements[0].label
21226 ),
21227 filterTextWrappers
21228 ),
21229 filter(item, field, filterValue) {
21230 if (filterValue === void 0) {
21231 return true;
21232 }
21233 const filterDate = (0, import_date.getDate)(filterValue);
21234 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21235 return fieldDate <= filterDate;
21236 },
21237 selection: "single"
21238 },
21239 {
21240 name: OPERATOR_AFTER_INC,
21241 /* translators: DataViews operator name */
21242 label: (0, import_i18n25.__)("After (inc)"),
21243 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21244 (0, import_i18n25.sprintf)(
21245 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21246 (0, import_i18n25.__)(
21247 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21248 ),
21249 filter.name,
21250 activeElements[0].label
21251 ),
21252 filterTextWrappers
21253 ),
21254 filter(item, field, filterValue) {
21255 if (filterValue === void 0) {
21256 return true;
21257 }
21258 const filterDate = (0, import_date.getDate)(filterValue);
21259 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21260 return fieldDate >= filterDate;
21261 },
21262 selection: "single"
21263 },
21264 {
21265 name: OPERATOR_CONTAINS,
21266 /* translators: DataViews operator name */
21267 label: (0, import_i18n25.__)("Contains"),
21268 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21269 (0, import_i18n25.sprintf)(
21270 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21271 (0, import_i18n25.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
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 typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21283 },
21284 selection: "single"
21285 },
21286 {
21287 name: OPERATOR_NOT_CONTAINS,
21288 /* translators: DataViews operator name */
21289 label: (0, import_i18n25.__)("Doesn't contain"),
21290 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21291 (0, import_i18n25.sprintf)(
21292 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21293 (0, import_i18n25.__)(
21294 "<Name>%1$s doesn't contain: </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 typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21307 },
21308 selection: "single"
21309 },
21310 {
21311 name: OPERATOR_STARTS_WITH,
21312 /* translators: DataViews operator name */
21313 label: (0, import_i18n25.__)("Starts with"),
21314 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21315 (0, import_i18n25.sprintf)(
21316 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21317 (0, import_i18n25.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21318 filter.name,
21319 activeElements[0].label
21320 ),
21321 filterTextWrappers
21322 ),
21323 filter(item, field, filterValue) {
21324 if (filterValue === void 0) {
21325 return true;
21326 }
21327 const fieldValue = field.getValue({ item });
21328 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21329 },
21330 selection: "single"
21331 },
21332 {
21333 name: OPERATOR_ON,
21334 /* translators: DataViews operator name */
21335 label: (0, import_i18n25.__)("On"),
21336 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21337 (0, import_i18n25.sprintf)(
21338 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21339 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21340 filter.name,
21341 activeElements[0].label
21342 ),
21343 filterTextWrappers
21344 ),
21345 filter(item, field, filterValue) {
21346 if (filterValue === void 0) {
21347 return true;
21348 }
21349 const filterDate = (0, import_date.getDate)(filterValue);
21350 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21351 return filterDate.getTime() === fieldDate.getTime();
21352 },
21353 selection: "single"
21354 },
21355 {
21356 name: OPERATOR_NOT_ON,
21357 /* translators: DataViews operator name */
21358 label: (0, import_i18n25.__)("Not on"),
21359 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21360 (0, import_i18n25.sprintf)(
21361 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21362 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21363 filter.name,
21364 activeElements[0].label
21365 ),
21366 filterTextWrappers
21367 ),
21368 filter(item, field, filterValue) {
21369 if (filterValue === void 0) {
21370 return true;
21371 }
21372 const filterDate = (0, import_date.getDate)(filterValue);
21373 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21374 return filterDate.getTime() !== fieldDate.getTime();
21375 },
21376 selection: "single"
21377 }
21378 ];
21379 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21380 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21381 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21382 (op) => op.name === name
21383 );
21384 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21385
21386 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21387 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21388 var ENTER = "Enter";
21389 var SPACE = " ";
21390 var FilterText = ({
21391 activeElements,
21392 filterInView,
21393 filter
21394 }) => {
21395 if (activeElements === void 0 || activeElements.length === 0) {
21396 return filter.name;
21397 }
21398 const operator = getOperatorByName(filterInView?.operator);
21399 if (operator !== void 0) {
21400 return operator.filterText(filter, activeElements);
21401 }
21402 return (0, import_i18n26.sprintf)(
21403 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21404 (0, import_i18n26.__)("Unknown status for %1$s"),
21405 filter.name
21406 );
21407 };
21408 function OperatorSelector({
21409 filter,
21410 view,
21411 onChangeView
21412 }) {
21413 const operatorOptions = filter.operators?.map((operator) => ({
21414 value: operator,
21415 label: getOperatorByName(operator)?.label || operator
21416 }));
21417 const currentFilter = view.filters?.find(
21418 (_filter) => _filter.field === filter.field
21419 );
21420 const value = currentFilter?.operator || filter.operators[0];
21421 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
21422 Stack,
21423 {
21424 direction: "row",
21425 gap: "sm",
21426 justify: "flex-start",
21427 className: "dataviews-filters__summary-operators-container",
21428 align: "center",
21429 children: [
21430 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21431 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21432 import_components21.SelectControl,
21433 {
21434 className: "dataviews-filters__summary-operators-filter-select",
21435 label: (0, import_i18n26.__)("Conditions"),
21436 value,
21437 options: operatorOptions,
21438 onChange: (newValue) => {
21439 const newOperator = newValue;
21440 const currentOperator = currentFilter?.operator;
21441 const newFilters = currentFilter ? [
21442 ...(view.filters ?? []).map(
21443 (_filter) => {
21444 if (_filter.field === filter.field) {
21445 const currentOpSelectionModel = getOperatorByName(
21446 currentOperator
21447 )?.selection;
21448 const newOpSelectionModel = getOperatorByName(
21449 newOperator
21450 )?.selection;
21451 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21452 currentOpSelectionModel,
21453 newOpSelectionModel
21454 ].includes("custom");
21455 return {
21456 ..._filter,
21457 value: shouldResetValue ? void 0 : _filter.value,
21458 operator: newOperator
21459 };
21460 }
21461 return _filter;
21462 }
21463 )
21464 ] : [
21465 ...view.filters ?? [],
21466 {
21467 field: filter.field,
21468 operator: newOperator,
21469 value: void 0
21470 }
21471 ];
21472 onChangeView({
21473 ...view,
21474 page: 1,
21475 filters: newFilters
21476 });
21477 },
21478 size: "small",
21479 variant: "minimal",
21480 hideLabelFromVision: true
21481 }
21482 )
21483 ]
21484 }
21485 );
21486 }
21487 function Filter({
21488 addFilterRef,
21489 openedFilter,
21490 fields,
21491 ...commonProps
21492 }) {
21493 const toggleRef = (0, import_element54.useRef)(null);
21494 const { filter, view, onChangeView } = commonProps;
21495 const filterInView = view.filters?.find(
21496 (f2) => f2.field === filter.field
21497 );
21498 let activeElements = [];
21499 const field = (0, import_element54.useMemo)(() => {
21500 const currentField = fields.find((f2) => f2.id === filter.field);
21501 if (currentField) {
21502 return {
21503 ...currentField,
21504 // Configure getValue as if Item was a plain object.
21505 // See related input-widget.tsx
21506 getValue: ({ item }) => item[currentField.id]
21507 };
21508 }
21509 return currentField;
21510 }, [fields, filter.field]);
21511 const { elements } = useElements({
21512 elements: filter.elements,
21513 getElements: filter.getElements
21514 });
21515 if (elements.length > 0) {
21516 activeElements = elements.filter((element) => {
21517 if (filter.singleSelection) {
21518 return element.value === filterInView?.value;
21519 }
21520 return filterInView?.value?.includes(element.value);
21521 });
21522 } else if (Array.isArray(filterInView?.value)) {
21523 const label = filterInView.value.map((v2) => {
21524 const formattedValue = field?.getValueFormatted({
21525 item: { [field.id]: v2 },
21526 field
21527 });
21528 return formattedValue || String(v2);
21529 });
21530 activeElements = [
21531 {
21532 value: filterInView.value,
21533 // @ts-ignore
21534 label
21535 }
21536 ];
21537 } else if (typeof filterInView?.value === "object") {
21538 activeElements = [
21539 { value: filterInView.value, label: filterInView.value }
21540 ];
21541 } else if (filterInView?.value !== void 0) {
21542 const label = field !== void 0 ? field.getValueFormatted({
21543 item: { [field.id]: filterInView.value },
21544 field
21545 }) : String(filterInView.value);
21546 activeElements = [
21547 {
21548 value: filterInView.value,
21549 label
21550 }
21551 ];
21552 }
21553 const isPrimary = filter.isPrimary;
21554 const isLocked = filterInView?.isLocked;
21555 const hasValues = !isLocked && filterInView?.value !== void 0;
21556 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21557 const resetOrRemoveLabel = isPrimary ? (0, import_i18n26.__)("Reset") : (0, import_i18n26.__)("Remove");
21558 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21559 import_components21.Dropdown,
21560 {
21561 defaultOpen: openedFilter === filter.field,
21562 contentClassName: "dataviews-filters__summary-popover",
21563 popoverProps: { placement: "bottom-start", role: "dialog" },
21564 onClose: () => {
21565 toggleRef.current?.focus();
21566 },
21567 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21568 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21569 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21570 tooltip_exports.Trigger,
21571 {
21572 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21573 "div",
21574 {
21575 className: clsx_default(
21576 "dataviews-filters__summary-chip",
21577 {
21578 "has-reset": canResetOrRemove,
21579 "has-values": hasValues,
21580 "is-not-clickable": isLocked
21581 }
21582 ),
21583 role: "button",
21584 tabIndex: isLocked ? -1 : 0,
21585 onClick: () => {
21586 if (!isLocked) {
21587 onToggle();
21588 }
21589 },
21590 onKeyDown: (event) => {
21591 if (!isLocked && [ENTER, SPACE].includes(
21592 event.key
21593 )) {
21594 onToggle();
21595 event.preventDefault();
21596 }
21597 },
21598 "aria-disabled": isLocked,
21599 "aria-pressed": isOpen,
21600 "aria-expanded": isOpen,
21601 ref: toggleRef,
21602 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21603 FilterText,
21604 {
21605 activeElements,
21606 filterInView,
21607 filter
21608 }
21609 )
21610 }
21611 )
21612 }
21613 ),
21614 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: (0, import_i18n26.sprintf)(
21615 /* translators: 1: Filter name. */
21616 (0, import_i18n26.__)("Filter by: %1$s"),
21617 filter.name.toLowerCase()
21618 ) })
21619 ] }),
21620 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21621 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21622 tooltip_exports.Trigger,
21623 {
21624 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21625 "button",
21626 {
21627 className: clsx_default(
21628 "dataviews-filters__summary-chip-remove",
21629 { "has-values": hasValues }
21630 ),
21631 "aria-label": resetOrRemoveLabel,
21632 onClick: () => {
21633 onChangeView({
21634 ...view,
21635 page: 1,
21636 filters: view.filters?.filter(
21637 (_filter) => _filter.field !== filter.field
21638 )
21639 });
21640 if (!isPrimary) {
21641 addFilterRef.current?.focus();
21642 } else {
21643 toggleRef.current?.focus();
21644 }
21645 },
21646 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.Icon, { icon: close_small_default })
21647 }
21648 )
21649 }
21650 ),
21651 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21652 ] })
21653 ] }),
21654 renderContent: () => {
21655 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21656 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(OperatorSelector, { ...commonProps }),
21657 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21658 SearchWidget,
21659 {
21660 ...commonProps,
21661 filter: {
21662 ...commonProps.filter,
21663 elements
21664 }
21665 }
21666 ) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(InputWidget, { ...commonProps, fields })
21667 ] });
21668 }
21669 }
21670 );
21671 }
21672
21673 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21674 var import_components22 = __toESM(require_components(), 1);
21675 var import_i18n27 = __toESM(require_i18n(), 1);
21676 var import_element55 = __toESM(require_element(), 1);
21677 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21678 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
21679 function AddFilterMenu({
21680 filters,
21681 view,
21682 onChangeView,
21683 setOpenedFilter,
21684 triggerProps
21685 }) {
21686 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21687 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu4, { children: [
21688 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21689 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21690 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21691 Menu4.Item,
21692 {
21693 onClick: () => {
21694 setOpenedFilter(filter.field);
21695 onChangeView({
21696 ...view,
21697 page: 1,
21698 filters: [
21699 ...view.filters || [],
21700 {
21701 field: filter.field,
21702 value: void 0,
21703 operator: filter.operators[0]
21704 }
21705 ]
21706 });
21707 },
21708 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.ItemLabel, { children: filter.name })
21709 },
21710 filter.field
21711 );
21712 }) })
21713 ] });
21714 }
21715 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21716 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21717 return null;
21718 }
21719 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21720 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21721 AddFilterMenu,
21722 {
21723 triggerProps: {
21724 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21725 import_components22.Button,
21726 {
21727 accessibleWhenDisabled: true,
21728 size: "compact",
21729 className: "dataviews-filters-button",
21730 variant: "tertiary",
21731 disabled: !inactiveFilters.length,
21732 ref
21733 }
21734 ),
21735 children: (0, import_i18n27.__)("Add filter")
21736 },
21737 ...{ filters, view, onChangeView, setOpenedFilter }
21738 }
21739 );
21740 }
21741 var add_filter_default = (0, import_element55.forwardRef)(AddFilter);
21742
21743 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21744 var import_components23 = __toESM(require_components(), 1);
21745 var import_i18n28 = __toESM(require_i18n(), 1);
21746 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21747 function ResetFilter({
21748 filters,
21749 view,
21750 onChangeView
21751 }) {
21752 const isPrimary = (field) => filters.some(
21753 (_filter) => _filter.field === field && _filter.isPrimary
21754 );
21755 const isDisabled = !view.search && !view.filters?.some(
21756 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21757 );
21758 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21759 import_components23.Button,
21760 {
21761 disabled: isDisabled,
21762 accessibleWhenDisabled: true,
21763 size: "compact",
21764 variant: "tertiary",
21765 className: "dataviews-filters__reset-button",
21766 onClick: () => {
21767 onChangeView({
21768 ...view,
21769 page: 1,
21770 search: "",
21771 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21772 });
21773 },
21774 children: (0, import_i18n28.__)("Reset")
21775 }
21776 );
21777 }
21778
21779 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21780 var import_element56 = __toESM(require_element(), 1);
21781 function useFilters(fields, view) {
21782 return (0, import_element56.useMemo)(() => {
21783 const filters = [];
21784 fields.forEach((field) => {
21785 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21786 return;
21787 }
21788 const operators = field.filterBy.operators;
21789 const isPrimary = !!field.filterBy?.isPrimary;
21790 const isLocked = view.filters?.some(
21791 (f2) => f2.field === field.id && !!f2.isLocked
21792 ) ?? false;
21793 filters.push({
21794 field: field.id,
21795 name: field.label,
21796 elements: field.elements,
21797 getElements: field.getElements,
21798 hasElements: field.hasElements,
21799 singleSelection: operators.some(
21800 (op) => isSingleSelectionOperator(op)
21801 ),
21802 operators,
21803 isVisible: isLocked || isPrimary || !!view.filters?.some(
21804 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21805 ),
21806 isPrimary,
21807 isLocked
21808 });
21809 });
21810 filters.sort((a2, b2) => {
21811 if (a2.isLocked && !b2.isLocked) {
21812 return -1;
21813 }
21814 if (!a2.isLocked && b2.isLocked) {
21815 return 1;
21816 }
21817 if (a2.isPrimary && !b2.isPrimary) {
21818 return -1;
21819 }
21820 if (!a2.isPrimary && b2.isPrimary) {
21821 return 1;
21822 }
21823 return a2.name.localeCompare(b2.name);
21824 });
21825 return filters;
21826 }, [fields, view]);
21827 }
21828 var use_filters_default = useFilters;
21829
21830 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21831 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21832 function Filters({ className }) {
21833 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element57.useContext)(dataviews_context_default);
21834 const addFilterRef = (0, import_element57.useRef)(null);
21835 const filters = use_filters_default(fields, view);
21836 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21837 add_filter_default,
21838 {
21839 filters,
21840 view,
21841 onChangeView,
21842 ref: addFilterRef,
21843 setOpenedFilter
21844 },
21845 "add-filter"
21846 );
21847 const visibleFilters = filters.filter((filter) => filter.isVisible);
21848 if (visibleFilters.length === 0) {
21849 return null;
21850 }
21851 const filterComponents = [
21852 ...visibleFilters.map((filter) => {
21853 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21854 Filter,
21855 {
21856 filter,
21857 view,
21858 fields,
21859 onChangeView,
21860 addFilterRef,
21861 openedFilter
21862 },
21863 filter.field
21864 );
21865 }),
21866 addFilter
21867 ];
21868 filterComponents.push(
21869 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21870 ResetFilter,
21871 {
21872 filters,
21873 view,
21874 onChangeView
21875 },
21876 "reset-filters"
21877 )
21878 );
21879 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21880 Stack,
21881 {
21882 direction: "row",
21883 justify: "flex-start",
21884 gap: "sm",
21885 style: { width: "fit-content" },
21886 wrap: "wrap",
21887 className,
21888 children: filterComponents
21889 }
21890 );
21891 }
21892 var filters_default = (0, import_element57.memo)(Filters);
21893
21894 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21895 var import_element58 = __toESM(require_element(), 1);
21896 var import_components24 = __toESM(require_components(), 1);
21897 var import_i18n29 = __toESM(require_i18n(), 1);
21898 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
21899 function FiltersToggle() {
21900 const {
21901 filters,
21902 view,
21903 onChangeView,
21904 setOpenedFilter,
21905 isShowingFilter,
21906 setIsShowingFilter
21907 } = (0, import_element58.useContext)(dataviews_context_default);
21908 const buttonRef = (0, import_element58.useRef)(null);
21909 const onChangeViewWithFilterVisibility = (0, import_element58.useCallback)(
21910 (_view) => {
21911 onChangeView(_view);
21912 setIsShowingFilter(true);
21913 },
21914 [onChangeView, setIsShowingFilter]
21915 );
21916 if (filters.length === 0) {
21917 return null;
21918 }
21919 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21920 const addFilterButtonProps = {
21921 label: (0, import_i18n29.__)("Add filter"),
21922 "aria-expanded": false,
21923 isPressed: false
21924 };
21925 const toggleFiltersButtonProps = {
21926 label: (0, import_i18n29._x)("Filter", "verb"),
21927 "aria-expanded": isShowingFilter,
21928 isPressed: isShowingFilter,
21929 onClick: () => {
21930 if (!isShowingFilter) {
21931 setOpenedFilter(null);
21932 }
21933 setIsShowingFilter(!isShowingFilter);
21934 }
21935 };
21936 const hasPrimaryOrLockedFilters = filters.some(
21937 (filter) => filter.isPrimary || filter.isLocked
21938 );
21939 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21940 import_components24.Button,
21941 {
21942 ref: buttonRef,
21943 className: "dataviews-filters__visibility-toggle",
21944 size: "compact",
21945 icon: funnel_default,
21946 disabled: hasPrimaryOrLockedFilters,
21947 accessibleWhenDisabled: true,
21948 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21949 }
21950 );
21951 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21952 AddFilterMenu,
21953 {
21954 filters,
21955 view,
21956 onChangeView: onChangeViewWithFilterVisibility,
21957 setOpenedFilter,
21958 triggerProps: { render: buttonComponent }
21959 }
21960 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21961 FilterVisibilityToggle,
21962 {
21963 buttonRef,
21964 filtersCount: view.filters?.length,
21965 children: buttonComponent
21966 }
21967 ) });
21968 }
21969 function FilterVisibilityToggle({
21970 buttonRef,
21971 filtersCount,
21972 children
21973 }) {
21974 (0, import_element58.useEffect)(
21975 () => () => {
21976 buttonRef.current?.focus();
21977 },
21978 [buttonRef]
21979 );
21980 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
21981 children,
21982 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21983 ] });
21984 }
21985 var toggle_default = FiltersToggle;
21986
21987 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21988 var import_element59 = __toESM(require_element(), 1);
21989 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
21990 function FiltersToggled(props) {
21991 const { isShowingFilter } = (0, import_element59.useContext)(dataviews_context_default);
21992 if (!isShowingFilter) {
21993 return null;
21994 }
21995 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(filters_default, { ...props });
21996 }
21997 var filters_toggled_default = FiltersToggled;
21998
21999 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22000 var import_element60 = __toESM(require_element(), 1);
22001 var import_components25 = __toESM(require_components(), 1);
22002 var import_i18n30 = __toESM(require_i18n(), 1);
22003 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22004 function DataViewsLayout({ className }) {
22005 const {
22006 actions = [],
22007 data,
22008 fields,
22009 getItemId,
22010 getItemLevel,
22011 hasInitiallyLoaded,
22012 isLoading,
22013 view,
22014 onChangeView,
22015 selection,
22016 onChangeSelection,
22017 setOpenedFilter,
22018 onClickItem,
22019 isItemClickable,
22020 renderItemLink,
22021 defaultLayouts,
22022 containerRef,
22023 empty = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: (0, import_i18n30.__)("No results") })
22024 } = (0, import_element60.useContext)(dataviews_context_default);
22025 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22026 delay: 200
22027 });
22028 if (!hasInitiallyLoaded) {
22029 if (!isDelayedInitialLoading) {
22030 return null;
22031 }
22032 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components25.Spinner, {}) }) });
22033 }
22034 const ViewComponent = VIEW_LAYOUTS.find(
22035 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22036 )?.component;
22037 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22038 ViewComponent,
22039 {
22040 className,
22041 actions,
22042 data,
22043 fields,
22044 getItemId,
22045 getItemLevel,
22046 isLoading,
22047 onChangeView,
22048 onChangeSelection,
22049 selection,
22050 setOpenedFilter,
22051 onClickItem,
22052 renderItemLink,
22053 isItemClickable,
22054 view,
22055 empty
22056 }
22057 ) });
22058 }
22059
22060 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22061 var import_element61 = __toESM(require_element(), 1);
22062 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22063 var EMPTY_ARRAY5 = [];
22064 function DataViewsFooter() {
22065 const {
22066 view,
22067 paginationInfo: { totalItems = 0, totalPages },
22068 data,
22069 actions = EMPTY_ARRAY5,
22070 isLoading,
22071 hasInitiallyLoaded
22072 } = (0, import_element61.useContext)(dataviews_context_default);
22073 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22074 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22075 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22076 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22077 return null;
22078 }
22079 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22080 "div",
22081 {
22082 className: "dataviews-footer",
22083 inert: isRefreshing ? "true" : void 0,
22084 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22085 Stack,
22086 {
22087 direction: "row",
22088 justify: "end",
22089 align: "center",
22090 className: clsx_default("dataviews-footer__content", {
22091 "is-refreshing": isDelayedRefreshing
22092 }),
22093 gap: "sm",
22094 children: [
22095 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(BulkActionsFooter, {}),
22096 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(dataviews_pagination_default, {})
22097 ]
22098 }
22099 )
22100 }
22101 );
22102 }
22103
22104 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22105 var import_i18n31 = __toESM(require_i18n(), 1);
22106 var import_element62 = __toESM(require_element(), 1);
22107 var import_components26 = __toESM(require_components(), 1);
22108 var import_compose10 = __toESM(require_compose(), 1);
22109 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22110 var DataViewsSearch = (0, import_element62.memo)(function Search({ label }) {
22111 const { view, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22112 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22113 view.search
22114 );
22115 (0, import_element62.useEffect)(() => {
22116 if (view.search !== debouncedSearch) {
22117 setSearch(view.search ?? "");
22118 }
22119 }, [view.search, setSearch]);
22120 const onChangeViewRef = (0, import_element62.useRef)(onChangeView);
22121 const viewRef = (0, import_element62.useRef)(view);
22122 (0, import_element62.useEffect)(() => {
22123 onChangeViewRef.current = onChangeView;
22124 viewRef.current = view;
22125 }, [onChangeView, view]);
22126 (0, import_element62.useEffect)(() => {
22127 if (debouncedSearch !== viewRef.current?.search) {
22128 onChangeViewRef.current({
22129 ...viewRef.current,
22130 page: view.page ? 1 : void 0,
22131 startPosition: view.startPosition ? 1 : void 0,
22132 search: debouncedSearch
22133 });
22134 }
22135 }, [debouncedSearch]);
22136 const searchLabel = label || (0, import_i18n31.__)("Search");
22137 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22138 import_components26.SearchControl,
22139 {
22140 className: "dataviews-search",
22141 onChange: setSearch,
22142 value: search,
22143 label: searchLabel,
22144 placeholder: searchLabel,
22145 size: "compact"
22146 }
22147 );
22148 });
22149 var dataviews_search_default = DataViewsSearch;
22150
22151 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22152 var import_components27 = __toESM(require_components(), 1);
22153 var import_i18n32 = __toESM(require_i18n(), 1);
22154 var import_element63 = __toESM(require_element(), 1);
22155 var import_warning = __toESM(require_warning(), 1);
22156 var import_compose11 = __toESM(require_compose(), 1);
22157 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22158 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22159 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22160 className: "dataviews-config__popover",
22161 placement: "bottom-end",
22162 offset: 9
22163 };
22164 function ViewTypeMenu() {
22165 const { view, onChangeView, defaultLayouts } = (0, import_element63.useContext)(dataviews_context_default);
22166 const availableLayouts = Object.keys(defaultLayouts);
22167 if (availableLayouts.length <= 1) {
22168 return null;
22169 }
22170 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22171 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22172 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22173 Menu5.TriggerButton,
22174 {
22175 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22176 import_components27.Button,
22177 {
22178 size: "compact",
22179 icon: activeView?.icon,
22180 label: (0, import_i18n32.__)("Layout")
22181 }
22182 )
22183 }
22184 ),
22185 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22186 const config = VIEW_LAYOUTS.find(
22187 (v2) => v2.type === layout
22188 );
22189 if (!config) {
22190 return null;
22191 }
22192 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22193 Menu5.RadioItem,
22194 {
22195 value: layout,
22196 name: "view-actions-available-view",
22197 checked: layout === view.type,
22198 hideOnClick: true,
22199 onChange: (e2) => {
22200 switch (e2.target.value) {
22201 case "list":
22202 case "grid":
22203 case "table":
22204 case "pickerGrid":
22205 case "pickerTable":
22206 case "pickerActivity":
22207 case "activity":
22208 const viewWithoutLayout = { ...view };
22209 if ("layout" in viewWithoutLayout) {
22210 delete viewWithoutLayout.layout;
22211 }
22212 return onChangeView({
22213 ...viewWithoutLayout,
22214 type: e2.target.value,
22215 ...defaultLayouts[e2.target.value]
22216 });
22217 }
22218 (0, import_warning.default)("Invalid dataview");
22219 },
22220 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22221 },
22222 layout
22223 );
22224 }) })
22225 ] });
22226 }
22227 function SortFieldControl() {
22228 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22229 const orderOptions = (0, import_element63.useMemo)(() => {
22230 const sortableFields = fields.filter(
22231 (field) => field.enableSorting !== false
22232 );
22233 return sortableFields.map((field) => {
22234 return {
22235 label: field.label,
22236 value: field.id
22237 };
22238 });
22239 }, [fields]);
22240 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22241 import_components27.SelectControl,
22242 {
22243 __next40pxDefaultSize: true,
22244 label: (0, import_i18n32.__)("Sort by"),
22245 value: view.sort?.field,
22246 options: orderOptions,
22247 onChange: (value) => {
22248 onChangeView({
22249 ...view,
22250 sort: {
22251 direction: view?.sort?.direction || "desc",
22252 field: value
22253 },
22254 showLevels: false
22255 });
22256 }
22257 }
22258 );
22259 }
22260 function SortDirectionControl() {
22261 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22262 const sortableFields = fields.filter(
22263 (field) => field.enableSorting !== false
22264 );
22265 if (sortableFields.length === 0) {
22266 return null;
22267 }
22268 let value = view.sort?.direction;
22269 if (!value && view.sort?.field) {
22270 value = "desc";
22271 }
22272 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22273 import_components27.__experimentalToggleGroupControl,
22274 {
22275 className: "dataviews-view-config__sort-direction",
22276 __next40pxDefaultSize: true,
22277 isBlock: true,
22278 label: (0, import_i18n32.__)("Order"),
22279 value,
22280 onChange: (newDirection) => {
22281 if (newDirection === "asc" || newDirection === "desc") {
22282 onChangeView({
22283 ...view,
22284 sort: {
22285 direction: newDirection,
22286 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22287 fields.find(
22288 (field) => field.enableSorting !== false
22289 )?.id || ""
22290 },
22291 showLevels: false
22292 });
22293 return;
22294 }
22295 (0, import_warning.default)("Invalid direction");
22296 },
22297 children: SORTING_DIRECTIONS.map((direction) => {
22298 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22299 import_components27.__experimentalToggleGroupControlOptionIcon,
22300 {
22301 value: direction,
22302 icon: sortIcons[direction],
22303 label: sortLabels[direction]
22304 },
22305 direction
22306 );
22307 })
22308 }
22309 );
22310 }
22311 function ItemsPerPageControl() {
22312 const { view, config, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22313 const { infiniteScrollEnabled } = view;
22314 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22315 return null;
22316 }
22317 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22318 import_components27.__experimentalToggleGroupControl,
22319 {
22320 __next40pxDefaultSize: true,
22321 isBlock: true,
22322 label: (0, import_i18n32.__)("Items per page"),
22323 value: view.perPage || 10,
22324 disabled: !view?.sort?.field,
22325 onChange: (newItemsPerPage) => {
22326 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22327 onChangeView({
22328 ...view,
22329 perPage: newItemsPerPageNumber,
22330 page: 1
22331 });
22332 },
22333 children: config.perPageSizes.map((value) => {
22334 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22335 import_components27.__experimentalToggleGroupControlOption,
22336 {
22337 value,
22338 label: value.toString()
22339 },
22340 value
22341 );
22342 })
22343 }
22344 );
22345 }
22346 function ResetViewButton() {
22347 const { onReset } = (0, import_element63.useContext)(dataviews_context_default);
22348 if (onReset === void 0) {
22349 return null;
22350 }
22351 const isDisabled = onReset === false;
22352 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22353 import_components27.Button,
22354 {
22355 variant: "tertiary",
22356 size: "compact",
22357 disabled: isDisabled,
22358 accessibleWhenDisabled: true,
22359 className: "dataviews-view-config__reset-button",
22360 onClick: () => {
22361 if (typeof onReset === "function") {
22362 onReset();
22363 }
22364 },
22365 children: (0, import_i18n32.__)("Reset view")
22366 }
22367 );
22368 }
22369 function DataviewsViewConfigDropdown() {
22370 const { view, onReset } = (0, import_element63.useContext)(dataviews_context_default);
22371 const popoverId = (0, import_compose11.useInstanceId)(
22372 _DataViewsViewConfig,
22373 "dataviews-view-config-dropdown"
22374 );
22375 const activeLayout = VIEW_LAYOUTS.find(
22376 (layout) => layout.type === view.type
22377 );
22378 const isModified = typeof onReset === "function";
22379 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22380 import_components27.Dropdown,
22381 {
22382 expandOnMobile: true,
22383 popoverProps: {
22384 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22385 id: popoverId
22386 },
22387 renderToggle: ({ onToggle, isOpen }) => {
22388 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22389 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22390 import_components27.Button,
22391 {
22392 size: "compact",
22393 icon: cog_default,
22394 label: (0, import_i18n32._x)(
22395 "View options",
22396 "View is used as a noun"
22397 ),
22398 onClick: onToggle,
22399 "aria-expanded": isOpen ? "true" : "false",
22400 "aria-controls": popoverId
22401 }
22402 ),
22403 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22404 ] });
22405 },
22406 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22407 import_components27.__experimentalDropdownContentWrapper,
22408 {
22409 paddingSize: "medium",
22410 className: "dataviews-config__popover-content-wrapper",
22411 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22412 Stack,
22413 {
22414 direction: "column",
22415 className: "dataviews-view-config",
22416 gap: "xl",
22417 children: [
22418 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22419 Stack,
22420 {
22421 direction: "row",
22422 justify: "space-between",
22423 align: "center",
22424 className: "dataviews-view-config__header",
22425 children: [
22426 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22427 import_components27.__experimentalHeading,
22428 {
22429 level: 2,
22430 className: "dataviews-settings-section__title",
22431 children: (0, import_i18n32.__)("Appearance")
22432 }
22433 ),
22434 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
22435 ]
22436 }
22437 ),
22438 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22439 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22440 Stack,
22441 {
22442 direction: "row",
22443 gap: "sm",
22444 className: "dataviews-view-config__sort-controls",
22445 children: [
22446 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
22447 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
22448 ]
22449 }
22450 ),
22451 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
22452 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
22453 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
22454 ] })
22455 ]
22456 }
22457 )
22458 }
22459 )
22460 }
22461 );
22462 }
22463 function _DataViewsViewConfig() {
22464 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
22465 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
22466 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
22467 ] });
22468 }
22469 var DataViewsViewConfig = (0, import_element63.memo)(_DataViewsViewConfig);
22470 var dataviews_view_config_default = DataViewsViewConfig;
22471
22472 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22473 var import_components28 = __toESM(require_components(), 1);
22474 var import_element64 = __toESM(require_element(), 1);
22475
22476 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22477 function getCustomValidity(isValid2, validity) {
22478 let customValidity;
22479 if (isValid2?.required && validity?.required) {
22480 customValidity = validity?.required?.message ? validity.required : void 0;
22481 } else if (isValid2?.pattern && validity?.pattern) {
22482 customValidity = validity.pattern;
22483 } else if (isValid2?.min && validity?.min) {
22484 customValidity = validity.min;
22485 } else if (isValid2?.max && validity?.max) {
22486 customValidity = validity.max;
22487 } else if (isValid2?.minLength && validity?.minLength) {
22488 customValidity = validity.minLength;
22489 } else if (isValid2?.maxLength && validity?.maxLength) {
22490 customValidity = validity.maxLength;
22491 } else if (isValid2?.elements && validity?.elements) {
22492 customValidity = validity.elements;
22493 } else if (validity?.custom) {
22494 customValidity = validity.custom;
22495 }
22496 return customValidity;
22497 }
22498
22499 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22500 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22501 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
22502 function Checkbox({
22503 field,
22504 onChange,
22505 data,
22506 hideLabelFromVision,
22507 markWhenOptional,
22508 validity
22509 }) {
22510 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22511 const disabled2 = field.isDisabled({ item: data, field });
22512 const onChangeControl = (0, import_element64.useCallback)(() => {
22513 onChange(
22514 setValue({ item: data, value: !getValue({ item: data }) })
22515 );
22516 }, [data, getValue, onChange, setValue]);
22517 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22518 ValidatedCheckboxControl,
22519 {
22520 required: !!field.isValid?.required,
22521 markWhenOptional,
22522 customValidity: getCustomValidity(isValid2, validity),
22523 hidden: hideLabelFromVision,
22524 label,
22525 help: description,
22526 checked: getValue({ item: data }),
22527 onChange: onChangeControl,
22528 disabled: disabled2
22529 }
22530 );
22531 }
22532
22533 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22534 var import_components29 = __toESM(require_components(), 1);
22535 var import_element65 = __toESM(require_element(), 1);
22536 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22537 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
22538 function Combobox3({
22539 data,
22540 field,
22541 onChange,
22542 hideLabelFromVision,
22543 validity
22544 }) {
22545 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22546 const value = getValue({ item: data }) ?? "";
22547 const onChangeControl = (0, import_element65.useCallback)(
22548 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22549 [data, onChange, setValue]
22550 );
22551 const { elements, isLoading } = useElements({
22552 elements: field.elements,
22553 getElements: field.getElements
22554 });
22555 if (isLoading) {
22556 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components29.Spinner, {});
22557 }
22558 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22559 ValidatedComboboxControl,
22560 {
22561 required: !!field.isValid?.required,
22562 customValidity: getCustomValidity(isValid2, validity),
22563 label,
22564 value,
22565 help: description,
22566 placeholder,
22567 options: elements,
22568 onChange: onChangeControl,
22569 hideLabelFromVision,
22570 allowReset: true,
22571 expandOnFocus: true
22572 }
22573 );
22574 }
22575
22576 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22577 var import_components31 = __toESM(require_components(), 1);
22578 var import_element68 = __toESM(require_element(), 1);
22579 var import_i18n34 = __toESM(require_i18n(), 1);
22580 var import_date3 = __toESM(require_date(), 1);
22581
22582 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22583 var import_components30 = __toESM(require_components(), 1);
22584 var import_element66 = __toESM(require_element(), 1);
22585 var import_i18n33 = __toESM(require_i18n(), 1);
22586 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22587 var TIME_UNITS_OPTIONS = {
22588 [OPERATOR_IN_THE_PAST]: [
22589 { value: "days", label: (0, import_i18n33.__)("Days") },
22590 { value: "weeks", label: (0, import_i18n33.__)("Weeks") },
22591 { value: "months", label: (0, import_i18n33.__)("Months") },
22592 { value: "years", label: (0, import_i18n33.__)("Years") }
22593 ],
22594 [OPERATOR_OVER]: [
22595 { value: "days", label: (0, import_i18n33.__)("Days ago") },
22596 { value: "weeks", label: (0, import_i18n33.__)("Weeks ago") },
22597 { value: "months", label: (0, import_i18n33.__)("Months ago") },
22598 { value: "years", label: (0, import_i18n33.__)("Years ago") }
22599 ]
22600 };
22601 function RelativeDateControl({
22602 className,
22603 data,
22604 field,
22605 onChange,
22606 hideLabelFromVision,
22607 operator
22608 }) {
22609 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22610 const { id, label, description, getValue, setValue } = field;
22611 const disabled2 = field.isDisabled({ item: data, field });
22612 const fieldValue = getValue({ item: data });
22613 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22614 const onChangeValue = (0, import_element66.useCallback)(
22615 (newValue) => onChange(
22616 setValue({
22617 item: data,
22618 value: { value: Number(newValue), unit }
22619 })
22620 ),
22621 [onChange, setValue, data, unit]
22622 );
22623 const onChangeUnit = (0, import_element66.useCallback)(
22624 (newUnit) => onChange(
22625 setValue({
22626 item: data,
22627 value: { value: relValue, unit: newUnit }
22628 })
22629 ),
22630 [onChange, setValue, data, relValue]
22631 );
22632 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22633 import_components30.BaseControl,
22634 {
22635 id,
22636 className: clsx_default(className, "dataviews-controls__relative-date"),
22637 label,
22638 hideLabelFromVision,
22639 help: description,
22640 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22641 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22642 import_components30.__experimentalNumberControl,
22643 {
22644 __next40pxDefaultSize: true,
22645 className: "dataviews-controls__relative-date-number",
22646 spinControls: "none",
22647 min: 1,
22648 step: 1,
22649 value: relValue,
22650 onChange: onChangeValue,
22651 disabled: disabled2
22652 }
22653 ),
22654 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22655 import_components30.SelectControl,
22656 {
22657 className: "dataviews-controls__relative-date-unit",
22658 __next40pxDefaultSize: true,
22659 label: (0, import_i18n33.__)("Unit"),
22660 value: unit,
22661 options,
22662 onChange: onChangeUnit,
22663 hideLabelFromVision: true,
22664 disabled: disabled2
22665 }
22666 )
22667 ] })
22668 }
22669 );
22670 }
22671
22672 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22673 var import_element67 = __toESM(require_element(), 1);
22674 function useDisabledDateMatchers(isValid2, parseDateFn) {
22675 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22676 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22677 const disabledMatchers = (0, import_element67.useMemo)(() => {
22678 const matchers = [];
22679 if (minConstraint) {
22680 const minDate = parseDateFn(minConstraint);
22681 if (minDate) {
22682 matchers.push({ before: minDate });
22683 }
22684 }
22685 if (maxConstraint) {
22686 const maxDate = parseDateFn(maxConstraint);
22687 if (maxDate) {
22688 matchers.push({ after: maxDate });
22689 }
22690 }
22691 return matchers.length > 0 ? matchers : void 0;
22692 }, [minConstraint, maxConstraint, parseDateFn]);
22693 return { minConstraint, maxConstraint, disabledMatchers };
22694 }
22695
22696 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22697 var import_date2 = __toESM(require_date(), 1);
22698 function parseDateTime(dateTimeString) {
22699 if (!dateTimeString) {
22700 return null;
22701 }
22702 const parsed = (0, import_date2.getDate)(dateTimeString);
22703 return parsed && isValid(parsed) ? parsed : null;
22704 }
22705
22706 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22707 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22708 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
22709 var formatDateTime = (value) => {
22710 if (!value) {
22711 return "";
22712 }
22713 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22714 };
22715 function CalendarDateTimeControl({
22716 data,
22717 field,
22718 onChange,
22719 hideLabelFromVision,
22720 markWhenOptional,
22721 validity,
22722 config
22723 }) {
22724 const { compact } = config || {};
22725 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22726 const disabled2 = field.isDisabled({ item: data, field });
22727 const fieldValue = getValue({ item: data });
22728 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22729 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
22730 const parsedDate = parseDateTime(value);
22731 return parsedDate || /* @__PURE__ */ new Date();
22732 });
22733 const inputControlRef = (0, import_element68.useRef)(null);
22734 const validationTimeoutRef = (0, import_element68.useRef)(void 0);
22735 const previousFocusRef = (0, import_element68.useRef)(null);
22736 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22737 const onChangeCallback = (0, import_element68.useCallback)(
22738 (newValue) => onChange(setValue({ item: data, value: newValue })),
22739 [data, onChange, setValue]
22740 );
22741 (0, import_element68.useEffect)(() => {
22742 return () => {
22743 if (validationTimeoutRef.current) {
22744 clearTimeout(validationTimeoutRef.current);
22745 }
22746 };
22747 }, []);
22748 const onSelectDate = (0, import_element68.useCallback)(
22749 (newDate) => {
22750 let dateTimeValue;
22751 if (newDate) {
22752 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22753 let wpTime;
22754 if (value) {
22755 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22756 } else {
22757 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22758 }
22759 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22760 dateTimeValue = finalDateTime.toISOString();
22761 onChangeCallback(dateTimeValue);
22762 if (validationTimeoutRef.current) {
22763 clearTimeout(validationTimeoutRef.current);
22764 }
22765 } else {
22766 onChangeCallback(void 0);
22767 }
22768 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22769 validationTimeoutRef.current = setTimeout(() => {
22770 if (inputControlRef.current) {
22771 inputControlRef.current.focus();
22772 inputControlRef.current.blur();
22773 onChangeCallback(dateTimeValue);
22774 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22775 previousFocusRef.current.focus();
22776 }
22777 }
22778 }, 0);
22779 },
22780 [onChangeCallback, value]
22781 );
22782 const handleManualDateTimeChange = (0, import_element68.useCallback)(
22783 (newValue) => {
22784 if (newValue) {
22785 const dateTime = (0, import_date3.getDate)(newValue);
22786 onChangeCallback(dateTime.toISOString());
22787 const parsedDate = parseDateTime(dateTime.toISOString());
22788 if (parsedDate) {
22789 setCalendarMonth(parsedDate);
22790 }
22791 } else {
22792 onChangeCallback(void 0);
22793 }
22794 },
22795 [onChangeCallback]
22796 );
22797 const { format: fieldFormat } = field;
22798 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22799 const {
22800 timezone: { string: timezoneString }
22801 } = (0, import_date3.getSettings)();
22802 let displayLabel = label;
22803 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22804 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
22805 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22806 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
22807 }
22808 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22809 import_components31.BaseControl,
22810 {
22811 id,
22812 label: displayLabel,
22813 help: description,
22814 hideLabelFromVision,
22815 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22816 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22817 ValidatedInputControl,
22818 {
22819 ref: inputControlRef,
22820 __next40pxDefaultSize: true,
22821 required: !!isValid2?.required,
22822 customValidity: getCustomValidity(isValid2, validity),
22823 type: "datetime-local",
22824 label: (0, import_i18n34.__)("Date time"),
22825 hideLabelFromVision: true,
22826 value: formatDateTime(value),
22827 onChange: handleManualDateTimeChange,
22828 disabled: disabled2,
22829 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22830 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22831 }
22832 ),
22833 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22834 DateCalendar,
22835 {
22836 style: { width: "100%" },
22837 selected: value ? parseDateTime(value) || void 0 : void 0,
22838 onSelect: onSelectDate,
22839 month: calendarMonth,
22840 onMonthChange: setCalendarMonth,
22841 timeZone: timezoneString || void 0,
22842 weekStartsOn,
22843 disabled: disabled2 || disabledMatchers
22844 }
22845 )
22846 ] })
22847 }
22848 );
22849 }
22850 function DateTime({
22851 data,
22852 field,
22853 onChange,
22854 hideLabelFromVision,
22855 markWhenOptional,
22856 operator,
22857 validity,
22858 config
22859 }) {
22860 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22861 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22862 RelativeDateControl,
22863 {
22864 className: "dataviews-controls__datetime",
22865 data,
22866 field,
22867 onChange,
22868 hideLabelFromVision,
22869 operator
22870 }
22871 );
22872 }
22873 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22874 CalendarDateTimeControl,
22875 {
22876 data,
22877 field,
22878 onChange,
22879 hideLabelFromVision,
22880 markWhenOptional,
22881 validity,
22882 config
22883 }
22884 );
22885 }
22886
22887 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22888 var import_components32 = __toESM(require_components(), 1);
22889 var import_element69 = __toESM(require_element(), 1);
22890 var import_i18n35 = __toESM(require_i18n(), 1);
22891 var import_date4 = __toESM(require_date(), 1);
22892 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
22893 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
22894 var DATE_PRESETS = [
22895 {
22896 id: "today",
22897 label: (0, import_i18n35.__)("Today"),
22898 getValue: () => (0, import_date4.getDate)(null)
22899 },
22900 {
22901 id: "yesterday",
22902 label: (0, import_i18n35.__)("Yesterday"),
22903 getValue: () => {
22904 const today = (0, import_date4.getDate)(null);
22905 return subDays(today, 1);
22906 }
22907 },
22908 {
22909 id: "past-week",
22910 label: (0, import_i18n35.__)("Past week"),
22911 getValue: () => {
22912 const today = (0, import_date4.getDate)(null);
22913 return subDays(today, 7);
22914 }
22915 },
22916 {
22917 id: "past-month",
22918 label: (0, import_i18n35.__)("Past month"),
22919 getValue: () => {
22920 const today = (0, import_date4.getDate)(null);
22921 return subMonths(today, 1);
22922 }
22923 }
22924 ];
22925 var DATE_RANGE_PRESETS = [
22926 {
22927 id: "last-7-days",
22928 label: (0, import_i18n35.__)("Last 7 days"),
22929 getValue: () => {
22930 const today = (0, import_date4.getDate)(null);
22931 return [subDays(today, 7), today];
22932 }
22933 },
22934 {
22935 id: "last-30-days",
22936 label: (0, import_i18n35.__)("Last 30 days"),
22937 getValue: () => {
22938 const today = (0, import_date4.getDate)(null);
22939 return [subDays(today, 30), today];
22940 }
22941 },
22942 {
22943 id: "month-to-date",
22944 label: (0, import_i18n35.__)("Month to date"),
22945 getValue: () => {
22946 const today = (0, import_date4.getDate)(null);
22947 return [startOfMonth(today), today];
22948 }
22949 },
22950 {
22951 id: "last-year",
22952 label: (0, import_i18n35.__)("Last year"),
22953 getValue: () => {
22954 const today = (0, import_date4.getDate)(null);
22955 return [subYears(today, 1), today];
22956 }
22957 },
22958 {
22959 id: "year-to-date",
22960 label: (0, import_i18n35.__)("Year to date"),
22961 getValue: () => {
22962 const today = (0, import_date4.getDate)(null);
22963 return [startOfYear(today), today];
22964 }
22965 }
22966 ];
22967 var parseDate = (dateString) => {
22968 if (!dateString) {
22969 return null;
22970 }
22971 const parsed = (0, import_date4.getDate)(dateString);
22972 return parsed && isValid(parsed) ? parsed : null;
22973 };
22974 var formatDate = (date) => {
22975 if (!date) {
22976 return "";
22977 }
22978 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22979 };
22980 function ValidatedDateControl({
22981 field,
22982 validity,
22983 inputRefs,
22984 isTouched,
22985 setIsTouched,
22986 children
22987 }) {
22988 const { isValid: isValid2 } = field;
22989 const [customValidity, setCustomValidity] = (0, import_element69.useState)(void 0);
22990 const validateRefs = (0, import_element69.useCallback)(() => {
22991 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22992 for (const ref of refs) {
22993 const input = ref.current;
22994 if (input && !input.validity.valid) {
22995 setCustomValidity({
22996 type: "invalid",
22997 message: input.validationMessage
22998 });
22999 return;
23000 }
23001 }
23002 setCustomValidity(void 0);
23003 }, [inputRefs]);
23004 (0, import_element69.useEffect)(() => {
23005 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23006 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23007 for (const ref of refs) {
23008 const input = ref.current;
23009 if (input) {
23010 input.setCustomValidity(
23011 result?.type === "invalid" && result.message ? result.message : ""
23012 );
23013 }
23014 }
23015 }, [inputRefs, isValid2, validity]);
23016 (0, import_element69.useEffect)(() => {
23017 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23018 const handleInvalid = (event) => {
23019 event.preventDefault();
23020 setIsTouched(true);
23021 };
23022 for (const ref of refs) {
23023 ref.current?.addEventListener("invalid", handleInvalid);
23024 }
23025 return () => {
23026 for (const ref of refs) {
23027 ref.current?.removeEventListener("invalid", handleInvalid);
23028 }
23029 };
23030 }, [inputRefs, setIsTouched]);
23031 (0, import_element69.useEffect)(() => {
23032 if (!isTouched) {
23033 return;
23034 }
23035 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23036 if (result) {
23037 setCustomValidity(result);
23038 } else {
23039 validateRefs();
23040 }
23041 }, [isTouched, isValid2, validity, validateRefs]);
23042 const onBlur = (event) => {
23043 if (isTouched) {
23044 return;
23045 }
23046 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23047 setIsTouched(true);
23048 }
23049 };
23050 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23051 children,
23052 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23053 "p",
23054 {
23055 className: clsx_default(
23056 "components-validated-control__indicator",
23057 customValidity.type === "invalid" ? "is-invalid" : void 0
23058 ),
23059 children: [
23060 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23061 import_components32.Icon,
23062 {
23063 className: "components-validated-control__indicator-icon",
23064 icon: error_default,
23065 size: 16,
23066 fill: "currentColor"
23067 }
23068 ),
23069 customValidity.message
23070 ]
23071 }
23072 ) })
23073 ] });
23074 }
23075 function CalendarDateControl({
23076 data,
23077 field,
23078 onChange,
23079 hideLabelFromVision,
23080 markWhenOptional,
23081 validity
23082 }) {
23083 const {
23084 id,
23085 label,
23086 description,
23087 setValue,
23088 getValue,
23089 isValid: isValid2,
23090 format: fieldFormat
23091 } = field;
23092 const disabled2 = field.isDisabled({ item: data, field });
23093 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23094 null
23095 );
23096 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23097 const fieldValue = getValue({ item: data });
23098 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23099 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23100 const parsedDate = parseDate(value);
23101 return parsedDate || /* @__PURE__ */ new Date();
23102 });
23103 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23104 const validityTargetRef = (0, import_element69.useRef)(null);
23105 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23106 const onChangeCallback = (0, import_element69.useCallback)(
23107 (newValue) => onChange(setValue({ item: data, value: newValue })),
23108 [data, onChange, setValue]
23109 );
23110 const onSelectDate = (0, import_element69.useCallback)(
23111 (newDate) => {
23112 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23113 onChangeCallback(dateValue);
23114 setSelectedPresetId(null);
23115 setIsTouched(true);
23116 },
23117 [onChangeCallback]
23118 );
23119 const handlePresetClick = (0, import_element69.useCallback)(
23120 (preset) => {
23121 const presetDate = preset.getValue();
23122 const dateValue = formatDate(presetDate);
23123 setCalendarMonth(presetDate);
23124 onChangeCallback(dateValue);
23125 setSelectedPresetId(preset.id);
23126 setIsTouched(true);
23127 },
23128 [onChangeCallback]
23129 );
23130 const handleManualDateChange = (0, import_element69.useCallback)(
23131 (newValue) => {
23132 onChangeCallback(newValue);
23133 if (newValue) {
23134 const parsedDate = parseDate(newValue);
23135 if (parsedDate) {
23136 setCalendarMonth(parsedDate);
23137 }
23138 }
23139 setSelectedPresetId(null);
23140 setIsTouched(true);
23141 },
23142 [onChangeCallback]
23143 );
23144 const {
23145 timezone: { string: timezoneString }
23146 } = (0, import_date4.getSettings)();
23147 let displayLabel = label;
23148 if (isValid2?.required && !markWhenOptional) {
23149 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23150 } else if (!isValid2?.required && markWhenOptional) {
23151 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23152 }
23153 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23154 ValidatedDateControl,
23155 {
23156 field,
23157 validity,
23158 inputRefs: validityTargetRef,
23159 isTouched,
23160 setIsTouched,
23161 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23162 import_components32.BaseControl,
23163 {
23164 id,
23165 className: "dataviews-controls__date",
23166 label: displayLabel,
23167 help: description,
23168 hideLabelFromVision,
23169 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23170 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23171 Stack,
23172 {
23173 direction: "row",
23174 gap: "sm",
23175 wrap: "wrap",
23176 justify: "flex-start",
23177 children: [
23178 DATE_PRESETS.map((preset) => {
23179 const isSelected2 = selectedPresetId === preset.id;
23180 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23181 import_components32.Button,
23182 {
23183 className: "dataviews-controls__date-preset",
23184 variant: "tertiary",
23185 isPressed: isSelected2,
23186 size: "small",
23187 disabled: disabled2,
23188 accessibleWhenDisabled: true,
23189 onClick: () => handlePresetClick(preset),
23190 children: preset.label
23191 },
23192 preset.id
23193 );
23194 }),
23195 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23196 import_components32.Button,
23197 {
23198 className: "dataviews-controls__date-preset",
23199 variant: "tertiary",
23200 isPressed: !selectedPresetId,
23201 size: "small",
23202 disabled: !!selectedPresetId || disabled2,
23203 accessibleWhenDisabled: true,
23204 children: (0, import_i18n35.__)("Custom")
23205 }
23206 )
23207 ]
23208 }
23209 ),
23210 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23211 import_components32.__experimentalInputControl,
23212 {
23213 __next40pxDefaultSize: true,
23214 ref: validityTargetRef,
23215 type: "date",
23216 label: (0, import_i18n35.__)("Date"),
23217 hideLabelFromVision: true,
23218 value,
23219 onChange: handleManualDateChange,
23220 required: !!field.isValid?.required,
23221 disabled: disabled2,
23222 min: minConstraint,
23223 max: maxConstraint
23224 }
23225 ),
23226 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23227 DateCalendar2,
23228 {
23229 style: { width: "100%" },
23230 selected: value ? parseDate(value) || void 0 : void 0,
23231 onSelect: onSelectDate,
23232 month: calendarMonth,
23233 onMonthChange: setCalendarMonth,
23234 timeZone: timezoneString || void 0,
23235 weekStartsOn,
23236 disabled: disabled2 || disabledMatchers,
23237 disableNavigation: disabled2
23238 }
23239 )
23240 ] })
23241 }
23242 )
23243 }
23244 );
23245 }
23246 function CalendarDateRangeControl({
23247 data,
23248 field,
23249 onChange,
23250 hideLabelFromVision,
23251 markWhenOptional,
23252 validity
23253 }) {
23254 const {
23255 id,
23256 label,
23257 description,
23258 getValue,
23259 setValue,
23260 isValid: isValid2,
23261 format: fieldFormat
23262 } = field;
23263 const disabled2 = field.isDisabled({ item: data, field });
23264 let value;
23265 const fieldValue = getValue({ item: data });
23266 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23267 value = fieldValue;
23268 }
23269 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23270 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23271 const onChangeCallback = (0, import_element69.useCallback)(
23272 (newValue) => {
23273 onChange(
23274 setValue({
23275 item: data,
23276 value: newValue
23277 })
23278 );
23279 },
23280 [data, onChange, setValue]
23281 );
23282 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23283 null
23284 );
23285 const selectedRange = (0, import_element69.useMemo)(() => {
23286 if (!value) {
23287 return { from: void 0, to: void 0 };
23288 }
23289 const [from, to] = value;
23290 return {
23291 from: parseDate(from) || void 0,
23292 to: parseDate(to) || void 0
23293 };
23294 }, [value]);
23295 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23296 return selectedRange.from || /* @__PURE__ */ new Date();
23297 });
23298 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23299 const fromInputRef = (0, import_element69.useRef)(null);
23300 const toInputRef = (0, import_element69.useRef)(null);
23301 const updateDateRange = (0, import_element69.useCallback)(
23302 (fromDate, toDate2) => {
23303 if (fromDate && toDate2) {
23304 onChangeCallback([
23305 formatDate(fromDate),
23306 formatDate(toDate2)
23307 ]);
23308 } else if (!fromDate && !toDate2) {
23309 onChangeCallback(void 0);
23310 }
23311 },
23312 [onChangeCallback]
23313 );
23314 const onSelectCalendarRange = (0, import_element69.useCallback)(
23315 (newRange) => {
23316 updateDateRange(newRange?.from, newRange?.to);
23317 setSelectedPresetId(null);
23318 setIsTouched(true);
23319 },
23320 [updateDateRange]
23321 );
23322 const handlePresetClick = (0, import_element69.useCallback)(
23323 (preset) => {
23324 const [startDate, endDate] = preset.getValue();
23325 setCalendarMonth(startDate);
23326 updateDateRange(startDate, endDate);
23327 setSelectedPresetId(preset.id);
23328 setIsTouched(true);
23329 },
23330 [updateDateRange]
23331 );
23332 const handleManualDateChange = (0, import_element69.useCallback)(
23333 (fromOrTo, newValue) => {
23334 const [currentFrom, currentTo] = value || [
23335 void 0,
23336 void 0
23337 ];
23338 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23339 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23340 updateDateRange(updatedFrom, updatedTo);
23341 if (newValue) {
23342 const parsedDate = parseDate(newValue);
23343 if (parsedDate) {
23344 setCalendarMonth(parsedDate);
23345 }
23346 }
23347 setSelectedPresetId(null);
23348 setIsTouched(true);
23349 },
23350 [value, updateDateRange]
23351 );
23352 const { timezone } = (0, import_date4.getSettings)();
23353 let displayLabel = label;
23354 if (field.isValid?.required && !markWhenOptional) {
23355 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23356 } else if (!field.isValid?.required && markWhenOptional) {
23357 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23358 }
23359 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23360 ValidatedDateControl,
23361 {
23362 field,
23363 validity,
23364 inputRefs: [fromInputRef, toInputRef],
23365 isTouched,
23366 setIsTouched,
23367 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23368 import_components32.BaseControl,
23369 {
23370 id,
23371 className: "dataviews-controls__date",
23372 label: displayLabel,
23373 help: description,
23374 hideLabelFromVision,
23375 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23376 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23377 Stack,
23378 {
23379 direction: "row",
23380 gap: "sm",
23381 wrap: "wrap",
23382 justify: "flex-start",
23383 children: [
23384 DATE_RANGE_PRESETS.map((preset) => {
23385 const isSelected2 = selectedPresetId === preset.id;
23386 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23387 import_components32.Button,
23388 {
23389 className: "dataviews-controls__date-preset",
23390 variant: "tertiary",
23391 isPressed: isSelected2,
23392 size: "small",
23393 disabled: disabled2,
23394 accessibleWhenDisabled: true,
23395 onClick: () => handlePresetClick(preset),
23396 children: preset.label
23397 },
23398 preset.id
23399 );
23400 }),
23401 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23402 import_components32.Button,
23403 {
23404 className: "dataviews-controls__date-preset",
23405 variant: "tertiary",
23406 isPressed: !selectedPresetId,
23407 size: "small",
23408 accessibleWhenDisabled: true,
23409 disabled: !!selectedPresetId || disabled2,
23410 children: (0, import_i18n35.__)("Custom")
23411 }
23412 )
23413 ]
23414 }
23415 ),
23416 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23417 Stack,
23418 {
23419 direction: "row",
23420 gap: "sm",
23421 justify: "space-between",
23422 className: "dataviews-controls__date-range-inputs",
23423 children: [
23424 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23425 import_components32.__experimentalInputControl,
23426 {
23427 __next40pxDefaultSize: true,
23428 ref: fromInputRef,
23429 type: "date",
23430 label: (0, import_i18n35.__)("From"),
23431 hideLabelFromVision: true,
23432 value: value?.[0],
23433 onChange: (newValue) => handleManualDateChange("from", newValue),
23434 required: !!field.isValid?.required,
23435 disabled: disabled2,
23436 min: minConstraint,
23437 max: maxConstraint
23438 }
23439 ),
23440 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23441 import_components32.__experimentalInputControl,
23442 {
23443 __next40pxDefaultSize: true,
23444 ref: toInputRef,
23445 type: "date",
23446 label: (0, import_i18n35.__)("To"),
23447 hideLabelFromVision: true,
23448 value: value?.[1],
23449 onChange: (newValue) => handleManualDateChange("to", newValue),
23450 required: !!field.isValid?.required,
23451 disabled: disabled2,
23452 min: minConstraint,
23453 max: maxConstraint
23454 }
23455 )
23456 ]
23457 }
23458 ),
23459 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23460 DateRangeCalendar,
23461 {
23462 style: { width: "100%" },
23463 selected: selectedRange,
23464 onSelect: onSelectCalendarRange,
23465 month: calendarMonth,
23466 onMonthChange: setCalendarMonth,
23467 timeZone: timezone.string || void 0,
23468 weekStartsOn,
23469 disabled: disabled2 || disabledMatchers
23470 }
23471 )
23472 ] })
23473 }
23474 )
23475 }
23476 );
23477 }
23478 function DateControl({
23479 data,
23480 field,
23481 onChange,
23482 hideLabelFromVision,
23483 markWhenOptional,
23484 operator,
23485 validity
23486 }) {
23487 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23488 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23489 RelativeDateControl,
23490 {
23491 className: "dataviews-controls__date",
23492 data,
23493 field,
23494 onChange,
23495 hideLabelFromVision,
23496 operator
23497 }
23498 );
23499 }
23500 if (operator === OPERATOR_BETWEEN) {
23501 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23502 CalendarDateRangeControl,
23503 {
23504 data,
23505 field,
23506 onChange,
23507 hideLabelFromVision,
23508 markWhenOptional,
23509 validity
23510 }
23511 );
23512 }
23513 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23514 CalendarDateControl,
23515 {
23516 data,
23517 field,
23518 onChange,
23519 hideLabelFromVision,
23520 markWhenOptional,
23521 validity
23522 }
23523 );
23524 }
23525
23526 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23527 var import_components33 = __toESM(require_components(), 1);
23528 var import_element70 = __toESM(require_element(), 1);
23529 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23530 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
23531 function Select({
23532 data,
23533 field,
23534 onChange,
23535 hideLabelFromVision,
23536 markWhenOptional,
23537 validity
23538 }) {
23539 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23540 const disabled2 = field.isDisabled({ item: data, field });
23541 const isMultiple = type === "array";
23542 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23543 const onChangeControl = (0, import_element70.useCallback)(
23544 (newValue) => onChange(setValue({ item: data, value: newValue })),
23545 [data, onChange, setValue]
23546 );
23547 const { elements, isLoading } = useElements({
23548 elements: field.elements,
23549 getElements: field.getElements
23550 });
23551 if (isLoading) {
23552 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components33.Spinner, {});
23553 }
23554 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23555 ValidatedSelectControl,
23556 {
23557 required: !!field.isValid?.required,
23558 markWhenOptional,
23559 customValidity: getCustomValidity(isValid2, validity),
23560 label,
23561 value,
23562 help: description,
23563 options: elements,
23564 onChange: onChangeControl,
23565 __next40pxDefaultSize: true,
23566 hideLabelFromVision,
23567 multiple: isMultiple,
23568 disabled: disabled2
23569 }
23570 );
23571 }
23572
23573 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23574 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23575 var ELEMENTS_THRESHOLD = 10;
23576 function AdaptiveSelect(props) {
23577 const { field } = props;
23578 const { elements } = useElements({
23579 elements: field.elements,
23580 getElements: field.getElements
23581 });
23582 if (elements.length >= ELEMENTS_THRESHOLD) {
23583 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
23584 }
23585 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
23586 }
23587
23588 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23589 var import_components35 = __toESM(require_components(), 1);
23590
23591 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23592 var import_components34 = __toESM(require_components(), 1);
23593 var import_element71 = __toESM(require_element(), 1);
23594 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23595 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
23596 function ValidatedText({
23597 data,
23598 field,
23599 onChange,
23600 hideLabelFromVision,
23601 markWhenOptional,
23602 type,
23603 prefix,
23604 suffix,
23605 validity
23606 }) {
23607 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23608 const value = getValue({ item: data });
23609 const disabled2 = field.isDisabled({ item: data, field });
23610 const onChangeControl = (0, import_element71.useCallback)(
23611 (newValue) => onChange(
23612 setValue({
23613 item: data,
23614 value: newValue
23615 })
23616 ),
23617 [data, setValue, onChange]
23618 );
23619 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23620 ValidatedInputControl2,
23621 {
23622 required: !!isValid2.required,
23623 markWhenOptional,
23624 customValidity: getCustomValidity(isValid2, validity),
23625 label,
23626 placeholder,
23627 value: value ?? "",
23628 help: description,
23629 onChange: onChangeControl,
23630 hideLabelFromVision,
23631 type,
23632 prefix,
23633 suffix,
23634 disabled: disabled2,
23635 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23636 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23637 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23638 __next40pxDefaultSize: true
23639 }
23640 );
23641 }
23642
23643 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23644 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23645 function Email({
23646 data,
23647 field,
23648 onChange,
23649 hideLabelFromVision,
23650 markWhenOptional,
23651 validity
23652 }) {
23653 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23654 ValidatedText,
23655 {
23656 ...{
23657 data,
23658 field,
23659 onChange,
23660 hideLabelFromVision,
23661 markWhenOptional,
23662 validity,
23663 type: "email",
23664 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: envelope_default }) })
23665 }
23666 }
23667 );
23668 }
23669
23670 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23671 var import_components36 = __toESM(require_components(), 1);
23672 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23673 function Telephone({
23674 data,
23675 field,
23676 onChange,
23677 hideLabelFromVision,
23678 markWhenOptional,
23679 validity
23680 }) {
23681 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23682 ValidatedText,
23683 {
23684 ...{
23685 data,
23686 field,
23687 onChange,
23688 hideLabelFromVision,
23689 markWhenOptional,
23690 validity,
23691 type: "tel",
23692 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: mobile_default }) })
23693 }
23694 }
23695 );
23696 }
23697
23698 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23699 var import_components37 = __toESM(require_components(), 1);
23700 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23701 function Url({
23702 data,
23703 field,
23704 onChange,
23705 hideLabelFromVision,
23706 markWhenOptional,
23707 validity
23708 }) {
23709 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23710 ValidatedText,
23711 {
23712 ...{
23713 data,
23714 field,
23715 onChange,
23716 hideLabelFromVision,
23717 markWhenOptional,
23718 validity,
23719 type: "url",
23720 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.Icon, { icon: link_default }) })
23721 }
23722 }
23723 );
23724 }
23725
23726 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23727 var import_components38 = __toESM(require_components(), 1);
23728 var import_element72 = __toESM(require_element(), 1);
23729 var import_i18n36 = __toESM(require_i18n(), 1);
23730 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23731 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
23732 function toNumberOrEmpty(value) {
23733 if (value === "" || value === void 0) {
23734 return "";
23735 }
23736 const number = Number(value);
23737 return Number.isFinite(number) ? number : "";
23738 }
23739 function BetweenControls({
23740 value,
23741 onChange,
23742 hideLabelFromVision,
23743 step
23744 }) {
23745 const [min2 = "", max2 = ""] = value;
23746 const onChangeMin = (0, import_element72.useCallback)(
23747 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23748 [onChange, max2]
23749 );
23750 const onChangeMax = (0, import_element72.useCallback)(
23751 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23752 [onChange, min2]
23753 );
23754 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23755 import_components38.BaseControl,
23756 {
23757 help: (0, import_i18n36.__)("The max. value must be greater than the min. value."),
23758 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23759 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23760 import_components38.__experimentalNumberControl,
23761 {
23762 label: (0, import_i18n36.__)("Min."),
23763 value: min2,
23764 max: max2 ? Number(max2) - step : void 0,
23765 onChange: onChangeMin,
23766 __next40pxDefaultSize: true,
23767 hideLabelFromVision,
23768 step
23769 }
23770 ),
23771 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23772 import_components38.__experimentalNumberControl,
23773 {
23774 label: (0, import_i18n36.__)("Max."),
23775 value: max2,
23776 min: min2 ? Number(min2) + step : void 0,
23777 onChange: onChangeMax,
23778 __next40pxDefaultSize: true,
23779 hideLabelFromVision,
23780 step
23781 }
23782 )
23783 ] })
23784 }
23785 );
23786 }
23787 function ValidatedNumber({
23788 data,
23789 field,
23790 onChange,
23791 hideLabelFromVision,
23792 markWhenOptional,
23793 operator,
23794 validity
23795 }) {
23796 const decimals = field.format?.decimals ?? 0;
23797 const step = Math.pow(10, Math.abs(decimals) * -1);
23798 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23799 const value = getValue({ item: data }) ?? "";
23800 const disabled2 = field.isDisabled({ item: data, field });
23801 const onChangeControl = (0, import_element72.useCallback)(
23802 (newValue) => {
23803 onChange(
23804 setValue({
23805 item: data,
23806 // Do not convert an empty string or undefined to a number,
23807 // otherwise there's a mismatch between the UI control (empty)
23808 // and the data relied by onChange (0).
23809 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23810 })
23811 );
23812 },
23813 [data, onChange, setValue]
23814 );
23815 const onChangeBetweenControls = (0, import_element72.useCallback)(
23816 (newValue) => {
23817 onChange(
23818 setValue({
23819 item: data,
23820 value: newValue
23821 })
23822 );
23823 },
23824 [data, onChange, setValue]
23825 );
23826 if (operator === OPERATOR_BETWEEN) {
23827 let valueBetween = ["", ""];
23828 if (Array.isArray(value) && value.length === 2 && value.every(
23829 (element) => typeof element === "number" || element === ""
23830 )) {
23831 valueBetween = value;
23832 }
23833 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23834 BetweenControls,
23835 {
23836 value: valueBetween,
23837 onChange: onChangeBetweenControls,
23838 hideLabelFromVision,
23839 step
23840 }
23841 );
23842 }
23843 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23844 ValidatedNumberControl,
23845 {
23846 required: !!isValid2.required,
23847 markWhenOptional,
23848 customValidity: getCustomValidity(isValid2, validity),
23849 label,
23850 help: description,
23851 value,
23852 onChange: onChangeControl,
23853 __next40pxDefaultSize: true,
23854 hideLabelFromVision,
23855 step,
23856 min: isValid2.min ? isValid2.min.constraint : void 0,
23857 max: isValid2.max ? isValid2.max.constraint : void 0,
23858 disabled: disabled2
23859 }
23860 );
23861 }
23862
23863 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23864 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23865 function Integer(props) {
23866 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
23867 }
23868
23869 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23870 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23871 function Number2(props) {
23872 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
23873 }
23874
23875 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23876 var import_components39 = __toESM(require_components(), 1);
23877 var import_element73 = __toESM(require_element(), 1);
23878 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23879 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
23880 function Radio({
23881 data,
23882 field,
23883 onChange,
23884 hideLabelFromVision,
23885 markWhenOptional,
23886 validity
23887 }) {
23888 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23889 const disabled2 = field.isDisabled({ item: data, field });
23890 const { elements, isLoading } = useElements({
23891 elements: field.elements,
23892 getElements: field.getElements
23893 });
23894 const value = getValue({ item: data });
23895 const onChangeControl = (0, import_element73.useCallback)(
23896 (newValue) => onChange(setValue({ item: data, value: newValue })),
23897 [data, onChange, setValue]
23898 );
23899 if (isLoading) {
23900 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components39.Spinner, {});
23901 }
23902 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23903 ValidatedRadioControl,
23904 {
23905 required: !!field.isValid?.required,
23906 markWhenOptional,
23907 customValidity: getCustomValidity(isValid2, validity),
23908 label,
23909 help: description,
23910 onChange: onChangeControl,
23911 options: elements,
23912 selected: value,
23913 hideLabelFromVision,
23914 disabled: disabled2
23915 }
23916 );
23917 }
23918
23919 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23920 var import_element74 = __toESM(require_element(), 1);
23921 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
23922 function Text3({
23923 data,
23924 field,
23925 onChange,
23926 hideLabelFromVision,
23927 markWhenOptional,
23928 config,
23929 validity
23930 }) {
23931 const { prefix, suffix } = config || {};
23932 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
23933 ValidatedText,
23934 {
23935 ...{
23936 data,
23937 field,
23938 onChange,
23939 hideLabelFromVision,
23940 markWhenOptional,
23941 validity,
23942 prefix: prefix ? (0, import_element74.createElement)(prefix) : void 0,
23943 suffix: suffix ? (0, import_element74.createElement)(suffix) : void 0
23944 }
23945 }
23946 );
23947 }
23948
23949 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23950 var import_components40 = __toESM(require_components(), 1);
23951 var import_element75 = __toESM(require_element(), 1);
23952 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
23953 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
23954 function Toggle({
23955 field,
23956 onChange,
23957 data,
23958 hideLabelFromVision,
23959 markWhenOptional,
23960 validity
23961 }) {
23962 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23963 const disabled2 = field.isDisabled({ item: data, field });
23964 const onChangeControl = (0, import_element75.useCallback)(() => {
23965 onChange(
23966 setValue({ item: data, value: !getValue({ item: data }) })
23967 );
23968 }, [onChange, setValue, data, getValue]);
23969 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23970 ValidatedToggleControl,
23971 {
23972 required: !!isValid2.required,
23973 markWhenOptional,
23974 customValidity: getCustomValidity(isValid2, validity),
23975 hidden: hideLabelFromVision,
23976 label,
23977 help: description,
23978 checked: getValue({ item: data }),
23979 onChange: onChangeControl,
23980 disabled: disabled2
23981 }
23982 );
23983 }
23984
23985 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23986 var import_components41 = __toESM(require_components(), 1);
23987 var import_element76 = __toESM(require_element(), 1);
23988 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
23989 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
23990 function Textarea({
23991 data,
23992 field,
23993 onChange,
23994 hideLabelFromVision,
23995 markWhenOptional,
23996 config,
23997 validity
23998 }) {
23999 const { rows = 4 } = config || {};
24000 const disabled2 = field.isDisabled({ item: data, field });
24001 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24002 const value = field.getValue({ item: data });
24003 const onChangeControl = (0, import_element76.useCallback)(
24004 (newValue) => onChange(setValue({ item: data, value: newValue })),
24005 [data, onChange, setValue]
24006 );
24007 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24008 ValidatedTextareaControl,
24009 {
24010 required: !!isValid2.required,
24011 markWhenOptional,
24012 customValidity: getCustomValidity(isValid2, validity),
24013 label,
24014 placeholder,
24015 value: value ?? "",
24016 help: description,
24017 onChange: onChangeControl,
24018 rows,
24019 disabled: disabled2,
24020 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24021 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24022 __next40pxDefaultSize: true,
24023 hideLabelFromVision
24024 }
24025 );
24026 }
24027
24028 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24029 var import_components42 = __toESM(require_components(), 1);
24030 var import_element77 = __toESM(require_element(), 1);
24031 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24032 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
24033 function ToggleGroup({
24034 data,
24035 field,
24036 onChange,
24037 hideLabelFromVision,
24038 markWhenOptional,
24039 validity
24040 }) {
24041 const { getValue, setValue, isValid: isValid2 } = field;
24042 const disabled2 = field.isDisabled({ item: data, field });
24043 const value = getValue({ item: data });
24044 const onChangeControl = (0, import_element77.useCallback)(
24045 (newValue) => onChange(setValue({ item: data, value: newValue })),
24046 [data, onChange, setValue]
24047 );
24048 const { elements, isLoading } = useElements({
24049 elements: field.elements,
24050 getElements: field.getElements
24051 });
24052 if (isLoading) {
24053 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components42.Spinner, {});
24054 }
24055 if (elements.length === 0) {
24056 return null;
24057 }
24058 const selectedOption = elements.find((el) => el.value === value);
24059 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24060 ValidatedToggleGroupControl,
24061 {
24062 required: !!field.isValid?.required,
24063 markWhenOptional,
24064 customValidity: getCustomValidity(isValid2, validity),
24065 __next40pxDefaultSize: true,
24066 isBlock: true,
24067 label: field.label,
24068 help: selectedOption?.description || field.description,
24069 onChange: onChangeControl,
24070 value,
24071 hideLabelFromVision,
24072 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24073 import_components42.__experimentalToggleGroupControlOption,
24074 {
24075 label: el.label,
24076 value: el.value,
24077 disabled: disabled2
24078 },
24079 el.value
24080 ))
24081 }
24082 );
24083 }
24084
24085 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24086 var import_components43 = __toESM(require_components(), 1);
24087 var import_element78 = __toESM(require_element(), 1);
24088 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24089 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
24090 function ArrayControl({
24091 data,
24092 field,
24093 onChange,
24094 hideLabelFromVision,
24095 markWhenOptional,
24096 validity
24097 }) {
24098 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24099 const value = getValue({ item: data });
24100 const disabled2 = field.isDisabled({ item: data, field });
24101 const { elements, isLoading } = useElements({
24102 elements: field.elements,
24103 getElements: field.getElements
24104 });
24105 const arrayValueAsElements = (0, import_element78.useMemo)(
24106 () => Array.isArray(value) ? value.map((token) => {
24107 const element = elements?.find(
24108 (suggestion) => suggestion.value === token
24109 );
24110 return element || { value: token, label: token };
24111 }) : [],
24112 [value, elements]
24113 );
24114 const onChangeControl = (0, import_element78.useCallback)(
24115 (tokens) => {
24116 const valueTokens = tokens.map((token) => {
24117 if (typeof token === "object" && "value" in token) {
24118 return token.value;
24119 }
24120 return token;
24121 });
24122 onChange(setValue({ item: data, value: valueTokens }));
24123 },
24124 [onChange, setValue, data]
24125 );
24126 if (isLoading) {
24127 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.Spinner, {});
24128 }
24129 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24130 ValidatedFormTokenField,
24131 {
24132 required: !!isValid2?.required,
24133 markWhenOptional,
24134 customValidity: getCustomValidity(isValid2, validity),
24135 label: hideLabelFromVision ? void 0 : label,
24136 value: arrayValueAsElements,
24137 onChange: onChangeControl,
24138 placeholder,
24139 suggestions: elements?.map((element) => element.value),
24140 disabled: disabled2,
24141 __experimentalValidateInput: (token) => {
24142 if (field.isValid?.elements && elements) {
24143 return elements.some(
24144 (element) => element.value === token || element.label === token
24145 );
24146 }
24147 return true;
24148 },
24149 __experimentalExpandOnFocus: elements && elements.length > 0,
24150 help: description ?? (field.isValid?.elements ? "" : void 0),
24151 displayTransform: (token) => {
24152 if (typeof token === "object" && "label" in token) {
24153 return token.label;
24154 }
24155 if (typeof token === "string" && elements) {
24156 const element = elements.find(
24157 (el) => el.value === token
24158 );
24159 return element?.label || token;
24160 }
24161 return token;
24162 },
24163 __experimentalRenderItem: ({ item }) => {
24164 if (typeof item === "string" && elements) {
24165 const element = elements.find(
24166 (el) => el.value === item
24167 );
24168 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: element?.label || item });
24169 }
24170 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: item });
24171 }
24172 }
24173 );
24174 }
24175
24176 // node_modules/colord/index.mjs
24177 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24178 var t = function(r3) {
24179 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24180 };
24181 var n = function(r3, t2, n2) {
24182 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24183 };
24184 var e = function(r3, t2, n2) {
24185 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24186 };
24187 var u = function(r3) {
24188 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24189 };
24190 var a = function(r3) {
24191 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24192 };
24193 var o = function(r3) {
24194 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24195 };
24196 var i = /^#([0-9a-f]{3,8})$/i;
24197 var s = function(r3) {
24198 var t2 = r3.toString(16);
24199 return t2.length < 2 ? "0" + t2 : t2;
24200 };
24201 var h = function(r3) {
24202 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;
24203 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24204 };
24205 var b = function(r3) {
24206 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24207 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24208 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;
24209 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 };
24210 };
24211 var g = function(r3) {
24212 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24213 };
24214 var d = function(r3) {
24215 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24216 };
24217 var f = function(r3) {
24218 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 }));
24219 var t2, n2, e2;
24220 };
24221 var c = function(r3) {
24222 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 };
24223 var t2, n2, e2, u2;
24224 };
24225 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24226 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24227 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24228 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24229 var y = { string: [[function(r3) {
24230 var t2 = i.exec(r3);
24231 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;
24232 }, "hex"], [function(r3) {
24233 var t2 = v.exec(r3) || m.exec(r3);
24234 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;
24235 }, "rgb"], [function(t2) {
24236 var n2 = l.exec(t2) || p.exec(t2);
24237 if (!n2) return null;
24238 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) });
24239 return f(a2);
24240 }, "hsl"]], object: [[function(r3) {
24241 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24242 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24243 }, "rgb"], [function(r3) {
24244 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24245 if (!t(n2) || !t(e2) || !t(u2)) return null;
24246 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24247 return f(i2);
24248 }, "hsl"], [function(r3) {
24249 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24250 if (!t(n2) || !t(a2) || !t(o2)) return null;
24251 var h2 = (function(r4) {
24252 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24253 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24254 return b(h2);
24255 }, "hsv"]] };
24256 var N = function(r3, t2) {
24257 for (var n2 = 0; n2 < t2.length; n2++) {
24258 var e2 = t2[n2][0](r3);
24259 if (e2) return [e2, t2[n2][1]];
24260 }
24261 return [null, void 0];
24262 };
24263 var x = function(r3) {
24264 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24265 };
24266 var M = function(r3, t2) {
24267 var n2 = c(r3);
24268 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24269 };
24270 var H = function(r3) {
24271 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24272 };
24273 var $ = function(r3, t2) {
24274 var n2 = c(r3);
24275 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24276 };
24277 var j = (function() {
24278 function r3(r4) {
24279 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24280 }
24281 return r3.prototype.isValid = function() {
24282 return null !== this.parsed;
24283 }, r3.prototype.brightness = function() {
24284 return n(H(this.rgba), 2);
24285 }, r3.prototype.isDark = function() {
24286 return H(this.rgba) < 0.5;
24287 }, r3.prototype.isLight = function() {
24288 return H(this.rgba) >= 0.5;
24289 }, r3.prototype.toHex = function() {
24290 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;
24291 var r4, t2, e2, u2, a2, i2;
24292 }, r3.prototype.toRgb = function() {
24293 return o(this.rgba);
24294 }, r3.prototype.toRgbString = function() {
24295 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 + ")";
24296 var r4, t2, n2, e2, u2;
24297 }, r3.prototype.toHsl = function() {
24298 return d(c(this.rgba));
24299 }, r3.prototype.toHslString = function() {
24300 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 + "%)";
24301 var r4, t2, n2, e2, u2;
24302 }, r3.prototype.toHsv = function() {
24303 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24304 var r4;
24305 }, r3.prototype.invert = function() {
24306 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24307 var r4;
24308 }, r3.prototype.saturate = function(r4) {
24309 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24310 }, r3.prototype.desaturate = function(r4) {
24311 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24312 }, r3.prototype.grayscale = function() {
24313 return w(M(this.rgba, -1));
24314 }, r3.prototype.lighten = function(r4) {
24315 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24316 }, r3.prototype.darken = function(r4) {
24317 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24318 }, r3.prototype.rotate = function(r4) {
24319 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24320 }, r3.prototype.alpha = function(r4) {
24321 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24322 var t2;
24323 }, r3.prototype.hue = function(r4) {
24324 var t2 = c(this.rgba);
24325 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24326 }, r3.prototype.isEqual = function(r4) {
24327 return this.toHex() === w(r4).toHex();
24328 }, r3;
24329 })();
24330 var w = function(r3) {
24331 return r3 instanceof j ? r3 : new j(r3);
24332 };
24333
24334 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24335 var import_components44 = __toESM(require_components(), 1);
24336 var import_element79 = __toESM(require_element(), 1);
24337 var import_i18n37 = __toESM(require_i18n(), 1);
24338 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24339 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
24340 var ColorPickerDropdown = ({
24341 color,
24342 onColorChange,
24343 disabled: disabled2
24344 }) => {
24345 const validColor = color && w(color).isValid() ? color : "#ffffff";
24346 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24347 import_components44.Dropdown,
24348 {
24349 className: "dataviews-controls__color-picker-dropdown",
24350 popoverProps: { resize: false },
24351 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24352 import_components44.Button,
24353 {
24354 onClick: onToggle,
24355 "aria-label": (0, import_i18n37.__)("Open color picker"),
24356 size: "small",
24357 disabled: disabled2,
24358 accessibleWhenDisabled: true,
24359 icon: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
24360 }
24361 ),
24362 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24363 import_components44.ColorPicker,
24364 {
24365 color: validColor,
24366 onChange: onColorChange,
24367 enableAlpha: true
24368 }
24369 ) })
24370 }
24371 );
24372 };
24373 function Color({
24374 data,
24375 field,
24376 onChange,
24377 hideLabelFromVision,
24378 markWhenOptional,
24379 validity
24380 }) {
24381 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24382 const disabled2 = field.isDisabled({ item: data, field });
24383 const value = field.getValue({ item: data }) || "";
24384 const handleColorChange = (0, import_element79.useCallback)(
24385 (newColor) => {
24386 onChange(setValue({ item: data, value: newColor }));
24387 },
24388 [data, onChange, setValue]
24389 );
24390 const handleInputChange = (0, import_element79.useCallback)(
24391 (newValue) => {
24392 onChange(setValue({ item: data, value: newValue || "" }));
24393 },
24394 [data, onChange, setValue]
24395 );
24396 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24397 ValidatedInputControl3,
24398 {
24399 required: !!field.isValid?.required,
24400 markWhenOptional,
24401 customValidity: getCustomValidity(isValid2, validity),
24402 label,
24403 placeholder,
24404 value,
24405 help: description,
24406 onChange: handleInputChange,
24407 hideLabelFromVision,
24408 type: "text",
24409 disabled: disabled2,
24410 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24411 ColorPickerDropdown,
24412 {
24413 color: value,
24414 onColorChange: handleColorChange,
24415 disabled: disabled2
24416 }
24417 ) })
24418 }
24419 );
24420 }
24421
24422 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24423 var import_components45 = __toESM(require_components(), 1);
24424 var import_element80 = __toESM(require_element(), 1);
24425 var import_i18n38 = __toESM(require_i18n(), 1);
24426 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24427 function Password({
24428 data,
24429 field,
24430 onChange,
24431 hideLabelFromVision,
24432 markWhenOptional,
24433 validity
24434 }) {
24435 const [isVisible2, setIsVisible] = (0, import_element80.useState)(false);
24436 const disabled2 = field.isDisabled({ item: data, field });
24437 const toggleVisibility = (0, import_element80.useCallback)(() => {
24438 setIsVisible((prev) => !prev);
24439 }, []);
24440 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24441 ValidatedText,
24442 {
24443 ...{
24444 data,
24445 field,
24446 onChange,
24447 hideLabelFromVision,
24448 markWhenOptional,
24449 validity,
24450 type: isVisible2 ? "text" : "password",
24451 suffix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24452 import_components45.Button,
24453 {
24454 icon: isVisible2 ? unseen_default : seen_default,
24455 onClick: toggleVisibility,
24456 size: "small",
24457 label: isVisible2 ? (0, import_i18n38.__)("Hide password") : (0, import_i18n38.__)("Show password"),
24458 disabled: disabled2,
24459 accessibleWhenDisabled: true
24460 }
24461 ) })
24462 }
24463 }
24464 );
24465 }
24466
24467 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24468 function hasElements(field) {
24469 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24470 }
24471
24472 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24473 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24474 var FORM_CONTROLS = {
24475 adaptiveSelect: AdaptiveSelect,
24476 array: ArrayControl,
24477 checkbox: Checkbox,
24478 color: Color,
24479 combobox: Combobox3,
24480 datetime: DateTime,
24481 date: DateControl,
24482 email: Email,
24483 telephone: Telephone,
24484 url: Url,
24485 integer: Integer,
24486 number: Number2,
24487 password: Password,
24488 radio: Radio,
24489 select: Select,
24490 text: Text3,
24491 toggle: Toggle,
24492 textarea: Textarea,
24493 toggleGroup: ToggleGroup
24494 };
24495 function isEditConfig(value) {
24496 return value && typeof value === "object" && typeof value.control === "string";
24497 }
24498 function createConfiguredControl(config) {
24499 const { control, ...controlConfig } = config;
24500 const BaseControlType = getControlByType(control);
24501 if (BaseControlType === null) {
24502 return null;
24503 }
24504 return function ConfiguredControl(props) {
24505 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(BaseControlType, { ...props, config: controlConfig });
24506 };
24507 }
24508 function getControl(field, fallback) {
24509 if (typeof field.Edit === "function") {
24510 return field.Edit;
24511 }
24512 if (typeof field.Edit === "string") {
24513 return getControlByType(field.Edit);
24514 }
24515 if (isEditConfig(field.Edit)) {
24516 return createConfiguredControl(field.Edit);
24517 }
24518 if (hasElements(field) && field.type !== "array") {
24519 return getControlByType("adaptiveSelect");
24520 }
24521 if (fallback === null) {
24522 return null;
24523 }
24524 return getControlByType(fallback);
24525 }
24526 function getControlByType(type) {
24527 if (Object.keys(FORM_CONTROLS).includes(type)) {
24528 return FORM_CONTROLS[type];
24529 }
24530 return null;
24531 }
24532
24533 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24534 function getFilterBy(field, defaultOperators, validOperators) {
24535 if (field.filterBy === false) {
24536 return false;
24537 }
24538 const operators = field.filterBy?.operators?.filter(
24539 (op) => validOperators.includes(op)
24540 ) ?? defaultOperators;
24541 if (operators.length === 0) {
24542 return false;
24543 }
24544 return {
24545 isPrimary: !!field.filterBy?.isPrimary,
24546 operators
24547 };
24548 }
24549 var get_filter_by_default = getFilterBy;
24550
24551 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24552 var getValueFromId = (id) => ({ item }) => {
24553 const path = id.split(".");
24554 let value = item;
24555 for (const segment of path) {
24556 if (value.hasOwnProperty(segment)) {
24557 value = value[segment];
24558 } else {
24559 value = void 0;
24560 }
24561 }
24562 return value;
24563 };
24564 var get_value_from_id_default = getValueFromId;
24565
24566 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24567 var setValueFromId = (id) => ({ value }) => {
24568 const path = id.split(".");
24569 const result = {};
24570 let current = result;
24571 for (const segment of path.slice(0, -1)) {
24572 current[segment] = {};
24573 current = current[segment];
24574 }
24575 current[path.at(-1)] = value;
24576 return result;
24577 };
24578 var set_value_from_id_default = setValueFromId;
24579
24580 // packages/dataviews/build-module/field-types/email.mjs
24581 var import_i18n39 = __toESM(require_i18n(), 1);
24582
24583 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24584 function RenderFromElements({
24585 item,
24586 field
24587 }) {
24588 const { elements, isLoading } = useElements({
24589 elements: field.elements,
24590 getElements: field.getElements
24591 });
24592 const value = field.getValue({ item });
24593 if (isLoading) {
24594 return value;
24595 }
24596 if (elements.length === 0) {
24597 return value;
24598 }
24599 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24600 }
24601
24602 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24603 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24604 function render({
24605 item,
24606 field
24607 }) {
24608 if (field.hasElements) {
24609 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
24610 }
24611 return field.getValueFormatted({ item, field });
24612 }
24613
24614 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24615 var sort_text_default = (a2, b2, direction) => {
24616 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24617 };
24618
24619 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24620 function isValidRequired(item, field) {
24621 const value = field.getValue({ item });
24622 return ![void 0, "", null].includes(value);
24623 }
24624
24625 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24626 function isValidMinLength(item, field) {
24627 if (typeof field.isValid.minLength?.constraint !== "number") {
24628 return false;
24629 }
24630 const value = field.getValue({ item });
24631 if ([void 0, "", null].includes(value)) {
24632 return true;
24633 }
24634 return String(value).length >= field.isValid.minLength.constraint;
24635 }
24636
24637 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24638 function isValidMaxLength(item, field) {
24639 if (typeof field.isValid.maxLength?.constraint !== "number") {
24640 return false;
24641 }
24642 const value = field.getValue({ item });
24643 if ([void 0, "", null].includes(value)) {
24644 return true;
24645 }
24646 return String(value).length <= field.isValid.maxLength.constraint;
24647 }
24648
24649 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24650 function isValidPattern(item, field) {
24651 if (field.isValid.pattern?.constraint === void 0) {
24652 return true;
24653 }
24654 try {
24655 const regexp = new RegExp(field.isValid.pattern.constraint);
24656 const value = field.getValue({ item });
24657 if ([void 0, "", null].includes(value)) {
24658 return true;
24659 }
24660 return regexp.test(String(value));
24661 } catch {
24662 return false;
24663 }
24664 }
24665
24666 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24667 function isValidElements(item, field) {
24668 const elements = field.elements ?? [];
24669 const validValues = elements.map((el) => el.value);
24670 if (validValues.length === 0) {
24671 return true;
24672 }
24673 const value = field.getValue({ item });
24674 return [].concat(value).every((v2) => validValues.includes(v2));
24675 }
24676
24677 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24678 function getValueFormatted({
24679 item,
24680 field
24681 }) {
24682 return field.getValue({ item });
24683 }
24684 var get_value_formatted_default_default = getValueFormatted;
24685
24686 // packages/dataviews/build-module/field-types/email.mjs
24687 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])?)*$/;
24688 function isValidCustom(item, field) {
24689 const value = field.getValue({ item });
24690 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24691 return (0, import_i18n39.__)("Value must be a valid email address.");
24692 }
24693 return null;
24694 }
24695 var email_default = {
24696 type: "email",
24697 render,
24698 Edit: "email",
24699 sort: sort_text_default,
24700 enableSorting: true,
24701 enableGlobalSearch: false,
24702 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24703 validOperators: [
24704 OPERATOR_IS,
24705 OPERATOR_IS_NOT,
24706 OPERATOR_CONTAINS,
24707 OPERATOR_NOT_CONTAINS,
24708 OPERATOR_STARTS_WITH,
24709 // Multiple selection
24710 OPERATOR_IS_ANY,
24711 OPERATOR_IS_NONE,
24712 OPERATOR_IS_ALL,
24713 OPERATOR_IS_NOT_ALL
24714 ],
24715 format: {},
24716 getValueFormatted: get_value_formatted_default_default,
24717 validate: {
24718 required: isValidRequired,
24719 pattern: isValidPattern,
24720 minLength: isValidMinLength,
24721 maxLength: isValidMaxLength,
24722 elements: isValidElements,
24723 custom: isValidCustom
24724 }
24725 };
24726
24727 // packages/dataviews/build-module/field-types/integer.mjs
24728 var import_i18n40 = __toESM(require_i18n(), 1);
24729
24730 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24731 var sort_number_default = (a2, b2, direction) => {
24732 return direction === "asc" ? a2 - b2 : b2 - a2;
24733 };
24734
24735 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24736 function isValidMin(item, field) {
24737 if (typeof field.isValid.min?.constraint !== "number") {
24738 return false;
24739 }
24740 const value = field.getValue({ item });
24741 if ([void 0, "", null].includes(value)) {
24742 return true;
24743 }
24744 return Number(value) >= field.isValid.min.constraint;
24745 }
24746
24747 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24748 function isValidMax(item, field) {
24749 if (typeof field.isValid.max?.constraint !== "number") {
24750 return false;
24751 }
24752 const value = field.getValue({ item });
24753 if ([void 0, "", null].includes(value)) {
24754 return true;
24755 }
24756 return Number(value) <= field.isValid.max.constraint;
24757 }
24758
24759 // packages/dataviews/build-module/field-types/integer.mjs
24760 var format2 = {
24761 separatorThousand: ","
24762 };
24763 function getValueFormatted2({
24764 item,
24765 field
24766 }) {
24767 let value = field.getValue({ item });
24768 if (value === null || value === void 0) {
24769 return "";
24770 }
24771 value = Number(value);
24772 if (!Number.isFinite(value)) {
24773 return String(value);
24774 }
24775 let formatInteger;
24776 if (field.type !== "integer") {
24777 formatInteger = format2;
24778 } else {
24779 formatInteger = field.format;
24780 }
24781 const { separatorThousand } = formatInteger;
24782 const integerValue = Math.trunc(value);
24783 if (!separatorThousand) {
24784 return String(integerValue);
24785 }
24786 return String(integerValue).replace(
24787 /\B(?=(\d{3})+(?!\d))/g,
24788 separatorThousand
24789 );
24790 }
24791 function isValidCustom2(item, field) {
24792 const value = field.getValue({ item });
24793 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24794 return (0, import_i18n40.__)("Value must be an integer.");
24795 }
24796 return null;
24797 }
24798 var integer_default = {
24799 type: "integer",
24800 render,
24801 Edit: "integer",
24802 sort: sort_number_default,
24803 enableSorting: true,
24804 enableGlobalSearch: false,
24805 defaultOperators: [
24806 OPERATOR_IS,
24807 OPERATOR_IS_NOT,
24808 OPERATOR_LESS_THAN,
24809 OPERATOR_GREATER_THAN,
24810 OPERATOR_LESS_THAN_OR_EQUAL,
24811 OPERATOR_GREATER_THAN_OR_EQUAL,
24812 OPERATOR_BETWEEN
24813 ],
24814 validOperators: [
24815 // Single-selection
24816 OPERATOR_IS,
24817 OPERATOR_IS_NOT,
24818 OPERATOR_LESS_THAN,
24819 OPERATOR_GREATER_THAN,
24820 OPERATOR_LESS_THAN_OR_EQUAL,
24821 OPERATOR_GREATER_THAN_OR_EQUAL,
24822 OPERATOR_BETWEEN,
24823 // Multiple-selection
24824 OPERATOR_IS_ANY,
24825 OPERATOR_IS_NONE,
24826 OPERATOR_IS_ALL,
24827 OPERATOR_IS_NOT_ALL
24828 ],
24829 format: format2,
24830 getValueFormatted: getValueFormatted2,
24831 validate: {
24832 required: isValidRequired,
24833 min: isValidMin,
24834 max: isValidMax,
24835 elements: isValidElements,
24836 custom: isValidCustom2
24837 }
24838 };
24839
24840 // packages/dataviews/build-module/field-types/number.mjs
24841 var import_i18n41 = __toESM(require_i18n(), 1);
24842 var format3 = {
24843 separatorThousand: ",",
24844 separatorDecimal: ".",
24845 decimals: 2
24846 };
24847 function getValueFormatted3({
24848 item,
24849 field
24850 }) {
24851 let value = field.getValue({ item });
24852 if (value === null || value === void 0) {
24853 return "";
24854 }
24855 value = Number(value);
24856 if (!Number.isFinite(value)) {
24857 return String(value);
24858 }
24859 let formatNumber;
24860 if (field.type !== "number") {
24861 formatNumber = format3;
24862 } else {
24863 formatNumber = field.format;
24864 }
24865 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24866 const fixedValue = value.toFixed(decimals);
24867 const [integerPart, decimalPart] = fixedValue.split(".");
24868 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24869 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24870 }
24871 function isEmpty(value) {
24872 return value === "" || value === void 0 || value === null;
24873 }
24874 function isValidCustom3(item, field) {
24875 const value = field.getValue({ item });
24876 if (!isEmpty(value) && !Number.isFinite(value)) {
24877 return (0, import_i18n41.__)("Value must be a number.");
24878 }
24879 return null;
24880 }
24881 var number_default = {
24882 type: "number",
24883 render,
24884 Edit: "number",
24885 sort: sort_number_default,
24886 enableSorting: true,
24887 enableGlobalSearch: false,
24888 defaultOperators: [
24889 OPERATOR_IS,
24890 OPERATOR_IS_NOT,
24891 OPERATOR_LESS_THAN,
24892 OPERATOR_GREATER_THAN,
24893 OPERATOR_LESS_THAN_OR_EQUAL,
24894 OPERATOR_GREATER_THAN_OR_EQUAL,
24895 OPERATOR_BETWEEN
24896 ],
24897 validOperators: [
24898 // Single-selection
24899 OPERATOR_IS,
24900 OPERATOR_IS_NOT,
24901 OPERATOR_LESS_THAN,
24902 OPERATOR_GREATER_THAN,
24903 OPERATOR_LESS_THAN_OR_EQUAL,
24904 OPERATOR_GREATER_THAN_OR_EQUAL,
24905 OPERATOR_BETWEEN,
24906 // Multiple-selection
24907 OPERATOR_IS_ANY,
24908 OPERATOR_IS_NONE,
24909 OPERATOR_IS_ALL,
24910 OPERATOR_IS_NOT_ALL
24911 ],
24912 format: format3,
24913 getValueFormatted: getValueFormatted3,
24914 validate: {
24915 required: isValidRequired,
24916 min: isValidMin,
24917 max: isValidMax,
24918 elements: isValidElements,
24919 custom: isValidCustom3
24920 }
24921 };
24922
24923 // packages/dataviews/build-module/field-types/text.mjs
24924 var text_default = {
24925 type: "text",
24926 render,
24927 Edit: "text",
24928 sort: sort_text_default,
24929 enableSorting: true,
24930 enableGlobalSearch: false,
24931 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24932 validOperators: [
24933 // Single selection
24934 OPERATOR_IS,
24935 OPERATOR_IS_NOT,
24936 OPERATOR_CONTAINS,
24937 OPERATOR_NOT_CONTAINS,
24938 OPERATOR_STARTS_WITH,
24939 // Multiple selection
24940 OPERATOR_IS_ANY,
24941 OPERATOR_IS_NONE,
24942 OPERATOR_IS_ALL,
24943 OPERATOR_IS_NOT_ALL
24944 ],
24945 format: {},
24946 getValueFormatted: get_value_formatted_default_default,
24947 validate: {
24948 required: isValidRequired,
24949 pattern: isValidPattern,
24950 minLength: isValidMinLength,
24951 maxLength: isValidMaxLength,
24952 elements: isValidElements
24953 }
24954 };
24955
24956 // packages/dataviews/build-module/field-types/datetime.mjs
24957 var import_date7 = __toESM(require_date(), 1);
24958
24959 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24960 var import_date6 = __toESM(require_date(), 1);
24961 function parseDateLike(value) {
24962 if (!value) {
24963 return null;
24964 }
24965 if (!isValid(new Date(value))) {
24966 return null;
24967 }
24968 const parsed = (0, import_date6.getDate)(value);
24969 return parsed && isValid(parsed) ? parsed : null;
24970 }
24971 function validateDateLikeBoundary(item, field, boundary) {
24972 const constraint = field.isValid[boundary]?.constraint;
24973 if (typeof constraint !== "string") {
24974 return false;
24975 }
24976 const value = field.getValue({ item });
24977 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24978 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24979 return true;
24980 }
24981 const parsedConstraint = parseDateLike(constraint);
24982 const parsedValue = parseDateLike(String(boundaryValue));
24983 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24984 }
24985 function isValidMinDate(item, field) {
24986 return validateDateLikeBoundary(item, field, "min");
24987 }
24988 function isValidMaxDate(item, field) {
24989 return validateDateLikeBoundary(item, field, "max");
24990 }
24991
24992 // packages/dataviews/build-module/field-types/datetime.mjs
24993 var format4 = {
24994 datetime: (0, import_date7.getSettings)().formats.datetime,
24995 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24996 };
24997 function getValueFormatted4({
24998 item,
24999 field
25000 }) {
25001 const value = field.getValue({ item });
25002 if (["", void 0, null].includes(value)) {
25003 return "";
25004 }
25005 let formatDatetime;
25006 if (field.type !== "datetime") {
25007 formatDatetime = format4;
25008 } else {
25009 formatDatetime = field.format;
25010 }
25011 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25012 }
25013 var sort = (a2, b2, direction) => {
25014 const timeA = new Date(a2).getTime();
25015 const timeB = new Date(b2).getTime();
25016 return direction === "asc" ? timeA - timeB : timeB - timeA;
25017 };
25018 var datetime_default = {
25019 type: "datetime",
25020 render,
25021 Edit: "datetime",
25022 sort,
25023 enableSorting: true,
25024 enableGlobalSearch: false,
25025 defaultOperators: [
25026 OPERATOR_ON,
25027 OPERATOR_NOT_ON,
25028 OPERATOR_BEFORE,
25029 OPERATOR_AFTER,
25030 OPERATOR_BEFORE_INC,
25031 OPERATOR_AFTER_INC,
25032 OPERATOR_IN_THE_PAST,
25033 OPERATOR_OVER
25034 ],
25035 validOperators: [
25036 OPERATOR_ON,
25037 OPERATOR_NOT_ON,
25038 OPERATOR_BEFORE,
25039 OPERATOR_AFTER,
25040 OPERATOR_BEFORE_INC,
25041 OPERATOR_AFTER_INC,
25042 OPERATOR_IN_THE_PAST,
25043 OPERATOR_OVER
25044 ],
25045 format: format4,
25046 getValueFormatted: getValueFormatted4,
25047 validate: {
25048 required: isValidRequired,
25049 elements: isValidElements,
25050 min: isValidMinDate,
25051 max: isValidMaxDate
25052 }
25053 };
25054
25055 // packages/dataviews/build-module/field-types/date.mjs
25056 var import_date8 = __toESM(require_date(), 1);
25057 var format5 = {
25058 date: (0, import_date8.getSettings)().formats.date,
25059 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25060 };
25061 function getValueFormatted5({
25062 item,
25063 field
25064 }) {
25065 const value = field.getValue({ item });
25066 if (["", void 0, null].includes(value)) {
25067 return "";
25068 }
25069 let formatDate2;
25070 if (field.type !== "date") {
25071 formatDate2 = format5;
25072 } else {
25073 formatDate2 = field.format;
25074 }
25075 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25076 }
25077 var sort2 = (a2, b2, direction) => {
25078 const timeA = new Date(a2).getTime();
25079 const timeB = new Date(b2).getTime();
25080 return direction === "asc" ? timeA - timeB : timeB - timeA;
25081 };
25082 var date_default = {
25083 type: "date",
25084 render,
25085 Edit: "date",
25086 sort: sort2,
25087 enableSorting: true,
25088 enableGlobalSearch: false,
25089 defaultOperators: [
25090 OPERATOR_ON,
25091 OPERATOR_NOT_ON,
25092 OPERATOR_BEFORE,
25093 OPERATOR_AFTER,
25094 OPERATOR_BEFORE_INC,
25095 OPERATOR_AFTER_INC,
25096 OPERATOR_IN_THE_PAST,
25097 OPERATOR_OVER,
25098 OPERATOR_BETWEEN
25099 ],
25100 validOperators: [
25101 OPERATOR_ON,
25102 OPERATOR_NOT_ON,
25103 OPERATOR_BEFORE,
25104 OPERATOR_AFTER,
25105 OPERATOR_BEFORE_INC,
25106 OPERATOR_AFTER_INC,
25107 OPERATOR_IN_THE_PAST,
25108 OPERATOR_OVER,
25109 OPERATOR_BETWEEN
25110 ],
25111 format: format5,
25112 getValueFormatted: getValueFormatted5,
25113 validate: {
25114 required: isValidRequired,
25115 elements: isValidElements,
25116 min: isValidMinDate,
25117 max: isValidMaxDate
25118 }
25119 };
25120
25121 // packages/dataviews/build-module/field-types/boolean.mjs
25122 var import_i18n42 = __toESM(require_i18n(), 1);
25123
25124 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25125 function isValidRequiredForBool(item, field) {
25126 const value = field.getValue({ item });
25127 return value === true;
25128 }
25129
25130 // packages/dataviews/build-module/field-types/boolean.mjs
25131 function getValueFormatted6({
25132 item,
25133 field
25134 }) {
25135 const value = field.getValue({ item });
25136 if (value === true) {
25137 return (0, import_i18n42.__)("True");
25138 }
25139 if (value === false) {
25140 return (0, import_i18n42.__)("False");
25141 }
25142 return "";
25143 }
25144 function isValidCustom4(item, field) {
25145 const value = field.getValue({ item });
25146 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25147 return (0, import_i18n42.__)("Value must be true, false, or undefined");
25148 }
25149 return null;
25150 }
25151 var sort3 = (a2, b2, direction) => {
25152 const boolA = Boolean(a2);
25153 const boolB = Boolean(b2);
25154 if (boolA === boolB) {
25155 return 0;
25156 }
25157 if (direction === "asc") {
25158 return boolA ? 1 : -1;
25159 }
25160 return boolA ? -1 : 1;
25161 };
25162 var boolean_default = {
25163 type: "boolean",
25164 render,
25165 Edit: "checkbox",
25166 sort: sort3,
25167 validate: {
25168 required: isValidRequiredForBool,
25169 elements: isValidElements,
25170 custom: isValidCustom4
25171 },
25172 enableSorting: true,
25173 enableGlobalSearch: false,
25174 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25175 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25176 format: {},
25177 getValueFormatted: getValueFormatted6
25178 };
25179
25180 // packages/dataviews/build-module/field-types/media.mjs
25181 var media_default = {
25182 type: "media",
25183 render: () => null,
25184 Edit: null,
25185 sort: () => 0,
25186 enableSorting: false,
25187 enableGlobalSearch: false,
25188 defaultOperators: [],
25189 validOperators: [],
25190 format: {},
25191 getValueFormatted: get_value_formatted_default_default,
25192 // cannot validate any constraint, so
25193 // the only available validation for the field author
25194 // would be providing a custom validator.
25195 validate: {}
25196 };
25197
25198 // packages/dataviews/build-module/field-types/array.mjs
25199 var import_i18n43 = __toESM(require_i18n(), 1);
25200
25201 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25202 function isValidRequiredForArray(item, field) {
25203 const value = field.getValue({ item });
25204 return Array.isArray(value) && value.length > 0 && value.every(
25205 (element) => ![void 0, "", null].includes(element)
25206 );
25207 }
25208
25209 // packages/dataviews/build-module/field-types/array.mjs
25210 function getValueFormatted7({
25211 item,
25212 field
25213 }) {
25214 const value = field.getValue({ item });
25215 const arr = Array.isArray(value) ? value : [];
25216 return arr.join(", ");
25217 }
25218 function render2({ item, field }) {
25219 return getValueFormatted7({ item, field });
25220 }
25221 function isValidCustom5(item, field) {
25222 const value = field.getValue({ item });
25223 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25224 return (0, import_i18n43.__)("Value must be an array.");
25225 }
25226 if (!value.every((v2) => typeof v2 === "string")) {
25227 return (0, import_i18n43.__)("Every value must be a string.");
25228 }
25229 return null;
25230 }
25231 var sort4 = (a2, b2, direction) => {
25232 const arrA = Array.isArray(a2) ? a2 : [];
25233 const arrB = Array.isArray(b2) ? b2 : [];
25234 if (arrA.length !== arrB.length) {
25235 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25236 }
25237 const joinedA = arrA.join(",");
25238 const joinedB = arrB.join(",");
25239 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25240 };
25241 var array_default = {
25242 type: "array",
25243 render: render2,
25244 Edit: "array",
25245 sort: sort4,
25246 enableSorting: true,
25247 enableGlobalSearch: false,
25248 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25249 validOperators: [
25250 OPERATOR_IS_ANY,
25251 OPERATOR_IS_NONE,
25252 OPERATOR_IS_ALL,
25253 OPERATOR_IS_NOT_ALL
25254 ],
25255 format: {},
25256 getValueFormatted: getValueFormatted7,
25257 validate: {
25258 required: isValidRequiredForArray,
25259 elements: isValidElements,
25260 custom: isValidCustom5
25261 }
25262 };
25263
25264 // packages/dataviews/build-module/field-types/password.mjs
25265 function getValueFormatted8({
25266 item,
25267 field
25268 }) {
25269 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25270 }
25271 var password_default = {
25272 type: "password",
25273 render,
25274 Edit: "password",
25275 sort: () => 0,
25276 // Passwords should not be sortable for security reasons
25277 enableSorting: false,
25278 enableGlobalSearch: false,
25279 defaultOperators: [],
25280 validOperators: [],
25281 format: {},
25282 getValueFormatted: getValueFormatted8,
25283 validate: {
25284 required: isValidRequired,
25285 pattern: isValidPattern,
25286 minLength: isValidMinLength,
25287 maxLength: isValidMaxLength,
25288 elements: isValidElements
25289 }
25290 };
25291
25292 // packages/dataviews/build-module/field-types/telephone.mjs
25293 var telephone_default = {
25294 type: "telephone",
25295 render,
25296 Edit: "telephone",
25297 sort: sort_text_default,
25298 enableSorting: true,
25299 enableGlobalSearch: false,
25300 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25301 validOperators: [
25302 OPERATOR_IS,
25303 OPERATOR_IS_NOT,
25304 OPERATOR_CONTAINS,
25305 OPERATOR_NOT_CONTAINS,
25306 OPERATOR_STARTS_WITH,
25307 // Multiple selection
25308 OPERATOR_IS_ANY,
25309 OPERATOR_IS_NONE,
25310 OPERATOR_IS_ALL,
25311 OPERATOR_IS_NOT_ALL
25312 ],
25313 format: {},
25314 getValueFormatted: get_value_formatted_default_default,
25315 validate: {
25316 required: isValidRequired,
25317 pattern: isValidPattern,
25318 minLength: isValidMinLength,
25319 maxLength: isValidMaxLength,
25320 elements: isValidElements
25321 }
25322 };
25323
25324 // packages/dataviews/build-module/field-types/color.mjs
25325 var import_i18n44 = __toESM(require_i18n(), 1);
25326 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25327 function render3({ item, field }) {
25328 if (field.hasElements) {
25329 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
25330 }
25331 const value = get_value_formatted_default_default({ item, field });
25332 if (!value || !w(value).isValid()) {
25333 return value;
25334 }
25335 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25336 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25337 "div",
25338 {
25339 style: {
25340 width: "16px",
25341 height: "16px",
25342 borderRadius: "50%",
25343 backgroundColor: value,
25344 border: "1px solid #ddd",
25345 flexShrink: 0
25346 }
25347 }
25348 ),
25349 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { children: value })
25350 ] });
25351 }
25352 function isValidCustom6(item, field) {
25353 const value = field.getValue({ item });
25354 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25355 return (0, import_i18n44.__)("Value must be a valid color.");
25356 }
25357 return null;
25358 }
25359 var sort5 = (a2, b2, direction) => {
25360 const colorA = w(a2);
25361 const colorB = w(b2);
25362 if (!colorA.isValid() && !colorB.isValid()) {
25363 return 0;
25364 }
25365 if (!colorA.isValid()) {
25366 return direction === "asc" ? 1 : -1;
25367 }
25368 if (!colorB.isValid()) {
25369 return direction === "asc" ? -1 : 1;
25370 }
25371 const hslA = colorA.toHsl();
25372 const hslB = colorB.toHsl();
25373 if (hslA.h !== hslB.h) {
25374 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25375 }
25376 if (hslA.s !== hslB.s) {
25377 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25378 }
25379 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25380 };
25381 var color_default = {
25382 type: "color",
25383 render: render3,
25384 Edit: "color",
25385 sort: sort5,
25386 enableSorting: true,
25387 enableGlobalSearch: false,
25388 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25389 validOperators: [
25390 OPERATOR_IS,
25391 OPERATOR_IS_NOT,
25392 OPERATOR_IS_ANY,
25393 OPERATOR_IS_NONE
25394 ],
25395 format: {},
25396 getValueFormatted: get_value_formatted_default_default,
25397 validate: {
25398 required: isValidRequired,
25399 elements: isValidElements,
25400 custom: isValidCustom6
25401 }
25402 };
25403
25404 // packages/dataviews/build-module/field-types/url.mjs
25405 var url_default = {
25406 type: "url",
25407 render,
25408 Edit: "url",
25409 sort: sort_text_default,
25410 enableSorting: true,
25411 enableGlobalSearch: false,
25412 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25413 validOperators: [
25414 OPERATOR_IS,
25415 OPERATOR_IS_NOT,
25416 OPERATOR_CONTAINS,
25417 OPERATOR_NOT_CONTAINS,
25418 OPERATOR_STARTS_WITH,
25419 // Multiple selection
25420 OPERATOR_IS_ANY,
25421 OPERATOR_IS_NONE,
25422 OPERATOR_IS_ALL,
25423 OPERATOR_IS_NOT_ALL
25424 ],
25425 format: {},
25426 getValueFormatted: get_value_formatted_default_default,
25427 validate: {
25428 required: isValidRequired,
25429 pattern: isValidPattern,
25430 minLength: isValidMinLength,
25431 maxLength: isValidMaxLength,
25432 elements: isValidElements
25433 }
25434 };
25435
25436 // packages/dataviews/build-module/field-types/no-type.mjs
25437 var sort6 = (a2, b2, direction) => {
25438 if (typeof a2 === "number" && typeof b2 === "number") {
25439 return sort_number_default(a2, b2, direction);
25440 }
25441 return sort_text_default(a2, b2, direction);
25442 };
25443 var no_type_default = {
25444 // type: no type for this one
25445 render,
25446 Edit: null,
25447 sort: sort6,
25448 enableSorting: true,
25449 enableGlobalSearch: false,
25450 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25451 validOperators: getAllOperatorNames(),
25452 format: {},
25453 getValueFormatted: get_value_formatted_default_default,
25454 validate: {
25455 required: isValidRequired,
25456 elements: isValidElements
25457 }
25458 };
25459
25460 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25461 function supportsNumericRangeConstraint(type) {
25462 return type === "integer" || type === "number";
25463 }
25464 function supportsDateRangeConstraint(type) {
25465 return type === "date" || type === "datetime";
25466 }
25467 function normalizeRangeRule(value, fieldType, key) {
25468 const validator = fieldType.validate[key];
25469 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25470 return { constraint: value, validate: validator };
25471 }
25472 return void 0;
25473 }
25474 function getIsValid(field, fieldType) {
25475 const rules = field.isValid;
25476 let required;
25477 if (rules?.required === true && fieldType.validate.required !== void 0) {
25478 required = {
25479 constraint: true,
25480 validate: fieldType.validate.required
25481 };
25482 }
25483 let elements;
25484 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25485 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25486 elements = {
25487 constraint: true,
25488 validate: fieldType.validate.elements
25489 };
25490 }
25491 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25492 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25493 const minLengthValue = rules?.minLength;
25494 let minLength;
25495 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25496 minLength = {
25497 constraint: minLengthValue,
25498 validate: fieldType.validate.minLength
25499 };
25500 }
25501 const maxLengthValue = rules?.maxLength;
25502 let maxLength;
25503 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25504 maxLength = {
25505 constraint: maxLengthValue,
25506 validate: fieldType.validate.maxLength
25507 };
25508 }
25509 const patternValue = rules?.pattern;
25510 let pattern;
25511 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25512 pattern = {
25513 constraint: patternValue,
25514 validate: fieldType.validate.pattern
25515 };
25516 }
25517 const custom = rules?.custom ?? fieldType.validate.custom;
25518 return {
25519 required,
25520 elements,
25521 min: min2,
25522 max: max2,
25523 minLength,
25524 maxLength,
25525 pattern,
25526 custom
25527 };
25528 }
25529
25530 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25531 function getFilter(fieldType) {
25532 return fieldType.validOperators.reduce((accumulator, operator) => {
25533 const operatorObj = getOperatorByName(operator);
25534 if (operatorObj?.filter) {
25535 accumulator[operator] = operatorObj.filter;
25536 }
25537 return accumulator;
25538 }, {});
25539 }
25540
25541 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25542 function getFormat(field, fieldType) {
25543 return {
25544 ...fieldType.format,
25545 ...field.format
25546 };
25547 }
25548 var get_format_default = getFormat;
25549
25550 // packages/dataviews/build-module/field-types/index.mjs
25551 function getFieldTypeByName(type) {
25552 const found = [
25553 email_default,
25554 integer_default,
25555 number_default,
25556 text_default,
25557 datetime_default,
25558 date_default,
25559 boolean_default,
25560 media_default,
25561 array_default,
25562 password_default,
25563 telephone_default,
25564 color_default,
25565 url_default
25566 ].find((fieldType) => fieldType?.type === type);
25567 if (!!found) {
25568 return found;
25569 }
25570 return no_type_default;
25571 }
25572 function normalizeFields(fields) {
25573 return fields.map((field) => {
25574 const fieldType = getFieldTypeByName(field.type);
25575 const getValue = field.getValue || get_value_from_id_default(field.id);
25576 const sort7 = function(a2, b2, direction) {
25577 const aValue = getValue({ item: a2 });
25578 const bValue = getValue({ item: b2 });
25579 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25580 };
25581 return {
25582 id: field.id,
25583 label: field.label || field.id,
25584 header: field.header || field.label || field.id,
25585 description: field.description,
25586 placeholder: field.placeholder,
25587 getValue,
25588 setValue: field.setValue || set_value_from_id_default(field.id),
25589 elements: field.elements,
25590 getElements: field.getElements,
25591 hasElements: hasElements(field),
25592 isVisible: field.isVisible,
25593 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25594 enableHiding: field.enableHiding ?? true,
25595 readOnly: field.readOnly ?? false,
25596 // The type provides defaults for the following props
25597 type: fieldType.type,
25598 render: field.render ?? fieldType.render,
25599 Edit: getControl(field, fieldType.Edit),
25600 sort: sort7,
25601 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25602 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25603 isValid: getIsValid(field, fieldType),
25604 filterBy: get_filter_by_default(
25605 field,
25606 fieldType.defaultOperators,
25607 fieldType.validOperators
25608 ),
25609 filter: getFilter(fieldType),
25610 format: get_format_default(field, fieldType),
25611 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25612 };
25613 });
25614 }
25615
25616 // packages/dataviews/build-module/hooks/use-data.mjs
25617 var import_element81 = __toESM(require_element(), 1);
25618 function useData({
25619 view,
25620 data: shownData,
25621 getItemId,
25622 isLoading,
25623 paginationInfo,
25624 selection
25625 }) {
25626 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25627 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element81.useState)(
25628 !isLoading
25629 );
25630 (0, import_element81.useEffect)(() => {
25631 if (!isLoading) {
25632 setHasInitiallyLoaded(true);
25633 }
25634 }, [isLoading]);
25635 const previousDataRef = (0, import_element81.useRef)(shownData);
25636 const previousPaginationInfoRef = (0, import_element81.useRef)(paginationInfo);
25637 (0, import_element81.useEffect)(() => {
25638 if (!isLoading) {
25639 previousDataRef.current = shownData;
25640 previousPaginationInfoRef.current = paginationInfo;
25641 }
25642 }, [shownData, isLoading, paginationInfo]);
25643 const [visibleEntries, setVisibleEntries] = (0, import_element81.useState)([]);
25644 const positionMapRef = (0, import_element81.useRef)(/* @__PURE__ */ new Map());
25645 const allLoadedRecordsRef = (0, import_element81.useRef)([]);
25646 const prevViewParamsRef = (0, import_element81.useRef)({
25647 search: void 0,
25648 filters: void 0,
25649 perPage: void 0
25650 });
25651 const scrollDirectionRef = (0, import_element81.useRef)(void 0);
25652 const prevStartPositionRef = (0, import_element81.useRef)(void 0);
25653 const hasInitializedRef = (0, import_element81.useRef)(false);
25654 const allLoadedRecords = (0, import_element81.useMemo)(() => {
25655 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25656 if (view.startPosition < prevStartPositionRef.current) {
25657 scrollDirectionRef.current = "up";
25658 } else if (view.startPosition > prevStartPositionRef.current) {
25659 scrollDirectionRef.current = "down";
25660 }
25661 }
25662 prevStartPositionRef.current = view.startPosition;
25663 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25664 const prevFiltersKey = prevViewParamsRef.current.filters;
25665 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25666 hasInitializedRef.current = true;
25667 prevViewParamsRef.current = {
25668 search: view.search,
25669 filters: currentFiltersKey,
25670 perPage: view.perPage
25671 };
25672 if (shouldReset) {
25673 positionMapRef.current.clear();
25674 scrollDirectionRef.current = void 0;
25675 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25676 const records = shownData.map((record, index2) => {
25677 const position = startPosition + index2;
25678 positionMapRef.current.set(getItemId(record), position);
25679 return {
25680 ...record,
25681 position
25682 };
25683 });
25684 allLoadedRecordsRef.current = records;
25685 return records;
25686 }
25687 const prev = allLoadedRecordsRef.current;
25688 const shownDataIds = new Set(shownData.map(getItemId));
25689 const scrollDirection = scrollDirectionRef.current;
25690 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25691 const newRecords = shownData.map((record, index2) => {
25692 const itemId = getItemId(record);
25693 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25694 if (position !== void 0) {
25695 positionMapRef.current.set(itemId, position);
25696 }
25697 return {
25698 ...record,
25699 position
25700 };
25701 });
25702 if (newRecords.length === 0) {
25703 return prev;
25704 }
25705 const prevWithoutDuplicates = prev.filter(
25706 (record) => !shownDataIds.has(getItemId(record))
25707 );
25708 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25709 allRecords.sort((a2, b2) => {
25710 const posA = a2.position;
25711 const posB = b2.position;
25712 return posA - posB;
25713 });
25714 let result = allRecords;
25715 if (visibleEntries.length > 0) {
25716 const visibleMin = Math.min(...visibleEntries);
25717 const visibleMax = Math.max(...visibleEntries);
25718 const buffer = 20;
25719 const recordPositions = allRecords.map(
25720 (r3) => r3.position
25721 );
25722 const minRecordPos = Math.min(...recordPositions);
25723 const maxRecordPos = Math.max(...recordPositions);
25724 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25725 if (hasOverlap) {
25726 result = allRecords.filter((record) => {
25727 const itemId = getItemId(record);
25728 const isSelected2 = selection?.includes(itemId);
25729 if (isSelected2) {
25730 return true;
25731 }
25732 const itemPosition = record.position;
25733 if (scrollDirection === "up") {
25734 return itemPosition <= visibleMax + buffer;
25735 } else if (scrollDirection === "down") {
25736 return itemPosition >= visibleMin - buffer;
25737 }
25738 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25739 });
25740 }
25741 }
25742 allLoadedRecordsRef.current = result;
25743 return result;
25744 }, [
25745 shownData,
25746 view.search,
25747 view.filters,
25748 view.perPage,
25749 view.startPosition,
25750 view.infiniteScrollEnabled,
25751 visibleEntries,
25752 selection,
25753 getItemId
25754 ]);
25755 if (!isInfiniteScrollEnabled) {
25756 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25757 return {
25758 data: dataToReturn.map((item) => ({
25759 ...item,
25760 position: void 0
25761 })),
25762 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25763 hasInitiallyLoaded,
25764 setVisibleEntries: void 0
25765 };
25766 }
25767 return {
25768 data: allLoadedRecords,
25769 paginationInfo,
25770 hasInitiallyLoaded,
25771 setVisibleEntries
25772 };
25773 }
25774
25775 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25776 var import_element82 = __toESM(require_element(), 1);
25777 var import_compose12 = __toESM(require_compose(), 1);
25778 function captureAnchorElement(container, anchorElementRef, direction) {
25779 const containerRect = container.getBoundingClientRect();
25780 const centerY = containerRect.top + containerRect.height / 2;
25781 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25782 if (items.length === 0) {
25783 return false;
25784 }
25785 const bestAnchor = items.reduce((best, item) => {
25786 const itemRect = item.getBoundingClientRect();
25787 const itemCenterY = itemRect.top + itemRect.height / 2;
25788 const distance = Math.abs(itemCenterY - centerY);
25789 const bestRect = best.getBoundingClientRect();
25790 const bestCenterY = bestRect.top + bestRect.height / 2;
25791 const bestDistance = Math.abs(bestCenterY - centerY);
25792 return distance < bestDistance ? item : best;
25793 });
25794 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25795 const anchorRect = bestAnchor.getBoundingClientRect();
25796 anchorElementRef.current = {
25797 posinset,
25798 viewportOffset: anchorRect.top - containerRect.top,
25799 direction
25800 };
25801 return true;
25802 }
25803 function useInfiniteScroll({
25804 view,
25805 onChangeView,
25806 isLoading,
25807 paginationInfo,
25808 containerRef,
25809 setVisibleEntries
25810 }) {
25811 const anchorElementRef = (0, import_element82.useRef)(null);
25812 const viewRef = (0, import_element82.useRef)(view);
25813 const isLoadingRef = (0, import_element82.useRef)(isLoading);
25814 const onChangeViewRef = (0, import_element82.useRef)(onChangeView);
25815 const totalItemsRef = (0, import_element82.useRef)(paginationInfo.totalItems);
25816 (0, import_element82.useLayoutEffect)(() => {
25817 viewRef.current = view;
25818 isLoadingRef.current = isLoading;
25819 onChangeViewRef.current = onChangeView;
25820 totalItemsRef.current = paginationInfo.totalItems;
25821 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25822 const intersectionObserverCallback = (0, import_element82.useCallback)(
25823 (entries) => {
25824 if (!setVisibleEntries) {
25825 return;
25826 }
25827 setVisibleEntries((prev) => {
25828 const newVisibleEntries = new Set(prev);
25829 let hasChanged = false;
25830 entries.forEach((entry) => {
25831 const posInSet = Number(
25832 entry.target?.attributes?.getNamedItem(
25833 "aria-posinset"
25834 )?.value
25835 );
25836 if (isNaN(posInSet)) {
25837 return;
25838 }
25839 if (entry.isIntersecting) {
25840 if (!newVisibleEntries.has(posInSet)) {
25841 newVisibleEntries.add(posInSet);
25842 hasChanged = true;
25843 }
25844 } else if (newVisibleEntries.has(posInSet)) {
25845 newVisibleEntries.delete(posInSet);
25846 hasChanged = true;
25847 }
25848 });
25849 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25850 });
25851 },
25852 [setVisibleEntries]
25853 );
25854 (0, import_element82.useLayoutEffect)(() => {
25855 const container = containerRef.current;
25856 const anchor = anchorElementRef.current;
25857 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25858 return;
25859 }
25860 const anchorElement = container.querySelector(
25861 `[aria-posinset="${anchor.posinset}"]`
25862 );
25863 if (anchorElement) {
25864 const containerRect = container.getBoundingClientRect();
25865 const anchorRect = anchorElement.getBoundingClientRect();
25866 const currentOffset = anchorRect.top - containerRect.top;
25867 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25868 if (Math.abs(scrollAdjustment) > 1) {
25869 container.scrollTop += scrollAdjustment;
25870 }
25871 }
25872 anchorElementRef.current = null;
25873 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25874 const intersectionObserverRef = (0, import_element82.useRef)(
25875 null
25876 );
25877 (0, import_element82.useEffect)(() => {
25878 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25879 if (intersectionObserverRef.current) {
25880 intersectionObserverRef.current.disconnect();
25881 intersectionObserverRef.current = null;
25882 }
25883 return;
25884 }
25885 intersectionObserverRef.current = new IntersectionObserver(
25886 intersectionObserverCallback,
25887 { root: null, rootMargin: "0px", threshold: 0.1 }
25888 );
25889 return () => {
25890 if (intersectionObserverRef.current) {
25891 intersectionObserverRef.current.disconnect();
25892 intersectionObserverRef.current = null;
25893 }
25894 };
25895 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25896 (0, import_element82.useEffect)(() => {
25897 if (!view.infiniteScrollEnabled || !containerRef.current) {
25898 return;
25899 }
25900 let lastScrollTop = 0;
25901 const BOTTOM_THRESHOLD = 600;
25902 const TOP_THRESHOLD = 800;
25903 const handleScroll = (0, import_compose12.throttle)((event) => {
25904 const currentView = viewRef.current;
25905 const totalItems = totalItemsRef.current;
25906 const target = event.target;
25907 const scrollTop = target.scrollTop;
25908 const scrollHeight = target.scrollHeight;
25909 const clientHeight = target.clientHeight;
25910 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25911 lastScrollTop = scrollTop;
25912 if (isLoadingRef.current) {
25913 return;
25914 }
25915 const currentStartPosition = currentView.startPosition || 1;
25916 const batchSize = currentView.perPage || 10;
25917 const currentEndPosition = Math.min(
25918 currentStartPosition + batchSize,
25919 totalItems
25920 );
25921 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25922 if (currentEndPosition < totalItems) {
25923 const newStartPosition = currentEndPosition;
25924 captureAnchorElement(target, anchorElementRef, "down");
25925 onChangeViewRef.current({
25926 ...currentView,
25927 startPosition: newStartPosition
25928 });
25929 }
25930 }
25931 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25932 if (currentStartPosition > 1) {
25933 const calculatedStartPosition = currentStartPosition - batchSize;
25934 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25935 captureAnchorElement(target, anchorElementRef, "up");
25936 onChangeViewRef.current({
25937 ...currentView,
25938 startPosition: newStartPosition
25939 });
25940 }
25941 }
25942 }, 50);
25943 const container = containerRef.current;
25944 container.addEventListener("scroll", handleScroll);
25945 return () => {
25946 container.removeEventListener("scroll", handleScroll);
25947 handleScroll.cancel();
25948 };
25949 }, [containerRef, view.infiniteScrollEnabled]);
25950 return {
25951 intersectionObserver: intersectionObserverRef.current
25952 };
25953 }
25954
25955 // packages/dataviews/build-module/dataviews/index.mjs
25956 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25957 var defaultGetItemId = (item) => item.id;
25958 var defaultIsItemClickable = () => true;
25959 var EMPTY_ARRAY6 = [];
25960 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25961 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25962 (viewLayout) => !viewLayout.isPicker
25963 );
25964 function DefaultUI({
25965 header,
25966 search = true,
25967 searchLabel = void 0
25968 }) {
25969 const { view } = (0, import_element83.useContext)(dataviews_context_default);
25970 const isInfiniteScroll = view.infiniteScrollEnabled;
25971 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
25972 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
25973 Stack,
25974 {
25975 direction: "row",
25976 align: "top",
25977 justify: "space-between",
25978 className: clsx_default("dataviews__view-actions", {
25979 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25980 }),
25981 gap: "xs",
25982 children: [
25983 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
25984 Stack,
25985 {
25986 direction: "row",
25987 justify: "start",
25988 gap: "sm",
25989 className: "dataviews__search",
25990 children: [
25991 search && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_search_default, { label: searchLabel }),
25992 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(toggle_default, {})
25993 ]
25994 }
25995 ),
25996 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
25997 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_view_config_default, {}),
25998 header
25999 ] })
26000 ]
26001 }
26002 ),
26003 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26004 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsLayout, {}),
26005 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsFooter, {})
26006 ] });
26007 }
26008 function DataViews({
26009 view,
26010 onChangeView,
26011 fields,
26012 search = true,
26013 searchLabel = void 0,
26014 actions = EMPTY_ARRAY6,
26015 data,
26016 getItemId = defaultGetItemId,
26017 getItemLevel,
26018 isLoading = false,
26019 paginationInfo,
26020 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26021 selection: selectionProperty,
26022 onChangeSelection,
26023 onClickItem,
26024 renderItemLink,
26025 isItemClickable = defaultIsItemClickable,
26026 header,
26027 children,
26028 config = { perPageSizes: [10, 20, 50, 100] },
26029 empty,
26030 onReset
26031 }) {
26032 const [selectionState, setSelectionState] = (0, import_element83.useState)([]);
26033 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26034 const selection = isUncontrolled ? selectionState : selectionProperty;
26035 const {
26036 data: displayData,
26037 paginationInfo: displayPaginationInfo,
26038 hasInitiallyLoaded,
26039 setVisibleEntries
26040 } = useData({
26041 view,
26042 data,
26043 getItemId,
26044 isLoading,
26045 selection,
26046 paginationInfo
26047 });
26048 const containerRef = (0, import_element83.useRef)(null);
26049 const [containerWidth, setContainerWidth] = (0, import_element83.useState)(0);
26050 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
26051 (resizeObserverEntries) => {
26052 setContainerWidth(
26053 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26054 );
26055 },
26056 { box: "border-box" }
26057 );
26058 const [openedFilter, setOpenedFilter] = (0, import_element83.useState)(null);
26059 function setSelectionWithChange(value) {
26060 const newValue = typeof value === "function" ? value(selection) : value;
26061 if (isUncontrolled) {
26062 setSelectionState(newValue);
26063 }
26064 if (onChangeSelection) {
26065 onChangeSelection(newValue);
26066 }
26067 }
26068 const _fields = (0, import_element83.useMemo)(() => normalizeFields(fields), [fields]);
26069 const _selection = (0, import_element83.useMemo)(() => {
26070 if (view.infiniteScrollEnabled) {
26071 return selection;
26072 }
26073 return selection.filter(
26074 (id) => data.some((item) => getItemId(item) === id)
26075 );
26076 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26077 const filters = use_filters_default(_fields, view);
26078 const hasPrimaryOrLockedFilters = (0, import_element83.useMemo)(
26079 () => (filters || []).some(
26080 (filter) => filter.isPrimary || filter.isLocked
26081 ),
26082 [filters]
26083 );
26084 const [isShowingFilter, setIsShowingFilter] = (0, import_element83.useState)(
26085 hasPrimaryOrLockedFilters
26086 );
26087 const { intersectionObserver } = useInfiniteScroll({
26088 view,
26089 onChangeView,
26090 isLoading,
26091 paginationInfo,
26092 containerRef,
26093 setVisibleEntries
26094 });
26095 (0, import_element83.useEffect)(() => {
26096 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26097 setIsShowingFilter(true);
26098 }
26099 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26100 const defaultLayouts = (0, import_element83.useMemo)(
26101 () => Object.fromEntries(
26102 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26103 return dataViewsLayouts.some(
26104 (viewLayout) => viewLayout.type === layoutType
26105 );
26106 }).map(([key, value]) => [
26107 key,
26108 value === true ? {} : value
26109 ])
26110 ),
26111 [defaultLayoutsProperty]
26112 );
26113 if (!defaultLayouts[view.type]) {
26114 return null;
26115 }
26116 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26117 dataviews_context_default.Provider,
26118 {
26119 value: {
26120 view,
26121 onChangeView,
26122 fields: _fields,
26123 actions,
26124 data: displayData,
26125 isLoading,
26126 paginationInfo: displayPaginationInfo,
26127 selection: _selection,
26128 onChangeSelection: setSelectionWithChange,
26129 openedFilter,
26130 setOpenedFilter,
26131 getItemId,
26132 getItemLevel,
26133 isItemClickable,
26134 onClickItem,
26135 renderItemLink,
26136 containerWidth,
26137 containerRef,
26138 resizeObserverRef,
26139 defaultLayouts,
26140 filters,
26141 isShowingFilter,
26142 setIsShowingFilter,
26143 config,
26144 empty,
26145 hasInitiallyLoaded,
26146 onReset,
26147 intersectionObserver
26148 },
26149 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26150 DefaultUI,
26151 {
26152 header,
26153 search,
26154 searchLabel
26155 }
26156 ) })
26157 }
26158 );
26159 }
26160 var DataViewsSubComponents = DataViews;
26161 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26162 DataViewsSubComponents.Filters = filters_default;
26163 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26164 DataViewsSubComponents.FiltersToggle = toggle_default;
26165 DataViewsSubComponents.Layout = DataViewsLayout;
26166 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26167 DataViewsSubComponents.Pagination = DataViewsPagination;
26168 DataViewsSubComponents.Search = dataviews_search_default;
26169 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26170 DataViewsSubComponents.Footer = DataViewsFooter;
26171 var dataviews_default = DataViewsSubComponents;
26172
26173 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26174 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26175 var import_deprecated = __toESM(require_deprecated(), 1);
26176 function normalizeSearchInput2(input = "") {
26177 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26178 }
26179 var EMPTY_ARRAY7 = [];
26180 function filterSortAndPaginate(data, view, fields) {
26181 if (!data) {
26182 return {
26183 data: EMPTY_ARRAY7,
26184 paginationInfo: { totalItems: 0, totalPages: 0 }
26185 };
26186 }
26187 const _fields = normalizeFields(fields);
26188 let filteredData = [...data];
26189 if (view.search) {
26190 const normalizedSearch = normalizeSearchInput2(view.search);
26191 filteredData = filteredData.filter((item) => {
26192 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26193 const fieldValue = field.getValue({ item });
26194 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26195 return values.some(
26196 (value) => normalizeSearchInput2(String(value)).includes(
26197 normalizedSearch
26198 )
26199 );
26200 });
26201 });
26202 }
26203 if (view.filters && view.filters?.length > 0) {
26204 view.filters.forEach((filter) => {
26205 const field = _fields.find(
26206 (_field) => _field.id === filter.field
26207 );
26208 if (field) {
26209 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26210 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26211 since: "7.0",
26212 alternative: "'isNone'"
26213 });
26214 }
26215 const handler = field.filter[filter.operator];
26216 if (handler) {
26217 filteredData = filteredData.filter(
26218 (item) => handler(item, field, filter.value)
26219 );
26220 }
26221 }
26222 });
26223 }
26224 const sortByField = view.sort?.field ? _fields.find((field) => {
26225 return field.enableSorting !== false && field.id === view.sort?.field;
26226 }) : null;
26227 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26228 return field.enableSorting !== false && field.id === view.groupBy?.field;
26229 }) : null;
26230 if (sortByField || groupByField) {
26231 filteredData.sort((a2, b2) => {
26232 if (groupByField) {
26233 const groupCompare = groupByField.sort(
26234 a2,
26235 b2,
26236 view.groupBy?.direction ?? "asc"
26237 );
26238 if (groupCompare !== 0) {
26239 return groupCompare;
26240 }
26241 }
26242 if (sortByField) {
26243 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26244 }
26245 return 0;
26246 });
26247 }
26248 let totalItems = filteredData.length;
26249 let totalPages = 1;
26250 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26251 const start = view.startPosition - 1;
26252 const end = Math.min(start + view.perPage, totalItems);
26253 filteredData = filteredData?.slice(start, end);
26254 } else if (view.page !== void 0 && view.perPage !== void 0) {
26255 const start = (view.page - 1) * view.perPage;
26256 totalItems = filteredData?.length || 0;
26257 totalPages = Math.ceil(totalItems / view.perPage);
26258 filteredData = filteredData?.slice(start, start + view.perPage);
26259 }
26260 return {
26261 data: filteredData,
26262 paginationInfo: {
26263 totalItems,
26264 totalPages
26265 }
26266 };
26267 }
26268
26269 // packages/style-runtime/src/index.ts
26270 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26271 function getRuntime14() {
26272 const globalScope = globalThis;
26273 if (globalScope.__wpStyleRuntime) {
26274 return globalScope.__wpStyleRuntime;
26275 }
26276 globalScope.__wpStyleRuntime = {
26277 documents: /* @__PURE__ */ new Map(),
26278 styles: /* @__PURE__ */ new Map(),
26279 injectedStyles: /* @__PURE__ */ new WeakMap()
26280 };
26281 if (typeof document !== "undefined") {
26282 registerDocument14(document);
26283 }
26284 return globalScope.__wpStyleRuntime;
26285 }
26286 function documentContainsStyleHash14(targetDocument, hash) {
26287 if (!targetDocument.head) {
26288 return false;
26289 }
26290 for (const style of targetDocument.head.querySelectorAll(
26291 `style[${STYLE_HASH_ATTRIBUTE14}]`
26292 )) {
26293 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26294 return true;
26295 }
26296 }
26297 return false;
26298 }
26299 function injectStyle14(targetDocument, hash, css) {
26300 if (!targetDocument.head) {
26301 return;
26302 }
26303 const runtime = getRuntime14();
26304 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26305 if (!injectedStyles) {
26306 injectedStyles = /* @__PURE__ */ new Set();
26307 runtime.injectedStyles.set(targetDocument, injectedStyles);
26308 }
26309 if (injectedStyles.has(hash)) {
26310 return;
26311 }
26312 if (documentContainsStyleHash14(targetDocument, hash)) {
26313 injectedStyles.add(hash);
26314 return;
26315 }
26316 const style = targetDocument.createElement("style");
26317 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26318 style.appendChild(targetDocument.createTextNode(css));
26319 targetDocument.head.appendChild(style);
26320 injectedStyles.add(hash);
26321 }
26322 function registerDocument14(targetDocument) {
26323 const runtime = getRuntime14();
26324 runtime.documents.set(
26325 targetDocument,
26326 (runtime.documents.get(targetDocument) ?? 0) + 1
26327 );
26328 for (const [hash, css] of runtime.styles) {
26329 injectStyle14(targetDocument, hash, css);
26330 }
26331 return () => {
26332 const count = runtime.documents.get(targetDocument);
26333 if (count === void 0) {
26334 return;
26335 }
26336 if (count <= 1) {
26337 runtime.documents.delete(targetDocument);
26338 return;
26339 }
26340 runtime.documents.set(targetDocument, count - 1);
26341 };
26342 }
26343 function registerStyle14(hash, css) {
26344 const runtime = getRuntime14();
26345 runtime.styles.set(hash, css);
26346 for (const targetDocument of runtime.documents.keys()) {
26347 injectStyle14(targetDocument, hash, css);
26348 }
26349 }
26350
26351 // widgets/activity/style.module.css
26352 if (typeof process === "undefined" || true) {
26353 registerStyle14("4aa3daa799", "._784d2967c5e53514__loading{height:100%}._21768f83511c9ec9__list{max-height:420px}");
26354 }
26355 var style_default13 = { "loading": "_784d2967c5e53514__loading", "list": "_21768f83511c9ec9__list" };
26356
26357 // widgets/activity/render.tsx
26358 var import_jsx_runtime118 = __toESM(require_jsx_runtime());
26359 function formatGroupDate(dateStr) {
26360 const now = (0, import_date10.getDate)();
26361 const today = (0, import_date10.dateI18n)("Y-m-d", now);
26362 if (dateStr === today) {
26363 return (0, import_i18n45.__)("Today");
26364 }
26365 const yesterday = (0, import_date10.getDate)();
26366 yesterday.setDate(yesterday.getDate() - 1);
26367 const yesterdayStr = (0, import_date10.dateI18n)("Y-m-d", yesterday);
26368 if (dateStr === yesterdayStr) {
26369 return (0, import_i18n45.__)("Yesterday");
26370 }
26371 const currentYear = (0, import_date10.dateI18n)("Y", now);
26372 if (dateStr.slice(0, 4) === currentYear) {
26373 return (0, import_date10.dateI18n)((0, import_i18n45.__)("M jS"), dateStr);
26374 }
26375 return (0, import_date10.dateI18n)((0, import_i18n45.__)("M jS Y"), dateStr);
26376 }
26377 function htmlToPlainText(html) {
26378 const { body } = new window.DOMParser().parseFromString(
26379 html,
26380 "text/html"
26381 );
26382 return (body.textContent ?? "").trim();
26383 }
26384 var FIELDS = [
26385 {
26386 id: "icon",
26387 label: (0, import_i18n45.__)("Icon"),
26388 type: "media",
26389 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(icon_default, { icon: item.kind === "comment" ? comment_default : post_list_default }),
26390 enableSorting: false,
26391 enableHiding: false
26392 },
26393 {
26394 id: "title",
26395 label: (0, import_i18n45.__)("Title"),
26396 type: "text",
26397 getValue: ({ item }) => item.title,
26398 enableSorting: false,
26399 enableGlobalSearch: true
26400 },
26401 {
26402 id: "description",
26403 label: (0, import_i18n45.__)("Description"),
26404 type: "text",
26405 getValue: ({ item }) => item.description,
26406 enableSorting: false,
26407 enableGlobalSearch: true
26408 },
26409 {
26410 id: "datetime",
26411 label: (0, import_i18n45.__)("Time"),
26412 getValue: ({ item }) => item.datetime,
26413 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("span", { children: (0, import_date10.dateI18n)((0, import_i18n45.__)("g:i a"), item.datetime) }),
26414 enableSorting: true
26415 },
26416 {
26417 id: "date",
26418 label: (0, import_i18n45.__)("Date"),
26419 getValue: ({ item }) => item.datetime.split("T")[0],
26420 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("span", { children: formatGroupDate(item.datetime.split("T")[0]) }),
26421 enableSorting: true,
26422 enableHiding: false
26423 }
26424 ];
26425 var DEFAULT_PER_PAGE = 5;
26426 var SOURCE_COUNT = 3;
26427 var DEFAULT_VIEW = {
26428 type: "activity",
26429 search: "",
26430 page: 1,
26431 perPage: DEFAULT_PER_PAGE,
26432 filters: [],
26433 fields: ["datetime"],
26434 titleField: "title",
26435 descriptionField: "description",
26436 mediaField: "icon",
26437 showMedia: true,
26438 sort: {
26439 field: "datetime",
26440 direction: "desc"
26441 },
26442 groupBy: {
26443 field: "date",
26444 direction: "desc",
26445 showLabel: false
26446 }
26447 };
26448 function Activity({
26449 attributes
26450 }) {
26451 const perPage = Math.max(1, attributes?.perPage ?? DEFAULT_PER_PAGE);
26452 const [view, setView] = (0, import_element84.useState)(DEFAULT_VIEW);
26453 const queries = (0, import_element84.useMemo)(
26454 () => ({
26455 future: {
26456 status: "future",
26457 orderby: "date",
26458 order: "asc",
26459 per_page: perPage
26460 },
26461 recent: {
26462 status: "publish",
26463 orderby: "date",
26464 order: "desc",
26465 per_page: perPage
26466 },
26467 comments: { per_page: perPage }
26468 }),
26469 [perPage]
26470 );
26471 const { futurePosts, recentPosts, comments, isResolved } = (0, import_data6.useSelect)(
26472 (select) => {
26473 const coreData = select(import_core_data.store);
26474 return {
26475 futurePosts: coreData.getEntityRecords(
26476 "postType",
26477 "post",
26478 queries.future
26479 ),
26480 recentPosts: coreData.getEntityRecords(
26481 "postType",
26482 "post",
26483 queries.recent
26484 ),
26485 comments: coreData.getEntityRecords(
26486 "root",
26487 "comment",
26488 queries.comments
26489 ),
26490 isResolved: coreData.hasFinishedResolution("getEntityRecords", [
26491 "postType",
26492 "post",
26493 queries.future
26494 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26495 "postType",
26496 "post",
26497 queries.recent
26498 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26499 "root",
26500 "comment",
26501 queries.comments
26502 ])
26503 };
26504 },
26505 [queries]
26506 );
26507 const allEvents = (0, import_element84.useMemo)(() => {
26508 const events = [];
26509 for (const post of futurePosts ?? []) {
26510 events.push({
26511 id: `post-future-${post.id}`,
26512 datetime: post.date ?? "",
26513 title: (0, import_html_entities.decodeEntities)(
26514 post.title?.rendered ?? ""
26515 ),
26516 description: "",
26517 link: post.link ?? "",
26518 kind: "post-future"
26519 });
26520 }
26521 for (const post of recentPosts ?? []) {
26522 events.push({
26523 id: `post-published-${post.id}`,
26524 datetime: post.date ?? "",
26525 title: (0, import_html_entities.decodeEntities)(
26526 post.title?.rendered ?? ""
26527 ),
26528 description: "",
26529 link: post.link ?? "",
26530 kind: "post-published"
26531 });
26532 }
26533 for (const c2 of comments ?? []) {
26534 events.push({
26535 id: `comment-${c2.id}`,
26536 datetime: c2.date ?? "",
26537 title: (0, import_html_entities.decodeEntities)(c2.author_name ?? ""),
26538 description: htmlToPlainText(
26539 c2.content?.rendered ?? ""
26540 ),
26541 link: c2.link ?? "",
26542 kind: "comment"
26543 });
26544 }
26545 return events;
26546 }, [futurePosts, recentPosts, comments]);
26547 const resolvedView = (0, import_element84.useMemo)(
26548 () => ({ ...view, perPage: perPage * SOURCE_COUNT }),
26549 [view, perPage]
26550 );
26551 const { data: shownData, paginationInfo } = (0, import_element84.useMemo)(
26552 () => filterSortAndPaginate(allEvents, resolvedView, FIELDS),
26553 [allEvents, resolvedView]
26554 );
26555 if (!isResolved) {
26556 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26557 Stack,
26558 {
26559 direction: "column",
26560 align: "center",
26561 justify: "center",
26562 className: style_default13.loading,
26563 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components46.Spinner, {})
26564 }
26565 );
26566 }
26567 if (allEvents.length === 0) {
26568 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26569 Stack,
26570 {
26571 direction: "column",
26572 align: "center",
26573 justify: "center",
26574 className: style_default13.loading,
26575 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(empty_state_exports.Root, { children: [
26576 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26577 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Title, { children: (0, import_i18n45.__)("No activity yet.") }),
26578 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Description, { children: (0, import_i18n45.__)(
26579 "When you publish posts or receive comments, they will appear here."
26580 ) })
26581 ] })
26582 }
26583 );
26584 }
26585 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Stack, { direction: "column", className: style_default13.list, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26586 dataviews_default,
26587 {
26588 data: shownData,
26589 fields: FIELDS,
26590 view: resolvedView,
26591 onChangeView: setView,
26592 paginationInfo,
26593 getItemId: (item) => item.id,
26594 search: false,
26595 isLoading: false,
26596 defaultLayouts: {
26597 activity: {
26598 sort: {
26599 field: "datetime",
26600 direction: "desc"
26601 }
26602 }
26603 },
26604 renderItemLink: ({ item, children, ...aProps }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Link, { href: item.link, ...aProps, children }),
26605 isItemClickable: (item) => !!item.link,
26606 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_default.Layout, {})
26607 }
26608 ) });
26609 }
26610 export {
26611 Activity as default
26612 };
26613 /*! Bundled license information:
26614
26615 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26616 (**
26617 * @license React
26618 * use-sync-external-store-shim.development.js
26619 *
26620 * Copyright (c) Meta Platforms, Inc. and affiliates.
26621 *
26622 * This source code is licensed under the MIT license found in the
26623 * LICENSE file in the root directory of this source tree.
26624 *)
26625
26626 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26627 (**
26628 * @license React
26629 * use-sync-external-store-shim/with-selector.development.js
26630 *
26631 * Copyright (c) Meta Platforms, Inc. and affiliates.
26632 *
26633 * This source code is licensed under the MIT license found in the
26634 * LICENSE file in the root directory of this source tree.
26635 *)
26636 */
26637