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

render.js in Gutenberg 23.5.0, at build/widgets/news/render.js

26,426 lines 923.7 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/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React49.startTransition || (didWarnOld18Alpha = true, console.error(
76 "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."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState36({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect5(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect32(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React49.useState, useEffect32 = 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;
124 exports.useSyncExternalStore = void 0 !== React49.useSyncExternalStore ? React49.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React49.useRef, useEffect32 = React49.useEffect, useMemo40 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef46(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo40(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect32(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "\xC0": "A",
275 "\xC1": "A",
276 "\xC2": "A",
277 "\xC3": "A",
278 "\xC4": "A",
279 "\xC5": "A",
280 "\u1EA4": "A",
281 "\u1EAE": "A",
282 "\u1EB2": "A",
283 "\u1EB4": "A",
284 "\u1EB6": "A",
285 "\xC6": "AE",
286 "\u1EA6": "A",
287 "\u1EB0": "A",
288 "\u0202": "A",
289 "\u1EA2": "A",
290 "\u1EA0": "A",
291 "\u1EA8": "A",
292 "\u1EAA": "A",
293 "\u1EAC": "A",
294 "\xC7": "C",
295 "\u1E08": "C",
296 "\xC8": "E",
297 "\xC9": "E",
298 "\xCA": "E",
299 "\xCB": "E",
300 "\u1EBE": "E",
301 "\u1E16": "E",
302 "\u1EC0": "E",
303 "\u1E14": "E",
304 "\u1E1C": "E",
305 "\u0206": "E",
306 "\u1EBA": "E",
307 "\u1EBC": "E",
308 "\u1EB8": "E",
309 "\u1EC2": "E",
310 "\u1EC4": "E",
311 "\u1EC6": "E",
312 "\xCC": "I",
313 "\xCD": "I",
314 "\xCE": "I",
315 "\xCF": "I",
316 "\u1E2E": "I",
317 "\u020A": "I",
318 "\u1EC8": "I",
319 "\u1ECA": "I",
320 "\xD0": "D",
321 "\xD1": "N",
322 "\xD2": "O",
323 "\xD3": "O",
324 "\xD4": "O",
325 "\xD5": "O",
326 "\xD6": "O",
327 "\xD8": "O",
328 "\u1ED0": "O",
329 "\u1E4C": "O",
330 "\u1E52": "O",
331 "\u020E": "O",
332 "\u1ECE": "O",
333 "\u1ECC": "O",
334 "\u1ED4": "O",
335 "\u1ED6": "O",
336 "\u1ED8": "O",
337 "\u1EDC": "O",
338 "\u1EDE": "O",
339 "\u1EE0": "O",
340 "\u1EDA": "O",
341 "\u1EE2": "O",
342 "\xD9": "U",
343 "\xDA": "U",
344 "\xDB": "U",
345 "\xDC": "U",
346 "\u1EE6": "U",
347 "\u1EE4": "U",
348 "\u1EEC": "U",
349 "\u1EEE": "U",
350 "\u1EF0": "U",
351 "\xDD": "Y",
352 "\xE0": "a",
353 "\xE1": "a",
354 "\xE2": "a",
355 "\xE3": "a",
356 "\xE4": "a",
357 "\xE5": "a",
358 "\u1EA5": "a",
359 "\u1EAF": "a",
360 "\u1EB3": "a",
361 "\u1EB5": "a",
362 "\u1EB7": "a",
363 "\xE6": "ae",
364 "\u1EA7": "a",
365 "\u1EB1": "a",
366 "\u0203": "a",
367 "\u1EA3": "a",
368 "\u1EA1": "a",
369 "\u1EA9": "a",
370 "\u1EAB": "a",
371 "\u1EAD": "a",
372 "\xE7": "c",
373 "\u1E09": "c",
374 "\xE8": "e",
375 "\xE9": "e",
376 "\xEA": "e",
377 "\xEB": "e",
378 "\u1EBF": "e",
379 "\u1E17": "e",
380 "\u1EC1": "e",
381 "\u1E15": "e",
382 "\u1E1D": "e",
383 "\u0207": "e",
384 "\u1EBB": "e",
385 "\u1EBD": "e",
386 "\u1EB9": "e",
387 "\u1EC3": "e",
388 "\u1EC5": "e",
389 "\u1EC7": "e",
390 "\xEC": "i",
391 "\xED": "i",
392 "\xEE": "i",
393 "\xEF": "i",
394 "\u1E2F": "i",
395 "\u020B": "i",
396 "\u1EC9": "i",
397 "\u1ECB": "i",
398 "\xF0": "d",
399 "\xF1": "n",
400 "\xF2": "o",
401 "\xF3": "o",
402 "\xF4": "o",
403 "\xF5": "o",
404 "\xF6": "o",
405 "\xF8": "o",
406 "\u1ED1": "o",
407 "\u1E4D": "o",
408 "\u1E53": "o",
409 "\u020F": "o",
410 "\u1ECF": "o",
411 "\u1ECD": "o",
412 "\u1ED5": "o",
413 "\u1ED7": "o",
414 "\u1ED9": "o",
415 "\u1EDD": "o",
416 "\u1EDF": "o",
417 "\u1EE1": "o",
418 "\u1EDB": "o",
419 "\u1EE3": "o",
420 "\xF9": "u",
421 "\xFA": "u",
422 "\xFB": "u",
423 "\xFC": "u",
424 "\u1EE7": "u",
425 "\u1EE5": "u",
426 "\u1EED": "u",
427 "\u1EEF": "u",
428 "\u1EF1": "u",
429 "\xFD": "y",
430 "\xFF": "y",
431 "\u0100": "A",
432 "\u0101": "a",
433 "\u0102": "A",
434 "\u0103": "a",
435 "\u0104": "A",
436 "\u0105": "a",
437 "\u0106": "C",
438 "\u0107": "c",
439 "\u0108": "C",
440 "\u0109": "c",
441 "\u010A": "C",
442 "\u010B": "c",
443 "\u010C": "C",
444 "\u010D": "c",
445 "C\u0306": "C",
446 "c\u0306": "c",
447 "\u010E": "D",
448 "\u010F": "d",
449 "\u0110": "D",
450 "\u0111": "d",
451 "\u0112": "E",
452 "\u0113": "e",
453 "\u0114": "E",
454 "\u0115": "e",
455 "\u0116": "E",
456 "\u0117": "e",
457 "\u0118": "E",
458 "\u0119": "e",
459 "\u011A": "E",
460 "\u011B": "e",
461 "\u011C": "G",
462 "\u01F4": "G",
463 "\u011D": "g",
464 "\u01F5": "g",
465 "\u011E": "G",
466 "\u011F": "g",
467 "\u0120": "G",
468 "\u0121": "g",
469 "\u0122": "G",
470 "\u0123": "g",
471 "\u0124": "H",
472 "\u0125": "h",
473 "\u0126": "H",
474 "\u0127": "h",
475 "\u1E2A": "H",
476 "\u1E2B": "h",
477 "\u0128": "I",
478 "\u0129": "i",
479 "\u012A": "I",
480 "\u012B": "i",
481 "\u012C": "I",
482 "\u012D": "i",
483 "\u012E": "I",
484 "\u012F": "i",
485 "\u0130": "I",
486 "\u0131": "i",
487 "\u0132": "IJ",
488 "\u0133": "ij",
489 "\u0134": "J",
490 "\u0135": "j",
491 "\u0136": "K",
492 "\u0137": "k",
493 "\u1E30": "K",
494 "\u1E31": "k",
495 "K\u0306": "K",
496 "k\u0306": "k",
497 "\u0139": "L",
498 "\u013A": "l",
499 "\u013B": "L",
500 "\u013C": "l",
501 "\u013D": "L",
502 "\u013E": "l",
503 "\u013F": "L",
504 "\u0140": "l",
505 "\u0141": "l",
506 "\u0142": "l",
507 "\u1E3E": "M",
508 "\u1E3F": "m",
509 "M\u0306": "M",
510 "m\u0306": "m",
511 "\u0143": "N",
512 "\u0144": "n",
513 "\u0145": "N",
514 "\u0146": "n",
515 "\u0147": "N",
516 "\u0148": "n",
517 "\u0149": "n",
518 "N\u0306": "N",
519 "n\u0306": "n",
520 "\u014C": "O",
521 "\u014D": "o",
522 "\u014E": "O",
523 "\u014F": "o",
524 "\u0150": "O",
525 "\u0151": "o",
526 "\u0152": "OE",
527 "\u0153": "oe",
528 "P\u0306": "P",
529 "p\u0306": "p",
530 "\u0154": "R",
531 "\u0155": "r",
532 "\u0156": "R",
533 "\u0157": "r",
534 "\u0158": "R",
535 "\u0159": "r",
536 "R\u0306": "R",
537 "r\u0306": "r",
538 "\u0212": "R",
539 "\u0213": "r",
540 "\u015A": "S",
541 "\u015B": "s",
542 "\u015C": "S",
543 "\u015D": "s",
544 "\u015E": "S",
545 "\u0218": "S",
546 "\u0219": "s",
547 "\u015F": "s",
548 "\u0160": "S",
549 "\u0161": "s",
550 "\u0162": "T",
551 "\u0163": "t",
552 "\u021B": "t",
553 "\u021A": "T",
554 "\u0164": "T",
555 "\u0165": "t",
556 "\u0166": "T",
557 "\u0167": "t",
558 "T\u0306": "T",
559 "t\u0306": "t",
560 "\u0168": "U",
561 "\u0169": "u",
562 "\u016A": "U",
563 "\u016B": "u",
564 "\u016C": "U",
565 "\u016D": "u",
566 "\u016E": "U",
567 "\u016F": "u",
568 "\u0170": "U",
569 "\u0171": "u",
570 "\u0172": "U",
571 "\u0173": "u",
572 "\u0216": "U",
573 "\u0217": "u",
574 "V\u0306": "V",
575 "v\u0306": "v",
576 "\u0174": "W",
577 "\u0175": "w",
578 "\u1E82": "W",
579 "\u1E83": "w",
580 "X\u0306": "X",
581 "x\u0306": "x",
582 "\u0176": "Y",
583 "\u0177": "y",
584 "\u0178": "Y",
585 "Y\u0306": "Y",
586 "y\u0306": "y",
587 "\u0179": "Z",
588 "\u017A": "z",
589 "\u017B": "Z",
590 "\u017C": "z",
591 "\u017D": "Z",
592 "\u017E": "z",
593 "\u017F": "s",
594 "\u0192": "f",
595 "\u01A0": "O",
596 "\u01A1": "o",
597 "\u01AF": "U",
598 "\u01B0": "u",
599 "\u01CD": "A",
600 "\u01CE": "a",
601 "\u01CF": "I",
602 "\u01D0": "i",
603 "\u01D1": "O",
604 "\u01D2": "o",
605 "\u01D3": "U",
606 "\u01D4": "u",
607 "\u01D5": "U",
608 "\u01D6": "u",
609 "\u01D7": "U",
610 "\u01D8": "u",
611 "\u01D9": "U",
612 "\u01DA": "u",
613 "\u01DB": "U",
614 "\u01DC": "u",
615 "\u1EE8": "U",
616 "\u1EE9": "u",
617 "\u1E78": "U",
618 "\u1E79": "u",
619 "\u01FA": "A",
620 "\u01FB": "a",
621 "\u01FC": "AE",
622 "\u01FD": "ae",
623 "\u01FE": "O",
624 "\u01FF": "o",
625 "\xDE": "TH",
626 "\xFE": "th",
627 "\u1E54": "P",
628 "\u1E55": "p",
629 "\u1E64": "S",
630 "\u1E65": "s",
631 "X\u0301": "X",
632 "x\u0301": "x",
633 "\u0403": "\u0413",
634 "\u0453": "\u0433",
635 "\u040C": "\u041A",
636 "\u045C": "\u043A",
637 "A\u030B": "A",
638 "a\u030B": "a",
639 "E\u030B": "E",
640 "e\u030B": "e",
641 "I\u030B": "I",
642 "i\u030B": "i",
643 "\u01F8": "N",
644 "\u01F9": "n",
645 "\u1ED2": "O",
646 "\u1ED3": "o",
647 "\u1E50": "O",
648 "\u1E51": "o",
649 "\u1EEA": "U",
650 "\u1EEB": "u",
651 "\u1E80": "W",
652 "\u1E81": "w",
653 "\u1EF2": "Y",
654 "\u1EF3": "y",
655 "\u0200": "A",
656 "\u0201": "a",
657 "\u0204": "E",
658 "\u0205": "e",
659 "\u0208": "I",
660 "\u0209": "i",
661 "\u020C": "O",
662 "\u020D": "o",
663 "\u0210": "R",
664 "\u0211": "r",
665 "\u0214": "U",
666 "\u0215": "u",
667 "B\u030C": "B",
668 "b\u030C": "b",
669 "\u010C\u0323": "C",
670 "\u010D\u0323": "c",
671 "\xCA\u030C": "E",
672 "\xEA\u030C": "e",
673 "F\u030C": "F",
674 "f\u030C": "f",
675 "\u01E6": "G",
676 "\u01E7": "g",
677 "\u021E": "H",
678 "\u021F": "h",
679 "J\u030C": "J",
680 "\u01F0": "j",
681 "\u01E8": "K",
682 "\u01E9": "k",
683 "M\u030C": "M",
684 "m\u030C": "m",
685 "P\u030C": "P",
686 "p\u030C": "p",
687 "Q\u030C": "Q",
688 "q\u030C": "q",
689 "\u0158\u0329": "R",
690 "\u0159\u0329": "r",
691 "\u1E66": "S",
692 "\u1E67": "s",
693 "V\u030C": "V",
694 "v\u030C": "v",
695 "W\u030C": "W",
696 "w\u030C": "w",
697 "X\u030C": "X",
698 "x\u030C": "x",
699 "Y\u030C": "Y",
700 "y\u030C": "y",
701 "A\u0327": "A",
702 "a\u0327": "a",
703 "B\u0327": "B",
704 "b\u0327": "b",
705 "\u1E10": "D",
706 "\u1E11": "d",
707 "\u0228": "E",
708 "\u0229": "e",
709 "\u0190\u0327": "E",
710 "\u025B\u0327": "e",
711 "\u1E28": "H",
712 "\u1E29": "h",
713 "I\u0327": "I",
714 "i\u0327": "i",
715 "\u0197\u0327": "I",
716 "\u0268\u0327": "i",
717 "M\u0327": "M",
718 "m\u0327": "m",
719 "O\u0327": "O",
720 "o\u0327": "o",
721 "Q\u0327": "Q",
722 "q\u0327": "q",
723 "U\u0327": "U",
724 "u\u0327": "u",
725 "X\u0327": "X",
726 "x\u0327": "x",
727 "Z\u0327": "Z",
728 "z\u0327": "z",
729 "\u0439": "\u0438",
730 "\u0419": "\u0418",
731 "\u0451": "\u0435",
732 "\u0401": "\u0415"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents2 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents2;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents2;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // package-external:@wordpress/html-entities
823 var require_html_entities = __commonJS({
824 "package-external:@wordpress/html-entities"(exports, module) {
825 module.exports = window.wp.htmlEntities;
826 }
827 });
828
829 // widgets/news/render.tsx
830 var import_i18n46 = __toESM(require_i18n());
831
832 // node_modules/clsx/dist/clsx.mjs
833 function r(e2) {
834 var t2, f2, n2 = "";
835 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
836 else if ("object" == typeof e2) if (Array.isArray(e2)) {
837 var o2 = e2.length;
838 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
839 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
840 return n2;
841 }
842 function clsx() {
843 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
844 return n2;
845 }
846 var clsx_default = clsx;
847
848 // node_modules/@base-ui/utils/esm/safeReact.js
849 var React = __toESM(require_react(), 1);
850 var SafeReact = {
851 ...React
852 };
853
854 // node_modules/@base-ui/utils/esm/useRefWithInit.js
855 var React2 = __toESM(require_react(), 1);
856 var UNINITIALIZED = {};
857 function useRefWithInit(init2, initArg) {
858 const ref = React2.useRef(UNINITIALIZED);
859 if (ref.current === UNINITIALIZED) {
860 ref.current = init2(initArg);
861 }
862 return ref;
863 }
864
865 // node_modules/@base-ui/utils/esm/useStableCallback.js
866 var useInsertionEffect = SafeReact.useInsertionEffect;
867 var useSafeInsertionEffect = (
868 // React 17 doesn't have useInsertionEffect.
869 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
870 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
871 );
872 function useStableCallback(callback) {
873 const stable = useRefWithInit(createStableCallback).current;
874 stable.next = callback;
875 useSafeInsertionEffect(stable.effect);
876 return stable.trampoline;
877 }
878 function createStableCallback() {
879 const stable = {
880 next: void 0,
881 callback: assertNotCalled,
882 trampoline: (...args) => stable.callback?.(...args),
883 effect: () => {
884 stable.callback = stable.next;
885 }
886 };
887 return stable;
888 }
889 function assertNotCalled() {
890 if (true) {
891 throw (
892 /* minify-error-disabled */
893 new Error("Base UI: Cannot call an event handler while rendering.")
894 );
895 }
896 }
897
898 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
899 var React3 = __toESM(require_react(), 1);
900 var noop = () => {
901 };
902 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
903
904 // node_modules/@base-ui/utils/esm/warn.js
905 var set;
906 if (true) {
907 set = /* @__PURE__ */ new Set();
908 }
909 function warn(...messages) {
910 if (true) {
911 const messageKey = messages.join(" ");
912 if (!set.has(messageKey)) {
913 set.add(messageKey);
914 console.warn(`Base UI: ${messageKey}`);
915 }
916 }
917 }
918
919 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
920 var React4 = __toESM(require_react(), 1);
921 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
922 if (true) DirectionContext.displayName = "DirectionContext";
923 function useDirection() {
924 const context = React4.useContext(DirectionContext);
925 return context?.direction ?? "ltr";
926 }
927
928 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
929 var React7 = __toESM(require_react(), 1);
930
931 // node_modules/@base-ui/utils/esm/useMergedRefs.js
932 function useMergedRefs(a2, b2, c2, d2) {
933 const forkRef = useRefWithInit(createForkRef).current;
934 if (didChange(forkRef, a2, b2, c2, d2)) {
935 update(forkRef, [a2, b2, c2, d2]);
936 }
937 return forkRef.callback;
938 }
939 function useMergedRefsN(refs) {
940 const forkRef = useRefWithInit(createForkRef).current;
941 if (didChangeN(forkRef, refs)) {
942 update(forkRef, refs);
943 }
944 return forkRef.callback;
945 }
946 function createForkRef() {
947 return {
948 callback: null,
949 cleanup: null,
950 refs: []
951 };
952 }
953 function didChange(forkRef, a2, b2, c2, d2) {
954 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
955 }
956 function didChangeN(forkRef, newRefs) {
957 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
958 }
959 function update(forkRef, refs) {
960 forkRef.refs = refs;
961 if (refs.every((ref) => ref == null)) {
962 forkRef.callback = null;
963 return;
964 }
965 forkRef.callback = (instance) => {
966 if (forkRef.cleanup) {
967 forkRef.cleanup();
968 forkRef.cleanup = null;
969 }
970 if (instance != null) {
971 const cleanupCallbacks = Array(refs.length).fill(null);
972 for (let i2 = 0; i2 < refs.length; i2 += 1) {
973 const ref = refs[i2];
974 if (ref == null) {
975 continue;
976 }
977 switch (typeof ref) {
978 case "function": {
979 const refCleanup = ref(instance);
980 if (typeof refCleanup === "function") {
981 cleanupCallbacks[i2] = refCleanup;
982 }
983 break;
984 }
985 case "object": {
986 ref.current = instance;
987 break;
988 }
989 default:
990 }
991 }
992 forkRef.cleanup = () => {
993 for (let i2 = 0; i2 < refs.length; i2 += 1) {
994 const ref = refs[i2];
995 if (ref == null) {
996 continue;
997 }
998 switch (typeof ref) {
999 case "function": {
1000 const cleanupCallback = cleanupCallbacks[i2];
1001 if (typeof cleanupCallback === "function") {
1002 cleanupCallback();
1003 } else {
1004 ref(null);
1005 }
1006 break;
1007 }
1008 case "object": {
1009 ref.current = null;
1010 break;
1011 }
1012 default:
1013 }
1014 }
1015 };
1016 }
1017 };
1018 }
1019
1020 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1021 var React6 = __toESM(require_react(), 1);
1022
1023 // node_modules/@base-ui/utils/esm/reactVersion.js
1024 var React5 = __toESM(require_react(), 1);
1025 var majorVersion = parseInt(React5.version, 10);
1026 function isReactVersionAtLeast(reactVersionToCheck) {
1027 return majorVersion >= reactVersionToCheck;
1028 }
1029
1030 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1031 function getReactElementRef(element) {
1032 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1033 return null;
1034 }
1035 const reactElement = element;
1036 const propsWithRef = reactElement.props;
1037 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1038 }
1039
1040 // node_modules/@base-ui/utils/esm/mergeObjects.js
1041 function mergeObjects(a2, b2) {
1042 if (a2 && !b2) {
1043 return a2;
1044 }
1045 if (!a2 && b2) {
1046 return b2;
1047 }
1048 if (a2 || b2) {
1049 return {
1050 ...a2,
1051 ...b2
1052 };
1053 }
1054 return void 0;
1055 }
1056
1057 // node_modules/@base-ui/utils/esm/empty.js
1058 function NOOP() {
1059 }
1060 var EMPTY_ARRAY = Object.freeze([]);
1061 var EMPTY_OBJECT = Object.freeze({});
1062
1063 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1064 function getStateAttributesProps(state, customMapping) {
1065 const props = {};
1066 for (const key in state) {
1067 const value = state[key];
1068 if (customMapping?.hasOwnProperty(key)) {
1069 const customProps = customMapping[key](value);
1070 if (customProps != null) {
1071 Object.assign(props, customProps);
1072 }
1073 continue;
1074 }
1075 if (value === true) {
1076 props[`data-${key.toLowerCase()}`] = "";
1077 } else if (value) {
1078 props[`data-${key.toLowerCase()}`] = value.toString();
1079 }
1080 }
1081 return props;
1082 }
1083
1084 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1085 function resolveClassName(className, state) {
1086 return typeof className === "function" ? className(state) : className;
1087 }
1088
1089 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1090 function resolveStyle(style, state) {
1091 return typeof style === "function" ? style(state) : style;
1092 }
1093
1094 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1095 var EMPTY_PROPS = {};
1096 function mergeProps(a2, b2, c2, d2, e2) {
1097 if (!c2 && !d2 && !e2 && !a2) {
1098 return createInitialMergedProps(b2);
1099 }
1100 let merged = createInitialMergedProps(a2);
1101 if (b2) {
1102 merged = mergeInto(merged, b2);
1103 }
1104 if (c2) {
1105 merged = mergeInto(merged, c2);
1106 }
1107 if (d2) {
1108 merged = mergeInto(merged, d2);
1109 }
1110 if (e2) {
1111 merged = mergeInto(merged, e2);
1112 }
1113 return merged;
1114 }
1115 function mergePropsN(props) {
1116 if (props.length === 0) {
1117 return EMPTY_PROPS;
1118 }
1119 if (props.length === 1) {
1120 return createInitialMergedProps(props[0]);
1121 }
1122 let merged = createInitialMergedProps(props[0]);
1123 for (let i2 = 1; i2 < props.length; i2 += 1) {
1124 merged = mergeInto(merged, props[i2]);
1125 }
1126 return merged;
1127 }
1128 function createInitialMergedProps(inputProps) {
1129 if (isPropsGetter(inputProps)) {
1130 return {
1131 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1132 };
1133 }
1134 return copyInitialProps(inputProps);
1135 }
1136 function mergeInto(merged, inputProps) {
1137 if (isPropsGetter(inputProps)) {
1138 return resolvePropsGetter(inputProps, merged);
1139 }
1140 return mutablyMergeInto(merged, inputProps);
1141 }
1142 function copyInitialProps(inputProps) {
1143 const copiedProps = {
1144 ...inputProps
1145 };
1146 for (const propName in copiedProps) {
1147 const propValue = copiedProps[propName];
1148 if (isEventHandler(propName, propValue)) {
1149 copiedProps[propName] = wrapEventHandler(propValue);
1150 }
1151 }
1152 return copiedProps;
1153 }
1154 function mutablyMergeInto(mergedProps, externalProps) {
1155 if (!externalProps) {
1156 return mergedProps;
1157 }
1158 for (const propName in externalProps) {
1159 const externalPropValue = externalProps[propName];
1160 switch (propName) {
1161 case "style": {
1162 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1163 break;
1164 }
1165 case "className": {
1166 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1167 break;
1168 }
1169 default: {
1170 if (isEventHandler(propName, externalPropValue)) {
1171 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1172 } else {
1173 mergedProps[propName] = externalPropValue;
1174 }
1175 }
1176 }
1177 }
1178 return mergedProps;
1179 }
1180 function isEventHandler(key, value) {
1181 const code0 = key.charCodeAt(0);
1182 const code1 = key.charCodeAt(1);
1183 const code2 = key.charCodeAt(2);
1184 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1185 }
1186 function isPropsGetter(inputProps) {
1187 return typeof inputProps === "function";
1188 }
1189 function resolvePropsGetter(inputProps, previousProps) {
1190 if (isPropsGetter(inputProps)) {
1191 return inputProps(previousProps);
1192 }
1193 return inputProps ?? EMPTY_PROPS;
1194 }
1195 function mergeEventHandlers(ourHandler, theirHandler) {
1196 if (!theirHandler) {
1197 return ourHandler;
1198 }
1199 if (!ourHandler) {
1200 return wrapEventHandler(theirHandler);
1201 }
1202 return (...args) => {
1203 const event = args[0];
1204 if (isSyntheticEvent(event)) {
1205 const baseUIEvent = event;
1206 makeEventPreventable(baseUIEvent);
1207 const result2 = theirHandler(...args);
1208 if (!baseUIEvent.baseUIHandlerPrevented) {
1209 ourHandler?.(...args);
1210 }
1211 return result2;
1212 }
1213 const result = theirHandler(...args);
1214 ourHandler?.(...args);
1215 return result;
1216 };
1217 }
1218 function wrapEventHandler(handler) {
1219 if (!handler) {
1220 return handler;
1221 }
1222 return (...args) => {
1223 const event = args[0];
1224 if (isSyntheticEvent(event)) {
1225 makeEventPreventable(event);
1226 }
1227 return handler(...args);
1228 };
1229 }
1230 function makeEventPreventable(event) {
1231 event.preventBaseUIHandler = () => {
1232 event.baseUIHandlerPrevented = true;
1233 };
1234 return event;
1235 }
1236 function mergeClassNames(ourClassName, theirClassName) {
1237 if (theirClassName) {
1238 if (ourClassName) {
1239 return theirClassName + " " + ourClassName;
1240 }
1241 return theirClassName;
1242 }
1243 return ourClassName;
1244 }
1245 function isSyntheticEvent(event) {
1246 return event != null && typeof event === "object" && "nativeEvent" in event;
1247 }
1248
1249 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1250 var import_react = __toESM(require_react(), 1);
1251 function useRenderElement(element, componentProps, params = {}) {
1252 const renderProp = componentProps.render;
1253 const outProps = useRenderElementProps(componentProps, params);
1254 if (params.enabled === false) {
1255 return null;
1256 }
1257 const state = params.state ?? EMPTY_OBJECT;
1258 return evaluateRenderProp(element, renderProp, outProps, state);
1259 }
1260 function useRenderElementProps(componentProps, params = {}) {
1261 const {
1262 className: classNameProp,
1263 style: styleProp,
1264 render: renderProp
1265 } = componentProps;
1266 const {
1267 state = EMPTY_OBJECT,
1268 ref,
1269 props,
1270 stateAttributesMapping: stateAttributesMapping3,
1271 enabled = true
1272 } = params;
1273 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1274 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1275 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1276 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1277 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1278 if (typeof document !== "undefined") {
1279 if (!enabled) {
1280 useMergedRefs(null, null);
1281 } else if (Array.isArray(ref)) {
1282 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1283 } else {
1284 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1285 }
1286 }
1287 if (!enabled) {
1288 return EMPTY_OBJECT;
1289 }
1290 if (className !== void 0) {
1291 outProps.className = mergeClassNames(outProps.className, className);
1292 }
1293 if (style !== void 0) {
1294 outProps.style = mergeObjects(outProps.style, style);
1295 }
1296 return outProps;
1297 }
1298 function resolveRenderFunctionProps(props) {
1299 if (Array.isArray(props)) {
1300 return mergePropsN(props);
1301 }
1302 return mergeProps(void 0, props);
1303 }
1304 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1305 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1306 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1307 function evaluateRenderProp(element, render4, props, state) {
1308 if (render4) {
1309 if (typeof render4 === "function") {
1310 if (true) {
1311 warnIfRenderPropLooksLikeComponent(render4);
1312 }
1313 return render4(props, state);
1314 }
1315 const mergedProps = mergeProps(props, render4.props);
1316 mergedProps.ref = props.ref;
1317 let newElement = render4;
1318 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1319 const children = React7.Children.toArray(render4);
1320 newElement = children[0];
1321 }
1322 if (true) {
1323 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1324 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"));
1325 }
1326 }
1327 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1328 }
1329 if (element) {
1330 if (typeof element === "string") {
1331 return renderTag(element, props);
1332 }
1333 }
1334 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1335 }
1336 function warnIfRenderPropLooksLikeComponent(renderFn) {
1337 const functionName = renderFn.name;
1338 if (functionName.length === 0) {
1339 return;
1340 }
1341 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1342 return;
1343 }
1344 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1345 return;
1346 }
1347 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");
1348 }
1349 function renderTag(Tag, props) {
1350 if (Tag === "button") {
1351 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1352 type: "button",
1353 ...props,
1354 key: props.key
1355 });
1356 }
1357 if (Tag === "img") {
1358 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1359 alt: "",
1360 ...props,
1361 key: props.key
1362 });
1363 }
1364 return /* @__PURE__ */ React7.createElement(Tag, props);
1365 }
1366
1367 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1368 var reason_parts_exports = {};
1369 __export(reason_parts_exports, {
1370 cancelOpen: () => cancelOpen,
1371 chipRemovePress: () => chipRemovePress,
1372 clearPress: () => clearPress,
1373 closePress: () => closePress,
1374 closeWatcher: () => closeWatcher,
1375 decrementPress: () => decrementPress,
1376 disabled: () => disabled,
1377 drag: () => drag,
1378 escapeKey: () => escapeKey,
1379 focusOut: () => focusOut,
1380 imperativeAction: () => imperativeAction,
1381 incrementPress: () => incrementPress,
1382 initial: () => initial,
1383 inputBlur: () => inputBlur,
1384 inputChange: () => inputChange,
1385 inputClear: () => inputClear,
1386 inputPaste: () => inputPaste,
1387 inputPress: () => inputPress,
1388 itemPress: () => itemPress,
1389 keyboard: () => keyboard,
1390 linkPress: () => linkPress,
1391 listNavigation: () => listNavigation,
1392 missing: () => missing,
1393 none: () => none,
1394 outsidePress: () => outsidePress,
1395 pointer: () => pointer,
1396 scrub: () => scrub,
1397 siblingOpen: () => siblingOpen,
1398 swipe: () => swipe,
1399 trackPress: () => trackPress,
1400 triggerFocus: () => triggerFocus,
1401 triggerHover: () => triggerHover,
1402 triggerPress: () => triggerPress,
1403 wheel: () => wheel,
1404 windowResize: () => windowResize
1405 });
1406 var none = "none";
1407 var triggerPress = "trigger-press";
1408 var triggerHover = "trigger-hover";
1409 var triggerFocus = "trigger-focus";
1410 var outsidePress = "outside-press";
1411 var itemPress = "item-press";
1412 var closePress = "close-press";
1413 var linkPress = "link-press";
1414 var clearPress = "clear-press";
1415 var chipRemovePress = "chip-remove-press";
1416 var trackPress = "track-press";
1417 var incrementPress = "increment-press";
1418 var decrementPress = "decrement-press";
1419 var inputChange = "input-change";
1420 var inputClear = "input-clear";
1421 var inputBlur = "input-blur";
1422 var inputPaste = "input-paste";
1423 var inputPress = "input-press";
1424 var focusOut = "focus-out";
1425 var escapeKey = "escape-key";
1426 var closeWatcher = "close-watcher";
1427 var listNavigation = "list-navigation";
1428 var keyboard = "keyboard";
1429 var pointer = "pointer";
1430 var drag = "drag";
1431 var wheel = "wheel";
1432 var scrub = "scrub";
1433 var cancelOpen = "cancel-open";
1434 var siblingOpen = "sibling-open";
1435 var disabled = "disabled";
1436 var missing = "missing";
1437 var initial = "initial";
1438 var imperativeAction = "imperative-action";
1439 var swipe = "swipe";
1440 var windowResize = "window-resize";
1441
1442 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1443 function createChangeEventDetails(reason, event, trigger, customProperties) {
1444 let canceled = false;
1445 let allowPropagation = false;
1446 const custom = customProperties ?? EMPTY_OBJECT;
1447 const details = {
1448 reason,
1449 event: event ?? new Event("base-ui"),
1450 cancel() {
1451 canceled = true;
1452 },
1453 allowPropagation() {
1454 allowPropagation = true;
1455 },
1456 get isCanceled() {
1457 return canceled;
1458 },
1459 get isPropagationAllowed() {
1460 return allowPropagation;
1461 },
1462 trigger,
1463 ...custom
1464 };
1465 return details;
1466 }
1467
1468 // node_modules/@base-ui/utils/esm/useId.js
1469 var React8 = __toESM(require_react(), 1);
1470 var globalId = 0;
1471 function useGlobalId(idOverride, prefix = "mui") {
1472 const [defaultId, setDefaultId] = React8.useState(idOverride);
1473 const id = idOverride || defaultId;
1474 React8.useEffect(() => {
1475 if (defaultId == null) {
1476 globalId += 1;
1477 setDefaultId(`${prefix}-${globalId}`);
1478 }
1479 }, [defaultId, prefix]);
1480 return id;
1481 }
1482 var maybeReactUseId = SafeReact.useId;
1483 function useId(idOverride, prefix) {
1484 if (maybeReactUseId !== void 0) {
1485 const reactId = maybeReactUseId();
1486 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1487 }
1488 return useGlobalId(idOverride, prefix);
1489 }
1490
1491 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1492 function useBaseUiId(idOverride) {
1493 return useId(idOverride, "base-ui");
1494 }
1495
1496 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1497 var React10 = __toESM(require_react(), 1);
1498
1499 // node_modules/@base-ui/utils/esm/useOnMount.js
1500 var React9 = __toESM(require_react(), 1);
1501 var EMPTY = [];
1502 function useOnMount(fn) {
1503 React9.useEffect(fn, EMPTY);
1504 }
1505
1506 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1507 var EMPTY2 = null;
1508 var LAST_RAF = globalThis.requestAnimationFrame;
1509 var Scheduler = class {
1510 /* This implementation uses an array as a backing data-structure for frame callbacks.
1511 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1512 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1513 * be much more efficient if there is a call pattern that alterns as
1514 * "request-cancel-request-cancel-…".
1515 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1516 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1517 callbacks = [];
1518 callbacksCount = 0;
1519 nextId = 1;
1520 startId = 1;
1521 isScheduled = false;
1522 tick = (timestamp) => {
1523 this.isScheduled = false;
1524 const currentCallbacks = this.callbacks;
1525 const currentCallbacksCount = this.callbacksCount;
1526 this.callbacks = [];
1527 this.callbacksCount = 0;
1528 this.startId = this.nextId;
1529 if (currentCallbacksCount > 0) {
1530 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1531 currentCallbacks[i2]?.(timestamp);
1532 }
1533 }
1534 };
1535 request(fn) {
1536 const id = this.nextId;
1537 this.nextId += 1;
1538 this.callbacks.push(fn);
1539 this.callbacksCount += 1;
1540 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1541 if (!this.isScheduled || didRAFChange) {
1542 requestAnimationFrame(this.tick);
1543 this.isScheduled = true;
1544 }
1545 return id;
1546 }
1547 cancel(id) {
1548 const index2 = id - this.startId;
1549 if (index2 < 0 || index2 >= this.callbacks.length) {
1550 return;
1551 }
1552 this.callbacks[index2] = null;
1553 this.callbacksCount -= 1;
1554 }
1555 };
1556 var scheduler = new Scheduler();
1557 var AnimationFrame = class _AnimationFrame {
1558 static create() {
1559 return new _AnimationFrame();
1560 }
1561 static request(fn) {
1562 return scheduler.request(fn);
1563 }
1564 static cancel(id) {
1565 return scheduler.cancel(id);
1566 }
1567 currentId = EMPTY2;
1568 /**
1569 * Executes `fn` after `delay`, clearing any previously scheduled call.
1570 */
1571 request(fn) {
1572 this.cancel();
1573 this.currentId = scheduler.request(() => {
1574 this.currentId = EMPTY2;
1575 fn();
1576 });
1577 }
1578 cancel = () => {
1579 if (this.currentId !== EMPTY2) {
1580 scheduler.cancel(this.currentId);
1581 this.currentId = EMPTY2;
1582 }
1583 };
1584 disposeEffect = () => {
1585 return this.cancel;
1586 };
1587 };
1588 function useAnimationFrame() {
1589 const timeout = useRefWithInit(AnimationFrame.create).current;
1590 useOnMount(timeout.disposeEffect);
1591 return timeout;
1592 }
1593
1594 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1595 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1596 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1597 const [mounted, setMounted] = React10.useState(open);
1598 if (open && !mounted) {
1599 setMounted(true);
1600 setTransitionStatus("starting");
1601 }
1602 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1603 setTransitionStatus("ending");
1604 }
1605 if (!open && !mounted && transitionStatus === "ending") {
1606 setTransitionStatus(void 0);
1607 }
1608 useIsoLayoutEffect(() => {
1609 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1610 const frame = AnimationFrame.request(() => {
1611 setTransitionStatus("ending");
1612 });
1613 return () => {
1614 AnimationFrame.cancel(frame);
1615 };
1616 }
1617 return void 0;
1618 }, [open, mounted, transitionStatus, deferEndingState]);
1619 useIsoLayoutEffect(() => {
1620 if (!open || enableIdleState) {
1621 return void 0;
1622 }
1623 const frame = AnimationFrame.request(() => {
1624 setTransitionStatus(void 0);
1625 });
1626 return () => {
1627 AnimationFrame.cancel(frame);
1628 };
1629 }, [enableIdleState, open]);
1630 useIsoLayoutEffect(() => {
1631 if (!open || !enableIdleState) {
1632 return void 0;
1633 }
1634 if (open && mounted && transitionStatus !== "idle") {
1635 setTransitionStatus("starting");
1636 }
1637 const frame = AnimationFrame.request(() => {
1638 setTransitionStatus("idle");
1639 });
1640 return () => {
1641 AnimationFrame.cancel(frame);
1642 };
1643 }, [enableIdleState, open, mounted, transitionStatus]);
1644 return {
1645 mounted,
1646 setMounted,
1647 transitionStatus
1648 };
1649 }
1650
1651 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1652 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1653 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1654 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1655 return TransitionStatusDataAttributes2;
1656 })({});
1657 var STARTING_HOOK = {
1658 [TransitionStatusDataAttributes.startingStyle]: ""
1659 };
1660 var ENDING_HOOK = {
1661 [TransitionStatusDataAttributes.endingStyle]: ""
1662 };
1663 var transitionStatusMapping = {
1664 transitionStatus(value) {
1665 if (value === "starting") {
1666 return STARTING_HOOK;
1667 }
1668 if (value === "ending") {
1669 return ENDING_HOOK;
1670 }
1671 return null;
1672 }
1673 };
1674
1675 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1676 function hasWindow() {
1677 return typeof window !== "undefined";
1678 }
1679 function getNodeName(node) {
1680 if (isNode(node)) {
1681 return (node.nodeName || "").toLowerCase();
1682 }
1683 return "#document";
1684 }
1685 function getWindow(node) {
1686 var _node$ownerDocument;
1687 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1688 }
1689 function getDocumentElement(node) {
1690 var _ref;
1691 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1692 }
1693 function isNode(value) {
1694 if (!hasWindow()) {
1695 return false;
1696 }
1697 return value instanceof Node || value instanceof getWindow(value).Node;
1698 }
1699 function isElement(value) {
1700 if (!hasWindow()) {
1701 return false;
1702 }
1703 return value instanceof Element || value instanceof getWindow(value).Element;
1704 }
1705 function isHTMLElement(value) {
1706 if (!hasWindow()) {
1707 return false;
1708 }
1709 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1710 }
1711 function isShadowRoot(value) {
1712 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1713 return false;
1714 }
1715 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1716 }
1717 function isOverflowElement(element) {
1718 const {
1719 overflow,
1720 overflowX,
1721 overflowY,
1722 display
1723 } = getComputedStyle2(element);
1724 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1725 }
1726 function isTableElement(element) {
1727 return /^(table|td|th)$/.test(getNodeName(element));
1728 }
1729 function isTopLayer(element) {
1730 try {
1731 if (element.matches(":popover-open")) {
1732 return true;
1733 }
1734 } catch (_e) {
1735 }
1736 try {
1737 return element.matches(":modal");
1738 } catch (_e) {
1739 return false;
1740 }
1741 }
1742 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1743 var containRe = /paint|layout|strict|content/;
1744 var isNotNone = (value) => !!value && value !== "none";
1745 var isWebKitValue;
1746 function isContainingBlock(elementOrCss) {
1747 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1748 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 || "");
1749 }
1750 function getContainingBlock(element) {
1751 let currentNode = getParentNode(element);
1752 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1753 if (isContainingBlock(currentNode)) {
1754 return currentNode;
1755 } else if (isTopLayer(currentNode)) {
1756 return null;
1757 }
1758 currentNode = getParentNode(currentNode);
1759 }
1760 return null;
1761 }
1762 function isWebKit() {
1763 if (isWebKitValue == null) {
1764 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1765 }
1766 return isWebKitValue;
1767 }
1768 function isLastTraversableNode(node) {
1769 return /^(html|body|#document)$/.test(getNodeName(node));
1770 }
1771 function getComputedStyle2(element) {
1772 return getWindow(element).getComputedStyle(element);
1773 }
1774 function getNodeScroll(element) {
1775 if (isElement(element)) {
1776 return {
1777 scrollLeft: element.scrollLeft,
1778 scrollTop: element.scrollTop
1779 };
1780 }
1781 return {
1782 scrollLeft: element.scrollX,
1783 scrollTop: element.scrollY
1784 };
1785 }
1786 function getParentNode(node) {
1787 if (getNodeName(node) === "html") {
1788 return node;
1789 }
1790 const result = (
1791 // Step into the shadow DOM of the parent of a slotted node.
1792 node.assignedSlot || // DOM Element detected.
1793 node.parentNode || // ShadowRoot detected.
1794 isShadowRoot(node) && node.host || // Fallback.
1795 getDocumentElement(node)
1796 );
1797 return isShadowRoot(result) ? result.host : result;
1798 }
1799 function getNearestOverflowAncestor(node) {
1800 const parentNode = getParentNode(node);
1801 if (isLastTraversableNode(parentNode)) {
1802 return node.ownerDocument ? node.ownerDocument.body : node.body;
1803 }
1804 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1805 return parentNode;
1806 }
1807 return getNearestOverflowAncestor(parentNode);
1808 }
1809 function getOverflowAncestors(node, list, traverseIframes) {
1810 var _node$ownerDocument2;
1811 if (list === void 0) {
1812 list = [];
1813 }
1814 if (traverseIframes === void 0) {
1815 traverseIframes = true;
1816 }
1817 const scrollableAncestor = getNearestOverflowAncestor(node);
1818 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1819 const win = getWindow(scrollableAncestor);
1820 if (isBody) {
1821 const frameElement = getFrameElement(win);
1822 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1823 } else {
1824 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1825 }
1826 }
1827 function getFrameElement(win) {
1828 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1829 }
1830
1831 // node_modules/@base-ui/utils/esm/detectBrowser.js
1832 var hasNavigator = typeof navigator !== "undefined";
1833 var nav = getNavigatorData();
1834 var platform = getPlatform();
1835 var userAgent = getUserAgent();
1836 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1837 var isIOS = (
1838 // iPads can claim to be MacIntel
1839 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1840 );
1841 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1842 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1843 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1844 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1845 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1846 var isJSDOM = userAgent.includes("jsdom/");
1847 function getNavigatorData() {
1848 if (!hasNavigator) {
1849 return {
1850 platform: "",
1851 maxTouchPoints: -1
1852 };
1853 }
1854 const uaData = navigator.userAgentData;
1855 if (uaData?.platform) {
1856 return {
1857 platform: uaData.platform,
1858 maxTouchPoints: navigator.maxTouchPoints
1859 };
1860 }
1861 return {
1862 platform: navigator.platform ?? "",
1863 maxTouchPoints: navigator.maxTouchPoints ?? -1
1864 };
1865 }
1866 function getUserAgent() {
1867 if (!hasNavigator) {
1868 return "";
1869 }
1870 const uaData = navigator.userAgentData;
1871 if (uaData && Array.isArray(uaData.brands)) {
1872 return uaData.brands.map(({
1873 brand,
1874 version: version2
1875 }) => `${brand}/${version2}`).join(" ");
1876 }
1877 return navigator.userAgent;
1878 }
1879 function getPlatform() {
1880 if (!hasNavigator) {
1881 return "";
1882 }
1883 const uaData = navigator.userAgentData;
1884 if (uaData?.platform) {
1885 return uaData.platform;
1886 }
1887 return navigator.platform ?? "";
1888 }
1889
1890 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1891 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1892 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1893
1894 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1895 function activeElement(doc) {
1896 let element = doc.activeElement;
1897 while (element?.shadowRoot?.activeElement != null) {
1898 element = element.shadowRoot.activeElement;
1899 }
1900 return element;
1901 }
1902 function contains(parent, child) {
1903 if (!parent || !child) {
1904 return false;
1905 }
1906 const rootNode = child.getRootNode?.();
1907 if (parent.contains(child)) {
1908 return true;
1909 }
1910 if (rootNode && isShadowRoot(rootNode)) {
1911 let next = child;
1912 while (next) {
1913 if (parent === next) {
1914 return true;
1915 }
1916 next = next.parentNode || next.host;
1917 }
1918 }
1919 return false;
1920 }
1921 function getTarget(event) {
1922 if ("composedPath" in event) {
1923 return event.composedPath()[0];
1924 }
1925 return event.target;
1926 }
1927
1928 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
1929 function isTargetInsideEnabledTrigger(target, triggerElements) {
1930 if (!isElement(target)) {
1931 return false;
1932 }
1933 const targetElement = target;
1934 if (triggerElements.hasElement(targetElement)) {
1935 return !targetElement.hasAttribute("data-trigger-disabled");
1936 }
1937 for (const [, trigger] of triggerElements.entries()) {
1938 if (contains(trigger, targetElement)) {
1939 return !trigger.hasAttribute("data-trigger-disabled");
1940 }
1941 }
1942 return false;
1943 }
1944 function isEventTargetWithin(event, node) {
1945 if (node == null) {
1946 return false;
1947 }
1948 if ("composedPath" in event) {
1949 return event.composedPath().includes(node);
1950 }
1951 const eventAgain = event;
1952 return eventAgain.target != null && node.contains(eventAgain.target);
1953 }
1954 function isRootElement(element) {
1955 return element.matches("html,body");
1956 }
1957 function isTypeableElement(element) {
1958 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
1959 }
1960 function isInteractiveElement(element) {
1961 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
1962 }
1963 function matchesFocusVisible(element) {
1964 if (!element || isJSDOM) {
1965 return true;
1966 }
1967 try {
1968 return element.matches(":focus-visible");
1969 } catch (_e) {
1970 return true;
1971 }
1972 }
1973
1974 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
1975 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
1976 const directChildren = nodes.filter((node) => node.parentId === id);
1977 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
1978 }
1979
1980 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
1981 function isReactEvent(event) {
1982 return "nativeEvent" in event;
1983 }
1984 function isMouseLikePointerType(pointerType, strict) {
1985 const values = ["mouse", "pen"];
1986 if (!strict) {
1987 values.push("", void 0);
1988 }
1989 return values.includes(pointerType);
1990 }
1991 function isClickLikeEvent(event) {
1992 const type = event.type;
1993 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
1994 }
1995
1996 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
1997 var sides = ["top", "right", "bottom", "left"];
1998 var min = Math.min;
1999 var max = Math.max;
2000 var round = Math.round;
2001 var floor = Math.floor;
2002 var createCoords = (v2) => ({
2003 x: v2,
2004 y: v2
2005 });
2006 var oppositeSideMap = {
2007 left: "right",
2008 right: "left",
2009 bottom: "top",
2010 top: "bottom"
2011 };
2012 function clamp(start, value, end) {
2013 return max(start, min(value, end));
2014 }
2015 function evaluate(value, param) {
2016 return typeof value === "function" ? value(param) : value;
2017 }
2018 function getSide(placement) {
2019 return placement.split("-")[0];
2020 }
2021 function getAlignment(placement) {
2022 return placement.split("-")[1];
2023 }
2024 function getOppositeAxis(axis) {
2025 return axis === "x" ? "y" : "x";
2026 }
2027 function getAxisLength(axis) {
2028 return axis === "y" ? "height" : "width";
2029 }
2030 function getSideAxis(placement) {
2031 const firstChar = placement[0];
2032 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2033 }
2034 function getAlignmentAxis(placement) {
2035 return getOppositeAxis(getSideAxis(placement));
2036 }
2037 function getAlignmentSides(placement, rects, rtl) {
2038 if (rtl === void 0) {
2039 rtl = false;
2040 }
2041 const alignment = getAlignment(placement);
2042 const alignmentAxis = getAlignmentAxis(placement);
2043 const length = getAxisLength(alignmentAxis);
2044 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2045 if (rects.reference[length] > rects.floating[length]) {
2046 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2047 }
2048 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2049 }
2050 function getExpandedPlacements(placement) {
2051 const oppositePlacement = getOppositePlacement(placement);
2052 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2053 }
2054 function getOppositeAlignmentPlacement(placement) {
2055 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2056 }
2057 var lrPlacement = ["left", "right"];
2058 var rlPlacement = ["right", "left"];
2059 var tbPlacement = ["top", "bottom"];
2060 var btPlacement = ["bottom", "top"];
2061 function getSideList(side, isStart, rtl) {
2062 switch (side) {
2063 case "top":
2064 case "bottom":
2065 if (rtl) return isStart ? rlPlacement : lrPlacement;
2066 return isStart ? lrPlacement : rlPlacement;
2067 case "left":
2068 case "right":
2069 return isStart ? tbPlacement : btPlacement;
2070 default:
2071 return [];
2072 }
2073 }
2074 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2075 const alignment = getAlignment(placement);
2076 let list = getSideList(getSide(placement), direction === "start", rtl);
2077 if (alignment) {
2078 list = list.map((side) => side + "-" + alignment);
2079 if (flipAlignment) {
2080 list = list.concat(list.map(getOppositeAlignmentPlacement));
2081 }
2082 }
2083 return list;
2084 }
2085 function getOppositePlacement(placement) {
2086 const side = getSide(placement);
2087 return oppositeSideMap[side] + placement.slice(side.length);
2088 }
2089 function expandPaddingObject(padding) {
2090 return {
2091 top: 0,
2092 right: 0,
2093 bottom: 0,
2094 left: 0,
2095 ...padding
2096 };
2097 }
2098 function getPaddingObject(padding) {
2099 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2100 top: padding,
2101 right: padding,
2102 bottom: padding,
2103 left: padding
2104 };
2105 }
2106 function rectToClientRect(rect) {
2107 const {
2108 x: x2,
2109 y: y2,
2110 width,
2111 height
2112 } = rect;
2113 return {
2114 width,
2115 height,
2116 top: y2,
2117 left: x2,
2118 right: x2 + width,
2119 bottom: y2 + height,
2120 x: x2,
2121 y: y2
2122 };
2123 }
2124
2125 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2126 function isHiddenByStyles(styles) {
2127 return styles.visibility === "hidden" || styles.visibility === "collapse";
2128 }
2129 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2130 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2131 return false;
2132 }
2133 if (typeof element.checkVisibility === "function") {
2134 return element.checkVisibility();
2135 }
2136 return styles.display !== "none" && styles.display !== "contents";
2137 }
2138
2139 // node_modules/@base-ui/utils/esm/owner.js
2140 function ownerDocument(node) {
2141 return node?.ownerDocument || document;
2142 }
2143
2144 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2145 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2146 function getParentElement(element) {
2147 const assignedSlot = element.assignedSlot;
2148 if (assignedSlot) {
2149 return assignedSlot;
2150 }
2151 if (element.parentElement) {
2152 return element.parentElement;
2153 }
2154 const rootNode = element.getRootNode();
2155 return isShadowRoot(rootNode) ? rootNode.host : null;
2156 }
2157 function getDetailsSummary(details) {
2158 for (const child of Array.from(details.children)) {
2159 if (getNodeName(child) === "summary") {
2160 return child;
2161 }
2162 }
2163 return null;
2164 }
2165 function isWithinOpenDetailsSummary(element, details) {
2166 const summary = getDetailsSummary(details);
2167 return !!summary && (element === summary || contains(summary, element));
2168 }
2169 function isFocusableCandidate(element) {
2170 const nodeName = element ? getNodeName(element) : "";
2171 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");
2172 }
2173 function isFocusableElement(element) {
2174 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2175 return false;
2176 }
2177 for (let current = element; current; current = getParentElement(current)) {
2178 const isAncestor = current !== element;
2179 const isSlot = getNodeName(current) === "slot";
2180 if (current.hasAttribute("inert")) {
2181 return false;
2182 }
2183 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2184 return false;
2185 }
2186 }
2187 return true;
2188 }
2189 function isVisibleInTabbableTree(element, isAncestor) {
2190 const styles = getComputedStyle2(element);
2191 if (!isAncestor) {
2192 return isElementVisible(element, styles);
2193 }
2194 return styles.display !== "none";
2195 }
2196 function getTabIndex(element) {
2197 const tabIndex = element.tabIndex;
2198 if (tabIndex < 0) {
2199 const nodeName = getNodeName(element);
2200 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2201 return 0;
2202 }
2203 }
2204 return tabIndex;
2205 }
2206 function getNamedRadioInput(element) {
2207 if (getNodeName(element) !== "input") {
2208 return null;
2209 }
2210 const input = element;
2211 return input.type === "radio" && input.name !== "" ? input : null;
2212 }
2213 function isTabbableRadio(element, candidates) {
2214 const input = getNamedRadioInput(element);
2215 if (!input) {
2216 return true;
2217 }
2218 const checkedRadio = candidates.find((candidate) => {
2219 const radio = getNamedRadioInput(candidate);
2220 return radio?.name === input.name && radio.form === input.form && radio.checked;
2221 });
2222 if (checkedRadio) {
2223 return checkedRadio === input;
2224 }
2225 return candidates.find((candidate) => {
2226 const radio = getNamedRadioInput(candidate);
2227 return radio?.name === input.name && radio.form === input.form;
2228 }) === input;
2229 }
2230 function getComposedChildren(container) {
2231 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2232 const assignedElements = container.assignedElements({
2233 flatten: true
2234 });
2235 if (assignedElements.length > 0) {
2236 return assignedElements;
2237 }
2238 }
2239 if (isHTMLElement(container) && container.shadowRoot) {
2240 return Array.from(container.shadowRoot.children);
2241 }
2242 return Array.from(container.children);
2243 }
2244 function appendCandidates(container, list) {
2245 getComposedChildren(container).forEach((child) => {
2246 if (isFocusableCandidate(child)) {
2247 list.push(child);
2248 }
2249 appendCandidates(child, list);
2250 });
2251 }
2252 function appendMatchingElements(container, selector2, list) {
2253 getComposedChildren(container).forEach((child) => {
2254 if (isHTMLElement(child) && child.matches(selector2)) {
2255 list.push(child);
2256 }
2257 appendMatchingElements(child, selector2, list);
2258 });
2259 }
2260 function focusable(container) {
2261 const candidates = [];
2262 appendCandidates(container, candidates);
2263 return candidates.filter(isFocusableElement);
2264 }
2265 function tabbable(container) {
2266 const candidates = focusable(container);
2267 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2268 }
2269 function getTabbableIn(container, dir) {
2270 const list = tabbable(container);
2271 const len = list.length;
2272 if (len === 0) {
2273 return void 0;
2274 }
2275 const active = activeElement(ownerDocument(container));
2276 const index2 = list.indexOf(active);
2277 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2278 return list[nextIndex];
2279 }
2280 function getNextTabbable(referenceElement) {
2281 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2282 }
2283 function getPreviousTabbable(referenceElement) {
2284 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2285 }
2286 function isOutsideEvent(event, container) {
2287 const containerElement = container || event.currentTarget;
2288 const relatedTarget = event.relatedTarget;
2289 return !relatedTarget || !contains(containerElement, relatedTarget);
2290 }
2291 function disableFocusInside(container) {
2292 const tabbableElements = tabbable(container);
2293 tabbableElements.forEach((element) => {
2294 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2295 element.setAttribute("tabindex", "-1");
2296 });
2297 }
2298 function enableFocusInside(container) {
2299 const elements = [];
2300 appendMatchingElements(container, "[data-tabindex]", elements);
2301 elements.forEach((element) => {
2302 const tabindex = element.dataset.tabindex;
2303 delete element.dataset.tabindex;
2304 if (tabindex) {
2305 element.setAttribute("tabindex", tabindex);
2306 } else {
2307 element.removeAttribute("tabindex");
2308 }
2309 });
2310 }
2311
2312 // node_modules/@base-ui/utils/esm/addEventListener.js
2313 function addEventListener(target, type, listener, options) {
2314 target.addEventListener(type, listener, options);
2315 return () => {
2316 target.removeEventListener(type, listener, options);
2317 };
2318 }
2319
2320 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2321 function useValueAsRef(value) {
2322 const latest = useRefWithInit(createLatestRef, value).current;
2323 latest.next = value;
2324 useIsoLayoutEffect(latest.effect);
2325 return latest;
2326 }
2327 function createLatestRef(value) {
2328 const latest = {
2329 current: value,
2330 next: value,
2331 effect: () => {
2332 latest.current = latest.next;
2333 }
2334 };
2335 return latest;
2336 }
2337
2338 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2339 var React11 = __toESM(require_react(), 1);
2340
2341 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2342 var ReactDOM = __toESM(require_react_dom(), 1);
2343
2344 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2345 function resolveRef(maybeRef) {
2346 if (maybeRef == null) {
2347 return maybeRef;
2348 }
2349 return "current" in maybeRef ? maybeRef.current : maybeRef;
2350 }
2351
2352 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2353 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2354 const frame = useAnimationFrame();
2355 return useStableCallback((fnToExecute, signal = null) => {
2356 frame.cancel();
2357 const element = resolveRef(elementOrRef);
2358 if (element == null) {
2359 return;
2360 }
2361 const resolvedElement = element;
2362 const done = () => {
2363 ReactDOM.flushSync(fnToExecute);
2364 };
2365 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2366 fnToExecute();
2367 return;
2368 }
2369 function exec() {
2370 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2371 if (!signal?.aborted) {
2372 done();
2373 }
2374 }).catch(() => {
2375 if (treatAbortedAsFinished) {
2376 if (!signal?.aborted) {
2377 done();
2378 }
2379 return;
2380 }
2381 const currentAnimations = resolvedElement.getAnimations();
2382 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2383 exec();
2384 }
2385 });
2386 }
2387 if (waitForStartingStyleRemoved) {
2388 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2389 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2390 frame.request(exec);
2391 return;
2392 }
2393 const attributeObserver = new MutationObserver(() => {
2394 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2395 attributeObserver.disconnect();
2396 exec();
2397 }
2398 });
2399 attributeObserver.observe(resolvedElement, {
2400 attributes: true,
2401 attributeFilter: [startingStyleAttribute]
2402 });
2403 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2404 once: true
2405 });
2406 return;
2407 }
2408 frame.request(exec);
2409 });
2410 }
2411
2412 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2413 function useOpenChangeComplete(parameters) {
2414 const {
2415 enabled = true,
2416 open,
2417 ref,
2418 onComplete: onCompleteParam
2419 } = parameters;
2420 const onComplete = useStableCallback(onCompleteParam);
2421 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2422 React11.useEffect(() => {
2423 if (!enabled) {
2424 return void 0;
2425 }
2426 const abortController = new AbortController();
2427 runOnceAnimationsFinish(onComplete, abortController.signal);
2428 return () => {
2429 abortController.abort();
2430 };
2431 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2432 }
2433
2434 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2435 var React12 = __toESM(require_react(), 1);
2436 function useOnFirstRender(fn) {
2437 const ref = React12.useRef(true);
2438 if (ref.current) {
2439 ref.current = false;
2440 fn();
2441 }
2442 }
2443
2444 // node_modules/@base-ui/utils/esm/useTimeout.js
2445 var EMPTY3 = 0;
2446 var Timeout = class _Timeout {
2447 static create() {
2448 return new _Timeout();
2449 }
2450 currentId = EMPTY3;
2451 /**
2452 * Executes `fn` after `delay`, clearing any previously scheduled call.
2453 */
2454 start(delay, fn) {
2455 this.clear();
2456 this.currentId = setTimeout(() => {
2457 this.currentId = EMPTY3;
2458 fn();
2459 }, delay);
2460 }
2461 isStarted() {
2462 return this.currentId !== EMPTY3;
2463 }
2464 clear = () => {
2465 if (this.currentId !== EMPTY3) {
2466 clearTimeout(this.currentId);
2467 this.currentId = EMPTY3;
2468 }
2469 };
2470 disposeEffect = () => {
2471 return this.clear;
2472 };
2473 };
2474 function useTimeout() {
2475 const timeout = useRefWithInit(Timeout.create).current;
2476 useOnMount(timeout.disposeEffect);
2477 return timeout;
2478 }
2479
2480 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2481 var React13 = __toESM(require_react(), 1);
2482
2483 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2484 function resolveValue(value, pointerType) {
2485 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2486 return 0;
2487 }
2488 if (typeof value === "function") {
2489 return value();
2490 }
2491 return value;
2492 }
2493 function getDelay(value, prop, pointerType) {
2494 const result = resolveValue(value, pointerType);
2495 if (typeof result === "number") {
2496 return result;
2497 }
2498 return result?.[prop];
2499 }
2500 function getRestMs(value) {
2501 if (typeof value === "function") {
2502 return value();
2503 }
2504 return value;
2505 }
2506 function isClickLikeOpenEvent(openEventType, interactedInside) {
2507 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2508 }
2509 function isHoverOpenEvent(openEventType) {
2510 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2511 }
2512
2513 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2514 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2515 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2516 hasProvider: false,
2517 timeoutMs: 0,
2518 delayRef: {
2519 current: 0
2520 },
2521 initialDelayRef: {
2522 current: 0
2523 },
2524 timeout: new Timeout(),
2525 currentIdRef: {
2526 current: null
2527 },
2528 currentContextRef: {
2529 current: null
2530 }
2531 });
2532 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2533 function FloatingDelayGroup(props) {
2534 const {
2535 children,
2536 delay,
2537 timeoutMs = 0
2538 } = props;
2539 const delayRef = React13.useRef(delay);
2540 const initialDelayRef = React13.useRef(delay);
2541 const currentIdRef = React13.useRef(null);
2542 const currentContextRef = React13.useRef(null);
2543 const timeout = useTimeout();
2544 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2545 value: React13.useMemo(() => ({
2546 hasProvider: true,
2547 delayRef,
2548 initialDelayRef,
2549 currentIdRef,
2550 timeoutMs,
2551 currentContextRef,
2552 timeout
2553 }), [timeoutMs, timeout]),
2554 children
2555 });
2556 }
2557 function useDelayGroup(context, options = {
2558 open: false
2559 }) {
2560 const {
2561 open
2562 } = options;
2563 const store = "rootStore" in context ? context.rootStore : context;
2564 const floatingId = store.useState("floatingId");
2565 const groupContext = React13.useContext(FloatingDelayGroupContext);
2566 const {
2567 currentIdRef,
2568 delayRef,
2569 timeoutMs,
2570 initialDelayRef,
2571 currentContextRef,
2572 hasProvider,
2573 timeout
2574 } = groupContext;
2575 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2576 useIsoLayoutEffect(() => {
2577 function unset() {
2578 setIsInstantPhase(false);
2579 currentContextRef.current?.setIsInstantPhase(false);
2580 currentIdRef.current = null;
2581 currentContextRef.current = null;
2582 delayRef.current = initialDelayRef.current;
2583 }
2584 if (!currentIdRef.current) {
2585 return void 0;
2586 }
2587 if (!open && currentIdRef.current === floatingId) {
2588 setIsInstantPhase(false);
2589 if (timeoutMs) {
2590 const closingId = floatingId;
2591 timeout.start(timeoutMs, () => {
2592 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2593 return;
2594 }
2595 unset();
2596 });
2597 return () => {
2598 timeout.clear();
2599 };
2600 }
2601 unset();
2602 }
2603 return void 0;
2604 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2605 useIsoLayoutEffect(() => {
2606 if (!open) {
2607 return;
2608 }
2609 const prevContext = currentContextRef.current;
2610 const prevId = currentIdRef.current;
2611 timeout.clear();
2612 currentContextRef.current = {
2613 onOpenChange: store.setOpen,
2614 setIsInstantPhase
2615 };
2616 currentIdRef.current = floatingId;
2617 delayRef.current = {
2618 open: 0,
2619 close: getDelay(initialDelayRef.current, "close")
2620 };
2621 if (prevId !== null && prevId !== floatingId) {
2622 setIsInstantPhase(true);
2623 prevContext?.setIsInstantPhase(true);
2624 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2625 } else {
2626 setIsInstantPhase(false);
2627 prevContext?.setIsInstantPhase(false);
2628 }
2629 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2630 useIsoLayoutEffect(() => {
2631 return () => {
2632 currentContextRef.current = null;
2633 };
2634 }, [currentContextRef]);
2635 return React13.useMemo(() => ({
2636 hasProvider,
2637 delayRef,
2638 isInstantPhase
2639 }), [hasProvider, delayRef, isInstantPhase]);
2640 }
2641
2642 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2643 function mergeCleanups(...cleanups) {
2644 return () => {
2645 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2646 const cleanup = cleanups[i2];
2647 if (cleanup) {
2648 cleanup();
2649 }
2650 }
2651 };
2652 }
2653
2654 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2655 var React14 = __toESM(require_react(), 1);
2656
2657 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2658 var visuallyHiddenBase = {
2659 clipPath: "inset(50%)",
2660 overflow: "hidden",
2661 whiteSpace: "nowrap",
2662 border: 0,
2663 padding: 0,
2664 width: 1,
2665 height: 1,
2666 margin: -1
2667 };
2668 var visuallyHidden = {
2669 ...visuallyHiddenBase,
2670 position: "fixed",
2671 top: 0,
2672 left: 0
2673 };
2674 var visuallyHiddenInput = {
2675 ...visuallyHiddenBase,
2676 position: "absolute"
2677 };
2678
2679 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2680 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2681 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2682 const [role, setRole] = React14.useState();
2683 useIsoLayoutEffect(() => {
2684 if (isSafari) {
2685 setRole("button");
2686 }
2687 }, []);
2688 const restProps = {
2689 tabIndex: 0,
2690 // Role is only for VoiceOver
2691 role
2692 };
2693 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2694 ...props,
2695 ref,
2696 style: visuallyHidden,
2697 "aria-hidden": role ? void 0 : true,
2698 ...restProps,
2699 "data-base-ui-focus-guard": ""
2700 });
2701 });
2702 if (true) FocusGuard.displayName = "FocusGuard";
2703
2704 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2705 function createAttribute(name) {
2706 return `data-base-ui-${name}`;
2707 }
2708
2709 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2710 var React15 = __toESM(require_react(), 1);
2711 var ReactDOM2 = __toESM(require_react_dom(), 1);
2712
2713 // node_modules/@base-ui/react/esm/internals/constants.js
2714 var DISABLED_TRANSITIONS_STYLE = {
2715 style: {
2716 transition: "none"
2717 }
2718 };
2719 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2720 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2721 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2722 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2723 var POPUP_COLLISION_AVOIDANCE = {
2724 fallbackAxisSide: "end"
2725 };
2726 var ownerVisuallyHidden = {
2727 clipPath: "inset(50%)",
2728 position: "fixed",
2729 top: 0,
2730 left: 0
2731 };
2732
2733 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2734 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2735 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2736 if (true) PortalContext.displayName = "PortalContext";
2737 var usePortalContext = () => React15.useContext(PortalContext);
2738 var attr = createAttribute("portal");
2739 function useFloatingPortalNode(props = {}) {
2740 const {
2741 ref,
2742 container: containerProp,
2743 componentProps = EMPTY_OBJECT,
2744 elementProps
2745 } = props;
2746 const uniqueId = useId();
2747 const portalContext = usePortalContext();
2748 const parentPortalNode = portalContext?.portalNode;
2749 const [containerElement, setContainerElement] = React15.useState(null);
2750 const [portalNode, setPortalNode] = React15.useState(null);
2751 const setPortalNodeRef = useStableCallback((node) => {
2752 if (node !== null) {
2753 setPortalNode(node);
2754 }
2755 });
2756 const containerRef = React15.useRef(null);
2757 useIsoLayoutEffect(() => {
2758 if (containerProp === null) {
2759 if (containerRef.current) {
2760 containerRef.current = null;
2761 setPortalNode(null);
2762 setContainerElement(null);
2763 }
2764 return;
2765 }
2766 if (uniqueId == null) {
2767 return;
2768 }
2769 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2770 if (resolvedContainer == null) {
2771 if (containerRef.current) {
2772 containerRef.current = null;
2773 setPortalNode(null);
2774 setContainerElement(null);
2775 }
2776 return;
2777 }
2778 if (containerRef.current !== resolvedContainer) {
2779 containerRef.current = resolvedContainer;
2780 setPortalNode(null);
2781 setContainerElement(resolvedContainer);
2782 }
2783 }, [containerProp, parentPortalNode, uniqueId]);
2784 const portalElement = useRenderElement("div", componentProps, {
2785 ref: [ref, setPortalNodeRef],
2786 props: [{
2787 id: uniqueId,
2788 [attr]: ""
2789 }, elementProps]
2790 });
2791 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2792 return {
2793 portalNode,
2794 portalSubtree
2795 };
2796 }
2797 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2798 const {
2799 render: render4,
2800 className,
2801 style,
2802 children,
2803 container,
2804 renderGuards,
2805 ...elementProps
2806 } = componentProps;
2807 const {
2808 portalNode,
2809 portalSubtree
2810 } = useFloatingPortalNode({
2811 container,
2812 ref: forwardedRef,
2813 componentProps,
2814 elementProps
2815 });
2816 const beforeOutsideRef = React15.useRef(null);
2817 const afterOutsideRef = React15.useRef(null);
2818 const beforeInsideRef = React15.useRef(null);
2819 const afterInsideRef = React15.useRef(null);
2820 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2821 const focusInsideDisabledRef = React15.useRef(false);
2822 const modal = focusManagerState?.modal;
2823 const open = focusManagerState?.open;
2824 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2825 React15.useEffect(() => {
2826 if (!portalNode || modal) {
2827 return void 0;
2828 }
2829 function onFocus(event) {
2830 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2831 if (event.type === "focusin") {
2832 if (focusInsideDisabledRef.current) {
2833 enableFocusInside(portalNode);
2834 focusInsideDisabledRef.current = false;
2835 }
2836 } else {
2837 disableFocusInside(portalNode);
2838 focusInsideDisabledRef.current = true;
2839 }
2840 }
2841 }
2842 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2843 }, [portalNode, modal]);
2844 React15.useEffect(() => {
2845 if (!portalNode || open !== false) {
2846 return;
2847 }
2848 enableFocusInside(portalNode);
2849 focusInsideDisabledRef.current = false;
2850 }, [open, portalNode]);
2851 const portalContextValue = React15.useMemo(() => ({
2852 beforeOutsideRef,
2853 afterOutsideRef,
2854 beforeInsideRef,
2855 afterInsideRef,
2856 portalNode,
2857 setFocusManagerState
2858 }), [portalNode]);
2859 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, {
2860 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2861 value: portalContextValue,
2862 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2863 "data-type": "outside",
2864 ref: beforeOutsideRef,
2865 onFocus: (event) => {
2866 if (isOutsideEvent(event, portalNode)) {
2867 beforeInsideRef.current?.focus();
2868 } else {
2869 const domReference = focusManagerState ? focusManagerState.domReference : null;
2870 const prevTabbable = getPreviousTabbable(domReference);
2871 prevTabbable?.focus();
2872 }
2873 }
2874 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2875 "aria-owns": portalNode.id,
2876 style: ownerVisuallyHidden
2877 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2878 "data-type": "outside",
2879 ref: afterOutsideRef,
2880 onFocus: (event) => {
2881 if (isOutsideEvent(event, portalNode)) {
2882 afterInsideRef.current?.focus();
2883 } else {
2884 const domReference = focusManagerState ? focusManagerState.domReference : null;
2885 const nextTabbable = getNextTabbable(domReference);
2886 nextTabbable?.focus();
2887 if (focusManagerState?.closeOnFocusOut) {
2888 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2889 }
2890 }
2891 }
2892 })]
2893 })]
2894 });
2895 });
2896 if (true) FloatingPortal.displayName = "FloatingPortal";
2897
2898 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2899 var React16 = __toESM(require_react(), 1);
2900
2901 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2902 function createEventEmitter() {
2903 const map = /* @__PURE__ */ new Map();
2904 return {
2905 emit(event, data) {
2906 map.get(event)?.forEach((listener) => listener(data));
2907 },
2908 on(event, listener) {
2909 if (!map.has(event)) {
2910 map.set(event, /* @__PURE__ */ new Set());
2911 }
2912 map.get(event).add(listener);
2913 },
2914 off(event, listener) {
2915 map.get(event)?.delete(listener);
2916 }
2917 };
2918 }
2919
2920 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2921 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2922 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
2923 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2924 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
2925 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2926 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
2927 var useFloatingTree = (externalTree) => {
2928 const contextTree = React16.useContext(FloatingTreeContext);
2929 return externalTree ?? contextTree;
2930 };
2931
2932 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2933 var React17 = __toESM(require_react(), 1);
2934 function createVirtualElement(domElement, data) {
2935 let offsetX = null;
2936 let offsetY = null;
2937 let isAutoUpdateEvent = false;
2938 return {
2939 contextElement: domElement || void 0,
2940 getBoundingClientRect() {
2941 const domRect = domElement?.getBoundingClientRect() || {
2942 width: 0,
2943 height: 0,
2944 x: 0,
2945 y: 0
2946 };
2947 const isXAxis = data.axis === "x" || data.axis === "both";
2948 const isYAxis = data.axis === "y" || data.axis === "both";
2949 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2950 let width = domRect.width;
2951 let height = domRect.height;
2952 let x2 = domRect.x;
2953 let y2 = domRect.y;
2954 if (offsetX == null && data.x && isXAxis) {
2955 offsetX = domRect.x - data.x;
2956 }
2957 if (offsetY == null && data.y && isYAxis) {
2958 offsetY = domRect.y - data.y;
2959 }
2960 x2 -= offsetX || 0;
2961 y2 -= offsetY || 0;
2962 width = 0;
2963 height = 0;
2964 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2965 width = data.axis === "y" ? domRect.width : 0;
2966 height = data.axis === "x" ? domRect.height : 0;
2967 x2 = isXAxis && data.x != null ? data.x : x2;
2968 y2 = isYAxis && data.y != null ? data.y : y2;
2969 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2970 height = data.axis === "x" ? domRect.height : height;
2971 width = data.axis === "y" ? domRect.width : width;
2972 }
2973 isAutoUpdateEvent = true;
2974 return {
2975 width,
2976 height,
2977 x: x2,
2978 y: y2,
2979 top: y2,
2980 right: x2 + width,
2981 bottom: y2 + height,
2982 left: x2
2983 };
2984 }
2985 };
2986 }
2987 function isMouseBasedEvent(event) {
2988 return event != null && event.clientX != null;
2989 }
2990 function useClientPoint(context, props = {}) {
2991 const {
2992 enabled = true,
2993 axis = "both"
2994 } = props;
2995 const store = "rootStore" in context ? context.rootStore : context;
2996 const open = store.useState("open");
2997 const floating = store.useState("floatingElement");
2998 const domReference = store.useState("domReferenceElement");
2999 const dataRef = store.context.dataRef;
3000 const initialRef = React17.useRef(false);
3001 const cleanupListenerRef = React17.useRef(null);
3002 const [pointerType, setPointerType] = React17.useState();
3003 const [reactive, setReactive] = React17.useState([]);
3004 const resetReference = useStableCallback((reference2) => {
3005 store.set("positionReference", reference2);
3006 });
3007 const setReference = useStableCallback((newX, newY, referenceElement) => {
3008 if (initialRef.current) {
3009 return;
3010 }
3011 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3012 return;
3013 }
3014 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3015 x: newX,
3016 y: newY,
3017 axis,
3018 dataRef,
3019 pointerType
3020 }));
3021 });
3022 const handleReferenceEnterOrMove = useStableCallback((event) => {
3023 if (!open) {
3024 setReference(event.clientX, event.clientY, event.currentTarget);
3025 } else if (!cleanupListenerRef.current) {
3026 setReference(event.clientX, event.clientY, event.currentTarget);
3027 setReactive([]);
3028 }
3029 });
3030 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3031 React17.useEffect(() => {
3032 if (!enabled) {
3033 resetReference(domReference);
3034 return void 0;
3035 }
3036 if (!openCheck) {
3037 return void 0;
3038 }
3039 function cleanupListener() {
3040 cleanupListenerRef.current?.();
3041 cleanupListenerRef.current = null;
3042 }
3043 const win = getWindow(floating);
3044 function handleMouseMove(event) {
3045 const target = getTarget(event);
3046 if (!contains(floating, target)) {
3047 setReference(event.clientX, event.clientY);
3048 } else {
3049 cleanupListener();
3050 }
3051 }
3052 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3053 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3054 } else {
3055 resetReference(domReference);
3056 }
3057 return cleanupListener;
3058 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3059 React17.useEffect(() => () => {
3060 store.set("positionReference", null);
3061 }, [store]);
3062 React17.useEffect(() => {
3063 if (enabled && !floating) {
3064 initialRef.current = false;
3065 }
3066 }, [enabled, floating]);
3067 React17.useEffect(() => {
3068 if (!enabled && open) {
3069 initialRef.current = true;
3070 }
3071 }, [enabled, open]);
3072 const reference = React17.useMemo(() => {
3073 function setPointerTypeRef(event) {
3074 setPointerType(event.pointerType);
3075 }
3076 return {
3077 onPointerDown: setPointerTypeRef,
3078 onPointerEnter: setPointerTypeRef,
3079 onMouseMove: handleReferenceEnterOrMove,
3080 onMouseEnter: handleReferenceEnterOrMove
3081 };
3082 }, [handleReferenceEnterOrMove]);
3083 return React17.useMemo(() => enabled ? {
3084 reference,
3085 trigger: reference
3086 } : {}, [enabled, reference]);
3087 }
3088
3089 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3090 var React18 = __toESM(require_react(), 1);
3091 var bubbleHandlerKeys = {
3092 intentional: "onClick",
3093 sloppy: "onPointerDown"
3094 };
3095 function alwaysFalse() {
3096 return false;
3097 }
3098 function normalizeProp(normalizable) {
3099 return {
3100 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3101 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3102 };
3103 }
3104 function useDismiss(context, props = {}) {
3105 const {
3106 enabled = true,
3107 escapeKey: escapeKey2 = true,
3108 outsidePress: outsidePressProp = true,
3109 outsidePressEvent = "sloppy",
3110 referencePress = alwaysFalse,
3111 referencePressEvent = "sloppy",
3112 bubbles,
3113 externalTree
3114 } = props;
3115 const store = "rootStore" in context ? context.rootStore : context;
3116 const open = store.useState("open");
3117 const floatingElement = store.useState("floatingElement");
3118 const {
3119 dataRef
3120 } = store.context;
3121 const tree = useFloatingTree(externalTree);
3122 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3123 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3124 const outsidePressEnabled = outsidePress2 !== false;
3125 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3126 const {
3127 escapeKey: escapeKeyBubbles,
3128 outsidePress: outsidePressBubbles
3129 } = normalizeProp(bubbles);
3130 const pressStartedInsideRef = React18.useRef(false);
3131 const pressStartPreventedRef = React18.useRef(false);
3132 const suppressNextOutsideClickRef = React18.useRef(false);
3133 const isComposingRef = React18.useRef(false);
3134 const currentPointerTypeRef = React18.useRef("");
3135 const touchStateRef = React18.useRef(null);
3136 const cancelDismissOnEndTimeout = useTimeout();
3137 const clearInsideReactTreeTimeout = useTimeout();
3138 const clearInsideReactTree = useStableCallback(() => {
3139 clearInsideReactTreeTimeout.clear();
3140 dataRef.current.insideReactTree = false;
3141 });
3142 const hasBlockingChild = useStableCallback((bubbleKey) => {
3143 const nodeId = dataRef.current.floatingContext?.nodeId;
3144 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3145 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3146 });
3147 const isEventWithinOwnElements = useStableCallback((event) => {
3148 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3149 });
3150 const closeOnReferencePress = useStableCallback((event) => {
3151 if (!referencePress()) {
3152 return;
3153 }
3154 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3155 });
3156 const closeOnEscapeKeyDown = useStableCallback((event) => {
3157 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3158 return;
3159 }
3160 if (isComposingRef.current) {
3161 return;
3162 }
3163 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3164 return;
3165 }
3166 const native = isReactEvent(event) ? event.nativeEvent : event;
3167 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3168 store.setOpen(false, eventDetails);
3169 if (!eventDetails.isCanceled) {
3170 event.preventDefault();
3171 }
3172 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3173 event.stopPropagation();
3174 }
3175 });
3176 const markInsideReactTree = useStableCallback(() => {
3177 dataRef.current.insideReactTree = true;
3178 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3179 });
3180 const markPressStartedInsideReactTree = useStableCallback((event) => {
3181 if (!open || !enabled || event.button !== 0) {
3182 return;
3183 }
3184 const target = getTarget(event.nativeEvent);
3185 if (!contains(store.select("floatingElement"), target)) {
3186 return;
3187 }
3188 if (!pressStartedInsideRef.current) {
3189 pressStartedInsideRef.current = true;
3190 pressStartPreventedRef.current = false;
3191 }
3192 });
3193 const markInsidePressStartPrevented = useStableCallback((event) => {
3194 if (!open || !enabled) {
3195 return;
3196 }
3197 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3198 return;
3199 }
3200 if (pressStartedInsideRef.current) {
3201 pressStartPreventedRef.current = true;
3202 }
3203 });
3204 React18.useEffect(() => {
3205 if (!open || !enabled) {
3206 return void 0;
3207 }
3208 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3209 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3210 const compositionTimeout = new Timeout();
3211 const preventedPressSuppressionTimeout = new Timeout();
3212 function handleCompositionStart() {
3213 compositionTimeout.clear();
3214 isComposingRef.current = true;
3215 }
3216 function handleCompositionEnd() {
3217 compositionTimeout.start(
3218 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3219 // Only apply to WebKit for the test to remain 0ms.
3220 isWebKit() ? 5 : 0,
3221 () => {
3222 isComposingRef.current = false;
3223 }
3224 );
3225 }
3226 function suppressImmediateOutsideClickAfterPreventedStart() {
3227 suppressNextOutsideClickRef.current = true;
3228 preventedPressSuppressionTimeout.start(0, () => {
3229 suppressNextOutsideClickRef.current = false;
3230 });
3231 }
3232 function resetPressStartState() {
3233 pressStartedInsideRef.current = false;
3234 pressStartPreventedRef.current = false;
3235 }
3236 function getOutsidePressEvent() {
3237 const type = currentPointerTypeRef.current;
3238 const computedType = type === "pen" || !type ? "mouse" : type;
3239 const outsidePressEventValue = getOutsidePressEventProp();
3240 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3241 if (typeof resolved === "string") {
3242 return resolved;
3243 }
3244 return resolved[computedType];
3245 }
3246 function shouldIgnoreEvent(event) {
3247 const computedOutsidePressEvent = getOutsidePressEvent();
3248 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3249 }
3250 function isEventWithinFloatingTree(event) {
3251 const nodeId = dataRef.current.floatingContext?.nodeId;
3252 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3253 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3254 }
3255 function closeOnPressOutside(event) {
3256 if (shouldIgnoreEvent(event)) {
3257 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3258 preventedPressSuppressionTimeout.clear();
3259 suppressNextOutsideClickRef.current = false;
3260 }
3261 clearInsideReactTree();
3262 return;
3263 }
3264 if (dataRef.current.insideReactTree) {
3265 clearInsideReactTree();
3266 return;
3267 }
3268 const target = getTarget(event);
3269 const inertSelector = `[${createAttribute("inert")}]`;
3270 const targetRoot = isElement(target) ? target.getRootNode() : null;
3271 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3272 const triggers = store.context.triggerElements;
3273 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3274 return;
3275 }
3276 let targetRootAncestor = isElement(target) ? target : null;
3277 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3278 const nextParent = getParentNode(targetRootAncestor);
3279 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3280 break;
3281 }
3282 targetRootAncestor = nextParent;
3283 }
3284 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3285 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3286 // element was injected after the floating element rendered.
3287 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3288 return;
3289 }
3290 if (isHTMLElement(target) && !("touches" in event)) {
3291 const lastTraversableNode = isLastTraversableNode(target);
3292 const style = getComputedStyle2(target);
3293 const scrollRe = /auto|scroll/;
3294 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3295 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3296 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3297 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3298 const isRTL7 = style.direction === "rtl";
3299 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3300 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3301 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3302 return;
3303 }
3304 }
3305 if (isEventWithinFloatingTree(event)) {
3306 return;
3307 }
3308 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3309 preventedPressSuppressionTimeout.clear();
3310 suppressNextOutsideClickRef.current = false;
3311 return;
3312 }
3313 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3314 return;
3315 }
3316 if (hasBlockingChild("__outsidePressBubbles")) {
3317 return;
3318 }
3319 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3320 clearInsideReactTree();
3321 }
3322 function handlePointerDown(event) {
3323 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3324 return;
3325 }
3326 closeOnPressOutside(event);
3327 }
3328 function handleTouchStart(event) {
3329 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3330 return;
3331 }
3332 const touch = event.touches[0];
3333 if (touch) {
3334 touchStateRef.current = {
3335 startTime: Date.now(),
3336 startX: touch.clientX,
3337 startY: touch.clientY,
3338 dismissOnTouchEnd: false,
3339 dismissOnMouseDown: true
3340 };
3341 cancelDismissOnEndTimeout.start(1e3, () => {
3342 if (touchStateRef.current) {
3343 touchStateRef.current.dismissOnTouchEnd = false;
3344 touchStateRef.current.dismissOnMouseDown = false;
3345 }
3346 });
3347 }
3348 }
3349 function addTargetEventListenerOnce(event, listener) {
3350 const target = getTarget(event);
3351 if (!target) {
3352 return;
3353 }
3354 const unsubscribe2 = addEventListener(target, event.type, () => {
3355 listener(event);
3356 unsubscribe2();
3357 });
3358 }
3359 function handleTouchStartCapture(event) {
3360 currentPointerTypeRef.current = "touch";
3361 addTargetEventListenerOnce(event, handleTouchStart);
3362 }
3363 function closeOnPressOutsideCapture(event) {
3364 cancelDismissOnEndTimeout.clear();
3365 if (event.type === "pointerdown") {
3366 currentPointerTypeRef.current = event.pointerType;
3367 }
3368 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3369 return;
3370 }
3371 addTargetEventListenerOnce(event, (targetEvent) => {
3372 if (targetEvent.type === "pointerdown") {
3373 handlePointerDown(targetEvent);
3374 } else {
3375 closeOnPressOutside(targetEvent);
3376 }
3377 });
3378 }
3379 function handlePressEndCapture(event) {
3380 if (!pressStartedInsideRef.current) {
3381 return;
3382 }
3383 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3384 resetPressStartState();
3385 if (getOutsidePressEvent() !== "intentional") {
3386 return;
3387 }
3388 if (event.type === "pointercancel") {
3389 if (pressStartedInsideDefaultPrevented) {
3390 suppressImmediateOutsideClickAfterPreventedStart();
3391 }
3392 return;
3393 }
3394 if (isEventWithinFloatingTree(event)) {
3395 return;
3396 }
3397 if (pressStartedInsideDefaultPrevented) {
3398 suppressImmediateOutsideClickAfterPreventedStart();
3399 return;
3400 }
3401 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3402 return;
3403 }
3404 preventedPressSuppressionTimeout.clear();
3405 suppressNextOutsideClickRef.current = true;
3406 clearInsideReactTree();
3407 }
3408 function handleTouchMove(event) {
3409 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3410 return;
3411 }
3412 const touch = event.touches[0];
3413 if (!touch) {
3414 return;
3415 }
3416 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3417 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3418 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3419 if (distance > 5) {
3420 touchStateRef.current.dismissOnTouchEnd = true;
3421 }
3422 if (distance > 10) {
3423 closeOnPressOutside(event);
3424 cancelDismissOnEndTimeout.clear();
3425 touchStateRef.current = null;
3426 }
3427 }
3428 function handleTouchMoveCapture(event) {
3429 addTargetEventListenerOnce(event, handleTouchMove);
3430 }
3431 function handleTouchEnd(event) {
3432 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3433 return;
3434 }
3435 if (touchStateRef.current.dismissOnTouchEnd) {
3436 closeOnPressOutside(event);
3437 }
3438 cancelDismissOnEndTimeout.clear();
3439 touchStateRef.current = null;
3440 }
3441 function handleTouchEndCapture(event) {
3442 addTargetEventListenerOnce(event, handleTouchEnd);
3443 }
3444 const doc = ownerDocument(floatingElement);
3445 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)));
3446 return () => {
3447 unsubscribe();
3448 compositionTimeout.clear();
3449 preventedPressSuppressionTimeout.clear();
3450 resetPressStartState();
3451 suppressNextOutsideClickRef.current = false;
3452 };
3453 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3454 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3455 const reference = React18.useMemo(() => ({
3456 onKeyDown: closeOnEscapeKeyDown,
3457 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3458 ...referencePressEvent !== "intentional" && {
3459 onClick: closeOnReferencePress
3460 }
3461 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3462 const floating = React18.useMemo(() => ({
3463 onKeyDown: closeOnEscapeKeyDown,
3464 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3465 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3466 // See https://github.com/mui/base-ui/pull/3379
3467 onPointerDown: markInsidePressStartPrevented,
3468 onMouseDown: markInsidePressStartPrevented,
3469 onClickCapture: markInsideReactTree,
3470 onMouseDownCapture(event) {
3471 markInsideReactTree();
3472 markPressStartedInsideReactTree(event);
3473 },
3474 onPointerDownCapture(event) {
3475 markInsideReactTree();
3476 markPressStartedInsideReactTree(event);
3477 },
3478 onMouseUpCapture: markInsideReactTree,
3479 onTouchEndCapture: markInsideReactTree,
3480 onTouchMoveCapture: markInsideReactTree
3481 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3482 return React18.useMemo(() => enabled ? {
3483 reference,
3484 floating,
3485 trigger: reference
3486 } : {}, [enabled, reference, floating]);
3487 }
3488
3489 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3490 var React25 = __toESM(require_react(), 1);
3491
3492 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3493 function computeCoordsFromPlacement(_ref, placement, rtl) {
3494 let {
3495 reference,
3496 floating
3497 } = _ref;
3498 const sideAxis = getSideAxis(placement);
3499 const alignmentAxis = getAlignmentAxis(placement);
3500 const alignLength = getAxisLength(alignmentAxis);
3501 const side = getSide(placement);
3502 const isVertical = sideAxis === "y";
3503 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3504 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3505 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3506 let coords;
3507 switch (side) {
3508 case "top":
3509 coords = {
3510 x: commonX,
3511 y: reference.y - floating.height
3512 };
3513 break;
3514 case "bottom":
3515 coords = {
3516 x: commonX,
3517 y: reference.y + reference.height
3518 };
3519 break;
3520 case "right":
3521 coords = {
3522 x: reference.x + reference.width,
3523 y: commonY
3524 };
3525 break;
3526 case "left":
3527 coords = {
3528 x: reference.x - floating.width,
3529 y: commonY
3530 };
3531 break;
3532 default:
3533 coords = {
3534 x: reference.x,
3535 y: reference.y
3536 };
3537 }
3538 switch (getAlignment(placement)) {
3539 case "start":
3540 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3541 break;
3542 case "end":
3543 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3544 break;
3545 }
3546 return coords;
3547 }
3548 async function detectOverflow(state, options) {
3549 var _await$platform$isEle;
3550 if (options === void 0) {
3551 options = {};
3552 }
3553 const {
3554 x: x2,
3555 y: y2,
3556 platform: platform3,
3557 rects,
3558 elements,
3559 strategy
3560 } = state;
3561 const {
3562 boundary = "clippingAncestors",
3563 rootBoundary = "viewport",
3564 elementContext = "floating",
3565 altBoundary = false,
3566 padding = 0
3567 } = evaluate(options, state);
3568 const paddingObject = getPaddingObject(padding);
3569 const altContext = elementContext === "floating" ? "reference" : "floating";
3570 const element = elements[altBoundary ? altContext : elementContext];
3571 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3572 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)),
3573 boundary,
3574 rootBoundary,
3575 strategy
3576 }));
3577 const rect = elementContext === "floating" ? {
3578 x: x2,
3579 y: y2,
3580 width: rects.floating.width,
3581 height: rects.floating.height
3582 } : rects.reference;
3583 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3584 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3585 x: 1,
3586 y: 1
3587 } : {
3588 x: 1,
3589 y: 1
3590 };
3591 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3592 elements,
3593 rect,
3594 offsetParent,
3595 strategy
3596 }) : rect);
3597 return {
3598 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3599 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3600 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3601 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3602 };
3603 }
3604 var MAX_RESET_COUNT = 50;
3605 var computePosition = async (reference, floating, config) => {
3606 const {
3607 placement = "bottom",
3608 strategy = "absolute",
3609 middleware = [],
3610 platform: platform3
3611 } = config;
3612 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3613 ...platform3,
3614 detectOverflow
3615 };
3616 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3617 let rects = await platform3.getElementRects({
3618 reference,
3619 floating,
3620 strategy
3621 });
3622 let {
3623 x: x2,
3624 y: y2
3625 } = computeCoordsFromPlacement(rects, placement, rtl);
3626 let statefulPlacement = placement;
3627 let resetCount = 0;
3628 const middlewareData = {};
3629 for (let i2 = 0; i2 < middleware.length; i2++) {
3630 const currentMiddleware = middleware[i2];
3631 if (!currentMiddleware) {
3632 continue;
3633 }
3634 const {
3635 name,
3636 fn
3637 } = currentMiddleware;
3638 const {
3639 x: nextX,
3640 y: nextY,
3641 data,
3642 reset
3643 } = await fn({
3644 x: x2,
3645 y: y2,
3646 initialPlacement: placement,
3647 placement: statefulPlacement,
3648 strategy,
3649 middlewareData,
3650 rects,
3651 platform: platformWithDetectOverflow,
3652 elements: {
3653 reference,
3654 floating
3655 }
3656 });
3657 x2 = nextX != null ? nextX : x2;
3658 y2 = nextY != null ? nextY : y2;
3659 middlewareData[name] = {
3660 ...middlewareData[name],
3661 ...data
3662 };
3663 if (reset && resetCount < MAX_RESET_COUNT) {
3664 resetCount++;
3665 if (typeof reset === "object") {
3666 if (reset.placement) {
3667 statefulPlacement = reset.placement;
3668 }
3669 if (reset.rects) {
3670 rects = reset.rects === true ? await platform3.getElementRects({
3671 reference,
3672 floating,
3673 strategy
3674 }) : reset.rects;
3675 }
3676 ({
3677 x: x2,
3678 y: y2
3679 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3680 }
3681 i2 = -1;
3682 }
3683 }
3684 return {
3685 x: x2,
3686 y: y2,
3687 placement: statefulPlacement,
3688 strategy,
3689 middlewareData
3690 };
3691 };
3692 var flip = function(options) {
3693 if (options === void 0) {
3694 options = {};
3695 }
3696 return {
3697 name: "flip",
3698 options,
3699 async fn(state) {
3700 var _middlewareData$arrow, _middlewareData$flip;
3701 const {
3702 placement,
3703 middlewareData,
3704 rects,
3705 initialPlacement,
3706 platform: platform3,
3707 elements
3708 } = state;
3709 const {
3710 mainAxis: checkMainAxis = true,
3711 crossAxis: checkCrossAxis = true,
3712 fallbackPlacements: specifiedFallbackPlacements,
3713 fallbackStrategy = "bestFit",
3714 fallbackAxisSideDirection = "none",
3715 flipAlignment = true,
3716 ...detectOverflowOptions
3717 } = evaluate(options, state);
3718 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3719 return {};
3720 }
3721 const side = getSide(placement);
3722 const initialSideAxis = getSideAxis(initialPlacement);
3723 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3724 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3725 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3726 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3727 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3728 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3729 }
3730 const placements2 = [initialPlacement, ...fallbackPlacements];
3731 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3732 const overflows = [];
3733 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3734 if (checkMainAxis) {
3735 overflows.push(overflow[side]);
3736 }
3737 if (checkCrossAxis) {
3738 const sides2 = getAlignmentSides(placement, rects, rtl);
3739 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3740 }
3741 overflowsData = [...overflowsData, {
3742 placement,
3743 overflows
3744 }];
3745 if (!overflows.every((side2) => side2 <= 0)) {
3746 var _middlewareData$flip2, _overflowsData$filter;
3747 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3748 const nextPlacement = placements2[nextIndex];
3749 if (nextPlacement) {
3750 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3751 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3752 // overflows the main axis.
3753 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3754 return {
3755 data: {
3756 index: nextIndex,
3757 overflows: overflowsData
3758 },
3759 reset: {
3760 placement: nextPlacement
3761 }
3762 };
3763 }
3764 }
3765 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;
3766 if (!resetPlacement) {
3767 switch (fallbackStrategy) {
3768 case "bestFit": {
3769 var _overflowsData$filter2;
3770 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3771 if (hasFallbackAxisSideDirection) {
3772 const currentSideAxis = getSideAxis(d2.placement);
3773 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3774 // reading directions favoring greater width.
3775 currentSideAxis === "y";
3776 }
3777 return true;
3778 }).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];
3779 if (placement2) {
3780 resetPlacement = placement2;
3781 }
3782 break;
3783 }
3784 case "initialPlacement":
3785 resetPlacement = initialPlacement;
3786 break;
3787 }
3788 }
3789 if (placement !== resetPlacement) {
3790 return {
3791 reset: {
3792 placement: resetPlacement
3793 }
3794 };
3795 }
3796 }
3797 return {};
3798 }
3799 };
3800 };
3801 function getSideOffsets(overflow, rect) {
3802 return {
3803 top: overflow.top - rect.height,
3804 right: overflow.right - rect.width,
3805 bottom: overflow.bottom - rect.height,
3806 left: overflow.left - rect.width
3807 };
3808 }
3809 function isAnySideFullyClipped(overflow) {
3810 return sides.some((side) => overflow[side] >= 0);
3811 }
3812 var hide = function(options) {
3813 if (options === void 0) {
3814 options = {};
3815 }
3816 return {
3817 name: "hide",
3818 options,
3819 async fn(state) {
3820 const {
3821 rects,
3822 platform: platform3
3823 } = state;
3824 const {
3825 strategy = "referenceHidden",
3826 ...detectOverflowOptions
3827 } = evaluate(options, state);
3828 switch (strategy) {
3829 case "referenceHidden": {
3830 const overflow = await platform3.detectOverflow(state, {
3831 ...detectOverflowOptions,
3832 elementContext: "reference"
3833 });
3834 const offsets = getSideOffsets(overflow, rects.reference);
3835 return {
3836 data: {
3837 referenceHiddenOffsets: offsets,
3838 referenceHidden: isAnySideFullyClipped(offsets)
3839 }
3840 };
3841 }
3842 case "escaped": {
3843 const overflow = await platform3.detectOverflow(state, {
3844 ...detectOverflowOptions,
3845 altBoundary: true
3846 });
3847 const offsets = getSideOffsets(overflow, rects.floating);
3848 return {
3849 data: {
3850 escapedOffsets: offsets,
3851 escaped: isAnySideFullyClipped(offsets)
3852 }
3853 };
3854 }
3855 default: {
3856 return {};
3857 }
3858 }
3859 }
3860 };
3861 };
3862 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3863 async function convertValueToCoords(state, options) {
3864 const {
3865 placement,
3866 platform: platform3,
3867 elements
3868 } = state;
3869 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3870 const side = getSide(placement);
3871 const alignment = getAlignment(placement);
3872 const isVertical = getSideAxis(placement) === "y";
3873 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3874 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3875 const rawValue = evaluate(options, state);
3876 let {
3877 mainAxis,
3878 crossAxis,
3879 alignmentAxis
3880 } = typeof rawValue === "number" ? {
3881 mainAxis: rawValue,
3882 crossAxis: 0,
3883 alignmentAxis: null
3884 } : {
3885 mainAxis: rawValue.mainAxis || 0,
3886 crossAxis: rawValue.crossAxis || 0,
3887 alignmentAxis: rawValue.alignmentAxis
3888 };
3889 if (alignment && typeof alignmentAxis === "number") {
3890 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3891 }
3892 return isVertical ? {
3893 x: crossAxis * crossAxisMulti,
3894 y: mainAxis * mainAxisMulti
3895 } : {
3896 x: mainAxis * mainAxisMulti,
3897 y: crossAxis * crossAxisMulti
3898 };
3899 }
3900 var offset = function(options) {
3901 if (options === void 0) {
3902 options = 0;
3903 }
3904 return {
3905 name: "offset",
3906 options,
3907 async fn(state) {
3908 var _middlewareData$offse, _middlewareData$arrow;
3909 const {
3910 x: x2,
3911 y: y2,
3912 placement,
3913 middlewareData
3914 } = state;
3915 const diffCoords = await convertValueToCoords(state, options);
3916 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3917 return {};
3918 }
3919 return {
3920 x: x2 + diffCoords.x,
3921 y: y2 + diffCoords.y,
3922 data: {
3923 ...diffCoords,
3924 placement
3925 }
3926 };
3927 }
3928 };
3929 };
3930 var shift = function(options) {
3931 if (options === void 0) {
3932 options = {};
3933 }
3934 return {
3935 name: "shift",
3936 options,
3937 async fn(state) {
3938 const {
3939 x: x2,
3940 y: y2,
3941 placement,
3942 platform: platform3
3943 } = state;
3944 const {
3945 mainAxis: checkMainAxis = true,
3946 crossAxis: checkCrossAxis = false,
3947 limiter = {
3948 fn: (_ref) => {
3949 let {
3950 x: x3,
3951 y: y3
3952 } = _ref;
3953 return {
3954 x: x3,
3955 y: y3
3956 };
3957 }
3958 },
3959 ...detectOverflowOptions
3960 } = evaluate(options, state);
3961 const coords = {
3962 x: x2,
3963 y: y2
3964 };
3965 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3966 const crossAxis = getSideAxis(getSide(placement));
3967 const mainAxis = getOppositeAxis(crossAxis);
3968 let mainAxisCoord = coords[mainAxis];
3969 let crossAxisCoord = coords[crossAxis];
3970 if (checkMainAxis) {
3971 const minSide = mainAxis === "y" ? "top" : "left";
3972 const maxSide = mainAxis === "y" ? "bottom" : "right";
3973 const min2 = mainAxisCoord + overflow[minSide];
3974 const max2 = mainAxisCoord - overflow[maxSide];
3975 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3976 }
3977 if (checkCrossAxis) {
3978 const minSide = crossAxis === "y" ? "top" : "left";
3979 const maxSide = crossAxis === "y" ? "bottom" : "right";
3980 const min2 = crossAxisCoord + overflow[minSide];
3981 const max2 = crossAxisCoord - overflow[maxSide];
3982 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3983 }
3984 const limitedCoords = limiter.fn({
3985 ...state,
3986 [mainAxis]: mainAxisCoord,
3987 [crossAxis]: crossAxisCoord
3988 });
3989 return {
3990 ...limitedCoords,
3991 data: {
3992 x: limitedCoords.x - x2,
3993 y: limitedCoords.y - y2,
3994 enabled: {
3995 [mainAxis]: checkMainAxis,
3996 [crossAxis]: checkCrossAxis
3997 }
3998 }
3999 };
4000 }
4001 };
4002 };
4003 var limitShift = function(options) {
4004 if (options === void 0) {
4005 options = {};
4006 }
4007 return {
4008 options,
4009 fn(state) {
4010 const {
4011 x: x2,
4012 y: y2,
4013 placement,
4014 rects,
4015 middlewareData
4016 } = state;
4017 const {
4018 offset: offset4 = 0,
4019 mainAxis: checkMainAxis = true,
4020 crossAxis: checkCrossAxis = true
4021 } = evaluate(options, state);
4022 const coords = {
4023 x: x2,
4024 y: y2
4025 };
4026 const crossAxis = getSideAxis(placement);
4027 const mainAxis = getOppositeAxis(crossAxis);
4028 let mainAxisCoord = coords[mainAxis];
4029 let crossAxisCoord = coords[crossAxis];
4030 const rawOffset = evaluate(offset4, state);
4031 const computedOffset = typeof rawOffset === "number" ? {
4032 mainAxis: rawOffset,
4033 crossAxis: 0
4034 } : {
4035 mainAxis: 0,
4036 crossAxis: 0,
4037 ...rawOffset
4038 };
4039 if (checkMainAxis) {
4040 const len = mainAxis === "y" ? "height" : "width";
4041 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4042 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4043 if (mainAxisCoord < limitMin) {
4044 mainAxisCoord = limitMin;
4045 } else if (mainAxisCoord > limitMax) {
4046 mainAxisCoord = limitMax;
4047 }
4048 }
4049 if (checkCrossAxis) {
4050 var _middlewareData$offse, _middlewareData$offse2;
4051 const len = mainAxis === "y" ? "width" : "height";
4052 const isOriginSide = originSides.has(getSide(placement));
4053 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);
4054 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);
4055 if (crossAxisCoord < limitMin) {
4056 crossAxisCoord = limitMin;
4057 } else if (crossAxisCoord > limitMax) {
4058 crossAxisCoord = limitMax;
4059 }
4060 }
4061 return {
4062 [mainAxis]: mainAxisCoord,
4063 [crossAxis]: crossAxisCoord
4064 };
4065 }
4066 };
4067 };
4068 var size = function(options) {
4069 if (options === void 0) {
4070 options = {};
4071 }
4072 return {
4073 name: "size",
4074 options,
4075 async fn(state) {
4076 var _state$middlewareData, _state$middlewareData2;
4077 const {
4078 placement,
4079 rects,
4080 platform: platform3,
4081 elements
4082 } = state;
4083 const {
4084 apply = () => {
4085 },
4086 ...detectOverflowOptions
4087 } = evaluate(options, state);
4088 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4089 const side = getSide(placement);
4090 const alignment = getAlignment(placement);
4091 const isYAxis = getSideAxis(placement) === "y";
4092 const {
4093 width,
4094 height
4095 } = rects.floating;
4096 let heightSide;
4097 let widthSide;
4098 if (side === "top" || side === "bottom") {
4099 heightSide = side;
4100 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4101 } else {
4102 widthSide = side;
4103 heightSide = alignment === "end" ? "top" : "bottom";
4104 }
4105 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4106 const maximumClippingWidth = width - overflow.left - overflow.right;
4107 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4108 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4109 const noShift = !state.middlewareData.shift;
4110 let availableHeight = overflowAvailableHeight;
4111 let availableWidth = overflowAvailableWidth;
4112 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4113 availableWidth = maximumClippingWidth;
4114 }
4115 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4116 availableHeight = maximumClippingHeight;
4117 }
4118 if (noShift && !alignment) {
4119 const xMin = max(overflow.left, 0);
4120 const xMax = max(overflow.right, 0);
4121 const yMin = max(overflow.top, 0);
4122 const yMax = max(overflow.bottom, 0);
4123 if (isYAxis) {
4124 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4125 } else {
4126 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4127 }
4128 }
4129 await apply({
4130 ...state,
4131 availableWidth,
4132 availableHeight
4133 });
4134 const nextDimensions = await platform3.getDimensions(elements.floating);
4135 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4136 return {
4137 reset: {
4138 rects: true
4139 }
4140 };
4141 }
4142 return {};
4143 }
4144 };
4145 };
4146
4147 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4148 function getCssDimensions(element) {
4149 const css = getComputedStyle2(element);
4150 let width = parseFloat(css.width) || 0;
4151 let height = parseFloat(css.height) || 0;
4152 const hasOffset = isHTMLElement(element);
4153 const offsetWidth = hasOffset ? element.offsetWidth : width;
4154 const offsetHeight = hasOffset ? element.offsetHeight : height;
4155 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4156 if (shouldFallback) {
4157 width = offsetWidth;
4158 height = offsetHeight;
4159 }
4160 return {
4161 width,
4162 height,
4163 $: shouldFallback
4164 };
4165 }
4166 function unwrapElement(element) {
4167 return !isElement(element) ? element.contextElement : element;
4168 }
4169 function getScale(element) {
4170 const domElement = unwrapElement(element);
4171 if (!isHTMLElement(domElement)) {
4172 return createCoords(1);
4173 }
4174 const rect = domElement.getBoundingClientRect();
4175 const {
4176 width,
4177 height,
4178 $: $2
4179 } = getCssDimensions(domElement);
4180 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4181 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4182 if (!x2 || !Number.isFinite(x2)) {
4183 x2 = 1;
4184 }
4185 if (!y2 || !Number.isFinite(y2)) {
4186 y2 = 1;
4187 }
4188 return {
4189 x: x2,
4190 y: y2
4191 };
4192 }
4193 var noOffsets = /* @__PURE__ */ createCoords(0);
4194 function getVisualOffsets(element) {
4195 const win = getWindow(element);
4196 if (!isWebKit() || !win.visualViewport) {
4197 return noOffsets;
4198 }
4199 return {
4200 x: win.visualViewport.offsetLeft,
4201 y: win.visualViewport.offsetTop
4202 };
4203 }
4204 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4205 if (isFixed === void 0) {
4206 isFixed = false;
4207 }
4208 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4209 return false;
4210 }
4211 return isFixed;
4212 }
4213 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4214 if (includeScale === void 0) {
4215 includeScale = false;
4216 }
4217 if (isFixedStrategy === void 0) {
4218 isFixedStrategy = false;
4219 }
4220 const clientRect = element.getBoundingClientRect();
4221 const domElement = unwrapElement(element);
4222 let scale = createCoords(1);
4223 if (includeScale) {
4224 if (offsetParent) {
4225 if (isElement(offsetParent)) {
4226 scale = getScale(offsetParent);
4227 }
4228 } else {
4229 scale = getScale(element);
4230 }
4231 }
4232 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4233 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4234 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4235 let width = clientRect.width / scale.x;
4236 let height = clientRect.height / scale.y;
4237 if (domElement) {
4238 const win = getWindow(domElement);
4239 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4240 let currentWin = win;
4241 let currentIFrame = getFrameElement(currentWin);
4242 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4243 const iframeScale = getScale(currentIFrame);
4244 const iframeRect = currentIFrame.getBoundingClientRect();
4245 const css = getComputedStyle2(currentIFrame);
4246 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4247 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4248 x2 *= iframeScale.x;
4249 y2 *= iframeScale.y;
4250 width *= iframeScale.x;
4251 height *= iframeScale.y;
4252 x2 += left;
4253 y2 += top;
4254 currentWin = getWindow(currentIFrame);
4255 currentIFrame = getFrameElement(currentWin);
4256 }
4257 }
4258 return rectToClientRect({
4259 width,
4260 height,
4261 x: x2,
4262 y: y2
4263 });
4264 }
4265 function getWindowScrollBarX(element, rect) {
4266 const leftScroll = getNodeScroll(element).scrollLeft;
4267 if (!rect) {
4268 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4269 }
4270 return rect.left + leftScroll;
4271 }
4272 function getHTMLOffset(documentElement, scroll) {
4273 const htmlRect = documentElement.getBoundingClientRect();
4274 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4275 const y2 = htmlRect.top + scroll.scrollTop;
4276 return {
4277 x: x2,
4278 y: y2
4279 };
4280 }
4281 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4282 let {
4283 elements,
4284 rect,
4285 offsetParent,
4286 strategy
4287 } = _ref;
4288 const isFixed = strategy === "fixed";
4289 const documentElement = getDocumentElement(offsetParent);
4290 const topLayer = elements ? isTopLayer(elements.floating) : false;
4291 if (offsetParent === documentElement || topLayer && isFixed) {
4292 return rect;
4293 }
4294 let scroll = {
4295 scrollLeft: 0,
4296 scrollTop: 0
4297 };
4298 let scale = createCoords(1);
4299 const offsets = createCoords(0);
4300 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4301 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4302 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4303 scroll = getNodeScroll(offsetParent);
4304 }
4305 if (isOffsetParentAnElement) {
4306 const offsetRect = getBoundingClientRect(offsetParent);
4307 scale = getScale(offsetParent);
4308 offsets.x = offsetRect.x + offsetParent.clientLeft;
4309 offsets.y = offsetRect.y + offsetParent.clientTop;
4310 }
4311 }
4312 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4313 return {
4314 width: rect.width * scale.x,
4315 height: rect.height * scale.y,
4316 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4317 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4318 };
4319 }
4320 function getClientRects(element) {
4321 return Array.from(element.getClientRects());
4322 }
4323 function getDocumentRect(element) {
4324 const html = getDocumentElement(element);
4325 const scroll = getNodeScroll(element);
4326 const body = element.ownerDocument.body;
4327 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4328 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4329 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4330 const y2 = -scroll.scrollTop;
4331 if (getComputedStyle2(body).direction === "rtl") {
4332 x2 += max(html.clientWidth, body.clientWidth) - width;
4333 }
4334 return {
4335 width,
4336 height,
4337 x: x2,
4338 y: y2
4339 };
4340 }
4341 var SCROLLBAR_MAX = 25;
4342 function getViewportRect(element, strategy) {
4343 const win = getWindow(element);
4344 const html = getDocumentElement(element);
4345 const visualViewport = win.visualViewport;
4346 let width = html.clientWidth;
4347 let height = html.clientHeight;
4348 let x2 = 0;
4349 let y2 = 0;
4350 if (visualViewport) {
4351 width = visualViewport.width;
4352 height = visualViewport.height;
4353 const visualViewportBased = isWebKit();
4354 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4355 x2 = visualViewport.offsetLeft;
4356 y2 = visualViewport.offsetTop;
4357 }
4358 }
4359 const windowScrollbarX = getWindowScrollBarX(html);
4360 if (windowScrollbarX <= 0) {
4361 const doc = html.ownerDocument;
4362 const body = doc.body;
4363 const bodyStyles = getComputedStyle(body);
4364 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4365 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4366 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4367 width -= clippingStableScrollbarWidth;
4368 }
4369 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4370 width += windowScrollbarX;
4371 }
4372 return {
4373 width,
4374 height,
4375 x: x2,
4376 y: y2
4377 };
4378 }
4379 function getInnerBoundingClientRect(element, strategy) {
4380 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4381 const top = clientRect.top + element.clientTop;
4382 const left = clientRect.left + element.clientLeft;
4383 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4384 const width = element.clientWidth * scale.x;
4385 const height = element.clientHeight * scale.y;
4386 const x2 = left * scale.x;
4387 const y2 = top * scale.y;
4388 return {
4389 width,
4390 height,
4391 x: x2,
4392 y: y2
4393 };
4394 }
4395 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4396 let rect;
4397 if (clippingAncestor === "viewport") {
4398 rect = getViewportRect(element, strategy);
4399 } else if (clippingAncestor === "document") {
4400 rect = getDocumentRect(getDocumentElement(element));
4401 } else if (isElement(clippingAncestor)) {
4402 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4403 } else {
4404 const visualOffsets = getVisualOffsets(element);
4405 rect = {
4406 x: clippingAncestor.x - visualOffsets.x,
4407 y: clippingAncestor.y - visualOffsets.y,
4408 width: clippingAncestor.width,
4409 height: clippingAncestor.height
4410 };
4411 }
4412 return rectToClientRect(rect);
4413 }
4414 function hasFixedPositionAncestor(element, stopNode) {
4415 const parentNode = getParentNode(element);
4416 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4417 return false;
4418 }
4419 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4420 }
4421 function getClippingElementAncestors(element, cache) {
4422 const cachedResult = cache.get(element);
4423 if (cachedResult) {
4424 return cachedResult;
4425 }
4426 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4427 let currentContainingBlockComputedStyle = null;
4428 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4429 let currentNode = elementIsFixed ? getParentNode(element) : element;
4430 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4431 const computedStyle = getComputedStyle2(currentNode);
4432 const currentNodeIsContaining = isContainingBlock(currentNode);
4433 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4434 currentContainingBlockComputedStyle = null;
4435 }
4436 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4437 if (shouldDropCurrentNode) {
4438 result = result.filter((ancestor) => ancestor !== currentNode);
4439 } else {
4440 currentContainingBlockComputedStyle = computedStyle;
4441 }
4442 currentNode = getParentNode(currentNode);
4443 }
4444 cache.set(element, result);
4445 return result;
4446 }
4447 function getClippingRect(_ref) {
4448 let {
4449 element,
4450 boundary,
4451 rootBoundary,
4452 strategy
4453 } = _ref;
4454 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4455 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4456 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4457 let top = firstRect.top;
4458 let right = firstRect.right;
4459 let bottom = firstRect.bottom;
4460 let left = firstRect.left;
4461 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4462 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4463 top = max(rect.top, top);
4464 right = min(rect.right, right);
4465 bottom = min(rect.bottom, bottom);
4466 left = max(rect.left, left);
4467 }
4468 return {
4469 width: right - left,
4470 height: bottom - top,
4471 x: left,
4472 y: top
4473 };
4474 }
4475 function getDimensions(element) {
4476 const {
4477 width,
4478 height
4479 } = getCssDimensions(element);
4480 return {
4481 width,
4482 height
4483 };
4484 }
4485 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4486 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4487 const documentElement = getDocumentElement(offsetParent);
4488 const isFixed = strategy === "fixed";
4489 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4490 let scroll = {
4491 scrollLeft: 0,
4492 scrollTop: 0
4493 };
4494 const offsets = createCoords(0);
4495 function setLeftRTLScrollbarOffset() {
4496 offsets.x = getWindowScrollBarX(documentElement);
4497 }
4498 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4499 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4500 scroll = getNodeScroll(offsetParent);
4501 }
4502 if (isOffsetParentAnElement) {
4503 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4504 offsets.x = offsetRect.x + offsetParent.clientLeft;
4505 offsets.y = offsetRect.y + offsetParent.clientTop;
4506 } else if (documentElement) {
4507 setLeftRTLScrollbarOffset();
4508 }
4509 }
4510 if (isFixed && !isOffsetParentAnElement && documentElement) {
4511 setLeftRTLScrollbarOffset();
4512 }
4513 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4514 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4515 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4516 return {
4517 x: x2,
4518 y: y2,
4519 width: rect.width,
4520 height: rect.height
4521 };
4522 }
4523 function isStaticPositioned(element) {
4524 return getComputedStyle2(element).position === "static";
4525 }
4526 function getTrueOffsetParent(element, polyfill) {
4527 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4528 return null;
4529 }
4530 if (polyfill) {
4531 return polyfill(element);
4532 }
4533 let rawOffsetParent = element.offsetParent;
4534 if (getDocumentElement(element) === rawOffsetParent) {
4535 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4536 }
4537 return rawOffsetParent;
4538 }
4539 function getOffsetParent(element, polyfill) {
4540 const win = getWindow(element);
4541 if (isTopLayer(element)) {
4542 return win;
4543 }
4544 if (!isHTMLElement(element)) {
4545 let svgOffsetParent = getParentNode(element);
4546 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4547 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4548 return svgOffsetParent;
4549 }
4550 svgOffsetParent = getParentNode(svgOffsetParent);
4551 }
4552 return win;
4553 }
4554 let offsetParent = getTrueOffsetParent(element, polyfill);
4555 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4556 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4557 }
4558 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4559 return win;
4560 }
4561 return offsetParent || getContainingBlock(element) || win;
4562 }
4563 var getElementRects = async function(data) {
4564 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4565 const getDimensionsFn = this.getDimensions;
4566 const floatingDimensions = await getDimensionsFn(data.floating);
4567 return {
4568 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4569 floating: {
4570 x: 0,
4571 y: 0,
4572 width: floatingDimensions.width,
4573 height: floatingDimensions.height
4574 }
4575 };
4576 };
4577 function isRTL(element) {
4578 return getComputedStyle2(element).direction === "rtl";
4579 }
4580 var platform2 = {
4581 convertOffsetParentRelativeRectToViewportRelativeRect,
4582 getDocumentElement,
4583 getClippingRect,
4584 getOffsetParent,
4585 getElementRects,
4586 getClientRects,
4587 getDimensions,
4588 getScale,
4589 isElement,
4590 isRTL
4591 };
4592 function rectsAreEqual(a2, b2) {
4593 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4594 }
4595 function observeMove(element, onMove) {
4596 let io = null;
4597 let timeoutId;
4598 const root = getDocumentElement(element);
4599 function cleanup() {
4600 var _io;
4601 clearTimeout(timeoutId);
4602 (_io = io) == null || _io.disconnect();
4603 io = null;
4604 }
4605 function refresh(skip, threshold) {
4606 if (skip === void 0) {
4607 skip = false;
4608 }
4609 if (threshold === void 0) {
4610 threshold = 1;
4611 }
4612 cleanup();
4613 const elementRectForRootMargin = element.getBoundingClientRect();
4614 const {
4615 left,
4616 top,
4617 width,
4618 height
4619 } = elementRectForRootMargin;
4620 if (!skip) {
4621 onMove();
4622 }
4623 if (!width || !height) {
4624 return;
4625 }
4626 const insetTop = floor(top);
4627 const insetRight = floor(root.clientWidth - (left + width));
4628 const insetBottom = floor(root.clientHeight - (top + height));
4629 const insetLeft = floor(left);
4630 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4631 const options = {
4632 rootMargin,
4633 threshold: max(0, min(1, threshold)) || 1
4634 };
4635 let isFirstUpdate = true;
4636 function handleObserve(entries) {
4637 const ratio = entries[0].intersectionRatio;
4638 if (ratio !== threshold) {
4639 if (!isFirstUpdate) {
4640 return refresh();
4641 }
4642 if (!ratio) {
4643 timeoutId = setTimeout(() => {
4644 refresh(false, 1e-7);
4645 }, 1e3);
4646 } else {
4647 refresh(false, ratio);
4648 }
4649 }
4650 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4651 refresh();
4652 }
4653 isFirstUpdate = false;
4654 }
4655 try {
4656 io = new IntersectionObserver(handleObserve, {
4657 ...options,
4658 // Handle <iframe>s
4659 root: root.ownerDocument
4660 });
4661 } catch (_e) {
4662 io = new IntersectionObserver(handleObserve, options);
4663 }
4664 io.observe(element);
4665 }
4666 refresh(true);
4667 return cleanup;
4668 }
4669 function autoUpdate(reference, floating, update2, options) {
4670 if (options === void 0) {
4671 options = {};
4672 }
4673 const {
4674 ancestorScroll = true,
4675 ancestorResize = true,
4676 elementResize = typeof ResizeObserver === "function",
4677 layoutShift = typeof IntersectionObserver === "function",
4678 animationFrame = false
4679 } = options;
4680 const referenceEl = unwrapElement(reference);
4681 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4682 ancestors.forEach((ancestor) => {
4683 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4684 passive: true
4685 });
4686 ancestorResize && ancestor.addEventListener("resize", update2);
4687 });
4688 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4689 let reobserveFrame = -1;
4690 let resizeObserver = null;
4691 if (elementResize) {
4692 resizeObserver = new ResizeObserver((_ref) => {
4693 let [firstEntry] = _ref;
4694 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4695 resizeObserver.unobserve(floating);
4696 cancelAnimationFrame(reobserveFrame);
4697 reobserveFrame = requestAnimationFrame(() => {
4698 var _resizeObserver;
4699 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4700 });
4701 }
4702 update2();
4703 });
4704 if (referenceEl && !animationFrame) {
4705 resizeObserver.observe(referenceEl);
4706 }
4707 if (floating) {
4708 resizeObserver.observe(floating);
4709 }
4710 }
4711 let frameId;
4712 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4713 if (animationFrame) {
4714 frameLoop();
4715 }
4716 function frameLoop() {
4717 const nextRefRect = getBoundingClientRect(reference);
4718 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4719 update2();
4720 }
4721 prevRefRect = nextRefRect;
4722 frameId = requestAnimationFrame(frameLoop);
4723 }
4724 update2();
4725 return () => {
4726 var _resizeObserver2;
4727 ancestors.forEach((ancestor) => {
4728 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4729 ancestorResize && ancestor.removeEventListener("resize", update2);
4730 });
4731 cleanupIo == null || cleanupIo();
4732 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4733 resizeObserver = null;
4734 if (animationFrame) {
4735 cancelAnimationFrame(frameId);
4736 }
4737 };
4738 }
4739 var offset2 = offset;
4740 var shift2 = shift;
4741 var flip2 = flip;
4742 var size2 = size;
4743 var hide2 = hide;
4744 var limitShift2 = limitShift;
4745 var computePosition2 = (reference, floating, options) => {
4746 const cache = /* @__PURE__ */ new Map();
4747 const mergedOptions = {
4748 platform: platform2,
4749 ...options
4750 };
4751 const platformWithCache = {
4752 ...mergedOptions.platform,
4753 _c: cache
4754 };
4755 return computePosition(reference, floating, {
4756 ...mergedOptions,
4757 platform: platformWithCache
4758 });
4759 };
4760
4761 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4762 var React19 = __toESM(require_react(), 1);
4763 var import_react2 = __toESM(require_react(), 1);
4764 var ReactDOM3 = __toESM(require_react_dom(), 1);
4765 var isClient = typeof document !== "undefined";
4766 var noop2 = function noop3() {
4767 };
4768 var index = isClient ? import_react2.useLayoutEffect : noop2;
4769 function deepEqual(a2, b2) {
4770 if (a2 === b2) {
4771 return true;
4772 }
4773 if (typeof a2 !== typeof b2) {
4774 return false;
4775 }
4776 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4777 return true;
4778 }
4779 let length;
4780 let i2;
4781 let keys;
4782 if (a2 && b2 && typeof a2 === "object") {
4783 if (Array.isArray(a2)) {
4784 length = a2.length;
4785 if (length !== b2.length) return false;
4786 for (i2 = length; i2-- !== 0; ) {
4787 if (!deepEqual(a2[i2], b2[i2])) {
4788 return false;
4789 }
4790 }
4791 return true;
4792 }
4793 keys = Object.keys(a2);
4794 length = keys.length;
4795 if (length !== Object.keys(b2).length) {
4796 return false;
4797 }
4798 for (i2 = length; i2-- !== 0; ) {
4799 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4800 return false;
4801 }
4802 }
4803 for (i2 = length; i2-- !== 0; ) {
4804 const key = keys[i2];
4805 if (key === "_owner" && a2.$$typeof) {
4806 continue;
4807 }
4808 if (!deepEqual(a2[key], b2[key])) {
4809 return false;
4810 }
4811 }
4812 return true;
4813 }
4814 return a2 !== a2 && b2 !== b2;
4815 }
4816 function getDPR(element) {
4817 if (typeof window === "undefined") {
4818 return 1;
4819 }
4820 const win = element.ownerDocument.defaultView || window;
4821 return win.devicePixelRatio || 1;
4822 }
4823 function roundByDPR(element, value) {
4824 const dpr = getDPR(element);
4825 return Math.round(value * dpr) / dpr;
4826 }
4827 function useLatestRef(value) {
4828 const ref = React19.useRef(value);
4829 index(() => {
4830 ref.current = value;
4831 });
4832 return ref;
4833 }
4834 function useFloating(options) {
4835 if (options === void 0) {
4836 options = {};
4837 }
4838 const {
4839 placement = "bottom",
4840 strategy = "absolute",
4841 middleware = [],
4842 platform: platform3,
4843 elements: {
4844 reference: externalReference,
4845 floating: externalFloating
4846 } = {},
4847 transform = true,
4848 whileElementsMounted,
4849 open
4850 } = options;
4851 const [data, setData] = React19.useState({
4852 x: 0,
4853 y: 0,
4854 strategy,
4855 placement,
4856 middlewareData: {},
4857 isPositioned: false
4858 });
4859 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
4860 if (!deepEqual(latestMiddleware, middleware)) {
4861 setLatestMiddleware(middleware);
4862 }
4863 const [_reference, _setReference] = React19.useState(null);
4864 const [_floating, _setFloating] = React19.useState(null);
4865 const setReference = React19.useCallback((node) => {
4866 if (node !== referenceRef.current) {
4867 referenceRef.current = node;
4868 _setReference(node);
4869 }
4870 }, []);
4871 const setFloating = React19.useCallback((node) => {
4872 if (node !== floatingRef.current) {
4873 floatingRef.current = node;
4874 _setFloating(node);
4875 }
4876 }, []);
4877 const referenceEl = externalReference || _reference;
4878 const floatingEl = externalFloating || _floating;
4879 const referenceRef = React19.useRef(null);
4880 const floatingRef = React19.useRef(null);
4881 const dataRef = React19.useRef(data);
4882 const hasWhileElementsMounted = whileElementsMounted != null;
4883 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4884 const platformRef = useLatestRef(platform3);
4885 const openRef = useLatestRef(open);
4886 const update2 = React19.useCallback(() => {
4887 if (!referenceRef.current || !floatingRef.current) {
4888 return;
4889 }
4890 const config = {
4891 placement,
4892 strategy,
4893 middleware: latestMiddleware
4894 };
4895 if (platformRef.current) {
4896 config.platform = platformRef.current;
4897 }
4898 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4899 const fullData = {
4900 ...data2,
4901 // The floating element's position may be recomputed while it's closed
4902 // but still mounted (such as when transitioning out). To ensure
4903 // `isPositioned` will be `false` initially on the next open, avoid
4904 // setting it to `true` when `open === false` (must be specified).
4905 isPositioned: openRef.current !== false
4906 };
4907 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4908 dataRef.current = fullData;
4909 ReactDOM3.flushSync(() => {
4910 setData(fullData);
4911 });
4912 }
4913 });
4914 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4915 index(() => {
4916 if (open === false && dataRef.current.isPositioned) {
4917 dataRef.current.isPositioned = false;
4918 setData((data2) => ({
4919 ...data2,
4920 isPositioned: false
4921 }));
4922 }
4923 }, [open]);
4924 const isMountedRef = React19.useRef(false);
4925 index(() => {
4926 isMountedRef.current = true;
4927 return () => {
4928 isMountedRef.current = false;
4929 };
4930 }, []);
4931 index(() => {
4932 if (referenceEl) referenceRef.current = referenceEl;
4933 if (floatingEl) floatingRef.current = floatingEl;
4934 if (referenceEl && floatingEl) {
4935 if (whileElementsMountedRef.current) {
4936 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4937 }
4938 update2();
4939 }
4940 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4941 const refs = React19.useMemo(() => ({
4942 reference: referenceRef,
4943 floating: floatingRef,
4944 setReference,
4945 setFloating
4946 }), [setReference, setFloating]);
4947 const elements = React19.useMemo(() => ({
4948 reference: referenceEl,
4949 floating: floatingEl
4950 }), [referenceEl, floatingEl]);
4951 const floatingStyles = React19.useMemo(() => {
4952 const initialStyles = {
4953 position: strategy,
4954 left: 0,
4955 top: 0
4956 };
4957 if (!elements.floating) {
4958 return initialStyles;
4959 }
4960 const x2 = roundByDPR(elements.floating, data.x);
4961 const y2 = roundByDPR(elements.floating, data.y);
4962 if (transform) {
4963 return {
4964 ...initialStyles,
4965 transform: "translate(" + x2 + "px, " + y2 + "px)",
4966 ...getDPR(elements.floating) >= 1.5 && {
4967 willChange: "transform"
4968 }
4969 };
4970 }
4971 return {
4972 position: strategy,
4973 left: x2,
4974 top: y2
4975 };
4976 }, [strategy, transform, elements.floating, data.x, data.y]);
4977 return React19.useMemo(() => ({
4978 ...data,
4979 update: update2,
4980 refs,
4981 elements,
4982 floatingStyles
4983 }), [data, update2, refs, elements, floatingStyles]);
4984 }
4985 var offset3 = (options, deps) => {
4986 const result = offset2(options);
4987 return {
4988 name: result.name,
4989 fn: result.fn,
4990 options: [options, deps]
4991 };
4992 };
4993 var shift3 = (options, deps) => {
4994 const result = shift2(options);
4995 return {
4996 name: result.name,
4997 fn: result.fn,
4998 options: [options, deps]
4999 };
5000 };
5001 var limitShift3 = (options, deps) => {
5002 const result = limitShift2(options);
5003 return {
5004 fn: result.fn,
5005 options: [options, deps]
5006 };
5007 };
5008 var flip3 = (options, deps) => {
5009 const result = flip2(options);
5010 return {
5011 name: result.name,
5012 fn: result.fn,
5013 options: [options, deps]
5014 };
5015 };
5016 var size3 = (options, deps) => {
5017 const result = size2(options);
5018 return {
5019 name: result.name,
5020 fn: result.fn,
5021 options: [options, deps]
5022 };
5023 };
5024 var hide3 = (options, deps) => {
5025 const result = hide2(options);
5026 return {
5027 name: result.name,
5028 fn: result.fn,
5029 options: [options, deps]
5030 };
5031 };
5032
5033 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5034 var React24 = __toESM(require_react(), 1);
5035
5036 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5037 var React23 = __toESM(require_react(), 1);
5038
5039 // node_modules/@base-ui/utils/esm/store/createSelector.js
5040 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5041 if (other.length > 0) {
5042 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5043 }
5044 let selector2;
5045 if (a2 && b2 && c2 && d2 && e2 && f2) {
5046 selector2 = (state, a1, a22, a3) => {
5047 const va = a2(state, a1, a22, a3);
5048 const vb = b2(state, a1, a22, a3);
5049 const vc = c2(state, a1, a22, a3);
5050 const vd = d2(state, a1, a22, a3);
5051 const ve = e2(state, a1, a22, a3);
5052 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5053 };
5054 } else if (a2 && b2 && c2 && d2 && e2) {
5055 selector2 = (state, a1, a22, a3) => {
5056 const va = a2(state, a1, a22, a3);
5057 const vb = b2(state, a1, a22, a3);
5058 const vc = c2(state, a1, a22, a3);
5059 const vd = d2(state, a1, a22, a3);
5060 return e2(va, vb, vc, vd, a1, a22, a3);
5061 };
5062 } else if (a2 && b2 && c2 && d2) {
5063 selector2 = (state, a1, a22, a3) => {
5064 const va = a2(state, a1, a22, a3);
5065 const vb = b2(state, a1, a22, a3);
5066 const vc = c2(state, a1, a22, a3);
5067 return d2(va, vb, vc, a1, a22, a3);
5068 };
5069 } else if (a2 && b2 && c2) {
5070 selector2 = (state, a1, a22, a3) => {
5071 const va = a2(state, a1, a22, a3);
5072 const vb = b2(state, a1, a22, a3);
5073 return c2(va, vb, a1, a22, a3);
5074 };
5075 } else if (a2 && b2) {
5076 selector2 = (state, a1, a22, a3) => {
5077 const va = a2(state, a1, a22, a3);
5078 return b2(va, a1, a22, a3);
5079 };
5080 } else if (a2) {
5081 selector2 = a2;
5082 } else {
5083 throw (
5084 /* minify-error-disabled */
5085 new Error("Missing arguments")
5086 );
5087 }
5088 return selector2;
5089 };
5090
5091 // node_modules/@base-ui/utils/esm/store/useStore.js
5092 var React21 = __toESM(require_react(), 1);
5093 var import_shim = __toESM(require_shim(), 1);
5094 var import_with_selector = __toESM(require_with_selector(), 1);
5095
5096 // node_modules/@base-ui/utils/esm/fastHooks.js
5097 var React20 = __toESM(require_react(), 1);
5098 var hooks = [];
5099 var currentInstance = void 0;
5100 function getInstance() {
5101 return currentInstance;
5102 }
5103 function register(hook) {
5104 hooks.push(hook);
5105 }
5106 function fastComponent(fn) {
5107 const FastComponent = (props, forwardedRef) => {
5108 const instance = useRefWithInit(createInstance).current;
5109 let result;
5110 try {
5111 currentInstance = instance;
5112 for (const hook of hooks) {
5113 hook.before(instance);
5114 }
5115 result = fn(props, forwardedRef);
5116 for (const hook of hooks) {
5117 hook.after(instance);
5118 }
5119 instance.didInitialize = true;
5120 } finally {
5121 currentInstance = void 0;
5122 }
5123 return result;
5124 };
5125 FastComponent.displayName = fn.displayName || fn.name;
5126 return FastComponent;
5127 }
5128 function fastComponentRef(fn) {
5129 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5130 }
5131 function createInstance() {
5132 return {
5133 didInitialize: false
5134 };
5135 }
5136
5137 // node_modules/@base-ui/utils/esm/store/useStore.js
5138 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5139 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5140 function useStore(store, selector2, a1, a2, a3) {
5141 return useStoreImplementation(store, selector2, a1, a2, a3);
5142 }
5143 function useStoreR19(store, selector2, a1, a2, a3) {
5144 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5145 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5146 }
5147 register({
5148 before(instance) {
5149 instance.syncIndex = 0;
5150 if (!instance.didInitialize) {
5151 instance.syncTick = 1;
5152 instance.syncHooks = [];
5153 instance.didChangeStore = true;
5154 instance.getSnapshot = () => {
5155 let didChange2 = false;
5156 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5157 const hook = instance.syncHooks[i2];
5158 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5159 if (hook.didChange || !Object.is(hook.value, value)) {
5160 didChange2 = true;
5161 hook.value = value;
5162 hook.didChange = false;
5163 }
5164 }
5165 if (didChange2) {
5166 instance.syncTick += 1;
5167 }
5168 return instance.syncTick;
5169 };
5170 }
5171 },
5172 after(instance) {
5173 if (instance.syncHooks.length > 0) {
5174 if (instance.didChangeStore) {
5175 instance.didChangeStore = false;
5176 instance.subscribe = (onStoreChange) => {
5177 const stores = /* @__PURE__ */ new Set();
5178 for (const hook of instance.syncHooks) {
5179 stores.add(hook.store);
5180 }
5181 const unsubscribes = [];
5182 for (const store of stores) {
5183 unsubscribes.push(store.subscribe(onStoreChange));
5184 }
5185 return () => {
5186 for (const unsubscribe of unsubscribes) {
5187 unsubscribe();
5188 }
5189 };
5190 };
5191 }
5192 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5193 }
5194 }
5195 });
5196 function useStoreFast(store, selector2, a1, a2, a3) {
5197 const instance = getInstance();
5198 if (!instance) {
5199 return useStoreR19(store, selector2, a1, a2, a3);
5200 }
5201 const index2 = instance.syncIndex;
5202 instance.syncIndex += 1;
5203 let hook;
5204 if (!instance.didInitialize) {
5205 hook = {
5206 store,
5207 selector: selector2,
5208 a1,
5209 a2,
5210 a3,
5211 value: selector2(store.getSnapshot(), a1, a2, a3),
5212 didChange: false
5213 };
5214 instance.syncHooks.push(hook);
5215 } else {
5216 hook = instance.syncHooks[index2];
5217 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5218 if (hook.store !== store) {
5219 instance.didChangeStore = true;
5220 }
5221 hook.store = store;
5222 hook.selector = selector2;
5223 hook.a1 = a1;
5224 hook.a2 = a2;
5225 hook.a3 = a3;
5226 hook.didChange = true;
5227 }
5228 }
5229 return hook.value;
5230 }
5231 function useStoreLegacy(store, selector2, a1, a2, a3) {
5232 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5233 }
5234
5235 // node_modules/@base-ui/utils/esm/store/Store.js
5236 var Store = class {
5237 /**
5238 * The current state of the store.
5239 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5240 * 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).
5241 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5242 *
5243 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5244 */
5245 // Internal state to handle recursive `setState()` calls
5246 constructor(state) {
5247 this.state = state;
5248 this.listeners = /* @__PURE__ */ new Set();
5249 this.updateTick = 0;
5250 }
5251 /**
5252 * Registers a listener that will be called whenever the store's state changes.
5253 *
5254 * @param fn The listener function to be called on state changes.
5255 * @returns A function to unsubscribe the listener.
5256 */
5257 subscribe = (fn) => {
5258 this.listeners.add(fn);
5259 return () => {
5260 this.listeners.delete(fn);
5261 };
5262 };
5263 /**
5264 * Returns the current state of the store.
5265 */
5266 getSnapshot = () => {
5267 return this.state;
5268 };
5269 /**
5270 * Updates the entire store's state and notifies all registered listeners.
5271 *
5272 * @param newState The new state to set for the store.
5273 */
5274 setState(newState) {
5275 if (this.state === newState) {
5276 return;
5277 }
5278 this.state = newState;
5279 this.updateTick += 1;
5280 const currentTick = this.updateTick;
5281 for (const listener of this.listeners) {
5282 if (currentTick !== this.updateTick) {
5283 return;
5284 }
5285 listener(newState);
5286 }
5287 }
5288 /**
5289 * Merges the provided changes into the current state and notifies listeners if there are changes.
5290 *
5291 * @param changes An object containing the changes to apply to the current state.
5292 */
5293 update(changes) {
5294 for (const key in changes) {
5295 if (!Object.is(this.state[key], changes[key])) {
5296 this.setState({
5297 ...this.state,
5298 ...changes
5299 });
5300 return;
5301 }
5302 }
5303 }
5304 /**
5305 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5306 *
5307 * @param key The key in the store's state to update.
5308 * @param value The new value to set for the specified key.
5309 */
5310 set(key, value) {
5311 if (!Object.is(this.state[key], value)) {
5312 this.setState({
5313 ...this.state,
5314 [key]: value
5315 });
5316 }
5317 }
5318 /**
5319 * Gives the state a new reference and updates all registered listeners.
5320 */
5321 notifyAll() {
5322 const newState = {
5323 ...this.state
5324 };
5325 this.setState(newState);
5326 }
5327 use(selector2, a1, a2, a3) {
5328 return useStore(this, selector2, a1, a2, a3);
5329 }
5330 };
5331
5332 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5333 var React22 = __toESM(require_react(), 1);
5334 var ReactStore = class extends Store {
5335 /**
5336 * Creates a new ReactStore instance.
5337 *
5338 * @param state Initial state of the store.
5339 * @param context Non-reactive context values.
5340 * @param selectors Optional selectors for use with `useState`.
5341 */
5342 constructor(state, context = {}, selectors3) {
5343 super(state);
5344 this.context = context;
5345 this.selectors = selectors3;
5346 }
5347 /**
5348 * Non-reactive values such as refs, callbacks, etc.
5349 */
5350 /**
5351 * Synchronizes a single external value into the store.
5352 *
5353 * Note that the while the value in `state` is updated immediately, the value returned
5354 * by `useState` is updated before the next render (similarly to React's `useState`).
5355 */
5356 useSyncedValue(key, value) {
5357 React22.useDebugValue(key);
5358 const store = this;
5359 useIsoLayoutEffect(() => {
5360 if (store.state[key] !== value) {
5361 store.set(key, value);
5362 }
5363 }, [store, key, value]);
5364 }
5365 /**
5366 * Synchronizes a single external value into the store and
5367 * cleans it up (sets to `undefined`) on unmount.
5368 *
5369 * Note that the while the value in `state` is updated immediately, the value returned
5370 * by `useState` is updated before the next render (similarly to React's `useState`).
5371 */
5372 useSyncedValueWithCleanup(key, value) {
5373 const store = this;
5374 useIsoLayoutEffect(() => {
5375 if (store.state[key] !== value) {
5376 store.set(key, value);
5377 }
5378 return () => {
5379 store.set(key, void 0);
5380 };
5381 }, [store, key, value]);
5382 }
5383 /**
5384 * Synchronizes multiple external values into the store.
5385 *
5386 * Note that the while the values in `state` are updated immediately, the values returned
5387 * by `useState` are updated before the next render (similarly to React's `useState`).
5388 */
5389 useSyncedValues(statePart) {
5390 const store = this;
5391 if (true) {
5392 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
5393 const keys = React22.useRef(Object.keys(statePart)).current;
5394 const nextKeys = Object.keys(statePart);
5395 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5396 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5397 }
5398 }
5399 const dependencies = Object.values(statePart);
5400 useIsoLayoutEffect(() => {
5401 store.update(statePart);
5402 }, [store, ...dependencies]);
5403 }
5404 /**
5405 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5406 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5407 */
5408 useControlledProp(key, controlled) {
5409 React22.useDebugValue(key);
5410 const store = this;
5411 const isControlled = controlled !== void 0;
5412 useIsoLayoutEffect(() => {
5413 if (isControlled && !Object.is(store.state[key], controlled)) {
5414 store.setState({
5415 ...store.state,
5416 [key]: controlled
5417 });
5418 }
5419 }, [store, key, controlled, isControlled]);
5420 if (true) {
5421 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5422 if (!cache.has(key)) {
5423 cache.set(key, isControlled);
5424 }
5425 const previouslyControlled = cache.get(key);
5426 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5427 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).`);
5428 }
5429 }
5430 }
5431 /** Gets the current value from the store using a selector with the provided key.
5432 *
5433 * @param key Key of the selector to use.
5434 */
5435 select(key, a1, a2, a3) {
5436 const selector2 = this.selectors[key];
5437 return selector2(this.state, a1, a2, a3);
5438 }
5439 /**
5440 * Returns a value from the store's state using a selector function.
5441 * Used to subscribe to specific parts of the state.
5442 * This methods causes a rerender whenever the selected state changes.
5443 *
5444 * @param key Key of the selector to use.
5445 */
5446 useState(key, a1, a2, a3) {
5447 React22.useDebugValue(key);
5448 return useStore(this, this.selectors[key], a1, a2, a3);
5449 }
5450 /**
5451 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5452 * and assigns it to the context.
5453 *
5454 * @param key Key of the event callback. Must be a function in the context.
5455 * @param fn Function to assign.
5456 */
5457 useContextCallback(key, fn) {
5458 React22.useDebugValue(key);
5459 const stableFunction = useStableCallback(fn ?? NOOP);
5460 this.context[key] = stableFunction;
5461 }
5462 /**
5463 * Returns a stable setter function for a specific key in the store's state.
5464 * It's commonly used to pass as a ref callback to React elements.
5465 *
5466 * @param key Key of the state to set.
5467 */
5468 useStateSetter(key) {
5469 const ref = React22.useRef(void 0);
5470 if (ref.current === void 0) {
5471 ref.current = (value) => {
5472 this.set(key, value);
5473 };
5474 }
5475 return ref.current;
5476 }
5477 /**
5478 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5479 *
5480 * @param key Key of the selector to observe.
5481 * @param listener Listener function called when the selector result changes.
5482 */
5483 observe(selector2, listener) {
5484 let selectFn;
5485 if (typeof selector2 === "function") {
5486 selectFn = selector2;
5487 } else {
5488 selectFn = this.selectors[selector2];
5489 }
5490 let prevValue = selectFn(this.state);
5491 listener(prevValue, prevValue, this);
5492 return this.subscribe((nextState) => {
5493 const nextValue = selectFn(nextState);
5494 if (!Object.is(prevValue, nextValue)) {
5495 const oldValue = prevValue;
5496 prevValue = nextValue;
5497 listener(nextValue, oldValue, this);
5498 }
5499 });
5500 }
5501 };
5502
5503 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5504 var selectors = {
5505 open: createSelector((state) => state.open),
5506 transitionStatus: createSelector((state) => state.transitionStatus),
5507 domReferenceElement: createSelector((state) => state.domReferenceElement),
5508 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5509 floatingElement: createSelector((state) => state.floatingElement),
5510 floatingId: createSelector((state) => state.floatingId)
5511 };
5512 var FloatingRootStore = class extends ReactStore {
5513 constructor(options) {
5514 const {
5515 syncOnly,
5516 nested,
5517 onOpenChange,
5518 triggerElements,
5519 ...initialState
5520 } = options;
5521 super({
5522 ...initialState,
5523 positionReference: initialState.referenceElement,
5524 domReferenceElement: initialState.referenceElement
5525 }, {
5526 onOpenChange,
5527 dataRef: {
5528 current: {}
5529 },
5530 events: createEventEmitter(),
5531 nested,
5532 triggerElements
5533 }, selectors);
5534 this.syncOnly = syncOnly;
5535 }
5536 /**
5537 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5538 */
5539 syncOpenEvent = (newOpen, event) => {
5540 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5541 // click events to upgrade a hover-open.
5542 event != null && isClickLikeEvent(event)) {
5543 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5544 }
5545 };
5546 /**
5547 * Runs the root-owned side effects for an open state change.
5548 */
5549 dispatchOpenChange = (newOpen, eventDetails) => {
5550 this.syncOpenEvent(newOpen, eventDetails.event);
5551 const details = {
5552 open: newOpen,
5553 reason: eventDetails.reason,
5554 nativeEvent: eventDetails.event,
5555 nested: this.context.nested,
5556 triggerElement: eventDetails.trigger
5557 };
5558 this.context.events.emit("openchange", details);
5559 };
5560 /**
5561 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5562 *
5563 * @param newOpen The new open state.
5564 * @param eventDetails Details about the event that triggered the open state change.
5565 */
5566 setOpen = (newOpen, eventDetails) => {
5567 if (this.syncOnly) {
5568 this.context.onOpenChange?.(newOpen, eventDetails);
5569 return;
5570 }
5571 this.dispatchOpenChange(newOpen, eventDetails);
5572 this.context.onOpenChange?.(newOpen, eventDetails);
5573 };
5574 };
5575
5576 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5577 function useSyncedFloatingRootContext(options) {
5578 const {
5579 popupStore,
5580 treatPopupAsFloatingElement = false,
5581 floatingRootContext: floatingRootContextProp,
5582 floatingId,
5583 nested,
5584 onOpenChange
5585 } = options;
5586 const open = popupStore.useState("open");
5587 const referenceElement = popupStore.useState("activeTriggerElement");
5588 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5589 const triggerElements = popupStore.context.triggerElements;
5590 const handleOpenChange = onOpenChange;
5591 const internalStoreRef = React23.useRef(null);
5592 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5593 internalStoreRef.current = new FloatingRootStore({
5594 open,
5595 transitionStatus: void 0,
5596 referenceElement,
5597 floatingElement,
5598 triggerElements,
5599 onOpenChange: handleOpenChange,
5600 floatingId,
5601 syncOnly: true,
5602 nested
5603 });
5604 }
5605 const store = floatingRootContextProp ?? internalStoreRef.current;
5606 popupStore.useSyncedValue("floatingId", floatingId);
5607 useIsoLayoutEffect(() => {
5608 const valuesToSync = {
5609 open,
5610 floatingId,
5611 referenceElement,
5612 floatingElement
5613 };
5614 if (isElement(referenceElement)) {
5615 valuesToSync.domReferenceElement = referenceElement;
5616 }
5617 if (store.state.positionReference === store.state.referenceElement) {
5618 valuesToSync.positionReference = referenceElement;
5619 }
5620 store.update(valuesToSync);
5621 }, [open, floatingId, referenceElement, floatingElement, store]);
5622 store.context.onOpenChange = handleOpenChange;
5623 store.context.nested = nested;
5624 return store;
5625 }
5626
5627 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5628 var FOCUSABLE_POPUP_PROPS = {
5629 tabIndex: -1,
5630 [FOCUSABLE_ATTRIBUTE]: ""
5631 };
5632 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5633 const floatingId = useId();
5634 const nested = useFloatingParentNodeId() != null;
5635 const internalStoreRef = React24.useRef(null);
5636 if (externalStore === void 0 && internalStoreRef.current === null) {
5637 internalStoreRef.current = createStore2(floatingId, nested);
5638 }
5639 const store = externalStore ?? internalStoreRef.current;
5640 useSyncedFloatingRootContext({
5641 popupStore: store,
5642 treatPopupAsFloatingElement,
5643 floatingRootContext: store.state.floatingRootContext,
5644 floatingId,
5645 nested,
5646 onOpenChange: store.setOpen
5647 });
5648 return {
5649 store,
5650 internalStore: internalStoreRef.current
5651 };
5652 }
5653 function useTriggerRegistration(id, store) {
5654 const registeredElementIdRef = React24.useRef(null);
5655 const registeredElementRef = React24.useRef(null);
5656 return React24.useCallback((element) => {
5657 if (id === void 0) {
5658 return;
5659 }
5660 let shouldSyncTriggerCount = false;
5661 if (registeredElementIdRef.current !== null) {
5662 const registeredId = registeredElementIdRef.current;
5663 const registeredElement = registeredElementRef.current;
5664 const currentElement = store.context.triggerElements.getById(registeredId);
5665 if (registeredElement && currentElement === registeredElement) {
5666 store.context.triggerElements.delete(registeredId);
5667 shouldSyncTriggerCount = true;
5668 }
5669 registeredElementIdRef.current = null;
5670 registeredElementRef.current = null;
5671 }
5672 if (element !== null) {
5673 registeredElementIdRef.current = id;
5674 registeredElementRef.current = element;
5675 store.context.triggerElements.add(id, element);
5676 shouldSyncTriggerCount = true;
5677 }
5678 if (shouldSyncTriggerCount) {
5679 const triggerCount = store.context.triggerElements.size;
5680 if (store.select("open") && store.state.triggerCount !== triggerCount) {
5681 store.set("triggerCount", triggerCount);
5682 }
5683 }
5684 }, [store, id]);
5685 }
5686 function setOpenTriggerState(state, open, trigger) {
5687 const triggerId = trigger?.id ?? null;
5688 if (triggerId || open) {
5689 state.activeTriggerId = triggerId;
5690 state.activeTriggerElement = trigger ?? null;
5691 }
5692 }
5693 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5694 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5695 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5696 const registerTrigger = useStableCallback((element) => {
5697 baseRegisterTrigger(element);
5698 if (!element) {
5699 return;
5700 }
5701 const open = store.select("open");
5702 const activeTriggerId = store.select("activeTriggerId");
5703 if (activeTriggerId === triggerId) {
5704 store.update({
5705 activeTriggerElement: element,
5706 ...open ? stateUpdates : null
5707 });
5708 return;
5709 }
5710 if (activeTriggerId == null && open) {
5711 store.update({
5712 activeTriggerId: triggerId,
5713 activeTriggerElement: element,
5714 ...stateUpdates
5715 });
5716 }
5717 });
5718 useIsoLayoutEffect(() => {
5719 if (isMountedByThisTrigger) {
5720 store.update({
5721 activeTriggerElement: triggerElementRef.current,
5722 ...stateUpdates
5723 });
5724 }
5725 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5726 return {
5727 registerTrigger,
5728 isMountedByThisTrigger
5729 };
5730 }
5731 function useImplicitActiveTrigger(store) {
5732 const open = store.useState("open");
5733 const reactiveTriggerCount = store.useState("triggerCount");
5734 useIsoLayoutEffect(() => {
5735 if (!open) {
5736 if (store.state.triggerCount !== 0) {
5737 store.set("triggerCount", 0);
5738 }
5739 return;
5740 }
5741 const triggerCount = store.context.triggerElements.size;
5742 const stateUpdates = {};
5743 if (store.state.triggerCount !== triggerCount) {
5744 stateUpdates.triggerCount = triggerCount;
5745 }
5746 if (!store.select("activeTriggerId") && triggerCount === 1) {
5747 const iteratorResult = store.context.triggerElements.entries().next();
5748 if (!iteratorResult.done) {
5749 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5750 stateUpdates.activeTriggerId = implicitTriggerId;
5751 stateUpdates.activeTriggerElement = implicitTriggerElement;
5752 }
5753 }
5754 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5755 store.update(stateUpdates);
5756 }
5757 }, [open, store, reactiveTriggerCount]);
5758 }
5759 function useOpenStateTransitions(open, store, onUnmount) {
5760 const {
5761 mounted,
5762 setMounted,
5763 transitionStatus
5764 } = useTransitionStatus(open);
5765 store.useSyncedValues({
5766 mounted,
5767 transitionStatus
5768 });
5769 const forceUnmount = useStableCallback(() => {
5770 setMounted(false);
5771 store.update({
5772 activeTriggerId: null,
5773 activeTriggerElement: null,
5774 mounted: false,
5775 preventUnmountingOnClose: false
5776 });
5777 onUnmount?.();
5778 store.context.onOpenChangeComplete?.(false);
5779 });
5780 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5781 useOpenChangeComplete({
5782 enabled: mounted && !open && !preventUnmountingOnClose,
5783 open,
5784 ref: store.context.popupRef,
5785 onComplete() {
5786 if (!open) {
5787 forceUnmount();
5788 }
5789 }
5790 });
5791 return {
5792 forceUnmount,
5793 transitionStatus
5794 };
5795 }
5796 function usePopupInteractionProps(store, statePart) {
5797 store.useSyncedValues(statePart);
5798 useIsoLayoutEffect(() => () => {
5799 store.update({
5800 activeTriggerProps: EMPTY_OBJECT,
5801 inactiveTriggerProps: EMPTY_OBJECT,
5802 popupProps: EMPTY_OBJECT
5803 });
5804 }, [store]);
5805 }
5806
5807 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5808 var PopupTriggerMap = class {
5809 constructor() {
5810 this.elementsSet = /* @__PURE__ */ new Set();
5811 this.idMap = /* @__PURE__ */ new Map();
5812 }
5813 /**
5814 * Adds a trigger element with the given ID.
5815 *
5816 * Note: The provided element is assumed to not be registered under multiple IDs.
5817 */
5818 add(id, element) {
5819 const existingElement = this.idMap.get(id);
5820 if (existingElement === element) {
5821 return;
5822 }
5823 if (existingElement !== void 0) {
5824 this.elementsSet.delete(existingElement);
5825 }
5826 this.elementsSet.add(element);
5827 this.idMap.set(id, element);
5828 if (true) {
5829 if (this.elementsSet.size !== this.idMap.size) {
5830 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5831 }
5832 }
5833 }
5834 /**
5835 * Removes the trigger element with the given ID.
5836 */
5837 delete(id) {
5838 const element = this.idMap.get(id);
5839 if (element) {
5840 this.elementsSet.delete(element);
5841 this.idMap.delete(id);
5842 }
5843 }
5844 /**
5845 * Whether the given element is registered as a trigger.
5846 */
5847 hasElement(element) {
5848 return this.elementsSet.has(element);
5849 }
5850 /**
5851 * Whether there is a registered trigger element matching the given predicate.
5852 */
5853 hasMatchingElement(predicate) {
5854 for (const element of this.elementsSet) {
5855 if (predicate(element)) {
5856 return true;
5857 }
5858 }
5859 return false;
5860 }
5861 /**
5862 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5863 */
5864 getById(id) {
5865 return this.idMap.get(id);
5866 }
5867 /**
5868 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5869 */
5870 entries() {
5871 return this.idMap.entries();
5872 }
5873 /**
5874 * Returns an iterable of all registered trigger elements.
5875 */
5876 elements() {
5877 return this.elementsSet.values();
5878 }
5879 /**
5880 * Returns the number of registered trigger elements.
5881 */
5882 get size() {
5883 return this.idMap.size;
5884 }
5885 };
5886
5887 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5888 function getEmptyRootContext() {
5889 return new FloatingRootStore({
5890 open: false,
5891 transitionStatus: void 0,
5892 floatingElement: null,
5893 referenceElement: null,
5894 triggerElements: new PopupTriggerMap(),
5895 floatingId: void 0,
5896 syncOnly: false,
5897 nested: false,
5898 onOpenChange: void 0
5899 });
5900 }
5901
5902 // node_modules/@base-ui/react/esm/utils/popups/store.js
5903 function createInitialPopupStoreState() {
5904 return {
5905 open: false,
5906 openProp: void 0,
5907 mounted: false,
5908 transitionStatus: void 0,
5909 floatingRootContext: getEmptyRootContext(),
5910 floatingId: void 0,
5911 triggerCount: 0,
5912 preventUnmountingOnClose: false,
5913 payload: void 0,
5914 activeTriggerId: null,
5915 activeTriggerElement: null,
5916 triggerIdProp: void 0,
5917 popupElement: null,
5918 positionerElement: null,
5919 activeTriggerProps: EMPTY_OBJECT,
5920 inactiveTriggerProps: EMPTY_OBJECT,
5921 popupProps: EMPTY_OBJECT
5922 };
5923 }
5924 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
5925 return new FloatingRootStore({
5926 open: false,
5927 transitionStatus: void 0,
5928 floatingElement: null,
5929 referenceElement: null,
5930 triggerElements,
5931 floatingId,
5932 syncOnly: true,
5933 nested,
5934 onOpenChange: void 0
5935 });
5936 }
5937 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5938 var openSelector = createSelector((state) => state.openProp ?? state.open);
5939 var popupIdSelector = createSelector((state) => {
5940 const popupId = state.popupElement?.id ?? state.floatingId;
5941 return popupId || void 0;
5942 });
5943 function triggerOwnsOpenPopup(state, triggerId) {
5944 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
5945 }
5946 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
5947 if (triggerOwnsOpenPopup(state, triggerId)) {
5948 return true;
5949 }
5950 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
5951 }
5952 var popupStoreSelectors = {
5953 open: openSelector,
5954 mounted: createSelector((state) => state.mounted),
5955 transitionStatus: createSelector((state) => state.transitionStatus),
5956 floatingRootContext: createSelector((state) => state.floatingRootContext),
5957 triggerCount: createSelector((state) => state.triggerCount),
5958 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5959 payload: createSelector((state) => state.payload),
5960 activeTriggerId: activeTriggerIdSelector,
5961 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5962 popupId: popupIdSelector,
5963 /**
5964 * Whether the trigger with the given ID was used to open the popup.
5965 */
5966 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5967 /**
5968 * Whether the popup is open and was activated by a trigger with the given ID.
5969 */
5970 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
5971 /**
5972 * Whether the popup is mounted and was activated by a trigger with the given ID.
5973 */
5974 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5975 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5976 /**
5977 * Popup id for the trigger that currently owns the open popup.
5978 */
5979 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
5980 popupProps: createSelector((state) => state.popupProps),
5981 popupElement: createSelector((state) => state.popupElement),
5982 positionerElement: createSelector((state) => state.positionerElement)
5983 };
5984
5985 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5986 function useFloatingRootContext(options) {
5987 const {
5988 open = false,
5989 onOpenChange,
5990 elements = {}
5991 } = options;
5992 const floatingId = useId();
5993 const nested = useFloatingParentNodeId() != null;
5994 if (true) {
5995 const optionDomReference = elements.reference;
5996 if (optionDomReference && !isElement(optionDomReference)) {
5997 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5998 }
5999 }
6000 const store = useRefWithInit(() => new FloatingRootStore({
6001 open,
6002 transitionStatus: void 0,
6003 onOpenChange,
6004 referenceElement: elements.reference ?? null,
6005 floatingElement: elements.floating ?? null,
6006 triggerElements: new PopupTriggerMap(),
6007 floatingId,
6008 syncOnly: false,
6009 nested
6010 })).current;
6011 useIsoLayoutEffect(() => {
6012 const valuesToSync = {
6013 open,
6014 floatingId
6015 };
6016 if (elements.reference !== void 0) {
6017 valuesToSync.referenceElement = elements.reference;
6018 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6019 }
6020 if (elements.floating !== void 0) {
6021 valuesToSync.floatingElement = elements.floating;
6022 }
6023 store.update(valuesToSync);
6024 }, [open, floatingId, elements.reference, elements.floating, store]);
6025 store.context.onOpenChange = onOpenChange;
6026 store.context.nested = nested;
6027 return store;
6028 }
6029
6030 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6031 function useFloating2(options = {}) {
6032 const {
6033 nodeId,
6034 externalTree
6035 } = options;
6036 const internalStore = useFloatingRootContext(options);
6037 const store = options.rootContext || internalStore;
6038 const referenceElement = store.useState("referenceElement");
6039 const floatingElement = store.useState("floatingElement");
6040 const domReferenceElement = store.useState("domReferenceElement");
6041 const open = store.useState("open");
6042 const floatingId = store.useState("floatingId");
6043 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6044 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6045 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6046 const domReferenceRef = React25.useRef(null);
6047 const tree = useFloatingTree(externalTree);
6048 const storeElements = React25.useMemo(() => ({
6049 reference: referenceElement,
6050 floating: floatingElement,
6051 domReference: domReferenceElement
6052 }), [referenceElement, floatingElement, domReferenceElement]);
6053 const position = useFloating({
6054 ...options,
6055 elements: {
6056 ...storeElements,
6057 ...positionReference && {
6058 reference: positionReference
6059 }
6060 }
6061 });
6062 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6063 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6064 store.useSyncedValue("referenceElement", localDomReference ?? null);
6065 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6066 store.useSyncedValue("floatingElement", syncedFloatingElement);
6067 const setPositionReference = React25.useCallback((node) => {
6068 const computedPositionReference = isElement(node) ? {
6069 getBoundingClientRect: () => node.getBoundingClientRect(),
6070 getClientRects: () => node.getClientRects(),
6071 contextElement: node
6072 } : node;
6073 setPositionReferenceRaw(computedPositionReference);
6074 position.refs.setReference(computedPositionReference);
6075 }, [position.refs]);
6076 const setReference = React25.useCallback((node) => {
6077 if (isElement(node) || node === null) {
6078 domReferenceRef.current = node;
6079 setLocalDomReference(node);
6080 }
6081 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6082 // `null` to support `positionReference` + an unstable `reference`
6083 // callback ref.
6084 node !== null && !isElement(node)) {
6085 position.refs.setReference(node);
6086 }
6087 }, [position.refs, setLocalDomReference]);
6088 const setFloating = React25.useCallback((node) => {
6089 setLocalFloatingElement(node);
6090 position.refs.setFloating(node);
6091 }, [position.refs]);
6092 const refs = React25.useMemo(() => ({
6093 ...position.refs,
6094 setReference,
6095 setFloating,
6096 setPositionReference,
6097 domReference: domReferenceRef
6098 }), [position.refs, setReference, setFloating, setPositionReference]);
6099 const elements = React25.useMemo(() => ({
6100 ...position.elements,
6101 domReference: domReferenceElement
6102 }), [position.elements, domReferenceElement]);
6103 const context = React25.useMemo(() => ({
6104 ...position,
6105 dataRef: store.context.dataRef,
6106 open,
6107 onOpenChange: store.setOpen,
6108 events: store.context.events,
6109 floatingId,
6110 refs,
6111 elements,
6112 nodeId,
6113 rootStore: store
6114 }), [position, refs, elements, nodeId, store, open, floatingId]);
6115 useIsoLayoutEffect(() => {
6116 if (domReferenceElement) {
6117 domReferenceRef.current = domReferenceElement;
6118 }
6119 }, [domReferenceElement]);
6120 useIsoLayoutEffect(() => {
6121 store.context.dataRef.current.floatingContext = context;
6122 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6123 if (node) {
6124 node.context = context;
6125 }
6126 });
6127 return React25.useMemo(() => ({
6128 ...position,
6129 context,
6130 refs,
6131 elements,
6132 rootStore: store
6133 }), [position, refs, elements, context, store]);
6134 }
6135
6136 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6137 var React26 = __toESM(require_react(), 1);
6138 var isMacSafari = isMac && isSafari;
6139 function useFocus(context, props = {}) {
6140 const {
6141 enabled = true,
6142 delay
6143 } = props;
6144 const store = "rootStore" in context ? context.rootStore : context;
6145 const {
6146 events,
6147 dataRef
6148 } = store.context;
6149 const blockFocusRef = React26.useRef(false);
6150 const blockedReferenceRef = React26.useRef(null);
6151 const keyboardModalityRef = React26.useRef(true);
6152 const timeout = useTimeout();
6153 React26.useEffect(() => {
6154 const domReference = store.select("domReferenceElement");
6155 if (!enabled) {
6156 return void 0;
6157 }
6158 const win = getWindow(domReference);
6159 function onBlur() {
6160 const currentDomReference = store.select("domReferenceElement");
6161 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6162 blockFocusRef.current = true;
6163 }
6164 }
6165 function onKeyDown() {
6166 keyboardModalityRef.current = true;
6167 }
6168 function onPointerDown() {
6169 keyboardModalityRef.current = false;
6170 }
6171 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6172 }, [store, enabled]);
6173 React26.useEffect(() => {
6174 if (!enabled) {
6175 return void 0;
6176 }
6177 function onOpenChangeLocal(details) {
6178 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6179 const referenceElement = store.select("domReferenceElement");
6180 if (isElement(referenceElement)) {
6181 blockedReferenceRef.current = referenceElement;
6182 blockFocusRef.current = true;
6183 }
6184 }
6185 }
6186 events.on("openchange", onOpenChangeLocal);
6187 return () => {
6188 events.off("openchange", onOpenChangeLocal);
6189 };
6190 }, [events, enabled, store]);
6191 const reference = React26.useMemo(() => {
6192 function resetBlockedFocus() {
6193 blockFocusRef.current = false;
6194 blockedReferenceRef.current = null;
6195 }
6196 return {
6197 onMouseLeave() {
6198 resetBlockedFocus();
6199 },
6200 onFocus(event) {
6201 const focusTarget = event.currentTarget;
6202 if (blockFocusRef.current) {
6203 if (blockedReferenceRef.current === focusTarget) {
6204 return;
6205 }
6206 resetBlockedFocus();
6207 }
6208 const target = getTarget(event.nativeEvent);
6209 if (isElement(target)) {
6210 if (isMacSafari && !event.relatedTarget) {
6211 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6212 return;
6213 }
6214 } else if (!matchesFocusVisible(target)) {
6215 return;
6216 }
6217 }
6218 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6219 const {
6220 nativeEvent,
6221 currentTarget
6222 } = event;
6223 const delayValue = typeof delay === "function" ? delay() : delay;
6224 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6225 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6226 return;
6227 }
6228 timeout.start(delayValue, () => {
6229 if (blockFocusRef.current) {
6230 return;
6231 }
6232 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6233 });
6234 },
6235 onBlur(event) {
6236 resetBlockedFocus();
6237 const relatedTarget = event.relatedTarget;
6238 const nativeEvent = event.nativeEvent;
6239 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6240 timeout.start(0, () => {
6241 const domReference = store.select("domReferenceElement");
6242 const activeEl = activeElement(ownerDocument(domReference));
6243 if (!relatedTarget && activeEl === domReference) {
6244 return;
6245 }
6246 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6247 return;
6248 }
6249 const nextFocusedElement = relatedTarget ?? activeEl;
6250 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6251 return;
6252 }
6253 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6254 });
6255 }
6256 };
6257 }, [dataRef, delay, store, timeout]);
6258 return React26.useMemo(() => enabled ? {
6259 reference,
6260 trigger: reference
6261 } : {}, [enabled, reference]);
6262 }
6263
6264 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6265 var React27 = __toESM(require_react(), 1);
6266
6267 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6268 var HoverInteraction = class _HoverInteraction {
6269 constructor() {
6270 this.pointerType = void 0;
6271 this.interactedInside = false;
6272 this.handler = void 0;
6273 this.blockMouseMove = true;
6274 this.performedPointerEventsMutation = false;
6275 this.pointerEventsScopeElement = null;
6276 this.pointerEventsReferenceElement = null;
6277 this.pointerEventsFloatingElement = null;
6278 this.restTimeoutPending = false;
6279 this.openChangeTimeout = new Timeout();
6280 this.restTimeout = new Timeout();
6281 this.handleCloseOptions = void 0;
6282 }
6283 static create() {
6284 return new _HoverInteraction();
6285 }
6286 dispose = () => {
6287 this.openChangeTimeout.clear();
6288 this.restTimeout.clear();
6289 };
6290 disposeEffect = () => {
6291 return this.dispose;
6292 };
6293 };
6294 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6295 function clearSafePolygonPointerEventsMutation(instance) {
6296 if (!instance.performedPointerEventsMutation) {
6297 return;
6298 }
6299 const scopeElement = instance.pointerEventsScopeElement;
6300 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6301 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6302 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6303 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6304 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6305 }
6306 instance.performedPointerEventsMutation = false;
6307 instance.pointerEventsScopeElement = null;
6308 instance.pointerEventsReferenceElement = null;
6309 instance.pointerEventsFloatingElement = null;
6310 }
6311 function applySafePolygonPointerEventsMutation(instance, options) {
6312 const {
6313 scopeElement,
6314 referenceElement,
6315 floatingElement
6316 } = options;
6317 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6318 if (existingOwner && existingOwner !== instance) {
6319 clearSafePolygonPointerEventsMutation(existingOwner);
6320 }
6321 clearSafePolygonPointerEventsMutation(instance);
6322 instance.performedPointerEventsMutation = true;
6323 instance.pointerEventsScopeElement = scopeElement;
6324 instance.pointerEventsReferenceElement = referenceElement;
6325 instance.pointerEventsFloatingElement = floatingElement;
6326 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6327 scopeElement.style.pointerEvents = "none";
6328 referenceElement.style.pointerEvents = "auto";
6329 floatingElement.style.pointerEvents = "auto";
6330 }
6331 function useHoverInteractionSharedState(store) {
6332 const data = store.context.dataRef.current;
6333 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6334 if (!data.hoverInteractionState) {
6335 data.hoverInteractionState = instance;
6336 }
6337 useOnMount(data.hoverInteractionState.disposeEffect);
6338 return data.hoverInteractionState;
6339 }
6340
6341 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6342 function useHoverFloatingInteraction(context, parameters = {}) {
6343 const {
6344 enabled = true,
6345 closeDelay: closeDelayProp = 0,
6346 nodeId: nodeIdProp
6347 } = parameters;
6348 const store = "rootStore" in context ? context.rootStore : context;
6349 const open = store.useState("open");
6350 const floatingElement = store.useState("floatingElement");
6351 const domReferenceElement = store.useState("domReferenceElement");
6352 const {
6353 dataRef
6354 } = store.context;
6355 const tree = useFloatingTree();
6356 const parentId = useFloatingParentNodeId();
6357 const instance = useHoverInteractionSharedState(store);
6358 const childClosedTimeout = useTimeout();
6359 const isClickLikeOpenEvent2 = useStableCallback(() => {
6360 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6361 });
6362 const isHoverOpen = useStableCallback(() => {
6363 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6364 });
6365 const clearPointerEvents = useStableCallback(() => {
6366 clearSafePolygonPointerEventsMutation(instance);
6367 });
6368 useIsoLayoutEffect(() => {
6369 if (!open) {
6370 instance.pointerType = void 0;
6371 instance.restTimeoutPending = false;
6372 instance.interactedInside = false;
6373 clearPointerEvents();
6374 }
6375 }, [open, instance, clearPointerEvents]);
6376 React27.useEffect(() => {
6377 return clearPointerEvents;
6378 }, [clearPointerEvents]);
6379 useIsoLayoutEffect(() => {
6380 if (!enabled) {
6381 return void 0;
6382 }
6383 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6384 const ref = domReferenceElement;
6385 const floatingEl = floatingElement;
6386 const doc = ownerDocument(floatingElement);
6387 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6388 if (parentFloating) {
6389 parentFloating.style.pointerEvents = "";
6390 }
6391 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6392 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6393 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6394 applySafePolygonPointerEventsMutation(instance, {
6395 scopeElement,
6396 referenceElement: ref,
6397 floatingElement: floatingEl
6398 });
6399 return () => {
6400 clearPointerEvents();
6401 };
6402 }
6403 return void 0;
6404 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6405 React27.useEffect(() => {
6406 if (!enabled) {
6407 return void 0;
6408 }
6409 function hasParentChildren() {
6410 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6411 }
6412 function closeWithDelay(event) {
6413 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6414 const close = () => {
6415 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6416 tree?.events.emit("floating.closed", event);
6417 };
6418 if (closeDelay) {
6419 instance.openChangeTimeout.start(closeDelay, close);
6420 } else {
6421 instance.openChangeTimeout.clear();
6422 close();
6423 }
6424 }
6425 function handleInteractInside(event) {
6426 const target = getTarget(event);
6427 if (!isInteractiveElement(target)) {
6428 instance.interactedInside = false;
6429 return;
6430 }
6431 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6432 }
6433 function onFloatingMouseEnter() {
6434 instance.openChangeTimeout.clear();
6435 childClosedTimeout.clear();
6436 tree?.events.off("floating.closed", onNodeClosed);
6437 clearPointerEvents();
6438 }
6439 function onFloatingMouseLeave(event) {
6440 if (hasParentChildren() && tree) {
6441 tree.events.on("floating.closed", onNodeClosed);
6442 return;
6443 }
6444 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6445 return;
6446 }
6447 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6448 const relatedTarget = event.relatedTarget;
6449 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6450 if (isMovingIntoDescendantFloating) {
6451 return;
6452 }
6453 if (instance.handler) {
6454 instance.handler(event);
6455 return;
6456 }
6457 clearPointerEvents();
6458 if (!isClickLikeOpenEvent2()) {
6459 closeWithDelay(event);
6460 }
6461 }
6462 function onNodeClosed(event) {
6463 if (!tree || !parentId || hasParentChildren()) {
6464 return;
6465 }
6466 childClosedTimeout.start(0, () => {
6467 tree.events.off("floating.closed", onNodeClosed);
6468 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6469 tree.events.emit("floating.closed", event);
6470 });
6471 }
6472 const floating = floatingElement;
6473 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6474 tree?.events.off("floating.closed", onNodeClosed);
6475 });
6476 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6477 }
6478
6479 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6480 var React28 = __toESM(require_react(), 1);
6481 var ReactDOM4 = __toESM(require_react_dom(), 1);
6482 var EMPTY_REF = {
6483 current: null
6484 };
6485 function useHoverReferenceInteraction(context, props = {}) {
6486 const {
6487 enabled = true,
6488 delay = 0,
6489 handleClose = null,
6490 mouseOnly = false,
6491 restMs = 0,
6492 move = true,
6493 triggerElementRef = EMPTY_REF,
6494 externalTree,
6495 isActiveTrigger = true,
6496 getHandleCloseContext,
6497 isClosing,
6498 shouldOpen: shouldOpenProp
6499 } = props;
6500 const store = "rootStore" in context ? context.rootStore : context;
6501 const {
6502 dataRef,
6503 events
6504 } = store.context;
6505 const tree = useFloatingTree(externalTree);
6506 const instance = useHoverInteractionSharedState(store);
6507 const isHoverCloseActiveRef = React28.useRef(false);
6508 const handleCloseRef = useValueAsRef(handleClose);
6509 const delayRef = useValueAsRef(delay);
6510 const restMsRef = useValueAsRef(restMs);
6511 const enabledRef = useValueAsRef(enabled);
6512 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6513 const isClosingRef = useValueAsRef(isClosing);
6514 const isClickLikeOpenEvent2 = useStableCallback(() => {
6515 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6516 });
6517 const checkShouldOpen = useStableCallback(() => {
6518 return shouldOpenRef.current?.() !== false;
6519 });
6520 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6521 const allTriggers = store.context.triggerElements;
6522 if (allTriggers.hasElement(currentTarget)) {
6523 return !currentDomReference || !contains(currentDomReference, currentTarget);
6524 }
6525 if (!isElement(target)) {
6526 return false;
6527 }
6528 const targetElement = target;
6529 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6530 });
6531 const cleanupMouseMoveHandler = useStableCallback(() => {
6532 if (!instance.handler) {
6533 return;
6534 }
6535 const doc = ownerDocument(store.select("domReferenceElement"));
6536 doc.removeEventListener("mousemove", instance.handler);
6537 instance.handler = void 0;
6538 });
6539 const clearPointerEvents = useStableCallback(() => {
6540 clearSafePolygonPointerEventsMutation(instance);
6541 });
6542 if (isActiveTrigger) {
6543 instance.handleCloseOptions = handleCloseRef.current?.__options;
6544 }
6545 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6546 React28.useEffect(() => {
6547 if (!enabled) {
6548 return void 0;
6549 }
6550 function onOpenChangeLocal(details) {
6551 if (!details.open) {
6552 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6553 cleanupMouseMoveHandler();
6554 instance.openChangeTimeout.clear();
6555 instance.restTimeout.clear();
6556 instance.blockMouseMove = true;
6557 instance.restTimeoutPending = false;
6558 } else {
6559 isHoverCloseActiveRef.current = false;
6560 }
6561 }
6562 events.on("openchange", onOpenChangeLocal);
6563 return () => {
6564 events.off("openchange", onOpenChangeLocal);
6565 };
6566 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6567 React28.useEffect(() => {
6568 if (!enabled) {
6569 return void 0;
6570 }
6571 function closeWithDelay(event, runElseBranch = true) {
6572 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6573 if (closeDelay) {
6574 instance.openChangeTimeout.start(closeDelay, () => {
6575 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6576 tree?.events.emit("floating.closed", event);
6577 });
6578 } else if (runElseBranch) {
6579 instance.openChangeTimeout.clear();
6580 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6581 tree?.events.emit("floating.closed", event);
6582 }
6583 }
6584 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6585 if (!isElement(trigger)) {
6586 return void 0;
6587 }
6588 function onMouseEnter(event) {
6589 instance.openChangeTimeout.clear();
6590 instance.blockMouseMove = false;
6591 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6592 return;
6593 }
6594 const restMsValue = getRestMs(restMsRef.current);
6595 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6596 const eventTarget = getTarget(event);
6597 const currentTarget = event.currentTarget ?? null;
6598 const currentDomReference = store.select("domReferenceElement");
6599 let triggerNode = currentTarget;
6600 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6601 for (const triggerElement of store.context.triggerElements.elements()) {
6602 if (contains(triggerElement, eventTarget)) {
6603 triggerNode = triggerElement;
6604 break;
6605 }
6606 }
6607 }
6608 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6609 triggerNode = currentDomReference;
6610 }
6611 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6612 const isOpen = store.select("open");
6613 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6614 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6615 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6616 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6617 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6618 const shouldOpen = !isOpen || isOverInactive;
6619 if (shouldOpenImmediately) {
6620 if (checkShouldOpen()) {
6621 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6622 }
6623 return;
6624 }
6625 if (isRestOnlyDelay) {
6626 return;
6627 }
6628 if (openDelay) {
6629 instance.openChangeTimeout.start(openDelay, () => {
6630 if (shouldOpen && checkShouldOpen()) {
6631 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6632 }
6633 });
6634 } else if (shouldOpen) {
6635 if (checkShouldOpen()) {
6636 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6637 }
6638 }
6639 }
6640 function onMouseLeave(event) {
6641 if (isClickLikeOpenEvent2()) {
6642 clearPointerEvents();
6643 return;
6644 }
6645 cleanupMouseMoveHandler();
6646 const domReferenceElement = store.select("domReferenceElement");
6647 const doc = ownerDocument(domReferenceElement);
6648 instance.restTimeout.clear();
6649 instance.restTimeoutPending = false;
6650 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6651 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6652 return;
6653 }
6654 if (handleCloseRef.current && handleCloseContextBase) {
6655 if (!store.select("open")) {
6656 instance.openChangeTimeout.clear();
6657 }
6658 const currentTrigger = triggerElementRef.current;
6659 instance.handler = handleCloseRef.current({
6660 ...handleCloseContextBase,
6661 tree,
6662 x: event.clientX,
6663 y: event.clientY,
6664 onClose() {
6665 clearPointerEvents();
6666 cleanupMouseMoveHandler();
6667 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6668 closeWithDelay(event, true);
6669 }
6670 }
6671 });
6672 doc.addEventListener("mousemove", instance.handler);
6673 instance.handler(event);
6674 return;
6675 }
6676 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6677 if (shouldClose) {
6678 closeWithDelay(event);
6679 }
6680 }
6681 if (move) {
6682 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6683 once: true
6684 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6685 }
6686 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6687 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6688 return React28.useMemo(() => {
6689 if (!enabled) {
6690 return void 0;
6691 }
6692 function setPointerRef(event) {
6693 instance.pointerType = event.pointerType;
6694 }
6695 return {
6696 onPointerDown: setPointerRef,
6697 onPointerEnter: setPointerRef,
6698 onMouseMove(event) {
6699 const {
6700 nativeEvent
6701 } = event;
6702 const trigger = event.currentTarget;
6703 const currentDomReference = store.select("domReferenceElement");
6704 const currentOpen = store.select("open");
6705 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6706 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6707 return;
6708 }
6709 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6710 const floatingElement = store.select("floatingElement");
6711 if (floatingElement) {
6712 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6713 applySafePolygonPointerEventsMutation(instance, {
6714 scopeElement,
6715 referenceElement: trigger,
6716 floatingElement
6717 });
6718 }
6719 }
6720 const restMsValue = getRestMs(restMsRef.current);
6721 if (currentOpen && !isOverInactive || restMsValue === 0) {
6722 return;
6723 }
6724 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6725 return;
6726 }
6727 instance.restTimeout.clear();
6728 function handleMouseMove() {
6729 instance.restTimeoutPending = false;
6730 if (isClickLikeOpenEvent2()) {
6731 return;
6732 }
6733 const latestOpen = store.select("open");
6734 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6735 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6736 }
6737 }
6738 if (instance.pointerType === "touch") {
6739 ReactDOM4.flushSync(() => {
6740 handleMouseMove();
6741 });
6742 } else if (isOverInactive && currentOpen) {
6743 handleMouseMove();
6744 } else {
6745 instance.restTimeoutPending = true;
6746 instance.restTimeout.start(restMsValue, handleMouseMove);
6747 }
6748 }
6749 };
6750 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
6751 }
6752
6753 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6754 var CURSOR_SPEED_THRESHOLD = 0.1;
6755 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6756 var POLYGON_BUFFER = 0.5;
6757 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6758 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6759 }
6760 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6761 let isInsideValue = false;
6762 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6763 isInsideValue = !isInsideValue;
6764 }
6765 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6766 isInsideValue = !isInsideValue;
6767 }
6768 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6769 isInsideValue = !isInsideValue;
6770 }
6771 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6772 isInsideValue = !isInsideValue;
6773 }
6774 return isInsideValue;
6775 }
6776 function isInsideRect(pointX, pointY, rect) {
6777 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6778 }
6779 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6780 const minX = Math.min(x1, x2);
6781 const maxX = Math.max(x1, x2);
6782 const minY = Math.min(y1, y2);
6783 const maxY = Math.max(y1, y2);
6784 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6785 }
6786 function safePolygon(options = {}) {
6787 const {
6788 blockPointerEvents = false
6789 } = options;
6790 const timeout = new Timeout();
6791 const fn = ({
6792 x: x2,
6793 y: y2,
6794 placement,
6795 elements,
6796 onClose,
6797 nodeId,
6798 tree
6799 }) => {
6800 const side = placement?.split("-")[0];
6801 let hasLanded = false;
6802 let lastX = null;
6803 let lastY = null;
6804 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6805 function isCursorMovingSlowly(nextX, nextY) {
6806 const currentTime = performance.now();
6807 const elapsedTime = currentTime - lastCursorTime;
6808 if (lastX === null || lastY === null || elapsedTime === 0) {
6809 lastX = nextX;
6810 lastY = nextY;
6811 lastCursorTime = currentTime;
6812 return false;
6813 }
6814 const deltaX = nextX - lastX;
6815 const deltaY = nextY - lastY;
6816 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6817 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6818 lastX = nextX;
6819 lastY = nextY;
6820 lastCursorTime = currentTime;
6821 return distanceSquared < thresholdSquared;
6822 }
6823 function close() {
6824 timeout.clear();
6825 onClose();
6826 }
6827 return function onMouseMove(event) {
6828 timeout.clear();
6829 const domReference = elements.domReference;
6830 const floating = elements.floating;
6831 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6832 return void 0;
6833 }
6834 const {
6835 clientX,
6836 clientY
6837 } = event;
6838 const target = getTarget(event);
6839 const isLeave = event.type === "mouseleave";
6840 const isOverFloatingEl = contains(floating, target);
6841 const isOverReferenceEl = contains(domReference, target);
6842 if (isOverFloatingEl) {
6843 hasLanded = true;
6844 if (!isLeave) {
6845 return void 0;
6846 }
6847 }
6848 if (isOverReferenceEl) {
6849 hasLanded = false;
6850 if (!isLeave) {
6851 hasLanded = true;
6852 return void 0;
6853 }
6854 }
6855 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6856 return void 0;
6857 }
6858 function hasOpenChildNode() {
6859 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6860 }
6861 function closeIfNoOpenChild() {
6862 if (!hasOpenChildNode()) {
6863 close();
6864 }
6865 }
6866 if (hasOpenChildNode()) {
6867 return void 0;
6868 }
6869 const refRect = domReference.getBoundingClientRect();
6870 const rect = floating.getBoundingClientRect();
6871 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6872 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6873 const isFloatingWider = rect.width > refRect.width;
6874 const isFloatingTaller = rect.height > refRect.height;
6875 const left = (isFloatingWider ? refRect : rect).left;
6876 const right = (isFloatingWider ? refRect : rect).right;
6877 const top = (isFloatingTaller ? refRect : rect).top;
6878 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6879 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) {
6880 closeIfNoOpenChild();
6881 return void 0;
6882 }
6883 let isInsideTroughRect = false;
6884 switch (side) {
6885 case "top":
6886 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6887 break;
6888 case "bottom":
6889 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6890 break;
6891 case "left":
6892 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6893 break;
6894 case "right":
6895 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6896 break;
6897 default:
6898 }
6899 if (isInsideTroughRect) {
6900 return void 0;
6901 }
6902 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6903 closeIfNoOpenChild();
6904 return void 0;
6905 }
6906 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6907 closeIfNoOpenChild();
6908 return void 0;
6909 }
6910 let isInsidePolygon = false;
6911 switch (side) {
6912 case "top": {
6913 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6914 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6915 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6916 const cursorPointY = y2 + POLYGON_BUFFER + 1;
6917 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6918 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6919 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6920 break;
6921 }
6922 case "bottom": {
6923 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6924 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6925 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6926 const cursorPointY = y2 - POLYGON_BUFFER;
6927 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6928 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6929 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6930 break;
6931 }
6932 case "left": {
6933 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6934 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6935 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6936 const cursorPointX = x2 + POLYGON_BUFFER + 1;
6937 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6938 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6939 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6940 break;
6941 }
6942 case "right": {
6943 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6944 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6945 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6946 const cursorPointX = x2 - POLYGON_BUFFER;
6947 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6948 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6949 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6950 break;
6951 }
6952 default:
6953 }
6954 if (!isInsidePolygon) {
6955 closeIfNoOpenChild();
6956 } else if (!hasLanded) {
6957 timeout.start(40, closeIfNoOpenChild);
6958 }
6959 return void 0;
6960 };
6961 };
6962 fn.__options = {
6963 ...options,
6964 blockPointerEvents
6965 };
6966 return fn;
6967 }
6968
6969 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6970 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6971 CommonPopupDataAttributes2["open"] = "data-open";
6972 CommonPopupDataAttributes2["closed"] = "data-closed";
6973 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6974 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6975 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6976 CommonPopupDataAttributes2["side"] = "data-side";
6977 CommonPopupDataAttributes2["align"] = "data-align";
6978 return CommonPopupDataAttributes2;
6979 })({});
6980 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6981 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6982 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6983 return CommonTriggerDataAttributes2;
6984 })({});
6985 var TRIGGER_HOOK = {
6986 [CommonTriggerDataAttributes.popupOpen]: ""
6987 };
6988 var PRESSABLE_TRIGGER_HOOK = {
6989 [CommonTriggerDataAttributes.popupOpen]: "",
6990 [CommonTriggerDataAttributes.pressed]: ""
6991 };
6992 var POPUP_OPEN_HOOK = {
6993 [CommonPopupDataAttributes.open]: ""
6994 };
6995 var POPUP_CLOSED_HOOK = {
6996 [CommonPopupDataAttributes.closed]: ""
6997 };
6998 var ANCHOR_HIDDEN_HOOK = {
6999 [CommonPopupDataAttributes.anchorHidden]: ""
7000 };
7001 var triggerOpenStateMapping = {
7002 open(value) {
7003 if (value) {
7004 return TRIGGER_HOOK;
7005 }
7006 return null;
7007 }
7008 };
7009 var popupStateMapping = {
7010 open(value) {
7011 if (value) {
7012 return POPUP_OPEN_HOOK;
7013 }
7014 return POPUP_CLOSED_HOOK;
7015 },
7016 anchorHidden(value) {
7017 if (value) {
7018 return ANCHOR_HIDDEN_HOOK;
7019 }
7020 return null;
7021 }
7022 };
7023
7024 // node_modules/@base-ui/utils/esm/inertValue.js
7025 function inertValue(value) {
7026 if (isReactVersionAtLeast(19)) {
7027 return value;
7028 }
7029 return value ? "true" : void 0;
7030 }
7031
7032 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7033 var React29 = __toESM(require_react(), 1);
7034
7035 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7036 var baseArrow = (options) => ({
7037 name: "arrow",
7038 options,
7039 async fn(state) {
7040 const {
7041 x: x2,
7042 y: y2,
7043 placement,
7044 rects,
7045 platform: platform3,
7046 elements,
7047 middlewareData
7048 } = state;
7049 const {
7050 element,
7051 padding = 0,
7052 offsetParent = "real"
7053 } = evaluate(options, state) || {};
7054 if (element == null) {
7055 return {};
7056 }
7057 const paddingObject = getPaddingObject(padding);
7058 const coords = {
7059 x: x2,
7060 y: y2
7061 };
7062 const axis = getAlignmentAxis(placement);
7063 const length = getAxisLength(axis);
7064 const arrowDimensions = await platform3.getDimensions(element);
7065 const isYAxis = axis === "y";
7066 const minProp = isYAxis ? "top" : "left";
7067 const maxProp = isYAxis ? "bottom" : "right";
7068 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7069 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7070 const startDiff = coords[axis] - rects.reference[axis];
7071 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7072 let clientSize = elements.floating[clientProp] || rects.floating[length];
7073 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7074 clientSize = elements.floating[clientProp] || rects.floating[length];
7075 }
7076 const centerToReference = endDiff / 2 - startDiff / 2;
7077 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7078 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7079 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7080 const min2 = minPadding;
7081 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7082 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7083 const offset4 = clamp(min2, center, max2);
7084 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7085 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7086 return {
7087 [axis]: coords[axis] + alignmentOffset,
7088 data: {
7089 [axis]: offset4,
7090 centerOffset: center - offset4 - alignmentOffset,
7091 ...shouldAddOffset && {
7092 alignmentOffset
7093 }
7094 },
7095 reset: shouldAddOffset
7096 };
7097 }
7098 });
7099 var arrow4 = (options, deps) => ({
7100 ...baseArrow(options),
7101 options: [options, deps]
7102 });
7103
7104 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7105 var hide4 = {
7106 name: "hide",
7107 async fn(state) {
7108 const {
7109 width,
7110 height,
7111 x: x2,
7112 y: y2
7113 } = state.rects.reference;
7114 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7115 const nativeHideResult = await hide3().fn(state);
7116 return {
7117 data: {
7118 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7119 }
7120 };
7121 }
7122 };
7123
7124 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7125 var DEFAULT_SIDES = {
7126 sideX: "left",
7127 sideY: "top"
7128 };
7129 var adaptiveOrigin = {
7130 name: "adaptiveOrigin",
7131 async fn(state) {
7132 const {
7133 x: rawX,
7134 y: rawY,
7135 rects: {
7136 floating: floatRect
7137 },
7138 elements: {
7139 floating
7140 },
7141 platform: platform3,
7142 strategy,
7143 placement
7144 } = state;
7145 const win = getWindow(floating);
7146 const styles = win.getComputedStyle(floating);
7147 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7148 if (!hasTransition) {
7149 return {
7150 x: rawX,
7151 y: rawY,
7152 data: DEFAULT_SIDES
7153 };
7154 }
7155 const offsetParent = await platform3.getOffsetParent?.(floating);
7156 let offsetDimensions = {
7157 width: 0,
7158 height: 0
7159 };
7160 if (strategy === "fixed" && win?.visualViewport) {
7161 offsetDimensions = {
7162 width: win.visualViewport.width,
7163 height: win.visualViewport.height
7164 };
7165 } else if (offsetParent === win) {
7166 const doc = ownerDocument(floating);
7167 offsetDimensions = {
7168 width: doc.documentElement.clientWidth,
7169 height: doc.documentElement.clientHeight
7170 };
7171 } else if (await platform3.isElement?.(offsetParent)) {
7172 offsetDimensions = await platform3.getDimensions(offsetParent);
7173 }
7174 const currentSide = getSide(placement);
7175 let x2 = rawX;
7176 let y2 = rawY;
7177 if (currentSide === "left") {
7178 x2 = offsetDimensions.width - (rawX + floatRect.width);
7179 }
7180 if (currentSide === "top") {
7181 y2 = offsetDimensions.height - (rawY + floatRect.height);
7182 }
7183 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7184 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7185 return {
7186 x: x2,
7187 y: y2,
7188 data: {
7189 sideX,
7190 sideY
7191 }
7192 };
7193 }
7194 };
7195
7196 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7197 function getLogicalSide(sideParam, renderedSide, isRtl) {
7198 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7199 const logicalRight = isRtl ? "inline-start" : "inline-end";
7200 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7201 return {
7202 top: "top",
7203 right: isLogicalSideParam ? logicalRight : "right",
7204 bottom: "bottom",
7205 left: isLogicalSideParam ? logicalLeft : "left"
7206 }[renderedSide];
7207 }
7208 function getOffsetData(state, sideParam, isRtl) {
7209 const {
7210 rects,
7211 placement
7212 } = state;
7213 const data = {
7214 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7215 align: getAlignment(placement) || "center",
7216 anchor: {
7217 width: rects.reference.width,
7218 height: rects.reference.height
7219 },
7220 positioner: {
7221 width: rects.floating.width,
7222 height: rects.floating.height
7223 }
7224 };
7225 return data;
7226 }
7227 function useAnchorPositioning(params) {
7228 const {
7229 // Public parameters
7230 anchor,
7231 positionMethod = "absolute",
7232 side: sideParam = "bottom",
7233 sideOffset = 0,
7234 align = "center",
7235 alignOffset = 0,
7236 collisionBoundary,
7237 collisionPadding: collisionPaddingParam = 5,
7238 sticky = false,
7239 arrowPadding = 5,
7240 disableAnchorTracking = false,
7241 inline: inlineMiddleware,
7242 // Private parameters
7243 keepMounted = false,
7244 floatingRootContext,
7245 mounted,
7246 collisionAvoidance,
7247 shiftCrossAxis = false,
7248 nodeId,
7249 adaptiveOrigin: adaptiveOrigin2,
7250 lazyFlip = false,
7251 externalTree
7252 } = params;
7253 const [mountSide, setMountSide] = React29.useState(null);
7254 if (!mounted && mountSide !== null) {
7255 setMountSide(null);
7256 }
7257 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7258 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7259 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7260 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7261 const anchorFnCallback = useStableCallback(anchorFn);
7262 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7263 const anchorValueRef = useValueAsRef(anchor);
7264 const mountedRef = useValueAsRef(mounted);
7265 const direction = useDirection();
7266 const isRtl = direction === "rtl";
7267 const side = mountSide || {
7268 top: "top",
7269 right: "right",
7270 bottom: "bottom",
7271 left: "left",
7272 "inline-end": isRtl ? "left" : "right",
7273 "inline-start": isRtl ? "right" : "left"
7274 }[sideParam];
7275 const placement = align === "center" ? side : `${side}-${align}`;
7276 let collisionPadding = collisionPaddingParam;
7277 const bias = 1;
7278 const biasTop = sideParam === "bottom" ? bias : 0;
7279 const biasBottom = sideParam === "top" ? bias : 0;
7280 const biasLeft = sideParam === "right" ? bias : 0;
7281 const biasRight = sideParam === "left" ? bias : 0;
7282 if (typeof collisionPadding === "number") {
7283 collisionPadding = {
7284 top: collisionPadding + biasTop,
7285 right: collisionPadding + biasRight,
7286 bottom: collisionPadding + biasBottom,
7287 left: collisionPadding + biasLeft
7288 };
7289 } else if (collisionPadding) {
7290 collisionPadding = {
7291 top: (collisionPadding.top || 0) + biasTop,
7292 right: (collisionPadding.right || 0) + biasRight,
7293 bottom: (collisionPadding.bottom || 0) + biasBottom,
7294 left: (collisionPadding.left || 0) + biasLeft
7295 };
7296 }
7297 const commonCollisionProps = {
7298 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7299 padding: collisionPadding
7300 };
7301 const arrowRef = React29.useRef(null);
7302 const sideOffsetRef = useValueAsRef(sideOffset);
7303 const alignOffsetRef = useValueAsRef(alignOffset);
7304 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7305 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7306 const middleware = [];
7307 if (inlineMiddleware) {
7308 middleware.push(inlineMiddleware);
7309 }
7310 middleware.push(offset3((state) => {
7311 const data = getOffsetData(state, sideParam, isRtl);
7312 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7313 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7314 return {
7315 mainAxis: sideAxis,
7316 crossAxis: alignAxis,
7317 alignmentAxis: alignAxis
7318 };
7319 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7320 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7321 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7322 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7323 ...commonCollisionProps,
7324 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7325 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7326 padding: {
7327 top: collisionPadding.top + bias,
7328 right: collisionPadding.right + bias,
7329 bottom: collisionPadding.bottom + bias,
7330 left: collisionPadding.left + bias
7331 },
7332 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7333 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7334 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7335 });
7336 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7337 const html = ownerDocument(data.elements.floating).documentElement;
7338 return {
7339 ...commonCollisionProps,
7340 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7341 // for context menus.
7342 rootBoundary: shiftCrossAxis ? {
7343 x: 0,
7344 y: 0,
7345 width: html.clientWidth,
7346 height: html.clientHeight
7347 } : void 0,
7348 mainAxis: collisionAvoidanceAlign !== "none",
7349 crossAxis: crossAxisShiftEnabled,
7350 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7351 if (!arrowRef.current) {
7352 return {};
7353 }
7354 const {
7355 width,
7356 height
7357 } = arrowRef.current.getBoundingClientRect();
7358 const sideAxis = getSideAxis(getSide(limitData.placement));
7359 const arrowSize = sideAxis === "y" ? width : height;
7360 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7361 return {
7362 offset: arrowSize / 2 + offsetAmount / 2
7363 };
7364 })
7365 };
7366 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7367 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7368 middleware.push(shiftMiddleware, flipMiddleware);
7369 } else {
7370 middleware.push(flipMiddleware, shiftMiddleware);
7371 }
7372 middleware.push(size3({
7373 ...commonCollisionProps,
7374 apply({
7375 elements: {
7376 floating
7377 },
7378 availableWidth,
7379 availableHeight,
7380 rects
7381 }) {
7382 if (!mountedRef.current) {
7383 return;
7384 }
7385 const floatingStyle = floating.style;
7386 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7387 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7388 const dpr = getWindow(floating).devicePixelRatio || 1;
7389 const {
7390 x: x3,
7391 y: y3,
7392 width,
7393 height
7394 } = rects.reference;
7395 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7396 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7397 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7398 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7399 }
7400 }), arrow4((state) => ({
7401 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7402 // we'll create a fake element.
7403 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7404 padding: arrowPadding,
7405 offsetParent: "floating"
7406 }), [arrowPadding]), {
7407 name: "transformOrigin",
7408 fn(state) {
7409 const {
7410 elements: elements2,
7411 middlewareData: middlewareData2,
7412 placement: renderedPlacement2,
7413 rects,
7414 y: y3
7415 } = state;
7416 const currentRenderedSide = getSide(renderedPlacement2);
7417 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7418 const arrowEl = arrowRef.current;
7419 const arrowX = middlewareData2.arrow?.x || 0;
7420 const arrowY = middlewareData2.arrow?.y || 0;
7421 const arrowWidth = arrowEl?.clientWidth || 0;
7422 const arrowHeight = arrowEl?.clientHeight || 0;
7423 const transformX = arrowX + arrowWidth / 2;
7424 const transformY = arrowY + arrowHeight / 2;
7425 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7426 const halfAnchorHeight = rects.reference.height / 2;
7427 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7428 const isOverlappingAnchor = shiftY > sideOffsetValue;
7429 const adjacentTransformOrigin = {
7430 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7431 bottom: `${transformX}px ${-sideOffsetValue}px`,
7432 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7433 right: `${-sideOffsetValue}px ${transformY}px`
7434 }[currentRenderedSide];
7435 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7436 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7437 return {};
7438 }
7439 }, hide4, adaptiveOrigin2);
7440 useIsoLayoutEffect(() => {
7441 if (!mounted && floatingRootContext) {
7442 floatingRootContext.update({
7443 referenceElement: null,
7444 floatingElement: null,
7445 domReferenceElement: null,
7446 positionReference: null
7447 });
7448 }
7449 }, [mounted, floatingRootContext]);
7450 const autoUpdateOptions = React29.useMemo(() => ({
7451 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7452 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7453 }), [disableAnchorTracking]);
7454 const {
7455 refs,
7456 elements,
7457 x: x2,
7458 y: y2,
7459 middlewareData,
7460 update: update2,
7461 placement: renderedPlacement,
7462 context,
7463 isPositioned,
7464 floatingStyles: originalFloatingStyles
7465 } = useFloating2({
7466 rootContext: floatingRootContext,
7467 open: keepMounted ? mounted : void 0,
7468 placement,
7469 middleware,
7470 strategy: positionMethod,
7471 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7472 nodeId,
7473 externalTree
7474 });
7475 const {
7476 sideX,
7477 sideY
7478 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7479 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7480 const floatingStyles = React29.useMemo(() => {
7481 const base = adaptiveOrigin2 ? {
7482 position: resolvedPosition,
7483 [sideX]: x2,
7484 [sideY]: y2
7485 } : {
7486 position: resolvedPosition,
7487 ...originalFloatingStyles
7488 };
7489 if (!isPositioned) {
7490 base.opacity = 0;
7491 }
7492 return base;
7493 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7494 const registeredPositionReferenceRef = React29.useRef(null);
7495 useIsoLayoutEffect(() => {
7496 if (!mounted) {
7497 return;
7498 }
7499 const anchorValue = anchorValueRef.current;
7500 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7501 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7502 const finalAnchor = unwrappedElement || null;
7503 if (finalAnchor !== registeredPositionReferenceRef.current) {
7504 refs.setPositionReference(finalAnchor);
7505 registeredPositionReferenceRef.current = finalAnchor;
7506 }
7507 }, [mounted, refs, anchorDep, anchorValueRef]);
7508 React29.useEffect(() => {
7509 if (!mounted) {
7510 return;
7511 }
7512 const anchorValue = anchorValueRef.current;
7513 if (typeof anchorValue === "function") {
7514 return;
7515 }
7516 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7517 refs.setPositionReference(anchorValue.current);
7518 registeredPositionReferenceRef.current = anchorValue.current;
7519 }
7520 }, [mounted, refs, anchorDep, anchorValueRef]);
7521 React29.useEffect(() => {
7522 if (keepMounted && mounted && elements.domReference && elements.floating) {
7523 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7524 }
7525 return void 0;
7526 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7527 const renderedSide = getSide(renderedPlacement);
7528 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7529 const renderedAlign = getAlignment(renderedPlacement) || "center";
7530 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7531 useIsoLayoutEffect(() => {
7532 if (lazyFlip && mounted && isPositioned) {
7533 setMountSide(renderedSide);
7534 }
7535 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7536 const arrowStyles = React29.useMemo(() => ({
7537 position: "absolute",
7538 top: middlewareData.arrow?.y,
7539 left: middlewareData.arrow?.x
7540 }), [middlewareData.arrow]);
7541 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7542 return React29.useMemo(() => ({
7543 positionerStyles: floatingStyles,
7544 arrowStyles,
7545 arrowRef,
7546 arrowUncentered,
7547 side: logicalRenderedSide,
7548 align: renderedAlign,
7549 physicalSide: renderedSide,
7550 anchorHidden,
7551 refs,
7552 context,
7553 isPositioned,
7554 update: update2
7555 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7556 }
7557 function isRef(param) {
7558 return param != null && "current" in param;
7559 }
7560
7561 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7562 function getDisabledMountTransitionStyles(transitionStatus) {
7563 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7564 }
7565
7566 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7567 function usePositioner(componentProps, state, {
7568 styles,
7569 transitionStatus,
7570 props,
7571 refs,
7572 hidden,
7573 inert = false
7574 }) {
7575 const style = {
7576 ...styles
7577 };
7578 if (inert) {
7579 style.pointerEvents = "none";
7580 }
7581 return useRenderElement("div", componentProps, {
7582 state,
7583 ref: refs,
7584 props: [{
7585 role: "presentation",
7586 hidden,
7587 style
7588 }, getDisabledMountTransitionStyles(transitionStatus), props],
7589 stateAttributesMapping: popupStateMapping
7590 });
7591 }
7592
7593 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7594 var React32 = __toESM(require_react(), 1);
7595 var ReactDOM5 = __toESM(require_react_dom(), 1);
7596
7597 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7598 var React30 = __toESM(require_react(), 1);
7599 function usePreviousValue(value) {
7600 const [state, setState] = React30.useState({
7601 current: value,
7602 previous: null
7603 });
7604 if (value !== state.current) {
7605 setState({
7606 current: value,
7607 previous: state.current
7608 });
7609 }
7610 return state.previous;
7611 }
7612
7613 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7614 var React31 = __toESM(require_react(), 1);
7615
7616 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7617 function getCssDimensions2(element) {
7618 const css = getComputedStyle2(element);
7619 let width = parseFloat(css.width) || 0;
7620 let height = parseFloat(css.height) || 0;
7621 const hasOffset = isHTMLElement(element);
7622 const offsetWidth = hasOffset ? element.offsetWidth : width;
7623 const offsetHeight = hasOffset ? element.offsetHeight : height;
7624 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7625 if (shouldFallback) {
7626 width = offsetWidth;
7627 height = offsetHeight;
7628 }
7629 return {
7630 width,
7631 height
7632 };
7633 }
7634
7635 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7636 var DEFAULT_ENABLED = () => true;
7637 function usePopupAutoResize(parameters) {
7638 const {
7639 popupElement,
7640 positionerElement,
7641 content,
7642 mounted,
7643 enabled = DEFAULT_ENABLED,
7644 onMeasureLayout: onMeasureLayoutParam,
7645 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7646 side,
7647 direction
7648 } = parameters;
7649 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7650 const animationFrame = useAnimationFrame();
7651 const committedDimensionsRef = React31.useRef(null);
7652 const liveDimensionsRef = React31.useRef(null);
7653 const isInitialRenderRef = React31.useRef(true);
7654 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7655 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7656 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7657 const anchoringStyles = React31.useMemo(() => {
7658 let isOriginSide = side === "top";
7659 let isPhysicalLeft = side === "left";
7660 if (direction === "rtl") {
7661 isOriginSide = isOriginSide || side === "inline-end";
7662 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7663 } else {
7664 isOriginSide = isOriginSide || side === "inline-start";
7665 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7666 }
7667 return isOriginSide ? {
7668 position: "absolute",
7669 [side === "top" ? "bottom" : "top"]: "0",
7670 [isPhysicalLeft ? "right" : "left"]: "0"
7671 } : EMPTY_OBJECT;
7672 }, [side, direction]);
7673 useIsoLayoutEffect(() => {
7674 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7675 restoreAnchoringStylesRef.current = NOOP;
7676 isInitialRenderRef.current = true;
7677 committedDimensionsRef.current = null;
7678 liveDimensionsRef.current = null;
7679 return void 0;
7680 }
7681 if (!popupElement || !positionerElement) {
7682 return void 0;
7683 }
7684 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7685 const observer = new ResizeObserver((entries) => {
7686 const entry = entries[0];
7687 if (entry) {
7688 liveDimensionsRef.current = {
7689 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7690 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7691 };
7692 }
7693 });
7694 observer.observe(popupElement);
7695 setPopupCssSize(popupElement, "auto");
7696 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7697 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7698 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7699 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7700 "--available-width": "max-content",
7701 "--available-height": "max-content"
7702 });
7703 function restoreMeasurementOverrides() {
7704 restorePopupPosition();
7705 restorePopupTransform();
7706 restorePositionerAvailableSize();
7707 }
7708 function restoreMeasurementOverridesIncludingScale() {
7709 restoreMeasurementOverrides();
7710 restorePopupScale();
7711 }
7712 onMeasureLayout?.();
7713 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7714 setPositionerCssSize(positionerElement, "max-content");
7715 const dimensions = getCssDimensions2(popupElement);
7716 committedDimensionsRef.current = dimensions;
7717 setPositionerCssSize(positionerElement, dimensions);
7718 restoreMeasurementOverridesIncludingScale();
7719 onMeasureLayoutComplete?.(null, dimensions);
7720 isInitialRenderRef.current = false;
7721 return () => {
7722 observer.disconnect();
7723 restoreAnchoringStylesRef.current();
7724 restoreAnchoringStylesRef.current = NOOP;
7725 };
7726 }
7727 setPopupCssSize(popupElement, "auto");
7728 setPositionerCssSize(positionerElement, "max-content");
7729 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7730 const newDimensions = getCssDimensions2(popupElement);
7731 committedDimensionsRef.current = newDimensions;
7732 if (!previousDimensions) {
7733 setPositionerCssSize(positionerElement, newDimensions);
7734 restoreMeasurementOverridesIncludingScale();
7735 onMeasureLayoutComplete?.(null, newDimensions);
7736 return () => {
7737 observer.disconnect();
7738 animationFrame.cancel();
7739 restoreAnchoringStylesRef.current();
7740 restoreAnchoringStylesRef.current = NOOP;
7741 };
7742 }
7743 setPopupCssSize(popupElement, previousDimensions);
7744 restoreMeasurementOverridesIncludingScale();
7745 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7746 setPositionerCssSize(positionerElement, newDimensions);
7747 const abortController = new AbortController();
7748 animationFrame.request(() => {
7749 setPopupCssSize(popupElement, newDimensions);
7750 runOnceAnimationsFinish(() => {
7751 popupElement.style.setProperty("--popup-width", "auto");
7752 popupElement.style.setProperty("--popup-height", "auto");
7753 }, abortController.signal);
7754 });
7755 return () => {
7756 observer.disconnect();
7757 abortController.abort();
7758 animationFrame.cancel();
7759 restoreAnchoringStylesRef.current();
7760 restoreAnchoringStylesRef.current = NOOP;
7761 };
7762 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7763 }
7764 function overrideElementStyle(element, property, value) {
7765 const originalValue = element.style.getPropertyValue(property);
7766 element.style.setProperty(property, value);
7767 return () => {
7768 element.style.setProperty(property, originalValue);
7769 };
7770 }
7771 function applyElementStyles(element, styles) {
7772 const restorers = [];
7773 for (const [key, value] of Object.entries(styles)) {
7774 restorers.push(overrideElementStyle(element, key, value));
7775 }
7776 return restorers.length ? () => {
7777 restorers.forEach((restore) => restore());
7778 } : NOOP;
7779 }
7780 function setPopupCssSize(popupElement, size4) {
7781 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7782 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7783 popupElement.style.setProperty("--popup-width", width);
7784 popupElement.style.setProperty("--popup-height", height);
7785 }
7786 function setPositionerCssSize(positionerElement, size4) {
7787 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7788 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7789 positionerElement.style.setProperty("--positioner-width", width);
7790 positionerElement.style.setProperty("--positioner-height", height);
7791 }
7792
7793 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7794 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7795 function usePopupViewport(parameters) {
7796 const {
7797 store,
7798 side,
7799 cssVars,
7800 children
7801 } = parameters;
7802 const direction = useDirection();
7803 const activeTrigger = store.useState("activeTriggerElement");
7804 const activeTriggerId = store.useState("activeTriggerId");
7805 const open = store.useState("open");
7806 const payload = store.useState("payload");
7807 const mounted = store.useState("mounted");
7808 const popupElement = store.useState("popupElement");
7809 const positionerElement = store.useState("positionerElement");
7810 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7811 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7812 const capturedNodeRef = React32.useRef(null);
7813 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7814 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7815 const currentContainerRef = React32.useRef(null);
7816 const previousContainerRef = React32.useRef(null);
7817 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7818 const cleanupFrame = useAnimationFrame();
7819 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7820 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7821 useIsoLayoutEffect(() => {
7822 store.set("hasViewport", true);
7823 return () => {
7824 store.set("hasViewport", false);
7825 };
7826 }, [store]);
7827 const handleMeasureLayout = useStableCallback(() => {
7828 currentContainerRef.current?.style.setProperty("animation", "none");
7829 currentContainerRef.current?.style.setProperty("transition", "none");
7830 previousContainerRef.current?.style.setProperty("display", "none");
7831 });
7832 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7833 currentContainerRef.current?.style.removeProperty("animation");
7834 currentContainerRef.current?.style.removeProperty("transition");
7835 previousContainerRef.current?.style.removeProperty("display");
7836 if (previousDimensions) {
7837 setPreviousContentDimensions(previousDimensions);
7838 }
7839 });
7840 const lastHandledTriggerRef = React32.useRef(null);
7841 useIsoLayoutEffect(() => {
7842 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7843 setPreviousContentNode(capturedNodeRef.current);
7844 setShowStartingStyleAttribute(true);
7845 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7846 setNewTriggerOffset(offset4);
7847 cleanupFrame.request(() => {
7848 ReactDOM5.flushSync(() => {
7849 setShowStartingStyleAttribute(false);
7850 });
7851 onAnimationsFinished(() => {
7852 setPreviousContentNode(null);
7853 setPreviousContentDimensions(null);
7854 capturedNodeRef.current = null;
7855 });
7856 });
7857 lastHandledTriggerRef.current = activeTrigger;
7858 }
7859 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7860 useIsoLayoutEffect(() => {
7861 const source = currentContainerRef.current;
7862 if (!source) {
7863 return;
7864 }
7865 const wrapper = ownerDocument(source).createElement("div");
7866 for (const child of Array.from(source.childNodes)) {
7867 wrapper.appendChild(child.cloneNode(true));
7868 }
7869 capturedNodeRef.current = wrapper;
7870 });
7871 const isTransitioning = previousContentNode != null;
7872 let childrenToRender;
7873 if (!isTransitioning) {
7874 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7875 "data-current": true,
7876 ref: currentContainerRef,
7877 children
7878 }, currentContentKey);
7879 } else {
7880 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, {
7881 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7882 "data-previous": true,
7883 inert: inertValue(true),
7884 ref: previousContainerRef,
7885 style: {
7886 ...previousContentDimensions ? {
7887 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7888 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7889 } : null,
7890 position: "absolute"
7891 },
7892 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7893 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7894 "data-current": true,
7895 ref: currentContainerRef,
7896 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7897 children
7898 }, currentContentKey)]
7899 });
7900 }
7901 useIsoLayoutEffect(() => {
7902 const container = previousContainerRef.current;
7903 if (!container || !previousContentNode) {
7904 return;
7905 }
7906 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7907 }, [previousContentNode]);
7908 usePopupAutoResize({
7909 popupElement,
7910 positionerElement,
7911 mounted,
7912 content: payload,
7913 onMeasureLayout: handleMeasureLayout,
7914 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7915 side,
7916 direction
7917 });
7918 const state = {
7919 activationDirection: getActivationDirection(newTriggerOffset),
7920 transitioning: isTransitioning
7921 };
7922 return {
7923 children: childrenToRender,
7924 state
7925 };
7926 }
7927 function getActivationDirection(offset4) {
7928 if (!offset4) {
7929 return void 0;
7930 }
7931 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7932 }
7933 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7934 if (value > tolerance) {
7935 return positiveLabel;
7936 }
7937 if (value < -tolerance) {
7938 return negativeLabel;
7939 }
7940 return "";
7941 }
7942 function calculateRelativePosition(from, to) {
7943 const fromRect = from.getBoundingClientRect();
7944 const toRect = to.getBoundingClientRect();
7945 const fromCenter = {
7946 x: fromRect.left + fromRect.width / 2,
7947 y: fromRect.top + fromRect.height / 2
7948 };
7949 const toCenter = {
7950 x: toRect.left + toRect.width / 2,
7951 y: toRect.top + toRect.height / 2
7952 };
7953 return {
7954 horizontal: toCenter.x - fromCenter.x,
7955 vertical: toCenter.y - fromCenter.y
7956 };
7957 }
7958 function usePopupContentKey(activeTriggerId, payload) {
7959 const [contentKey, setContentKey] = React32.useState(0);
7960 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
7961 const previousPayloadRef = React32.useRef(payload);
7962 const pendingPayloadUpdateRef = React32.useRef(false);
7963 useIsoLayoutEffect(() => {
7964 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7965 const previousPayload = previousPayloadRef.current;
7966 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7967 const payloadChanged = payload !== previousPayload;
7968 if (triggerIdChanged) {
7969 setContentKey((value) => value + 1);
7970 pendingPayloadUpdateRef.current = !payloadChanged;
7971 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7972 setContentKey((value) => value + 1);
7973 pendingPayloadUpdateRef.current = false;
7974 }
7975 previousActiveTriggerIdRef.current = activeTriggerId;
7976 previousPayloadRef.current = payload;
7977 }, [activeTriggerId, payload]);
7978 return `${activeTriggerId ?? "current"}-${contentKey}`;
7979 }
7980
7981 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7982 var React33 = __toESM(require_react(), 1);
7983 var ReactDOM6 = __toESM(require_react_dom(), 1);
7984 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7985 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7986 const {
7987 children,
7988 container,
7989 className,
7990 render: render4,
7991 style,
7992 ...elementProps
7993 } = componentProps;
7994 const {
7995 portalNode,
7996 portalSubtree
7997 } = useFloatingPortalNode({
7998 container,
7999 ref: forwardedRef,
8000 componentProps,
8001 elementProps
8002 });
8003 if (!portalSubtree && !portalNode) {
8004 return null;
8005 }
8006 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, {
8007 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8008 });
8009 });
8010 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8011
8012 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8013 var index_parts_exports = {};
8014 __export(index_parts_exports, {
8015 Arrow: () => TooltipArrow,
8016 Handle: () => TooltipHandle,
8017 Popup: () => TooltipPopup,
8018 Portal: () => TooltipPortal,
8019 Positioner: () => TooltipPositioner,
8020 Provider: () => TooltipProvider,
8021 Root: () => TooltipRoot,
8022 Trigger: () => TooltipTrigger,
8023 Viewport: () => TooltipViewport,
8024 createHandle: () => createTooltipHandle
8025 });
8026
8027 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8028 var React36 = __toESM(require_react(), 1);
8029
8030 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8031 var React34 = __toESM(require_react(), 1);
8032 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8033 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8034 function useTooltipRootContext(optional) {
8035 const context = React34.useContext(TooltipRootContext);
8036 if (context === void 0 && !optional) {
8037 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8038 }
8039 return context;
8040 }
8041
8042 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8043 var React35 = __toESM(require_react(), 1);
8044 var ReactDOM7 = __toESM(require_react_dom(), 1);
8045 var selectors2 = {
8046 ...popupStoreSelectors,
8047 disabled: createSelector((state) => state.disabled),
8048 instantType: createSelector((state) => state.instantType),
8049 isInstantPhase: createSelector((state) => state.isInstantPhase),
8050 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8051 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8052 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8053 closeOnClick: createSelector((state) => state.closeOnClick),
8054 closeDelay: createSelector((state) => state.closeDelay),
8055 hasViewport: createSelector((state) => state.hasViewport)
8056 };
8057 var TooltipStore = class _TooltipStore extends ReactStore {
8058 constructor(initialState, floatingId, nested = false) {
8059 const triggerElements = new PopupTriggerMap();
8060 const state = {
8061 ...createInitialState(),
8062 ...initialState
8063 };
8064 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8065 super(state, {
8066 popupRef: /* @__PURE__ */ React35.createRef(),
8067 onOpenChange: void 0,
8068 onOpenChangeComplete: void 0,
8069 triggerElements
8070 }, selectors2);
8071 }
8072 setOpen = (nextOpen, eventDetails) => {
8073 const reason = eventDetails.reason;
8074 const isHover = reason === reason_parts_exports.triggerHover;
8075 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8076 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8077 eventDetails.preventUnmountOnClose = () => {
8078 this.set("preventUnmountingOnClose", true);
8079 };
8080 this.context.onOpenChange?.(nextOpen, eventDetails);
8081 if (eventDetails.isCanceled) {
8082 return;
8083 }
8084 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8085 const changeState = () => {
8086 const updatedState = {
8087 open: nextOpen,
8088 openChangeReason: reason
8089 };
8090 if (isFocusOpen) {
8091 updatedState.instantType = "focus";
8092 } else if (isDismissClose) {
8093 updatedState.instantType = "dismiss";
8094 } else if (reason === reason_parts_exports.triggerHover) {
8095 updatedState.instantType = void 0;
8096 }
8097 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8098 this.update(updatedState);
8099 };
8100 if (isHover) {
8101 ReactDOM7.flushSync(changeState);
8102 } else {
8103 changeState();
8104 }
8105 };
8106 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8107 cancelPendingOpen(event) {
8108 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8109 }
8110 static useStore(externalStore, initialState) {
8111 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8112 return store;
8113 }
8114 };
8115 function createInitialState() {
8116 return {
8117 ...createInitialPopupStoreState(),
8118 disabled: false,
8119 instantType: void 0,
8120 isInstantPhase: false,
8121 trackCursorAxis: "none",
8122 disableHoverablePopup: false,
8123 openChangeReason: null,
8124 closeOnClick: true,
8125 closeDelay: 0,
8126 hasViewport: false
8127 };
8128 }
8129
8130 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8131 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8132 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8133 const {
8134 disabled: disabled2 = false,
8135 defaultOpen = false,
8136 open: openProp,
8137 disableHoverablePopup = false,
8138 trackCursorAxis = "none",
8139 actionsRef,
8140 onOpenChange,
8141 onOpenChangeComplete,
8142 handle,
8143 triggerId: triggerIdProp,
8144 defaultTriggerId: defaultTriggerIdProp = null,
8145 children
8146 } = props;
8147 const store = TooltipStore.useStore(handle?.store, {
8148 open: defaultOpen,
8149 openProp,
8150 activeTriggerId: defaultTriggerIdProp,
8151 triggerIdProp
8152 });
8153 useOnFirstRender(() => {
8154 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8155 store.update({
8156 open: true,
8157 activeTriggerId: defaultTriggerIdProp
8158 });
8159 }
8160 });
8161 store.useControlledProp("openProp", openProp);
8162 store.useControlledProp("triggerIdProp", triggerIdProp);
8163 store.useContextCallback("onOpenChange", onOpenChange);
8164 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8165 const openState = store.useState("open");
8166 const open = !disabled2 && openState;
8167 const activeTriggerId = store.useState("activeTriggerId");
8168 const mounted = store.useState("mounted");
8169 const payload = store.useState("payload");
8170 store.useSyncedValues({
8171 trackCursorAxis,
8172 disableHoverablePopup
8173 });
8174 store.useSyncedValue("disabled", disabled2);
8175 useImplicitActiveTrigger(store);
8176 const {
8177 forceUnmount,
8178 transitionStatus
8179 } = useOpenStateTransitions(open, store);
8180 const isInstantPhase = store.useState("isInstantPhase");
8181 const instantType = store.useState("instantType");
8182 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8183 const previousInstantTypeRef = React36.useRef(null);
8184 useIsoLayoutEffect(() => {
8185 if (openState && disabled2) {
8186 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8187 }
8188 }, [openState, disabled2, store]);
8189 useIsoLayoutEffect(() => {
8190 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8191 if (instantType !== "delay") {
8192 previousInstantTypeRef.current = instantType;
8193 }
8194 store.set("instantType", "delay");
8195 } else if (previousInstantTypeRef.current !== null) {
8196 store.set("instantType", previousInstantTypeRef.current);
8197 previousInstantTypeRef.current = null;
8198 }
8199 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8200 useIsoLayoutEffect(() => {
8201 if (open) {
8202 if (activeTriggerId == null) {
8203 store.set("payload", void 0);
8204 }
8205 }
8206 }, [store, activeTriggerId, open]);
8207 const handleImperativeClose = React36.useCallback(() => {
8208 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8209 }, [store]);
8210 React36.useImperativeHandle(actionsRef, () => ({
8211 unmount: forceUnmount,
8212 close: handleImperativeClose
8213 }), [forceUnmount, handleImperativeClose]);
8214 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8215 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8216 value: store,
8217 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8218 store,
8219 disabled: disabled2,
8220 trackCursorAxis
8221 }), typeof children === "function" ? children({
8222 payload
8223 }) : children]
8224 });
8225 });
8226 if (true) TooltipRoot.displayName = "TooltipRoot";
8227 function TooltipInteractions({
8228 store,
8229 disabled: disabled2,
8230 trackCursorAxis
8231 }) {
8232 const floatingRootContext = store.useState("floatingRootContext");
8233 const dismiss = useDismiss(floatingRootContext, {
8234 enabled: !disabled2,
8235 referencePress: () => store.select("closeOnClick")
8236 });
8237 const clientPoint = useClientPoint(floatingRootContext, {
8238 enabled: !disabled2 && trackCursorAxis !== "none",
8239 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8240 });
8241 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8242 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8243 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8244 usePopupInteractionProps(store, {
8245 activeTriggerProps,
8246 inactiveTriggerProps,
8247 popupProps
8248 });
8249 return null;
8250 }
8251
8252 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8253 var React38 = __toESM(require_react(), 1);
8254
8255 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8256 var React37 = __toESM(require_react(), 1);
8257 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8258 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8259 function useTooltipProviderContext() {
8260 return React37.useContext(TooltipProviderContext);
8261 }
8262
8263 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8264 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8265 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8266 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8267 return TooltipTriggerDataAttributes2;
8268 })({});
8269
8270 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8271 var OPEN_DELAY = 600;
8272
8273 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8274 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8275 function getTargetElement(event) {
8276 if ("composedPath" in event) {
8277 const path = event.composedPath();
8278 for (let i2 = 0; i2 < path.length; i2 += 1) {
8279 const element = path[i2];
8280 if (isElement(element)) {
8281 return element;
8282 }
8283 }
8284 }
8285 const target = event.target;
8286 if (isElement(target)) {
8287 return target;
8288 }
8289 return null;
8290 }
8291 function closestEnabledTooltipTrigger(element) {
8292 let current = element;
8293 while (current) {
8294 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8295 return current;
8296 }
8297 const parentElement = current.parentElement;
8298 if (parentElement) {
8299 current = parentElement;
8300 continue;
8301 }
8302 const root = current.getRootNode();
8303 current = "host" in root && isElement(root.host) ? root.host : null;
8304 }
8305 return null;
8306 }
8307 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8308 const {
8309 render: render4,
8310 className,
8311 style,
8312 handle,
8313 payload,
8314 disabled: disabledProp,
8315 delay,
8316 closeOnClick = true,
8317 closeDelay,
8318 id: idProp,
8319 ...elementProps
8320 } = componentProps;
8321 const rootContext = useTooltipRootContext(true);
8322 const store = handle?.store ?? rootContext;
8323 if (!store) {
8324 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));
8325 }
8326 const thisTriggerId = useBaseUiId(idProp);
8327 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8328 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8329 const floatingRootContext = store.useState("floatingRootContext");
8330 const triggerElementRef = React38.useRef(null);
8331 const delayWithDefault = delay ?? OPEN_DELAY;
8332 const closeDelayWithDefault = closeDelay ?? 0;
8333 const {
8334 registerTrigger,
8335 isMountedByThisTrigger
8336 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8337 payload,
8338 closeOnClick,
8339 closeDelay: closeDelayWithDefault
8340 });
8341 const providerContext = useTooltipProviderContext();
8342 const {
8343 delayRef,
8344 isInstantPhase,
8345 hasProvider
8346 } = useDelayGroup(floatingRootContext, {
8347 open: isOpenedByThisTrigger
8348 });
8349 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8350 store.useSyncedValue("isInstantPhase", isInstantPhase);
8351 const rootDisabled = store.useState("disabled");
8352 const disabled2 = disabledProp ?? rootDisabled;
8353 const disabledRef = useValueAsRef(disabled2);
8354 const trackCursorAxis = store.useState("trackCursorAxis");
8355 const disableHoverablePopup = store.useState("disableHoverablePopup");
8356 const isNestedTriggerHoveredRef = React38.useRef(false);
8357 const nestedTriggerOpenTimeout = useTimeout();
8358 const pointerTypeRef = React38.useRef(void 0);
8359 function getOpenDelay() {
8360 const providerDelay = providerContext?.delay;
8361 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8362 let computedOpenDelay = delayWithDefault;
8363 if (hasProvider) {
8364 if (groupOpenValue !== 0) {
8365 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8366 } else {
8367 computedOpenDelay = 0;
8368 }
8369 }
8370 return computedOpenDelay;
8371 }
8372 function isEnabledNestedTriggerTarget(target) {
8373 const triggerEl = triggerElementRef.current;
8374 if (!triggerEl || !target) {
8375 return false;
8376 }
8377 const nearestTrigger = closestEnabledTooltipTrigger(target);
8378 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8379 }
8380 function detectNestedTriggerHover(target) {
8381 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8382 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8383 if (nestedTriggerHovered) {
8384 hoverInteraction.openChangeTimeout.clear();
8385 hoverInteraction.restTimeout.clear();
8386 hoverInteraction.restTimeoutPending = false;
8387 nestedTriggerOpenTimeout.clear();
8388 }
8389 return nestedTriggerHovered;
8390 }
8391 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8392 enabled: !disabled2,
8393 mouseOnly: true,
8394 move: false,
8395 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8396 restMs: getOpenDelay,
8397 delay() {
8398 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8399 let computedCloseDelay = closeDelayWithDefault;
8400 if (closeDelay == null && hasProvider) {
8401 computedCloseDelay = closeValue;
8402 }
8403 return {
8404 close: computedCloseDelay
8405 };
8406 },
8407 triggerElementRef,
8408 isActiveTrigger: isTriggerActive,
8409 isClosing: () => store.select("transitionStatus") === "ending",
8410 shouldOpen() {
8411 return !isNestedTriggerHoveredRef.current;
8412 }
8413 });
8414 const focusProps = useFocus(floatingRootContext, {
8415 enabled: !disabled2
8416 }).reference;
8417 const handleNestedTriggerHover = (event) => {
8418 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8419 const target = getTargetElement(event);
8420 const nestedTriggerHovered = detectNestedTriggerHover(target);
8421 const triggerEl = triggerElementRef.current;
8422 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8423 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8424 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8425 return;
8426 }
8427 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8428 isMouseLikePointerType(pointerTypeRef.current)) {
8429 const open = () => {
8430 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8431 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8432 }
8433 };
8434 const openDelay = getOpenDelay();
8435 if (openDelay === 0) {
8436 nestedTriggerOpenTimeout.clear();
8437 open();
8438 } else {
8439 nestedTriggerOpenTimeout.start(openDelay, open);
8440 }
8441 }
8442 };
8443 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8444 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8445 const state = {
8446 open: isOpenedByThisTrigger
8447 };
8448 const element = useRenderElement("button", componentProps, {
8449 state,
8450 ref: [forwardedRef, registerTrigger, triggerElementRef],
8451 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8452 onMouseOver(event) {
8453 handleNestedTriggerHover(event.nativeEvent);
8454 },
8455 onFocus(event) {
8456 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8457 event.preventBaseUIHandler();
8458 }
8459 },
8460 onMouseLeave() {
8461 isNestedTriggerHoveredRef.current = false;
8462 nestedTriggerOpenTimeout.clear();
8463 pointerTypeRef.current = void 0;
8464 },
8465 onPointerEnter(event) {
8466 pointerTypeRef.current = event.pointerType;
8467 },
8468 onPointerDown(event) {
8469 pointerTypeRef.current = event.pointerType;
8470 store.set("closeOnClick", closeOnClick);
8471 if (closeOnClick && !store.select("open")) {
8472 store.cancelPendingOpen(event.nativeEvent);
8473 }
8474 },
8475 onClick(event) {
8476 if (closeOnClick && !store.select("open")) {
8477 store.cancelPendingOpen(event.nativeEvent);
8478 }
8479 },
8480 id: thisTriggerId,
8481 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8482 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8483 }, elementProps],
8484 stateAttributesMapping: triggerOpenStateMapping
8485 });
8486 return element;
8487 });
8488 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8489
8490 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8491 var React40 = __toESM(require_react(), 1);
8492
8493 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8494 var React39 = __toESM(require_react(), 1);
8495 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8496 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8497 function useTooltipPortalContext() {
8498 const value = React39.useContext(TooltipPortalContext);
8499 if (value === void 0) {
8500 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8501 }
8502 return value;
8503 }
8504
8505 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8506 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8507 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8508 const {
8509 keepMounted = false,
8510 ...portalProps
8511 } = props;
8512 const store = useTooltipRootContext();
8513 const mounted = store.useState("mounted");
8514 const shouldRender = mounted || keepMounted;
8515 if (!shouldRender) {
8516 return null;
8517 }
8518 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8519 value: keepMounted,
8520 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8521 ref: forwardedRef,
8522 ...portalProps
8523 })
8524 });
8525 });
8526 if (true) TooltipPortal.displayName = "TooltipPortal";
8527
8528 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8529 var React42 = __toESM(require_react(), 1);
8530
8531 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8532 var React41 = __toESM(require_react(), 1);
8533 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8534 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8535 function useTooltipPositionerContext() {
8536 const context = React41.useContext(TooltipPositionerContext);
8537 if (context === void 0) {
8538 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8539 }
8540 return context;
8541 }
8542
8543 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8544 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8545 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8546 const {
8547 render: render4,
8548 className,
8549 anchor,
8550 positionMethod = "absolute",
8551 side = "top",
8552 align = "center",
8553 sideOffset = 0,
8554 alignOffset = 0,
8555 collisionBoundary = "clipping-ancestors",
8556 collisionPadding = 5,
8557 arrowPadding = 5,
8558 sticky = false,
8559 disableAnchorTracking = false,
8560 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8561 style,
8562 ...elementProps
8563 } = componentProps;
8564 const store = useTooltipRootContext();
8565 const keepMounted = useTooltipPortalContext();
8566 const open = store.useState("open");
8567 const mounted = store.useState("mounted");
8568 const trackCursorAxis = store.useState("trackCursorAxis");
8569 const disableHoverablePopup = store.useState("disableHoverablePopup");
8570 const floatingRootContext = store.useState("floatingRootContext");
8571 const instantType = store.useState("instantType");
8572 const transitionStatus = store.useState("transitionStatus");
8573 const hasViewport = store.useState("hasViewport");
8574 const positioning = useAnchorPositioning({
8575 anchor,
8576 positionMethod,
8577 floatingRootContext,
8578 mounted,
8579 side,
8580 sideOffset,
8581 align,
8582 alignOffset,
8583 collisionBoundary,
8584 collisionPadding,
8585 sticky,
8586 arrowPadding,
8587 disableAnchorTracking,
8588 keepMounted,
8589 collisionAvoidance,
8590 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8591 });
8592 const state = React42.useMemo(() => ({
8593 open,
8594 side: positioning.side,
8595 align: positioning.align,
8596 anchorHidden: positioning.anchorHidden,
8597 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8598 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8599 const element = usePositioner(componentProps, state, {
8600 styles: positioning.positionerStyles,
8601 transitionStatus,
8602 props: elementProps,
8603 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8604 hidden: !mounted,
8605 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8606 });
8607 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8608 value: positioning,
8609 children: element
8610 });
8611 });
8612 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8613
8614 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8615 var React43 = __toESM(require_react(), 1);
8616 var stateAttributesMapping = {
8617 ...popupStateMapping,
8618 ...transitionStatusMapping
8619 };
8620 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8621 const {
8622 render: render4,
8623 className,
8624 style,
8625 ...elementProps
8626 } = componentProps;
8627 const store = useTooltipRootContext();
8628 const {
8629 side,
8630 align
8631 } = useTooltipPositionerContext();
8632 const open = store.useState("open");
8633 const instantType = store.useState("instantType");
8634 const transitionStatus = store.useState("transitionStatus");
8635 const popupProps = store.useState("popupProps");
8636 const floatingContext = store.useState("floatingRootContext");
8637 const disabled2 = store.useState("disabled");
8638 const closeDelay = store.useState("closeDelay");
8639 useOpenChangeComplete({
8640 open,
8641 ref: store.context.popupRef,
8642 onComplete() {
8643 if (open) {
8644 store.context.onOpenChangeComplete?.(true);
8645 }
8646 }
8647 });
8648 useHoverFloatingInteraction(floatingContext, {
8649 enabled: !disabled2,
8650 closeDelay
8651 });
8652 const setPopupElement = store.useStateSetter("popupElement");
8653 const state = {
8654 open,
8655 side,
8656 align,
8657 instant: instantType,
8658 transitionStatus
8659 };
8660 const element = useRenderElement("div", componentProps, {
8661 state,
8662 ref: [forwardedRef, store.context.popupRef, setPopupElement],
8663 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8664 stateAttributesMapping
8665 });
8666 return element;
8667 });
8668 if (true) TooltipPopup.displayName = "TooltipPopup";
8669
8670 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8671 var React44 = __toESM(require_react(), 1);
8672 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8673 const {
8674 render: render4,
8675 className,
8676 style,
8677 ...elementProps
8678 } = componentProps;
8679 const store = useTooltipRootContext();
8680 const {
8681 arrowRef,
8682 side,
8683 align,
8684 arrowUncentered,
8685 arrowStyles
8686 } = useTooltipPositionerContext();
8687 const open = store.useState("open");
8688 const instantType = store.useState("instantType");
8689 const state = {
8690 open,
8691 side,
8692 align,
8693 uncentered: arrowUncentered,
8694 instant: instantType
8695 };
8696 const element = useRenderElement("div", componentProps, {
8697 state,
8698 ref: [forwardedRef, arrowRef],
8699 props: [{
8700 style: arrowStyles,
8701 "aria-hidden": true
8702 }, elementProps],
8703 stateAttributesMapping: popupStateMapping
8704 });
8705 return element;
8706 });
8707 if (true) TooltipArrow.displayName = "TooltipArrow";
8708
8709 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8710 var React45 = __toESM(require_react(), 1);
8711 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8712 var TooltipProvider = function TooltipProvider2(props) {
8713 const {
8714 delay,
8715 closeDelay,
8716 timeout = 400
8717 } = props;
8718 const contextValue = React45.useMemo(() => ({
8719 delay,
8720 closeDelay
8721 }), [delay, closeDelay]);
8722 const delayValue = React45.useMemo(() => ({
8723 open: delay,
8724 close: closeDelay
8725 }), [delay, closeDelay]);
8726 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8727 value: contextValue,
8728 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8729 delay: delayValue,
8730 timeoutMs: timeout,
8731 children: props.children
8732 })
8733 });
8734 };
8735 if (true) TooltipProvider.displayName = "TooltipProvider";
8736
8737 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8738 var React46 = __toESM(require_react(), 1);
8739
8740 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8741 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8742 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8743 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8744 return TooltipViewportCssVars2;
8745 })({});
8746
8747 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8748 var stateAttributesMapping2 = {
8749 activationDirection: (value) => value ? {
8750 "data-activation-direction": value
8751 } : null
8752 };
8753 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8754 const {
8755 render: render4,
8756 className,
8757 style,
8758 children,
8759 ...elementProps
8760 } = componentProps;
8761 const store = useTooltipRootContext();
8762 const positioner = useTooltipPositionerContext();
8763 const instantType = store.useState("instantType");
8764 const {
8765 children: childrenToRender,
8766 state: viewportState
8767 } = usePopupViewport({
8768 store,
8769 side: positioner.side,
8770 cssVars: TooltipViewportCssVars,
8771 children
8772 });
8773 const state = {
8774 activationDirection: viewportState.activationDirection,
8775 transitioning: viewportState.transitioning,
8776 instant: instantType
8777 };
8778 return useRenderElement("div", componentProps, {
8779 state,
8780 ref: forwardedRef,
8781 props: [elementProps, {
8782 children: childrenToRender
8783 }],
8784 stateAttributesMapping: stateAttributesMapping2
8785 });
8786 });
8787 if (true) TooltipViewport.displayName = "TooltipViewport";
8788
8789 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8790 var TooltipHandle = class {
8791 /**
8792 * Internal store holding the tooltip state.
8793 * @internal
8794 */
8795 constructor() {
8796 this.store = new TooltipStore();
8797 }
8798 /**
8799 * Opens the tooltip and associates it with the trigger with the given ID.
8800 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8801 *
8802 * This method should only be called in an event handler or an effect (not during rendering).
8803 *
8804 * @param triggerId ID of the trigger to associate with the tooltip.
8805 */
8806 open(triggerId) {
8807 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8808 if (triggerId && !triggerElement) {
8809 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8810 }
8811 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8812 }
8813 /**
8814 * Closes the tooltip.
8815 */
8816 close() {
8817 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8818 }
8819 /**
8820 * Indicates whether the tooltip is currently open.
8821 */
8822 get isOpen() {
8823 return this.store.select("open");
8824 }
8825 };
8826 function createTooltipHandle() {
8827 return new TooltipHandle();
8828 }
8829
8830 // node_modules/@base-ui/react/esm/use-render/useRender.js
8831 function useRender(params) {
8832 return useRenderElement(params.defaultTagName ?? "div", params, params);
8833 }
8834
8835 // packages/ui/build-module/text/text.mjs
8836 var import_element10 = __toESM(require_element(), 1);
8837 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8838 function getRuntime() {
8839 const globalScope = globalThis;
8840 if (globalScope.__wpStyleRuntime) {
8841 return globalScope.__wpStyleRuntime;
8842 }
8843 globalScope.__wpStyleRuntime = {
8844 documents: /* @__PURE__ */ new Map(),
8845 styles: /* @__PURE__ */ new Map(),
8846 injectedStyles: /* @__PURE__ */ new WeakMap()
8847 };
8848 if (typeof document !== "undefined") {
8849 registerDocument(document);
8850 }
8851 return globalScope.__wpStyleRuntime;
8852 }
8853 function documentContainsStyleHash(targetDocument, hash) {
8854 if (!targetDocument.head) {
8855 return false;
8856 }
8857 for (const style of targetDocument.head.querySelectorAll(
8858 `style[${STYLE_HASH_ATTRIBUTE}]`
8859 )) {
8860 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8861 return true;
8862 }
8863 }
8864 return false;
8865 }
8866 function injectStyle(targetDocument, hash, css) {
8867 if (!targetDocument.head) {
8868 return;
8869 }
8870 const runtime = getRuntime();
8871 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8872 if (!injectedStyles) {
8873 injectedStyles = /* @__PURE__ */ new Set();
8874 runtime.injectedStyles.set(targetDocument, injectedStyles);
8875 }
8876 if (injectedStyles.has(hash)) {
8877 return;
8878 }
8879 if (documentContainsStyleHash(targetDocument, hash)) {
8880 injectedStyles.add(hash);
8881 return;
8882 }
8883 const style = targetDocument.createElement("style");
8884 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8885 style.appendChild(targetDocument.createTextNode(css));
8886 targetDocument.head.appendChild(style);
8887 injectedStyles.add(hash);
8888 }
8889 function registerDocument(targetDocument) {
8890 const runtime = getRuntime();
8891 runtime.documents.set(
8892 targetDocument,
8893 (runtime.documents.get(targetDocument) ?? 0) + 1
8894 );
8895 for (const [hash, css] of runtime.styles) {
8896 injectStyle(targetDocument, hash, css);
8897 }
8898 return () => {
8899 const count = runtime.documents.get(targetDocument);
8900 if (count === void 0) {
8901 return;
8902 }
8903 if (count <= 1) {
8904 runtime.documents.delete(targetDocument);
8905 return;
8906 }
8907 runtime.documents.set(targetDocument, count - 1);
8908 };
8909 }
8910 function registerStyle(hash, css) {
8911 const runtime = getRuntime();
8912 runtime.styles.set(hash, css);
8913 for (const targetDocument of runtime.documents.keys()) {
8914 injectStyle(targetDocument, hash, css);
8915 }
8916 }
8917 if (typeof process === "undefined" || true) {
8918 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)}}}');
8919 }
8920 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" };
8921 if (typeof process === "undefined" || true) {
8922 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)}");
8923 }
8924 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" };
8925 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8926 const element = useRender({
8927 render: render4,
8928 defaultTagName: "span",
8929 ref,
8930 props: mergeProps(props, {
8931 className: clsx_default(
8932 style_default.text,
8933 global_css_defense_default.heading,
8934 global_css_defense_default.p,
8935 style_default[variant],
8936 className
8937 )
8938 })
8939 });
8940 return element;
8941 });
8942
8943 // packages/ui/build-module/icon/icon.mjs
8944 var import_element11 = __toESM(require_element(), 1);
8945 var import_primitives = __toESM(require_primitives(), 1);
8946 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8947 var Icon = (0, import_element11.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8948 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8949 import_primitives.SVG,
8950 {
8951 ref,
8952 ...icon.props,
8953 ...restProps,
8954 width: size4,
8955 height: size4
8956 }
8957 );
8958 });
8959
8960 // packages/icons/build-module/library/arrow-down.mjs
8961 var import_primitives2 = __toESM(require_primitives(), 1);
8962 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8963 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "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" }) });
8964
8965 // packages/icons/build-module/library/arrow-left.mjs
8966 var import_primitives3 = __toESM(require_primitives(), 1);
8967 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8968 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
8969
8970 // packages/icons/build-module/library/arrow-right.mjs
8971 var import_primitives4 = __toESM(require_primitives(), 1);
8972 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8973 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
8974
8975 // packages/icons/build-module/library/arrow-up.mjs
8976 var import_primitives5 = __toESM(require_primitives(), 1);
8977 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8978 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
8979
8980 // packages/icons/build-module/library/block-table.mjs
8981 var import_primitives6 = __toESM(require_primitives(), 1);
8982 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8983 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { 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" }) });
8984
8985 // packages/icons/build-module/library/category.mjs
8986 var import_primitives7 = __toESM(require_primitives(), 1);
8987 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8988 var category_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { 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" }) });
8989
8990 // packages/icons/build-module/library/check.mjs
8991 var import_primitives8 = __toESM(require_primitives(), 1);
8992 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8993 var check_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
8994
8995 // packages/icons/build-module/library/close-small.mjs
8996 var import_primitives9 = __toESM(require_primitives(), 1);
8997 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8998 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { 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" }) });
8999
9000 // packages/icons/build-module/library/cog.mjs
9001 var import_primitives10 = __toESM(require_primitives(), 1);
9002 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9003 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9004
9005 // packages/icons/build-module/library/envelope.mjs
9006 var import_primitives11 = __toESM(require_primitives(), 1);
9007 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9008 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9009
9010 // packages/icons/build-module/library/error.mjs
9011 var import_primitives12 = __toESM(require_primitives(), 1);
9012 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9013 var error_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.Path, { 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" }) });
9014
9015 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9016 var import_primitives13 = __toESM(require_primitives(), 1);
9017 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9018 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.Path, { d: "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" }) });
9019
9020 // packages/icons/build-module/library/format-list-bullets.mjs
9021 var import_primitives14 = __toESM(require_primitives(), 1);
9022 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9023 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.Path, { d: "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" }) });
9024
9025 // packages/icons/build-module/library/funnel.mjs
9026 var import_primitives15 = __toESM(require_primitives(), 1);
9027 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9028 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9029
9030 // packages/icons/build-module/library/globe.mjs
9031 var import_primitives16 = __toESM(require_primitives(), 1);
9032 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9033 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) });
9034
9035 // packages/icons/build-module/library/link.mjs
9036 var import_primitives17 = __toESM(require_primitives(), 1);
9037 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9038 var link_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.Path, { d: "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" }) });
9039
9040 // packages/icons/build-module/library/mobile.mjs
9041 var import_primitives18 = __toESM(require_primitives(), 1);
9042 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9043 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.Path, { d: "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" }) });
9044
9045 // packages/icons/build-module/library/more-vertical.mjs
9046 var import_primitives19 = __toESM(require_primitives(), 1);
9047 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9048 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9049
9050 // packages/icons/build-module/library/next.mjs
9051 var import_primitives20 = __toESM(require_primitives(), 1);
9052 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9053 var next_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.Path, { 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" }) });
9054
9055 // packages/icons/build-module/library/post-list.mjs
9056 var import_primitives21 = __toESM(require_primitives(), 1);
9057 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9058 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "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" }) });
9059
9060 // packages/icons/build-module/library/previous.mjs
9061 var import_primitives22 = __toESM(require_primitives(), 1);
9062 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9063 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.Path, { d: "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" }) });
9064
9065 // packages/icons/build-module/library/scheduled.mjs
9066 var import_primitives23 = __toESM(require_primitives(), 1);
9067 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9068 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.Path, { 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" }) });
9069
9070 // packages/icons/build-module/library/search.mjs
9071 var import_primitives24 = __toESM(require_primitives(), 1);
9072 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9073 var search_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.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" }) });
9074
9075 // packages/icons/build-module/library/seen.mjs
9076 var import_primitives25 = __toESM(require_primitives(), 1);
9077 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9078 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.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" }) });
9079
9080 // packages/icons/build-module/library/unseen.mjs
9081 var import_primitives26 = __toESM(require_primitives(), 1);
9082 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9083 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.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" }) });
9084
9085 // packages/icons/build-module/library/wordpress.mjs
9086 var import_primitives27 = __toESM(require_primitives(), 1);
9087 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9088 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
9089
9090 // packages/ui/build-module/utils/render-slot-with-children.mjs
9091 var import_element12 = __toESM(require_element(), 1);
9092 function renderSlotWithChildren(slot, defaultSlot, children) {
9093 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9094 }
9095
9096 // packages/ui/build-module/utils/theme-provider.mjs
9097 var theme = __toESM(require_theme(), 1);
9098
9099 // packages/ui/build-module/lock-unlock.mjs
9100 var import_private_apis = __toESM(require_private_apis(), 1);
9101 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9102 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9103 "@wordpress/ui"
9104 );
9105
9106 // packages/ui/build-module/utils/theme-provider.mjs
9107 function getThemeProvider() {
9108 const themePackage = theme;
9109 if (themePackage.ThemeProvider) {
9110 return themePackage.ThemeProvider;
9111 }
9112 if (!themePackage.privateApis) {
9113 throw new Error(
9114 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9115 );
9116 }
9117 return unlock(
9118 themePackage.privateApis
9119 ).ThemeProvider;
9120 }
9121 var ThemeProvider = getThemeProvider();
9122
9123 // packages/ui/build-module/stack/stack.mjs
9124 var import_element13 = __toESM(require_element(), 1);
9125 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9126 function getRuntime2() {
9127 const globalScope = globalThis;
9128 if (globalScope.__wpStyleRuntime) {
9129 return globalScope.__wpStyleRuntime;
9130 }
9131 globalScope.__wpStyleRuntime = {
9132 documents: /* @__PURE__ */ new Map(),
9133 styles: /* @__PURE__ */ new Map(),
9134 injectedStyles: /* @__PURE__ */ new WeakMap()
9135 };
9136 if (typeof document !== "undefined") {
9137 registerDocument2(document);
9138 }
9139 return globalScope.__wpStyleRuntime;
9140 }
9141 function documentContainsStyleHash2(targetDocument, hash) {
9142 if (!targetDocument.head) {
9143 return false;
9144 }
9145 for (const style of targetDocument.head.querySelectorAll(
9146 `style[${STYLE_HASH_ATTRIBUTE2}]`
9147 )) {
9148 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9149 return true;
9150 }
9151 }
9152 return false;
9153 }
9154 function injectStyle2(targetDocument, hash, css) {
9155 if (!targetDocument.head) {
9156 return;
9157 }
9158 const runtime = getRuntime2();
9159 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9160 if (!injectedStyles) {
9161 injectedStyles = /* @__PURE__ */ new Set();
9162 runtime.injectedStyles.set(targetDocument, injectedStyles);
9163 }
9164 if (injectedStyles.has(hash)) {
9165 return;
9166 }
9167 if (documentContainsStyleHash2(targetDocument, hash)) {
9168 injectedStyles.add(hash);
9169 return;
9170 }
9171 const style = targetDocument.createElement("style");
9172 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9173 style.appendChild(targetDocument.createTextNode(css));
9174 targetDocument.head.appendChild(style);
9175 injectedStyles.add(hash);
9176 }
9177 function registerDocument2(targetDocument) {
9178 const runtime = getRuntime2();
9179 runtime.documents.set(
9180 targetDocument,
9181 (runtime.documents.get(targetDocument) ?? 0) + 1
9182 );
9183 for (const [hash, css] of runtime.styles) {
9184 injectStyle2(targetDocument, hash, css);
9185 }
9186 return () => {
9187 const count = runtime.documents.get(targetDocument);
9188 if (count === void 0) {
9189 return;
9190 }
9191 if (count <= 1) {
9192 runtime.documents.delete(targetDocument);
9193 return;
9194 }
9195 runtime.documents.set(targetDocument, count - 1);
9196 };
9197 }
9198 function registerStyle2(hash, css) {
9199 const runtime = getRuntime2();
9200 runtime.styles.set(hash, css);
9201 for (const targetDocument of runtime.documents.keys()) {
9202 injectStyle2(targetDocument, hash, css);
9203 }
9204 }
9205 if (typeof process === "undefined" || true) {
9206 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9207 }
9208 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9209 var gapTokens = {
9210 xs: "var(--wpds-dimension-gap-xs, 4px)",
9211 sm: "var(--wpds-dimension-gap-sm, 8px)",
9212 md: "var(--wpds-dimension-gap-md, 12px)",
9213 lg: "var(--wpds-dimension-gap-lg, 16px)",
9214 xl: "var(--wpds-dimension-gap-xl, 24px)",
9215 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9216 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9217 };
9218 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9219 const style = {
9220 gap: gap && gapTokens[gap],
9221 alignItems: align,
9222 justifyContent: justify,
9223 flexDirection: direction,
9224 flexWrap: wrap
9225 };
9226 const element = useRender({
9227 render: render4,
9228 ref,
9229 props: mergeProps(props, { style, className: style_default2.stack })
9230 });
9231 return element;
9232 });
9233
9234 // packages/ui/build-module/tooltip/index.mjs
9235 var tooltip_exports = {};
9236 __export(tooltip_exports, {
9237 Popup: () => Popup,
9238 Portal: () => Portal,
9239 Positioner: () => Positioner,
9240 Provider: () => Provider,
9241 Root: () => Root,
9242 Trigger: () => Trigger
9243 });
9244
9245 // packages/ui/build-module/tooltip/popup.mjs
9246 var import_element16 = __toESM(require_element(), 1);
9247
9248 // packages/ui/build-module/tooltip/portal.mjs
9249 var import_element14 = __toESM(require_element(), 1);
9250
9251 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9252 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9253 function getRuntime3() {
9254 const globalScope = globalThis;
9255 if (globalScope.__wpStyleRuntime) {
9256 return globalScope.__wpStyleRuntime;
9257 }
9258 globalScope.__wpStyleRuntime = {
9259 documents: /* @__PURE__ */ new Map(),
9260 styles: /* @__PURE__ */ new Map(),
9261 injectedStyles: /* @__PURE__ */ new WeakMap()
9262 };
9263 if (typeof document !== "undefined") {
9264 registerDocument3(document);
9265 }
9266 return globalScope.__wpStyleRuntime;
9267 }
9268 function documentContainsStyleHash3(targetDocument, hash) {
9269 if (!targetDocument.head) {
9270 return false;
9271 }
9272 for (const style of targetDocument.head.querySelectorAll(
9273 `style[${STYLE_HASH_ATTRIBUTE3}]`
9274 )) {
9275 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9276 return true;
9277 }
9278 }
9279 return false;
9280 }
9281 function injectStyle3(targetDocument, hash, css) {
9282 if (!targetDocument.head) {
9283 return;
9284 }
9285 const runtime = getRuntime3();
9286 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9287 if (!injectedStyles) {
9288 injectedStyles = /* @__PURE__ */ new Set();
9289 runtime.injectedStyles.set(targetDocument, injectedStyles);
9290 }
9291 if (injectedStyles.has(hash)) {
9292 return;
9293 }
9294 if (documentContainsStyleHash3(targetDocument, hash)) {
9295 injectedStyles.add(hash);
9296 return;
9297 }
9298 const style = targetDocument.createElement("style");
9299 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9300 style.appendChild(targetDocument.createTextNode(css));
9301 targetDocument.head.appendChild(style);
9302 injectedStyles.add(hash);
9303 }
9304 function registerDocument3(targetDocument) {
9305 const runtime = getRuntime3();
9306 runtime.documents.set(
9307 targetDocument,
9308 (runtime.documents.get(targetDocument) ?? 0) + 1
9309 );
9310 for (const [hash, css] of runtime.styles) {
9311 injectStyle3(targetDocument, hash, css);
9312 }
9313 return () => {
9314 const count = runtime.documents.get(targetDocument);
9315 if (count === void 0) {
9316 return;
9317 }
9318 if (count <= 1) {
9319 runtime.documents.delete(targetDocument);
9320 return;
9321 }
9322 runtime.documents.set(targetDocument, count - 1);
9323 };
9324 }
9325 function registerStyle3(hash, css) {
9326 const runtime = getRuntime3();
9327 runtime.styles.set(hash, css);
9328 for (const targetDocument of runtime.documents.keys()) {
9329 injectStyle3(targetDocument, hash, css);
9330 }
9331 }
9332 if (typeof process === "undefined" || true) {
9333 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}}}");
9334 }
9335 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9336 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9337 function resolveOwnerDocument() {
9338 return typeof document === "undefined" ? null : document;
9339 }
9340 function isInWordPressEnvironment() {
9341 let topWp;
9342 try {
9343 topWp = window.top?.wp;
9344 } catch {
9345 }
9346 const wp = topWp ?? window.wp;
9347 return typeof wp?.components === "object" && wp.components !== null;
9348 }
9349 var cachedSlot = null;
9350 function createSlot(ownerDocument2) {
9351 const element = ownerDocument2.createElement("div");
9352 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9353 if (wp_compat_overlay_slot_default.slot) {
9354 element.classList.add(wp_compat_overlay_slot_default.slot);
9355 }
9356 ownerDocument2.body.appendChild(element);
9357 return element;
9358 }
9359 function getWpCompatOverlaySlot() {
9360 if (typeof window === "undefined") {
9361 return void 0;
9362 }
9363 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9364 return void 0;
9365 }
9366 const ownerDocument2 = resolveOwnerDocument();
9367 if (!ownerDocument2 || !ownerDocument2.body) {
9368 return void 0;
9369 }
9370 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9371 return cachedSlot;
9372 }
9373 const existing = ownerDocument2.querySelector(
9374 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9375 );
9376 if (existing instanceof HTMLDivElement) {
9377 cachedSlot = existing;
9378 return existing;
9379 }
9380 if (cachedSlot?.isConnected) {
9381 cachedSlot.remove();
9382 }
9383 cachedSlot = createSlot(ownerDocument2);
9384 return cachedSlot;
9385 }
9386
9387 // packages/ui/build-module/tooltip/portal.mjs
9388 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9389 var Portal = (0, import_element14.forwardRef)(
9390 function TooltipPortal3({ container, ...restProps }, ref) {
9391 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9392 index_parts_exports.Portal,
9393 {
9394 container: container ?? getWpCompatOverlaySlot(),
9395 ...restProps,
9396 ref
9397 }
9398 );
9399 }
9400 );
9401
9402 // packages/ui/build-module/tooltip/positioner.mjs
9403 var import_element15 = __toESM(require_element(), 1);
9404 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9405 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9406 function getRuntime4() {
9407 const globalScope = globalThis;
9408 if (globalScope.__wpStyleRuntime) {
9409 return globalScope.__wpStyleRuntime;
9410 }
9411 globalScope.__wpStyleRuntime = {
9412 documents: /* @__PURE__ */ new Map(),
9413 styles: /* @__PURE__ */ new Map(),
9414 injectedStyles: /* @__PURE__ */ new WeakMap()
9415 };
9416 if (typeof document !== "undefined") {
9417 registerDocument4(document);
9418 }
9419 return globalScope.__wpStyleRuntime;
9420 }
9421 function documentContainsStyleHash4(targetDocument, hash) {
9422 if (!targetDocument.head) {
9423 return false;
9424 }
9425 for (const style of targetDocument.head.querySelectorAll(
9426 `style[${STYLE_HASH_ATTRIBUTE4}]`
9427 )) {
9428 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9429 return true;
9430 }
9431 }
9432 return false;
9433 }
9434 function injectStyle4(targetDocument, hash, css) {
9435 if (!targetDocument.head) {
9436 return;
9437 }
9438 const runtime = getRuntime4();
9439 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9440 if (!injectedStyles) {
9441 injectedStyles = /* @__PURE__ */ new Set();
9442 runtime.injectedStyles.set(targetDocument, injectedStyles);
9443 }
9444 if (injectedStyles.has(hash)) {
9445 return;
9446 }
9447 if (documentContainsStyleHash4(targetDocument, hash)) {
9448 injectedStyles.add(hash);
9449 return;
9450 }
9451 const style = targetDocument.createElement("style");
9452 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9453 style.appendChild(targetDocument.createTextNode(css));
9454 targetDocument.head.appendChild(style);
9455 injectedStyles.add(hash);
9456 }
9457 function registerDocument4(targetDocument) {
9458 const runtime = getRuntime4();
9459 runtime.documents.set(
9460 targetDocument,
9461 (runtime.documents.get(targetDocument) ?? 0) + 1
9462 );
9463 for (const [hash, css] of runtime.styles) {
9464 injectStyle4(targetDocument, hash, css);
9465 }
9466 return () => {
9467 const count = runtime.documents.get(targetDocument);
9468 if (count === void 0) {
9469 return;
9470 }
9471 if (count <= 1) {
9472 runtime.documents.delete(targetDocument);
9473 return;
9474 }
9475 runtime.documents.set(targetDocument, count - 1);
9476 };
9477 }
9478 function registerStyle4(hash, css) {
9479 const runtime = getRuntime4();
9480 runtime.styles.set(hash, css);
9481 for (const targetDocument of runtime.documents.keys()) {
9482 injectStyle4(targetDocument, hash, css);
9483 }
9484 }
9485 if (typeof process === "undefined" || true) {
9486 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9487 }
9488 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9489 if (typeof process === "undefined" || true) {
9490 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}}}}');
9491 }
9492 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9493 var Positioner = (0, import_element15.forwardRef)(
9494 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9495 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9496 index_parts_exports.Positioner,
9497 {
9498 ref,
9499 align,
9500 side,
9501 sideOffset,
9502 ...props,
9503 className: clsx_default(
9504 resets_default["box-sizing"],
9505 style_default3.positioner,
9506 className
9507 )
9508 }
9509 );
9510 }
9511 );
9512
9513 // packages/ui/build-module/tooltip/popup.mjs
9514 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9515 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9516 function getRuntime5() {
9517 const globalScope = globalThis;
9518 if (globalScope.__wpStyleRuntime) {
9519 return globalScope.__wpStyleRuntime;
9520 }
9521 globalScope.__wpStyleRuntime = {
9522 documents: /* @__PURE__ */ new Map(),
9523 styles: /* @__PURE__ */ new Map(),
9524 injectedStyles: /* @__PURE__ */ new WeakMap()
9525 };
9526 if (typeof document !== "undefined") {
9527 registerDocument5(document);
9528 }
9529 return globalScope.__wpStyleRuntime;
9530 }
9531 function documentContainsStyleHash5(targetDocument, hash) {
9532 if (!targetDocument.head) {
9533 return false;
9534 }
9535 for (const style of targetDocument.head.querySelectorAll(
9536 `style[${STYLE_HASH_ATTRIBUTE5}]`
9537 )) {
9538 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9539 return true;
9540 }
9541 }
9542 return false;
9543 }
9544 function injectStyle5(targetDocument, hash, css) {
9545 if (!targetDocument.head) {
9546 return;
9547 }
9548 const runtime = getRuntime5();
9549 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9550 if (!injectedStyles) {
9551 injectedStyles = /* @__PURE__ */ new Set();
9552 runtime.injectedStyles.set(targetDocument, injectedStyles);
9553 }
9554 if (injectedStyles.has(hash)) {
9555 return;
9556 }
9557 if (documentContainsStyleHash5(targetDocument, hash)) {
9558 injectedStyles.add(hash);
9559 return;
9560 }
9561 const style = targetDocument.createElement("style");
9562 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9563 style.appendChild(targetDocument.createTextNode(css));
9564 targetDocument.head.appendChild(style);
9565 injectedStyles.add(hash);
9566 }
9567 function registerDocument5(targetDocument) {
9568 const runtime = getRuntime5();
9569 runtime.documents.set(
9570 targetDocument,
9571 (runtime.documents.get(targetDocument) ?? 0) + 1
9572 );
9573 for (const [hash, css] of runtime.styles) {
9574 injectStyle5(targetDocument, hash, css);
9575 }
9576 return () => {
9577 const count = runtime.documents.get(targetDocument);
9578 if (count === void 0) {
9579 return;
9580 }
9581 if (count <= 1) {
9582 runtime.documents.delete(targetDocument);
9583 return;
9584 }
9585 runtime.documents.set(targetDocument, count - 1);
9586 };
9587 }
9588 function registerStyle5(hash, css) {
9589 const runtime = getRuntime5();
9590 runtime.styles.set(hash, css);
9591 for (const targetDocument of runtime.documents.keys()) {
9592 injectStyle5(targetDocument, hash, css);
9593 }
9594 }
9595 if (typeof process === "undefined" || true) {
9596 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}}}}');
9597 }
9598 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9599 var POPUP_COLOR = { background: "#1e1e1e" };
9600 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9601 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
9602 index_parts_exports.Popup,
9603 {
9604 ref,
9605 className: clsx_default(style_default4.popup, className),
9606 ...props,
9607 children
9608 }
9609 ) });
9610 const positionedPopup = renderSlotWithChildren(
9611 positioner,
9612 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Positioner, {}),
9613 popupContent
9614 );
9615 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Portal, {}), positionedPopup);
9616 });
9617
9618 // packages/ui/build-module/tooltip/trigger.mjs
9619 var import_element17 = __toESM(require_element(), 1);
9620 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9621 var Trigger = (0, import_element17.forwardRef)(
9622 function TooltipTrigger3(props, ref) {
9623 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Trigger, { ref, ...props });
9624 }
9625 );
9626
9627 // packages/ui/build-module/tooltip/root.mjs
9628 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9629 function Root(props) {
9630 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Root, { ...props });
9631 }
9632
9633 // packages/ui/build-module/tooltip/provider.mjs
9634 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9635 function Provider({ ...props }) {
9636 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(index_parts_exports.Provider, { ...props });
9637 }
9638
9639 // packages/ui/build-module/empty-state/index.mjs
9640 var empty_state_exports = {};
9641 __export(empty_state_exports, {
9642 Actions: () => Actions,
9643 Description: () => Description,
9644 Icon: () => Icon3,
9645 Root: () => Root2,
9646 Title: () => Title,
9647 Visual: () => Visual
9648 });
9649
9650 // packages/ui/build-module/empty-state/root.mjs
9651 var import_element18 = __toESM(require_element(), 1);
9652 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9653 function getRuntime6() {
9654 const globalScope = globalThis;
9655 if (globalScope.__wpStyleRuntime) {
9656 return globalScope.__wpStyleRuntime;
9657 }
9658 globalScope.__wpStyleRuntime = {
9659 documents: /* @__PURE__ */ new Map(),
9660 styles: /* @__PURE__ */ new Map(),
9661 injectedStyles: /* @__PURE__ */ new WeakMap()
9662 };
9663 if (typeof document !== "undefined") {
9664 registerDocument6(document);
9665 }
9666 return globalScope.__wpStyleRuntime;
9667 }
9668 function documentContainsStyleHash6(targetDocument, hash) {
9669 if (!targetDocument.head) {
9670 return false;
9671 }
9672 for (const style of targetDocument.head.querySelectorAll(
9673 `style[${STYLE_HASH_ATTRIBUTE6}]`
9674 )) {
9675 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9676 return true;
9677 }
9678 }
9679 return false;
9680 }
9681 function injectStyle6(targetDocument, hash, css) {
9682 if (!targetDocument.head) {
9683 return;
9684 }
9685 const runtime = getRuntime6();
9686 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9687 if (!injectedStyles) {
9688 injectedStyles = /* @__PURE__ */ new Set();
9689 runtime.injectedStyles.set(targetDocument, injectedStyles);
9690 }
9691 if (injectedStyles.has(hash)) {
9692 return;
9693 }
9694 if (documentContainsStyleHash6(targetDocument, hash)) {
9695 injectedStyles.add(hash);
9696 return;
9697 }
9698 const style = targetDocument.createElement("style");
9699 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9700 style.appendChild(targetDocument.createTextNode(css));
9701 targetDocument.head.appendChild(style);
9702 injectedStyles.add(hash);
9703 }
9704 function registerDocument6(targetDocument) {
9705 const runtime = getRuntime6();
9706 runtime.documents.set(
9707 targetDocument,
9708 (runtime.documents.get(targetDocument) ?? 0) + 1
9709 );
9710 for (const [hash, css] of runtime.styles) {
9711 injectStyle6(targetDocument, hash, css);
9712 }
9713 return () => {
9714 const count = runtime.documents.get(targetDocument);
9715 if (count === void 0) {
9716 return;
9717 }
9718 if (count <= 1) {
9719 runtime.documents.delete(targetDocument);
9720 return;
9721 }
9722 runtime.documents.set(targetDocument, count - 1);
9723 };
9724 }
9725 function registerStyle6(hash, css) {
9726 const runtime = getRuntime6();
9727 runtime.styles.set(hash, css);
9728 for (const targetDocument of runtime.documents.keys()) {
9729 injectStyle6(targetDocument, hash, css);
9730 }
9731 }
9732 if (typeof process === "undefined" || true) {
9733 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}}}}');
9734 }
9735 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9736 var Root2 = (0, import_element18.forwardRef)(
9737 function EmptyStateRoot({ render: render4, ...props }, ref) {
9738 const className = clsx_default(style_default5.root);
9739 const element = useRender({
9740 defaultTagName: "div",
9741 render: render4,
9742 ref,
9743 props: mergeProps({ className }, props)
9744 });
9745 return element;
9746 }
9747 );
9748
9749 // packages/ui/build-module/empty-state/visual.mjs
9750 var import_element19 = __toESM(require_element(), 1);
9751 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9752 function getRuntime7() {
9753 const globalScope = globalThis;
9754 if (globalScope.__wpStyleRuntime) {
9755 return globalScope.__wpStyleRuntime;
9756 }
9757 globalScope.__wpStyleRuntime = {
9758 documents: /* @__PURE__ */ new Map(),
9759 styles: /* @__PURE__ */ new Map(),
9760 injectedStyles: /* @__PURE__ */ new WeakMap()
9761 };
9762 if (typeof document !== "undefined") {
9763 registerDocument7(document);
9764 }
9765 return globalScope.__wpStyleRuntime;
9766 }
9767 function documentContainsStyleHash7(targetDocument, hash) {
9768 if (!targetDocument.head) {
9769 return false;
9770 }
9771 for (const style of targetDocument.head.querySelectorAll(
9772 `style[${STYLE_HASH_ATTRIBUTE7}]`
9773 )) {
9774 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9775 return true;
9776 }
9777 }
9778 return false;
9779 }
9780 function injectStyle7(targetDocument, hash, css) {
9781 if (!targetDocument.head) {
9782 return;
9783 }
9784 const runtime = getRuntime7();
9785 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9786 if (!injectedStyles) {
9787 injectedStyles = /* @__PURE__ */ new Set();
9788 runtime.injectedStyles.set(targetDocument, injectedStyles);
9789 }
9790 if (injectedStyles.has(hash)) {
9791 return;
9792 }
9793 if (documentContainsStyleHash7(targetDocument, hash)) {
9794 injectedStyles.add(hash);
9795 return;
9796 }
9797 const style = targetDocument.createElement("style");
9798 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9799 style.appendChild(targetDocument.createTextNode(css));
9800 targetDocument.head.appendChild(style);
9801 injectedStyles.add(hash);
9802 }
9803 function registerDocument7(targetDocument) {
9804 const runtime = getRuntime7();
9805 runtime.documents.set(
9806 targetDocument,
9807 (runtime.documents.get(targetDocument) ?? 0) + 1
9808 );
9809 for (const [hash, css] of runtime.styles) {
9810 injectStyle7(targetDocument, hash, css);
9811 }
9812 return () => {
9813 const count = runtime.documents.get(targetDocument);
9814 if (count === void 0) {
9815 return;
9816 }
9817 if (count <= 1) {
9818 runtime.documents.delete(targetDocument);
9819 return;
9820 }
9821 runtime.documents.set(targetDocument, count - 1);
9822 };
9823 }
9824 function registerStyle7(hash, css) {
9825 const runtime = getRuntime7();
9826 runtime.styles.set(hash, css);
9827 for (const targetDocument of runtime.documents.keys()) {
9828 injectStyle7(targetDocument, hash, css);
9829 }
9830 }
9831 if (typeof process === "undefined" || true) {
9832 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}}}}');
9833 }
9834 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9835 var Visual = (0, import_element19.forwardRef)(
9836 function EmptyStateVisual({ render: render4, ...props }, ref) {
9837 const className = clsx_default(style_default6.visual);
9838 const element = useRender({
9839 defaultTagName: "div",
9840 render: render4,
9841 ref,
9842 props: mergeProps({ className }, props)
9843 });
9844 return element;
9845 }
9846 );
9847
9848 // packages/ui/build-module/empty-state/icon.mjs
9849 var import_element20 = __toESM(require_element(), 1);
9850 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9851 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9852 function getRuntime8() {
9853 const globalScope = globalThis;
9854 if (globalScope.__wpStyleRuntime) {
9855 return globalScope.__wpStyleRuntime;
9856 }
9857 globalScope.__wpStyleRuntime = {
9858 documents: /* @__PURE__ */ new Map(),
9859 styles: /* @__PURE__ */ new Map(),
9860 injectedStyles: /* @__PURE__ */ new WeakMap()
9861 };
9862 if (typeof document !== "undefined") {
9863 registerDocument8(document);
9864 }
9865 return globalScope.__wpStyleRuntime;
9866 }
9867 function documentContainsStyleHash8(targetDocument, hash) {
9868 if (!targetDocument.head) {
9869 return false;
9870 }
9871 for (const style of targetDocument.head.querySelectorAll(
9872 `style[${STYLE_HASH_ATTRIBUTE8}]`
9873 )) {
9874 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9875 return true;
9876 }
9877 }
9878 return false;
9879 }
9880 function injectStyle8(targetDocument, hash, css) {
9881 if (!targetDocument.head) {
9882 return;
9883 }
9884 const runtime = getRuntime8();
9885 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9886 if (!injectedStyles) {
9887 injectedStyles = /* @__PURE__ */ new Set();
9888 runtime.injectedStyles.set(targetDocument, injectedStyles);
9889 }
9890 if (injectedStyles.has(hash)) {
9891 return;
9892 }
9893 if (documentContainsStyleHash8(targetDocument, hash)) {
9894 injectedStyles.add(hash);
9895 return;
9896 }
9897 const style = targetDocument.createElement("style");
9898 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9899 style.appendChild(targetDocument.createTextNode(css));
9900 targetDocument.head.appendChild(style);
9901 injectedStyles.add(hash);
9902 }
9903 function registerDocument8(targetDocument) {
9904 const runtime = getRuntime8();
9905 runtime.documents.set(
9906 targetDocument,
9907 (runtime.documents.get(targetDocument) ?? 0) + 1
9908 );
9909 for (const [hash, css] of runtime.styles) {
9910 injectStyle8(targetDocument, hash, css);
9911 }
9912 return () => {
9913 const count = runtime.documents.get(targetDocument);
9914 if (count === void 0) {
9915 return;
9916 }
9917 if (count <= 1) {
9918 runtime.documents.delete(targetDocument);
9919 return;
9920 }
9921 runtime.documents.set(targetDocument, count - 1);
9922 };
9923 }
9924 function registerStyle8(hash, css) {
9925 const runtime = getRuntime8();
9926 runtime.styles.set(hash, css);
9927 for (const targetDocument of runtime.documents.keys()) {
9928 injectStyle8(targetDocument, hash, css);
9929 }
9930 }
9931 if (typeof process === "undefined" || true) {
9932 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}}}}');
9933 }
9934 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9935 var Icon3 = (0, import_element20.forwardRef)(
9936 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9937 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9938 Visual,
9939 {
9940 ref,
9941 className: clsx_default(style_default7.icon, className),
9942 ...restProps,
9943 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon })
9944 }
9945 );
9946 }
9947 );
9948
9949 // packages/ui/build-module/empty-state/title.mjs
9950 var import_element21 = __toESM(require_element(), 1);
9951 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9952 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9953 function getRuntime9() {
9954 const globalScope = globalThis;
9955 if (globalScope.__wpStyleRuntime) {
9956 return globalScope.__wpStyleRuntime;
9957 }
9958 globalScope.__wpStyleRuntime = {
9959 documents: /* @__PURE__ */ new Map(),
9960 styles: /* @__PURE__ */ new Map(),
9961 injectedStyles: /* @__PURE__ */ new WeakMap()
9962 };
9963 if (typeof document !== "undefined") {
9964 registerDocument9(document);
9965 }
9966 return globalScope.__wpStyleRuntime;
9967 }
9968 function documentContainsStyleHash9(targetDocument, hash) {
9969 if (!targetDocument.head) {
9970 return false;
9971 }
9972 for (const style of targetDocument.head.querySelectorAll(
9973 `style[${STYLE_HASH_ATTRIBUTE9}]`
9974 )) {
9975 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9976 return true;
9977 }
9978 }
9979 return false;
9980 }
9981 function injectStyle9(targetDocument, hash, css) {
9982 if (!targetDocument.head) {
9983 return;
9984 }
9985 const runtime = getRuntime9();
9986 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9987 if (!injectedStyles) {
9988 injectedStyles = /* @__PURE__ */ new Set();
9989 runtime.injectedStyles.set(targetDocument, injectedStyles);
9990 }
9991 if (injectedStyles.has(hash)) {
9992 return;
9993 }
9994 if (documentContainsStyleHash9(targetDocument, hash)) {
9995 injectedStyles.add(hash);
9996 return;
9997 }
9998 const style = targetDocument.createElement("style");
9999 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
10000 style.appendChild(targetDocument.createTextNode(css));
10001 targetDocument.head.appendChild(style);
10002 injectedStyles.add(hash);
10003 }
10004 function registerDocument9(targetDocument) {
10005 const runtime = getRuntime9();
10006 runtime.documents.set(
10007 targetDocument,
10008 (runtime.documents.get(targetDocument) ?? 0) + 1
10009 );
10010 for (const [hash, css] of runtime.styles) {
10011 injectStyle9(targetDocument, hash, css);
10012 }
10013 return () => {
10014 const count = runtime.documents.get(targetDocument);
10015 if (count === void 0) {
10016 return;
10017 }
10018 if (count <= 1) {
10019 runtime.documents.delete(targetDocument);
10020 return;
10021 }
10022 runtime.documents.set(targetDocument, count - 1);
10023 };
10024 }
10025 function registerStyle9(hash, css) {
10026 const runtime = getRuntime9();
10027 runtime.styles.set(hash, css);
10028 for (const targetDocument of runtime.documents.keys()) {
10029 injectStyle9(targetDocument, hash, css);
10030 }
10031 }
10032 if (typeof process === "undefined" || true) {
10033 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}}}}');
10034 }
10035 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10036 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", {});
10037 var Title = (0, import_element21.forwardRef)(
10038 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
10039 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10040 Text,
10041 {
10042 ref,
10043 variant: "heading-lg",
10044 render: render4,
10045 className: clsx_default(style_default8.title, className),
10046 ...props,
10047 children
10048 }
10049 );
10050 }
10051 );
10052
10053 // packages/ui/build-module/empty-state/description.mjs
10054 var import_element22 = __toESM(require_element(), 1);
10055 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10056 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
10057 function getRuntime10() {
10058 const globalScope = globalThis;
10059 if (globalScope.__wpStyleRuntime) {
10060 return globalScope.__wpStyleRuntime;
10061 }
10062 globalScope.__wpStyleRuntime = {
10063 documents: /* @__PURE__ */ new Map(),
10064 styles: /* @__PURE__ */ new Map(),
10065 injectedStyles: /* @__PURE__ */ new WeakMap()
10066 };
10067 if (typeof document !== "undefined") {
10068 registerDocument10(document);
10069 }
10070 return globalScope.__wpStyleRuntime;
10071 }
10072 function documentContainsStyleHash10(targetDocument, hash) {
10073 if (!targetDocument.head) {
10074 return false;
10075 }
10076 for (const style of targetDocument.head.querySelectorAll(
10077 `style[${STYLE_HASH_ATTRIBUTE10}]`
10078 )) {
10079 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
10080 return true;
10081 }
10082 }
10083 return false;
10084 }
10085 function injectStyle10(targetDocument, hash, css) {
10086 if (!targetDocument.head) {
10087 return;
10088 }
10089 const runtime = getRuntime10();
10090 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10091 if (!injectedStyles) {
10092 injectedStyles = /* @__PURE__ */ new Set();
10093 runtime.injectedStyles.set(targetDocument, injectedStyles);
10094 }
10095 if (injectedStyles.has(hash)) {
10096 return;
10097 }
10098 if (documentContainsStyleHash10(targetDocument, hash)) {
10099 injectedStyles.add(hash);
10100 return;
10101 }
10102 const style = targetDocument.createElement("style");
10103 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
10104 style.appendChild(targetDocument.createTextNode(css));
10105 targetDocument.head.appendChild(style);
10106 injectedStyles.add(hash);
10107 }
10108 function registerDocument10(targetDocument) {
10109 const runtime = getRuntime10();
10110 runtime.documents.set(
10111 targetDocument,
10112 (runtime.documents.get(targetDocument) ?? 0) + 1
10113 );
10114 for (const [hash, css] of runtime.styles) {
10115 injectStyle10(targetDocument, hash, css);
10116 }
10117 return () => {
10118 const count = runtime.documents.get(targetDocument);
10119 if (count === void 0) {
10120 return;
10121 }
10122 if (count <= 1) {
10123 runtime.documents.delete(targetDocument);
10124 return;
10125 }
10126 runtime.documents.set(targetDocument, count - 1);
10127 };
10128 }
10129 function registerStyle10(hash, css) {
10130 const runtime = getRuntime10();
10131 runtime.styles.set(hash, css);
10132 for (const targetDocument of runtime.documents.keys()) {
10133 injectStyle10(targetDocument, hash, css);
10134 }
10135 }
10136 if (typeof process === "undefined" || true) {
10137 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}}}}');
10138 }
10139 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10140 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", {});
10141 var Description = (0, import_element22.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10142 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10143 Text,
10144 {
10145 ref,
10146 variant: "body-md",
10147 render: render4,
10148 className: clsx_default(style_default9.description, className),
10149 ...props,
10150 children
10151 }
10152 );
10153 });
10154
10155 // packages/ui/build-module/empty-state/actions.mjs
10156 var import_element23 = __toESM(require_element(), 1);
10157 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10158 function getRuntime11() {
10159 const globalScope = globalThis;
10160 if (globalScope.__wpStyleRuntime) {
10161 return globalScope.__wpStyleRuntime;
10162 }
10163 globalScope.__wpStyleRuntime = {
10164 documents: /* @__PURE__ */ new Map(),
10165 styles: /* @__PURE__ */ new Map(),
10166 injectedStyles: /* @__PURE__ */ new WeakMap()
10167 };
10168 if (typeof document !== "undefined") {
10169 registerDocument11(document);
10170 }
10171 return globalScope.__wpStyleRuntime;
10172 }
10173 function documentContainsStyleHash11(targetDocument, hash) {
10174 if (!targetDocument.head) {
10175 return false;
10176 }
10177 for (const style of targetDocument.head.querySelectorAll(
10178 `style[${STYLE_HASH_ATTRIBUTE11}]`
10179 )) {
10180 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10181 return true;
10182 }
10183 }
10184 return false;
10185 }
10186 function injectStyle11(targetDocument, hash, css) {
10187 if (!targetDocument.head) {
10188 return;
10189 }
10190 const runtime = getRuntime11();
10191 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10192 if (!injectedStyles) {
10193 injectedStyles = /* @__PURE__ */ new Set();
10194 runtime.injectedStyles.set(targetDocument, injectedStyles);
10195 }
10196 if (injectedStyles.has(hash)) {
10197 return;
10198 }
10199 if (documentContainsStyleHash11(targetDocument, hash)) {
10200 injectedStyles.add(hash);
10201 return;
10202 }
10203 const style = targetDocument.createElement("style");
10204 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10205 style.appendChild(targetDocument.createTextNode(css));
10206 targetDocument.head.appendChild(style);
10207 injectedStyles.add(hash);
10208 }
10209 function registerDocument11(targetDocument) {
10210 const runtime = getRuntime11();
10211 runtime.documents.set(
10212 targetDocument,
10213 (runtime.documents.get(targetDocument) ?? 0) + 1
10214 );
10215 for (const [hash, css] of runtime.styles) {
10216 injectStyle11(targetDocument, hash, css);
10217 }
10218 return () => {
10219 const count = runtime.documents.get(targetDocument);
10220 if (count === void 0) {
10221 return;
10222 }
10223 if (count <= 1) {
10224 runtime.documents.delete(targetDocument);
10225 return;
10226 }
10227 runtime.documents.set(targetDocument, count - 1);
10228 };
10229 }
10230 function registerStyle11(hash, css) {
10231 const runtime = getRuntime11();
10232 runtime.styles.set(hash, css);
10233 for (const targetDocument of runtime.documents.keys()) {
10234 injectStyle11(targetDocument, hash, css);
10235 }
10236 }
10237 if (typeof process === "undefined" || true) {
10238 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}}}}');
10239 }
10240 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10241 var Actions = (0, import_element23.forwardRef)(
10242 function EmptyStateActions({ render: render4, ...props }, ref) {
10243 const className = clsx_default(style_default10.actions);
10244 const element = useRender({
10245 defaultTagName: "div",
10246 render: render4,
10247 ref,
10248 props: mergeProps({ className }, props)
10249 });
10250 return element;
10251 }
10252 );
10253
10254 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10255 var import_element24 = __toESM(require_element(), 1);
10256 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10257 function getRuntime12() {
10258 const globalScope = globalThis;
10259 if (globalScope.__wpStyleRuntime) {
10260 return globalScope.__wpStyleRuntime;
10261 }
10262 globalScope.__wpStyleRuntime = {
10263 documents: /* @__PURE__ */ new Map(),
10264 styles: /* @__PURE__ */ new Map(),
10265 injectedStyles: /* @__PURE__ */ new WeakMap()
10266 };
10267 if (typeof document !== "undefined") {
10268 registerDocument12(document);
10269 }
10270 return globalScope.__wpStyleRuntime;
10271 }
10272 function documentContainsStyleHash12(targetDocument, hash) {
10273 if (!targetDocument.head) {
10274 return false;
10275 }
10276 for (const style of targetDocument.head.querySelectorAll(
10277 `style[${STYLE_HASH_ATTRIBUTE12}]`
10278 )) {
10279 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10280 return true;
10281 }
10282 }
10283 return false;
10284 }
10285 function injectStyle12(targetDocument, hash, css) {
10286 if (!targetDocument.head) {
10287 return;
10288 }
10289 const runtime = getRuntime12();
10290 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10291 if (!injectedStyles) {
10292 injectedStyles = /* @__PURE__ */ new Set();
10293 runtime.injectedStyles.set(targetDocument, injectedStyles);
10294 }
10295 if (injectedStyles.has(hash)) {
10296 return;
10297 }
10298 if (documentContainsStyleHash12(targetDocument, hash)) {
10299 injectedStyles.add(hash);
10300 return;
10301 }
10302 const style = targetDocument.createElement("style");
10303 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10304 style.appendChild(targetDocument.createTextNode(css));
10305 targetDocument.head.appendChild(style);
10306 injectedStyles.add(hash);
10307 }
10308 function registerDocument12(targetDocument) {
10309 const runtime = getRuntime12();
10310 runtime.documents.set(
10311 targetDocument,
10312 (runtime.documents.get(targetDocument) ?? 0) + 1
10313 );
10314 for (const [hash, css] of runtime.styles) {
10315 injectStyle12(targetDocument, hash, css);
10316 }
10317 return () => {
10318 const count = runtime.documents.get(targetDocument);
10319 if (count === void 0) {
10320 return;
10321 }
10322 if (count <= 1) {
10323 runtime.documents.delete(targetDocument);
10324 return;
10325 }
10326 runtime.documents.set(targetDocument, count - 1);
10327 };
10328 }
10329 function registerStyle12(hash, css) {
10330 const runtime = getRuntime12();
10331 runtime.styles.set(hash, css);
10332 for (const targetDocument of runtime.documents.keys()) {
10333 injectStyle12(targetDocument, hash, css);
10334 }
10335 }
10336 if (typeof process === "undefined" || true) {
10337 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}}}");
10338 }
10339 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10340 var VisuallyHidden = (0, import_element24.forwardRef)(
10341 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10342 const element = useRender({
10343 render: render4,
10344 ref,
10345 props: mergeProps(
10346 { className: style_default11["visually-hidden"] },
10347 restProps,
10348 {
10349 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10350 "data-visually-hidden": ""
10351 }
10352 )
10353 });
10354 return element;
10355 }
10356 );
10357
10358 // packages/ui/build-module/link/link.mjs
10359 var import_element25 = __toESM(require_element(), 1);
10360 var import_i18n = __toESM(require_i18n(), 1);
10361 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10362 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10363 function getRuntime13() {
10364 const globalScope = globalThis;
10365 if (globalScope.__wpStyleRuntime) {
10366 return globalScope.__wpStyleRuntime;
10367 }
10368 globalScope.__wpStyleRuntime = {
10369 documents: /* @__PURE__ */ new Map(),
10370 styles: /* @__PURE__ */ new Map(),
10371 injectedStyles: /* @__PURE__ */ new WeakMap()
10372 };
10373 if (typeof document !== "undefined") {
10374 registerDocument13(document);
10375 }
10376 return globalScope.__wpStyleRuntime;
10377 }
10378 function documentContainsStyleHash13(targetDocument, hash) {
10379 if (!targetDocument.head) {
10380 return false;
10381 }
10382 for (const style of targetDocument.head.querySelectorAll(
10383 `style[${STYLE_HASH_ATTRIBUTE13}]`
10384 )) {
10385 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10386 return true;
10387 }
10388 }
10389 return false;
10390 }
10391 function injectStyle13(targetDocument, hash, css) {
10392 if (!targetDocument.head) {
10393 return;
10394 }
10395 const runtime = getRuntime13();
10396 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10397 if (!injectedStyles) {
10398 injectedStyles = /* @__PURE__ */ new Set();
10399 runtime.injectedStyles.set(targetDocument, injectedStyles);
10400 }
10401 if (injectedStyles.has(hash)) {
10402 return;
10403 }
10404 if (documentContainsStyleHash13(targetDocument, hash)) {
10405 injectedStyles.add(hash);
10406 return;
10407 }
10408 const style = targetDocument.createElement("style");
10409 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10410 style.appendChild(targetDocument.createTextNode(css));
10411 targetDocument.head.appendChild(style);
10412 injectedStyles.add(hash);
10413 }
10414 function registerDocument13(targetDocument) {
10415 const runtime = getRuntime13();
10416 runtime.documents.set(
10417 targetDocument,
10418 (runtime.documents.get(targetDocument) ?? 0) + 1
10419 );
10420 for (const [hash, css] of runtime.styles) {
10421 injectStyle13(targetDocument, hash, css);
10422 }
10423 return () => {
10424 const count = runtime.documents.get(targetDocument);
10425 if (count === void 0) {
10426 return;
10427 }
10428 if (count <= 1) {
10429 runtime.documents.delete(targetDocument);
10430 return;
10431 }
10432 runtime.documents.set(targetDocument, count - 1);
10433 };
10434 }
10435 function registerStyle13(hash, css) {
10436 const runtime = getRuntime13();
10437 runtime.styles.set(hash, css);
10438 for (const targetDocument of runtime.documents.keys()) {
10439 injectStyle13(targetDocument, hash, css);
10440 }
10441 }
10442 if (typeof process === "undefined" || true) {
10443 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10444 }
10445 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10446 if (typeof process === "undefined" || true) {
10447 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))}}}");
10448 }
10449 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" };
10450 if (typeof process === "undefined" || true) {
10451 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"}}}');
10452 }
10453 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" };
10454 if (typeof process === "undefined" || true) {
10455 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)}");
10456 }
10457 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" };
10458 var Link = (0, import_element25.forwardRef)(function Link2({
10459 children,
10460 variant = "default",
10461 tone = "brand",
10462 openInNewTab = false,
10463 render: render4,
10464 className,
10465 ...props
10466 }, ref) {
10467 const element = useRender({
10468 render: render4,
10469 defaultTagName: "a",
10470 ref,
10471 props: mergeProps(props, {
10472 className: clsx_default(
10473 global_css_defense_default2.a,
10474 resets_default2["box-sizing"],
10475 focus_default["outset-ring--focus"],
10476 variant !== "unstyled" && style_default12.link,
10477 variant !== "unstyled" && style_default12[`is-${tone}`],
10478 variant === "unstyled" && style_default12["is-unstyled"],
10479 className
10480 ),
10481 target: openInNewTab ? "_blank" : void 0,
10482 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10483 children,
10484 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10485 "span",
10486 {
10487 className: style_default12["link-icon"],
10488 role: "img",
10489 "aria-label": (
10490 /* translators: accessibility text appended to link text */
10491 (0, import_i18n.__)("(opens in a new tab)")
10492 )
10493 }
10494 )
10495 ] })
10496 })
10497 });
10498 return element;
10499 });
10500
10501 // packages/dataviews/build-module/dataviews/index.mjs
10502 var import_element82 = __toESM(require_element(), 1);
10503 var import_compose13 = __toESM(require_compose(), 1);
10504
10505 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10506 var import_element26 = __toESM(require_element(), 1);
10507
10508 // packages/dataviews/build-module/constants.mjs
10509 var import_i18n2 = __toESM(require_i18n(), 1);
10510 var OPERATOR_IS_ANY = "isAny";
10511 var OPERATOR_IS_NONE = "isNone";
10512 var OPERATOR_IS_ALL = "isAll";
10513 var OPERATOR_IS_NOT_ALL = "isNotAll";
10514 var OPERATOR_BETWEEN = "between";
10515 var OPERATOR_IN_THE_PAST = "inThePast";
10516 var OPERATOR_OVER = "over";
10517 var OPERATOR_IS = "is";
10518 var OPERATOR_IS_NOT = "isNot";
10519 var OPERATOR_LESS_THAN = "lessThan";
10520 var OPERATOR_GREATER_THAN = "greaterThan";
10521 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10522 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10523 var OPERATOR_BEFORE = "before";
10524 var OPERATOR_AFTER = "after";
10525 var OPERATOR_BEFORE_INC = "beforeInc";
10526 var OPERATOR_AFTER_INC = "afterInc";
10527 var OPERATOR_CONTAINS = "contains";
10528 var OPERATOR_NOT_CONTAINS = "notContains";
10529 var OPERATOR_STARTS_WITH = "startsWith";
10530 var OPERATOR_ON = "on";
10531 var OPERATOR_NOT_ON = "notOn";
10532 var SORTING_DIRECTIONS = ["asc", "desc"];
10533 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10534 var sortValues = { asc: "ascending", desc: "descending" };
10535 var sortLabels = {
10536 asc: (0, import_i18n2.__)("Sort ascending"),
10537 desc: (0, import_i18n2.__)("Sort descending")
10538 };
10539 var sortIcons = {
10540 asc: arrow_up_default,
10541 desc: arrow_down_default
10542 };
10543 var LAYOUT_TABLE = "table";
10544 var LAYOUT_GRID = "grid";
10545 var LAYOUT_LIST = "list";
10546 var LAYOUT_ACTIVITY = "activity";
10547 var LAYOUT_PICKER_GRID = "pickerGrid";
10548 var LAYOUT_PICKER_TABLE = "pickerTable";
10549 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10550
10551 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10552 var DataViewsContext = (0, import_element26.createContext)({
10553 view: { type: LAYOUT_TABLE },
10554 onChangeView: () => {
10555 },
10556 fields: [],
10557 data: [],
10558 paginationInfo: {
10559 totalItems: 0,
10560 totalPages: 0
10561 },
10562 selection: [],
10563 onChangeSelection: () => {
10564 },
10565 setOpenedFilter: () => {
10566 },
10567 openedFilter: null,
10568 getItemId: (item) => item.id,
10569 isItemClickable: () => true,
10570 renderItemLink: void 0,
10571 containerWidth: 0,
10572 containerRef: (0, import_element26.createRef)(),
10573 resizeObserverRef: () => {
10574 },
10575 defaultLayouts: { list: {}, grid: {}, table: {} },
10576 filters: [],
10577 isShowingFilter: false,
10578 setIsShowingFilter: () => {
10579 },
10580 hasInitiallyLoaded: false,
10581 config: {
10582 perPageSizes: []
10583 },
10584 intersectionObserver: null
10585 });
10586 DataViewsContext.displayName = "DataViewsContext";
10587 var dataviews_context_default = DataViewsContext;
10588
10589 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10590 var import_i18n23 = __toESM(require_i18n(), 1);
10591
10592 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10593 var import_i18n10 = __toESM(require_i18n(), 1);
10594 var import_components6 = __toESM(require_components(), 1);
10595 var import_element34 = __toESM(require_element(), 1);
10596 var import_keycodes = __toESM(require_keycodes(), 1);
10597
10598 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10599 var import_components = __toESM(require_components(), 1);
10600 var import_i18n3 = __toESM(require_i18n(), 1);
10601 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10602 function DataViewsSelectionCheckbox({
10603 selection,
10604 onChangeSelection,
10605 item,
10606 getItemId,
10607 titleField,
10608 disabled: disabled2,
10609 ...extraProps
10610 }) {
10611 const id = getItemId(item);
10612 const isInSelectionArray = selection.includes(id);
10613 const checked = !disabled2 && isInSelectionArray;
10614 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10615 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10616 import_components.CheckboxControl,
10617 {
10618 className: "dataviews-selection-checkbox",
10619 "aria-label": selectionLabel,
10620 "aria-disabled": disabled2,
10621 checked,
10622 onChange: () => {
10623 if (disabled2) {
10624 return;
10625 }
10626 onChangeSelection(
10627 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10628 );
10629 },
10630 ...extraProps
10631 }
10632 );
10633 }
10634
10635 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10636 var import_components2 = __toESM(require_components(), 1);
10637 var import_i18n4 = __toESM(require_i18n(), 1);
10638 var import_element27 = __toESM(require_element(), 1);
10639 var import_data = __toESM(require_data(), 1);
10640 var import_compose = __toESM(require_compose(), 1);
10641
10642 // packages/dataviews/build-module/lock-unlock.mjs
10643 var import_private_apis2 = __toESM(require_private_apis(), 1);
10644 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10645 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10646 "@wordpress/dataviews"
10647 );
10648
10649 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10650 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10651 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10652 function ButtonTrigger({
10653 action,
10654 onClick,
10655 items,
10656 variant
10657 }) {
10658 const label = typeof action.label === "string" ? action.label : action.label(items);
10659 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10660 import_components2.Button,
10661 {
10662 disabled: !!action.disabled,
10663 accessibleWhenDisabled: true,
10664 size: "compact",
10665 variant,
10666 onClick,
10667 children: label
10668 }
10669 );
10670 }
10671 function MenuItemTrigger({
10672 action,
10673 onClick,
10674 items
10675 }) {
10676 const label = typeof action.label === "string" ? action.label : action.label(items);
10677 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10678 }
10679 function ActionModal({
10680 action,
10681 items,
10682 closeModal
10683 }) {
10684 const label = typeof action.label === "string" ? action.label : action.label(items);
10685 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10686 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10687 import_components2.Modal,
10688 {
10689 title: modalHeader || label,
10690 __experimentalHideHeader: !!action.hideModalHeader,
10691 onRequestClose: closeModal,
10692 focusOnMount: action.modalFocusOnMount ?? true,
10693 size: action.modalSize || "medium",
10694 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10695 action.id
10696 )}`,
10697 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10698 }
10699 );
10700 }
10701 function ActionsMenuGroup({
10702 actions,
10703 item,
10704 registry,
10705 setActiveModalAction
10706 }) {
10707 const { primaryActions, regularActions } = (0, import_element27.useMemo)(() => {
10708 return actions.reduce(
10709 (acc, action) => {
10710 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10711 return acc;
10712 },
10713 {
10714 primaryActions: [],
10715 regularActions: []
10716 }
10717 );
10718 }, [actions]);
10719 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10720 MenuItemTrigger,
10721 {
10722 action,
10723 onClick: () => {
10724 if ("RenderModal" in action) {
10725 setActiveModalAction(action);
10726 return;
10727 }
10728 action.callback([item], { registry });
10729 },
10730 items: [item]
10731 },
10732 action.id
10733 ));
10734 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10735 renderActionGroup(primaryActions),
10736 renderActionGroup(regularActions)
10737 ] });
10738 }
10739 function ItemActions({
10740 item,
10741 actions,
10742 isCompact
10743 }) {
10744 const registry = (0, import_data.useRegistry)();
10745 const { primaryActions, eligibleActions } = (0, import_element27.useMemo)(() => {
10746 const _eligibleActions = actions.filter(
10747 (action) => !action.isEligible || action.isEligible(item)
10748 );
10749 const _primaryActions = _eligibleActions.filter(
10750 (action) => action.isPrimary
10751 );
10752 return {
10753 primaryActions: _primaryActions,
10754 eligibleActions: _eligibleActions
10755 };
10756 }, [actions, item]);
10757 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10758 if (isCompact) {
10759 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10760 CompactItemActions,
10761 {
10762 item,
10763 actions: eligibleActions,
10764 isSmall: true,
10765 registry
10766 }
10767 );
10768 }
10769 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10770 Stack,
10771 {
10772 direction: "row",
10773 justify: "flex-end",
10774 className: "dataviews-item-actions",
10775 style: {
10776 flexShrink: 0,
10777 width: "auto"
10778 },
10779 children: [
10780 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10781 PrimaryActions,
10782 {
10783 item,
10784 actions: primaryActions,
10785 registry
10786 }
10787 ),
10788 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10789 // there if there are any actions at all.
10790 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10791 CompactItemActions,
10792 {
10793 item,
10794 actions: eligibleActions,
10795 registry
10796 }
10797 )
10798 ]
10799 }
10800 );
10801 }
10802 function CompactItemActions({
10803 item,
10804 actions,
10805 isSmall,
10806 registry
10807 }) {
10808 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(
10809 null
10810 );
10811 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10812 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
10813 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10814 Menu.TriggerButton,
10815 {
10816 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10817 import_components2.Button,
10818 {
10819 size: isSmall ? "small" : "compact",
10820 icon: more_vertical_default,
10821 label: (0, import_i18n4.__)("Actions"),
10822 accessibleWhenDisabled: true,
10823 disabled: !actions.length,
10824 className: "dataviews-all-actions-button"
10825 }
10826 )
10827 }
10828 ),
10829 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10830 ActionsMenuGroup,
10831 {
10832 actions,
10833 item,
10834 registry,
10835 setActiveModalAction
10836 }
10837 ) })
10838 ] }),
10839 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10840 ActionModal,
10841 {
10842 action: activeModalAction,
10843 items: [item],
10844 closeModal: () => setActiveModalAction(null)
10845 }
10846 )
10847 ] });
10848 }
10849 function PrimaryActions({
10850 item,
10851 actions,
10852 registry,
10853 buttonVariant
10854 }) {
10855 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(null);
10856 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10857 if (isMobileViewport) {
10858 return null;
10859 }
10860 if (!Array.isArray(actions) || actions.length === 0) {
10861 return null;
10862 }
10863 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10864 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10865 ButtonTrigger,
10866 {
10867 action,
10868 onClick: () => {
10869 if ("RenderModal" in action) {
10870 setActiveModalAction(action);
10871 return;
10872 }
10873 action.callback([item], { registry });
10874 },
10875 items: [item],
10876 variant: buttonVariant
10877 },
10878 action.id
10879 )),
10880 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10881 ActionModal,
10882 {
10883 action: activeModalAction,
10884 items: [item],
10885 closeModal: () => setActiveModalAction(null)
10886 }
10887 )
10888 ] });
10889 }
10890
10891 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10892 var import_components3 = __toESM(require_components(), 1);
10893 var import_i18n6 = __toESM(require_i18n(), 1);
10894 var import_element28 = __toESM(require_element(), 1);
10895 var import_data2 = __toESM(require_data(), 1);
10896 var import_compose2 = __toESM(require_compose(), 1);
10897
10898 // packages/dataviews/build-module/utils/get-footer-message.mjs
10899 var import_i18n5 = __toESM(require_i18n(), 1);
10900 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10901 if (selectionCount > 0) {
10902 return (0, import_i18n5.sprintf)(
10903 /* translators: %d: number of items. */
10904 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10905 selectionCount
10906 );
10907 }
10908 if (onlyTotalCount || totalItems <= itemsCount) {
10909 return (0, import_i18n5.sprintf)(
10910 /* translators: %d: number of items. */
10911 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10912 totalItems
10913 );
10914 }
10915 return (0, import_i18n5.sprintf)(
10916 /* translators: %1$d: number of items. %2$d: total number of items. */
10917 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10918 itemsCount,
10919 totalItems
10920 );
10921 }
10922
10923 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10924 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
10925 function ActionWithModal({
10926 action,
10927 items,
10928 ActionTriggerComponent
10929 }) {
10930 const [isModalOpen, setIsModalOpen] = (0, import_element28.useState)(false);
10931 const actionTriggerProps = {
10932 action,
10933 onClick: () => {
10934 setIsModalOpen(true);
10935 },
10936 items
10937 };
10938 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
10939 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10940 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10941 ActionModal,
10942 {
10943 action,
10944 items,
10945 closeModal: () => setIsModalOpen(false)
10946 }
10947 )
10948 ] });
10949 }
10950 function useHasAPossibleBulkAction(actions, item) {
10951 return (0, import_element28.useMemo)(() => {
10952 return actions.some((action) => {
10953 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10954 });
10955 }, [actions, item]);
10956 }
10957 function useSomeItemHasAPossibleBulkAction(actions, data) {
10958 return (0, import_element28.useMemo)(() => {
10959 return data.some((item) => {
10960 return actions.some((action) => {
10961 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10962 });
10963 });
10964 }, [actions, data]);
10965 }
10966 function BulkSelectionCheckbox({
10967 selection,
10968 onChangeSelection,
10969 data,
10970 actions,
10971 getItemId,
10972 disableSelectAll = false
10973 }) {
10974 const selectableItems = (0, import_element28.useMemo)(() => {
10975 return data.filter((item) => {
10976 return actions.some(
10977 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10978 );
10979 });
10980 }, [data, actions]);
10981 const selectedItems = data.filter(
10982 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10983 );
10984 const hasSelection = selection.length > 0;
10985 const areAllSelected = selectedItems.length === selectableItems.length;
10986 if (disableSelectAll) {
10987 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10988 import_components3.CheckboxControl,
10989 {
10990 className: "dataviews-view-table-selection-checkbox",
10991 checked: hasSelection,
10992 disabled: !hasSelection,
10993 onChange: () => {
10994 onChangeSelection([]);
10995 },
10996 "aria-label": (0, import_i18n6.__)("Deselect all")
10997 }
10998 );
10999 }
11000 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11001 import_components3.CheckboxControl,
11002 {
11003 className: "dataviews-view-table-selection-checkbox",
11004 checked: areAllSelected,
11005 indeterminate: !areAllSelected && !!selectedItems.length,
11006 onChange: () => {
11007 if (areAllSelected) {
11008 onChangeSelection([]);
11009 } else {
11010 onChangeSelection(
11011 selectableItems.map((item) => getItemId(item))
11012 );
11013 }
11014 },
11015 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
11016 }
11017 );
11018 }
11019 function ActionTrigger({
11020 action,
11021 onClick,
11022 isBusy,
11023 items
11024 }) {
11025 const label = typeof action.label === "string" ? action.label : action.label(items);
11026 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11027 if (isMobile) {
11028 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11029 import_components3.Button,
11030 {
11031 disabled: isBusy,
11032 accessibleWhenDisabled: true,
11033 label,
11034 icon: action.icon,
11035 size: "compact",
11036 onClick,
11037 isBusy
11038 }
11039 );
11040 }
11041 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11042 import_components3.Button,
11043 {
11044 disabled: isBusy,
11045 accessibleWhenDisabled: true,
11046 size: "compact",
11047 onClick,
11048 isBusy,
11049 children: label
11050 }
11051 );
11052 }
11053 var EMPTY_ARRAY2 = [];
11054 function ActionButton({
11055 action,
11056 selectedItems,
11057 actionInProgress,
11058 setActionInProgress
11059 }) {
11060 const registry = (0, import_data2.useRegistry)();
11061 const selectedEligibleItems = (0, import_element28.useMemo)(() => {
11062 return selectedItems.filter((item) => {
11063 return !action.isEligible || action.isEligible(item);
11064 });
11065 }, [action, selectedItems]);
11066 if ("RenderModal" in action) {
11067 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11068 ActionWithModal,
11069 {
11070 action,
11071 items: selectedEligibleItems,
11072 ActionTriggerComponent: ActionTrigger
11073 },
11074 action.id
11075 );
11076 }
11077 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11078 ActionTrigger,
11079 {
11080 action,
11081 onClick: async () => {
11082 setActionInProgress(action.id);
11083 await action.callback(selectedItems, {
11084 registry
11085 });
11086 setActionInProgress(null);
11087 },
11088 items: selectedEligibleItems,
11089 isBusy: actionInProgress === action.id
11090 },
11091 action.id
11092 );
11093 }
11094 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
11095 const message2 = getFooterMessage(
11096 selection.length,
11097 data.length,
11098 paginationInfo.totalItems,
11099 isInfiniteScroll
11100 );
11101 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11102 Stack,
11103 {
11104 direction: "row",
11105 className: "dataviews-bulk-actions-footer__container",
11106 gap: "md",
11107 align: "center",
11108 children: [
11109 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11110 BulkSelectionCheckbox,
11111 {
11112 selection,
11113 onChangeSelection,
11114 data,
11115 actions,
11116 getItemId,
11117 disableSelectAll: isInfiniteScroll
11118 }
11119 ),
11120 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
11121 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11122 Stack,
11123 {
11124 direction: "row",
11125 className: "dataviews-bulk-actions-footer__action-buttons",
11126 gap: "xs",
11127 children: [
11128 actionsToShow.map((action) => {
11129 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11130 ActionButton,
11131 {
11132 action,
11133 selectedItems,
11134 actionInProgress,
11135 setActionInProgress
11136 },
11137 action.id
11138 );
11139 }),
11140 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11141 import_components3.Button,
11142 {
11143 icon: close_small_default,
11144 showTooltip: true,
11145 tooltipPosition: "top",
11146 size: "compact",
11147 label: (0, import_i18n6.__)("Cancel"),
11148 disabled: !!actionInProgress,
11149 accessibleWhenDisabled: false,
11150 onClick: () => {
11151 onChangeSelection(EMPTY_ARRAY2);
11152 }
11153 }
11154 )
11155 ]
11156 }
11157 )
11158 ]
11159 }
11160 );
11161 }
11162 function FooterContent({
11163 selection,
11164 actions,
11165 onChangeSelection,
11166 data,
11167 getItemId,
11168 isInfiniteScroll,
11169 paginationInfo
11170 }) {
11171 const [actionInProgress, setActionInProgress] = (0, import_element28.useState)(
11172 null
11173 );
11174 const footerContentRef = (0, import_element28.useRef)(void 0);
11175 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11176 const bulkActions = (0, import_element28.useMemo)(
11177 () => actions.filter((action) => action.supportsBulk),
11178 [actions]
11179 );
11180 const selectableItems = (0, import_element28.useMemo)(() => {
11181 return data.filter((item) => {
11182 return bulkActions.some(
11183 (action) => !action.isEligible || action.isEligible(item)
11184 );
11185 });
11186 }, [data, bulkActions]);
11187 const selectedItems = (0, import_element28.useMemo)(() => {
11188 return data.filter(
11189 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11190 );
11191 }, [selection, data, getItemId, selectableItems]);
11192 const actionsToShow = (0, import_element28.useMemo)(
11193 () => actions.filter((action) => {
11194 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11195 (item) => !action.isEligible || action.isEligible(item)
11196 );
11197 }),
11198 [actions, selectedItems, isMobile]
11199 );
11200 if (!actionInProgress) {
11201 if (footerContentRef.current) {
11202 footerContentRef.current = void 0;
11203 }
11204 return renderFooterContent(
11205 data,
11206 actions,
11207 getItemId,
11208 isInfiniteScroll,
11209 selection,
11210 actionsToShow,
11211 selectedItems,
11212 actionInProgress,
11213 setActionInProgress,
11214 onChangeSelection,
11215 paginationInfo
11216 );
11217 } else if (!footerContentRef.current) {
11218 footerContentRef.current = renderFooterContent(
11219 data,
11220 actions,
11221 getItemId,
11222 isInfiniteScroll,
11223 selection,
11224 actionsToShow,
11225 selectedItems,
11226 actionInProgress,
11227 setActionInProgress,
11228 onChangeSelection,
11229 paginationInfo
11230 );
11231 }
11232 return footerContentRef.current;
11233 }
11234 function BulkActionsFooter() {
11235 const {
11236 data,
11237 selection,
11238 actions = EMPTY_ARRAY2,
11239 onChangeSelection,
11240 getItemId,
11241 paginationInfo,
11242 view
11243 } = (0, import_element28.useContext)(dataviews_context_default);
11244 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11245 FooterContent,
11246 {
11247 selection,
11248 onChangeSelection,
11249 data,
11250 actions,
11251 getItemId,
11252 isInfiniteScroll: !!view.infiniteScrollEnabled,
11253 paginationInfo
11254 }
11255 );
11256 }
11257
11258 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11259 var import_i18n7 = __toESM(require_i18n(), 1);
11260 var import_components4 = __toESM(require_components(), 1);
11261 var import_element29 = __toESM(require_element(), 1);
11262
11263 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11264 function getHideableFields(view, fields) {
11265 const togglableFields = [
11266 view?.titleField,
11267 view?.mediaField,
11268 view?.descriptionField
11269 ].filter(Boolean);
11270 return fields.filter(
11271 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11272 );
11273 }
11274
11275 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11276 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11277 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11278 function WithMenuSeparators({ children }) {
11279 return import_element29.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element29.Fragment, { children: [
11280 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11281 child
11282 ] }, i2));
11283 }
11284 var _HeaderMenu = (0, import_element29.forwardRef)(function HeaderMenu({
11285 fieldId,
11286 view,
11287 fields,
11288 onChangeView,
11289 onHide,
11290 setOpenedFilter,
11291 canMove = true,
11292 canInsertLeft = true,
11293 canInsertRight = true
11294 }, ref) {
11295 const visibleFieldIds = view.fields ?? [];
11296 const index2 = visibleFieldIds?.indexOf(fieldId);
11297 const isSorted = view.sort?.field === fieldId;
11298 let isHidable = false;
11299 let isSortable = false;
11300 let canAddFilter = false;
11301 let operators = [];
11302 const field = fields.find((f2) => f2.id === fieldId);
11303 const { setIsShowingFilter } = (0, import_element29.useContext)(dataviews_context_default);
11304 if (!field) {
11305 return null;
11306 }
11307 isHidable = field.enableHiding !== false;
11308 isSortable = field.enableSorting !== false;
11309 const header = field.header;
11310 operators = !!field.filterBy && field.filterBy?.operators || [];
11311 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11312 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11313 return header;
11314 }
11315 const hiddenFields = getHideableFields(view, fields).filter(
11316 (f2) => !visibleFieldIds.includes(f2.id)
11317 );
11318 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11319 const isRtl = (0, import_i18n7.isRTL)();
11320 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11321 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11322 Menu2.TriggerButton,
11323 {
11324 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11325 import_components4.Button,
11326 {
11327 size: "compact",
11328 className: "dataviews-view-table-header-button",
11329 ref,
11330 variant: "tertiary"
11331 }
11332 ),
11333 children: [
11334 header,
11335 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11336 ]
11337 }
11338 ),
11339 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11340 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11341 (direction) => {
11342 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11343 const value = `${fieldId}-${direction}`;
11344 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11345 Menu2.RadioItem,
11346 {
11347 name: "view-table-sorting",
11348 value,
11349 checked: isChecked,
11350 onChange: () => {
11351 onChangeView({
11352 ...view,
11353 sort: {
11354 field: fieldId,
11355 direction
11356 },
11357 showLevels: false
11358 });
11359 },
11360 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11361 },
11362 value
11363 );
11364 }
11365 ) }),
11366 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11367 Menu2.Item,
11368 {
11369 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11370 onClick: () => {
11371 setOpenedFilter(fieldId);
11372 setIsShowingFilter(true);
11373 onChangeView({
11374 ...view,
11375 page: 1,
11376 filters: [
11377 ...view.filters || [],
11378 {
11379 field: fieldId,
11380 value: void 0,
11381 operator: operators[0]
11382 }
11383 ]
11384 });
11385 },
11386 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11387 }
11388 ) }),
11389 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11390 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11391 Menu2.Item,
11392 {
11393 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11394 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11395 onClick: () => {
11396 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11397 const newFields = [
11398 ...visibleFieldIds
11399 ];
11400 newFields.splice(index2, 1);
11401 newFields.splice(
11402 targetIndex,
11403 0,
11404 fieldId
11405 );
11406 onChangeView({
11407 ...view,
11408 fields: newFields
11409 });
11410 },
11411 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11412 }
11413 ),
11414 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11415 Menu2.Item,
11416 {
11417 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11418 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11419 onClick: () => {
11420 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11421 const newFields = [
11422 ...visibleFieldIds
11423 ];
11424 newFields.splice(index2, 1);
11425 newFields.splice(
11426 targetIndex,
11427 0,
11428 fieldId
11429 );
11430 onChangeView({
11431 ...view,
11432 fields: newFields
11433 });
11434 },
11435 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11436 }
11437 ),
11438 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11439 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11440 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11441 const insertIndex = isRtl ? index2 + 1 : index2;
11442 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11443 Menu2.Item,
11444 {
11445 onClick: () => {
11446 onChangeView({
11447 ...view,
11448 fields: [
11449 ...visibleFieldIds.slice(
11450 0,
11451 insertIndex
11452 ),
11453 hiddenField.id,
11454 ...visibleFieldIds.slice(
11455 insertIndex
11456 )
11457 ]
11458 });
11459 },
11460 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11461 },
11462 hiddenField.id
11463 );
11464 }) })
11465 ] }),
11466 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11467 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11468 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11469 const insertIndex = isRtl ? index2 : index2 + 1;
11470 return /* @__PURE__ */ (0, import_jsx_runtime51.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_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11489 },
11490 hiddenField.id
11491 );
11492 }) })
11493 ] }),
11494 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11495 Menu2.Item,
11496 {
11497 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11498 onClick: () => {
11499 onHide(field);
11500 onChangeView({
11501 ...view,
11502 fields: visibleFieldIds.filter(
11503 (id) => id !== fieldId
11504 )
11505 });
11506 },
11507 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11508 }
11509 )
11510 ] })
11511 ] }) })
11512 ] });
11513 });
11514 var ColumnHeaderMenu = _HeaderMenu;
11515 var column_header_menu_default = ColumnHeaderMenu;
11516
11517 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11518 var import_element30 = __toESM(require_element(), 1);
11519 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11520 function getClickableItemProps({
11521 item,
11522 isItemClickable,
11523 onClickItem,
11524 className
11525 }) {
11526 if (!isItemClickable(item) || !onClickItem) {
11527 return { className };
11528 }
11529 return {
11530 className: className ? `${className} ${className}--clickable` : void 0,
11531 role: "button",
11532 tabIndex: 0,
11533 onClick: (event) => {
11534 event.stopPropagation();
11535 onClickItem(item);
11536 },
11537 onKeyDown: (event) => {
11538 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11539 event.stopPropagation();
11540 onClickItem(item);
11541 }
11542 }
11543 };
11544 }
11545 function ItemClickWrapper({
11546 item,
11547 isItemClickable,
11548 onClickItem,
11549 renderItemLink,
11550 className,
11551 children,
11552 ...extraProps
11553 }) {
11554 if (!isItemClickable(item)) {
11555 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11556 }
11557 if (renderItemLink) {
11558 const renderedElement = renderItemLink({
11559 item,
11560 className: `${className} ${className}--clickable`,
11561 ...extraProps,
11562 children
11563 });
11564 return (0, import_element30.cloneElement)(renderedElement, {
11565 onClick: (event) => {
11566 event.stopPropagation();
11567 if (renderedElement.props.onClick) {
11568 renderedElement.props.onClick(event);
11569 }
11570 },
11571 onKeyDown: (event) => {
11572 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11573 event.stopPropagation();
11574 if (renderedElement.props.onKeyDown) {
11575 renderedElement.props.onKeyDown(event);
11576 }
11577 }
11578 }
11579 });
11580 }
11581 const clickProps = getClickableItemProps({
11582 item,
11583 isItemClickable,
11584 onClickItem,
11585 className
11586 });
11587 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11588 }
11589
11590 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11591 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11592 function ColumnPrimary({
11593 item,
11594 level,
11595 titleField,
11596 mediaField,
11597 descriptionField,
11598 onClickItem,
11599 renderItemLink,
11600 isItemClickable
11601 }) {
11602 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11603 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11604 ItemClickWrapper,
11605 {
11606 item,
11607 isItemClickable,
11608 onClickItem,
11609 renderItemLink,
11610 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11611 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11612 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11613 mediaField.render,
11614 {
11615 item,
11616 field: mediaField,
11617 config: { sizes: "32px" }
11618 }
11619 )
11620 }
11621 ),
11622 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11623 Stack,
11624 {
11625 direction: "column",
11626 align: "flex-start",
11627 className: "dataviews-view-table__primary-column-content",
11628 children: [
11629 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11630 ItemClickWrapper,
11631 {
11632 item,
11633 isItemClickable,
11634 onClickItem,
11635 renderItemLink,
11636 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11637 children: [
11638 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11639 Array(level).fill("\u2014").join(" "),
11640 "\xA0"
11641 ] }),
11642 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11643 ]
11644 }
11645 ),
11646 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11647 descriptionField.render,
11648 {
11649 item,
11650 field: descriptionField
11651 }
11652 )
11653 ]
11654 }
11655 )
11656 ] });
11657 }
11658 var column_primary_default = ColumnPrimary;
11659
11660 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11661 var import_element31 = __toESM(require_element(), 1);
11662 var import_i18n8 = __toESM(require_i18n(), 1);
11663 var isScrolledToEnd = (element) => {
11664 if ((0, import_i18n8.isRTL)()) {
11665 const scrollLeft = Math.abs(element.scrollLeft);
11666 return scrollLeft <= 1;
11667 }
11668 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11669 };
11670 function useScrollState({
11671 scrollContainerRef,
11672 enabledHorizontal = false
11673 }) {
11674 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element31.useState)(false);
11675 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element31.useState)(false);
11676 const handleScroll = (0, import_element31.useCallback)(() => {
11677 const scrollContainer = scrollContainerRef.current;
11678 if (!scrollContainer) {
11679 return;
11680 }
11681 if (enabledHorizontal) {
11682 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11683 }
11684 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11685 }, [scrollContainerRef, enabledHorizontal]);
11686 (0, import_element31.useEffect)(() => {
11687 if (typeof window === "undefined" || !scrollContainerRef.current) {
11688 return () => {
11689 };
11690 }
11691 const scrollContainer = scrollContainerRef.current;
11692 handleScroll();
11693 scrollContainer.addEventListener("scroll", handleScroll);
11694 window.addEventListener("resize", handleScroll);
11695 return () => {
11696 scrollContainer.removeEventListener("scroll", handleScroll);
11697 window.removeEventListener("resize", handleScroll);
11698 };
11699 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11700 return { isHorizontalScrollEnd, isVerticallyScrolled };
11701 }
11702
11703 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11704 function getDataByGroup(data, groupByField) {
11705 return data.reduce((groups, item) => {
11706 const groupName = groupByField.getValue({ item });
11707 if (!groups.has(groupName)) {
11708 groups.set(groupName, []);
11709 }
11710 groups.get(groupName)?.push(item);
11711 return groups;
11712 }, /* @__PURE__ */ new Map());
11713 }
11714
11715 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11716 var import_components5 = __toESM(require_components(), 1);
11717 var import_i18n9 = __toESM(require_i18n(), 1);
11718 var import_element32 = __toESM(require_element(), 1);
11719 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11720 function FieldItem({
11721 field,
11722 isVisible: isVisible2,
11723 onToggleVisibility
11724 }) {
11725 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11726 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.Icon, { icon: check_default }) }),
11727 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11728 ] }) });
11729 }
11730 function isDefined(item) {
11731 return !!item;
11732 }
11733 function PropertiesSection({
11734 showLabel = true
11735 }) {
11736 const { view, fields, onChangeView } = (0, import_element32.useContext)(dataviews_context_default);
11737 const regularFields = getHideableFields(view, fields);
11738 if (!regularFields?.length) {
11739 return null;
11740 }
11741 const titleField = fields.find((f2) => f2.id === view.titleField);
11742 const previewField = fields.find((f2) => f2.id === view.mediaField);
11743 const descriptionField = fields.find(
11744 (f2) => f2.id === view.descriptionField
11745 );
11746 const lockedFields = [
11747 {
11748 field: titleField,
11749 isVisibleFlag: "showTitle"
11750 },
11751 {
11752 field: previewField,
11753 isVisibleFlag: "showMedia"
11754 },
11755 {
11756 field: descriptionField,
11757 isVisibleFlag: "showDescription"
11758 }
11759 ].filter(({ field }) => isDefined(field));
11760 const visibleFieldIds = view.fields ?? [];
11761 const visibleRegularFieldsCount = regularFields.filter(
11762 (f2) => visibleFieldIds.includes(f2.id)
11763 ).length;
11764 const visibleLockedFields = lockedFields.filter(
11765 ({ isVisibleFlag }) => (
11766 // @ts-expect-error
11767 view[isVisibleFlag] ?? true
11768 )
11769 );
11770 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11771 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11772 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11773 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11774 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11775 Stack,
11776 {
11777 direction: "column",
11778 className: "dataviews-view-config__properties",
11779 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11780 lockedFields.map(({ field, isVisibleFlag }) => {
11781 const isVisible2 = view[isVisibleFlag] ?? true;
11782 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11783 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11784 FieldItem,
11785 {
11786 field: fieldToRender,
11787 isVisible: isVisible2,
11788 onToggleVisibility: () => {
11789 onChangeView({
11790 ...view,
11791 [isVisibleFlag]: !isVisible2
11792 });
11793 }
11794 },
11795 field.id
11796 );
11797 }),
11798 regularFields.map((field) => {
11799 const isVisible2 = visibleFieldIds.includes(field.id);
11800 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11801 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11802 FieldItem,
11803 {
11804 field: fieldToRender,
11805 isVisible: isVisible2,
11806 onToggleVisibility: () => {
11807 onChangeView({
11808 ...view,
11809 fields: isVisible2 ? visibleFieldIds.filter(
11810 (fieldId) => fieldId !== field.id
11811 ) : [...visibleFieldIds, field.id]
11812 });
11813 }
11814 },
11815 field.id
11816 );
11817 })
11818 ] })
11819 }
11820 )
11821 ] });
11822 }
11823
11824 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11825 var import_element33 = __toESM(require_element(), 1);
11826 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11827 const [showLoader, setShowLoader] = (0, import_element33.useState)(false);
11828 (0, import_element33.useEffect)(() => {
11829 if (!isLoading) {
11830 return;
11831 }
11832 const timeout = setTimeout(() => {
11833 setShowLoader(true);
11834 }, options.delay);
11835 return () => {
11836 clearTimeout(timeout);
11837 setShowLoader(false);
11838 };
11839 }, [isLoading, options.delay]);
11840 return showLoader;
11841 }
11842
11843 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11844 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11845 function getEffectiveAlign(explicitAlign, fieldType) {
11846 if (explicitAlign) {
11847 return explicitAlign;
11848 }
11849 if (fieldType === "integer" || fieldType === "number") {
11850 return "end";
11851 }
11852 return void 0;
11853 }
11854 function TableColumnField({
11855 item,
11856 fields,
11857 column,
11858 align
11859 }) {
11860 const field = fields.find((f2) => f2.id === column);
11861 if (!field) {
11862 return null;
11863 }
11864 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11865 "dataviews-view-table__cell-align-end": align === "end",
11866 "dataviews-view-table__cell-align-center": align === "center"
11867 });
11868 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11869 }
11870 function TableRow({
11871 hasBulkActions,
11872 item,
11873 level,
11874 actions,
11875 fields,
11876 id,
11877 view,
11878 titleField,
11879 mediaField,
11880 descriptionField,
11881 selection,
11882 getItemId,
11883 isItemClickable,
11884 onClickItem,
11885 renderItemLink,
11886 onChangeSelection,
11887 isActionsColumnSticky,
11888 posinset
11889 }) {
11890 const { paginationInfo } = (0, import_element34.useContext)(dataviews_context_default);
11891 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11892 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11893 const {
11894 showTitle = true,
11895 showMedia = true,
11896 showDescription = true,
11897 infiniteScrollEnabled
11898 } = view;
11899 const isTouchDeviceRef = (0, import_element34.useRef)(false);
11900 const columns = view.fields ?? [];
11901 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11902 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11903 "tr",
11904 {
11905 className: clsx_default("dataviews-view-table__row", {
11906 "is-selected": hasPossibleBulkAction && isSelected2,
11907 "has-bulk-actions": hasPossibleBulkAction
11908 }),
11909 onTouchStart: () => {
11910 isTouchDeviceRef.current = true;
11911 },
11912 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11913 "aria-posinset": posinset,
11914 role: infiniteScrollEnabled ? "article" : void 0,
11915 onMouseDown: (event) => {
11916 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11917 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11918 event?.preventDefault();
11919 }
11920 },
11921 onClick: (event) => {
11922 if (!hasPossibleBulkAction) {
11923 return;
11924 }
11925 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11926 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11927 onChangeSelection(
11928 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11929 );
11930 }
11931 },
11932 children: [
11933 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11934 DataViewsSelectionCheckbox,
11935 {
11936 item,
11937 selection,
11938 onChangeSelection,
11939 getItemId,
11940 titleField,
11941 disabled: !hasPossibleBulkAction
11942 }
11943 ) }) }),
11944 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11945 column_primary_default,
11946 {
11947 item,
11948 level,
11949 titleField: showTitle ? titleField : void 0,
11950 mediaField: showMedia ? mediaField : void 0,
11951 descriptionField: showDescription ? descriptionField : void 0,
11952 isItemClickable,
11953 onClickItem,
11954 renderItemLink
11955 }
11956 ) }),
11957 columns.map((column) => {
11958 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11959 const field = fields.find((f2) => f2.id === column);
11960 const effectiveAlign = getEffectiveAlign(align, field?.type);
11961 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11962 "td",
11963 {
11964 style: {
11965 width,
11966 maxWidth,
11967 minWidth
11968 },
11969 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11970 TableColumnField,
11971 {
11972 fields,
11973 item,
11974 column,
11975 align: effectiveAlign
11976 }
11977 )
11978 },
11979 column
11980 );
11981 }),
11982 !!actions?.length && // Disable reason: we are not making the element interactive,
11983 // but preventing any click events from bubbling up to the
11984 // table row. This allows us to add a click handler to the row
11985 // itself (to toggle row selection) without erroneously
11986 // intercepting click events from ItemActions.
11987 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11988 "td",
11989 {
11990 className: clsx_default("dataviews-view-table__actions-column", {
11991 "dataviews-view-table__actions-column--sticky": true,
11992 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11993 }),
11994 onClick: (e2) => e2.stopPropagation(),
11995 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
11996 }
11997 )
11998 ]
11999 }
12000 );
12001 }
12002 function ViewTable({
12003 actions,
12004 data,
12005 fields,
12006 getItemId,
12007 getItemLevel,
12008 isLoading = false,
12009 onChangeView,
12010 onChangeSelection,
12011 selection,
12012 setOpenedFilter,
12013 onClickItem,
12014 isItemClickable,
12015 renderItemLink,
12016 view,
12017 className,
12018 empty
12019 }) {
12020 const { containerRef } = (0, import_element34.useContext)(dataviews_context_default);
12021 const isDelayedLoading = useDelayedLoading(isLoading);
12022 const headerMenuRefs = (0, import_element34.useRef)(/* @__PURE__ */ new Map());
12023 const headerMenuToFocusRef = (0, import_element34.useRef)(void 0);
12024 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element34.useState)();
12025 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element34.useState)(null);
12026 (0, import_element34.useEffect)(() => {
12027 if (headerMenuToFocusRef.current) {
12028 headerMenuToFocusRef.current.focus();
12029 headerMenuToFocusRef.current = void 0;
12030 }
12031 });
12032 const tableNoticeId = (0, import_element34.useId)();
12033 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12034 scrollContainerRef: containerRef,
12035 enabledHorizontal: !!actions?.length
12036 });
12037 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12038 if (nextHeaderMenuToFocus) {
12039 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12040 setNextHeaderMenuToFocus(void 0);
12041 return;
12042 }
12043 const onHide = (field) => {
12044 const hidden = headerMenuRefs.current.get(field.id);
12045 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12046 setNextHeaderMenuToFocus(fallback?.node);
12047 };
12048 const handleHeaderContextMenu = (event) => {
12049 event.preventDefault();
12050 event.stopPropagation();
12051 const virtualAnchor = {
12052 getBoundingClientRect: () => ({
12053 x: event.clientX,
12054 y: event.clientY,
12055 top: event.clientY,
12056 left: event.clientX,
12057 right: event.clientX,
12058 bottom: event.clientY,
12059 width: 0,
12060 height: 0,
12061 toJSON: () => ({})
12062 })
12063 };
12064 window.requestAnimationFrame(() => {
12065 setContextMenuAnchor(virtualAnchor);
12066 });
12067 };
12068 const hasData = !!data?.length;
12069 const titleField = fields.find((field) => field.id === view.titleField);
12070 const mediaField = fields.find((field) => field.id === view.mediaField);
12071 const descriptionField = fields.find(
12072 (field) => field.id === view.descriptionField
12073 );
12074 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12075 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12076 const { showTitle = true, showMedia = true, showDescription = true } = view;
12077 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12078 const columns = view.fields ?? [];
12079 const headerMenuRef = (column, index2) => (node) => {
12080 if (node) {
12081 headerMenuRefs.current.set(column, {
12082 node,
12083 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12084 });
12085 } else {
12086 headerMenuRefs.current.delete(column);
12087 }
12088 };
12089 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12090 const isRtl = (0, import_i18n10.isRTL)();
12091 if (!hasData) {
12092 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12093 "div",
12094 {
12095 className: clsx_default("dataviews-no-results", {
12096 "is-refreshing": isDelayedLoading
12097 }),
12098 id: tableNoticeId,
12099 children: empty
12100 }
12101 );
12102 }
12103 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12104 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12105 "table",
12106 {
12107 className: clsx_default("dataviews-view-table", className, {
12108 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12109 view.layout.density
12110 ),
12111 "has-bulk-actions": hasBulkActions,
12112 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12113 }),
12114 "aria-busy": isLoading,
12115 "aria-describedby": tableNoticeId,
12116 role: isInfiniteScroll ? "feed" : void 0,
12117 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12118 children: [
12119 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12120 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12121 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12122 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12123 "col",
12124 {
12125 className: clsx_default(
12126 `dataviews-view-table__col-${column}`,
12127 {
12128 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12129 }
12130 )
12131 },
12132 `col-${column}`
12133 )),
12134 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12135 ] }),
12136 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12137 import_components6.Popover,
12138 {
12139 anchor: contextMenuAnchor,
12140 onClose: () => setContextMenuAnchor(null),
12141 placement: "bottom-start",
12142 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12143 }
12144 ),
12145 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12146 "thead",
12147 {
12148 className: clsx_default({
12149 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12150 }),
12151 onContextMenu: handleHeaderContextMenu,
12152 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12153 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12154 "th",
12155 {
12156 className: "dataviews-view-table__checkbox-column",
12157 scope: "col",
12158 onContextMenu: handleHeaderContextMenu,
12159 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12160 BulkSelectionCheckbox,
12161 {
12162 selection,
12163 onChangeSelection,
12164 data,
12165 actions,
12166 getItemId
12167 }
12168 )
12169 }
12170 ),
12171 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12172 column_header_menu_default,
12173 {
12174 ref: headerMenuRef(
12175 titleField.id,
12176 0
12177 ),
12178 fieldId: titleField.id,
12179 view,
12180 fields,
12181 onChangeView,
12182 onHide,
12183 setOpenedFilter,
12184 canMove: false,
12185 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12186 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12187 }
12188 ) }),
12189 columns.map((column, index2) => {
12190 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12191 const field = fields.find(
12192 (f2) => f2.id === column
12193 );
12194 const effectiveAlign = getEffectiveAlign(
12195 align,
12196 field?.type
12197 );
12198 const canInsertOrMove = view.layout?.enableMoving ?? true;
12199 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12200 "th",
12201 {
12202 style: {
12203 width,
12204 maxWidth,
12205 minWidth,
12206 textAlign: effectiveAlign
12207 },
12208 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12209 scope: "col",
12210 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12211 column_header_menu_default,
12212 {
12213 ref: headerMenuRef(column, index2),
12214 fieldId: column,
12215 view,
12216 fields,
12217 onChangeView,
12218 onHide,
12219 setOpenedFilter,
12220 canMove: canInsertOrMove,
12221 canInsertLeft: canInsertOrMove,
12222 canInsertRight: canInsertOrMove
12223 }
12224 )
12225 },
12226 column
12227 );
12228 }),
12229 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12230 "th",
12231 {
12232 className: clsx_default(
12233 "dataviews-view-table__actions-column",
12234 {
12235 "dataviews-view-table__actions-column--sticky": true,
12236 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12237 }
12238 ),
12239 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12240 }
12241 )
12242 ] })
12243 }
12244 ),
12245 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12246 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12247 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12248 "td",
12249 {
12250 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12251 className: "dataviews-view-table__group-header-cell",
12252 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12253 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12254 (0, import_i18n10.__)("%1$s: %2$s"),
12255 groupField.label,
12256 groupName
12257 )
12258 }
12259 ) }),
12260 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12261 TableRow,
12262 {
12263 item,
12264 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12265 hasBulkActions,
12266 actions,
12267 fields,
12268 id: getItemId(item) || index2.toString(),
12269 view,
12270 titleField,
12271 mediaField,
12272 descriptionField,
12273 selection,
12274 getItemId,
12275 onChangeSelection,
12276 onClickItem,
12277 renderItemLink,
12278 isItemClickable,
12279 isActionsColumnSticky: !isHorizontalScrollEnd
12280 },
12281 getItemId(item)
12282 ))
12283 ] }, `group-${groupName}`)
12284 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12285 TableRow,
12286 {
12287 item,
12288 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12289 hasBulkActions,
12290 actions,
12291 fields,
12292 id: getItemId(item) || index2.toString(),
12293 view,
12294 titleField,
12295 mediaField,
12296 descriptionField,
12297 selection,
12298 getItemId,
12299 onChangeSelection,
12300 onClickItem,
12301 renderItemLink,
12302 isItemClickable,
12303 isActionsColumnSticky: !isHorizontalScrollEnd,
12304 posinset: isInfiniteScroll ? index2 + 1 : void 0
12305 },
12306 getItemId(item)
12307 )) })
12308 ]
12309 }
12310 ),
12311 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components6.Spinner, {}) }) })
12312 ] });
12313 }
12314 var table_default = ViewTable;
12315
12316 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12317 var import_components9 = __toESM(require_components(), 1);
12318 var import_i18n13 = __toESM(require_i18n(), 1);
12319
12320 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12321 var import_components8 = __toESM(require_components(), 1);
12322 var import_i18n12 = __toESM(require_i18n(), 1);
12323 var import_compose3 = __toESM(require_compose(), 1);
12324 var import_keycodes2 = __toESM(require_keycodes(), 1);
12325 var import_element38 = __toESM(require_element(), 1);
12326
12327 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12328 var import_components7 = __toESM(require_components(), 1);
12329 var import_i18n11 = __toESM(require_i18n(), 1);
12330 var import_element35 = __toESM(require_element(), 1);
12331 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12332 var imageSizes = [
12333 {
12334 value: 120,
12335 breakpoint: 1
12336 },
12337 {
12338 value: 170,
12339 breakpoint: 1
12340 },
12341 {
12342 value: 230,
12343 breakpoint: 1
12344 },
12345 {
12346 value: 290,
12347 breakpoint: 1112
12348 // at minimum image width, 4 images display at this container size
12349 },
12350 {
12351 value: 350,
12352 breakpoint: 1636
12353 // at minimum image width, 6 images display at this container size
12354 },
12355 {
12356 value: 430,
12357 breakpoint: 588
12358 // at minimum image width, 2 images display at this container size
12359 }
12360 ];
12361 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12362 function useGridColumns() {
12363 const context = (0, import_element35.useContext)(dataviews_context_default);
12364 const view = context.view;
12365 return (0, import_element35.useMemo)(() => {
12366 const containerWidth = context.containerWidth;
12367 const gap = 32;
12368 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12369 const columns = Math.floor(
12370 (containerWidth + gap) / (previewSize + gap)
12371 );
12372 return Math.max(1, columns);
12373 }, [context.containerWidth, view.layout?.previewSize]);
12374 }
12375
12376 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12377 var import_element36 = __toESM(require_element(), 1);
12378 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12379 var GridItems = (0, import_element36.forwardRef)(({ className, previewSize, ...props }, ref) => {
12380 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12381 "div",
12382 {
12383 ref,
12384 className: clsx_default("dataviews-view-grid-items", className),
12385 style: {
12386 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12387 },
12388 ...props
12389 }
12390 );
12391 });
12392
12393 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12394 var import_element37 = __toESM(require_element(), 1);
12395 function useIntersectionObserver(elementRef, posinset) {
12396 const { intersectionObserver } = (0, import_element37.useContext)(dataviews_context_default);
12397 (0, import_element37.useEffect)(() => {
12398 const element = elementRef.current;
12399 if (!element || posinset === void 0 || !intersectionObserver) {
12400 return;
12401 }
12402 intersectionObserver.observe(element);
12403 return () => {
12404 intersectionObserver.unobserve(element);
12405 };
12406 }, [elementRef, intersectionObserver, posinset]);
12407 }
12408 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12409 const hasData = !!data?.length;
12410 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12411 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12412 }
12413
12414 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12415 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12416 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12417 function chunk(array, size4) {
12418 const chunks = [];
12419 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12420 chunks.push(array.slice(i2, i2 + size4));
12421 }
12422 return chunks;
12423 }
12424 var GridItem = (0, import_element38.forwardRef)(
12425 function GridItem2({
12426 view,
12427 selection,
12428 onChangeSelection,
12429 onClickItem,
12430 isItemClickable,
12431 renderItemLink,
12432 getItemId,
12433 item,
12434 actions,
12435 mediaField,
12436 titleField,
12437 descriptionField,
12438 regularFields,
12439 badgeFields,
12440 hasBulkActions,
12441 config,
12442 posinset,
12443 setsize,
12444 ...props
12445 }, forwardedRef) {
12446 const {
12447 showTitle = true,
12448 showMedia = true,
12449 showDescription = true
12450 } = view;
12451 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12452 const id = getItemId(item);
12453 const elementRef = (0, import_element38.useRef)(null);
12454 const setRefs = (0, import_element38.useCallback)(
12455 (node) => {
12456 elementRef.current = node;
12457 if (typeof forwardedRef === "function") {
12458 forwardedRef(node);
12459 } else if (forwardedRef) {
12460 forwardedRef.current = node;
12461 }
12462 },
12463 [forwardedRef]
12464 );
12465 useIntersectionObserver(elementRef, posinset);
12466 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12467 const isSelected2 = selection.includes(id);
12468 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12469 const rendersMediaField = showMedia && mediaField?.render;
12470 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12471 mediaField.render,
12472 {
12473 item,
12474 field: mediaField,
12475 config
12476 }
12477 ) : mediaPlaceholder;
12478 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12479 let mediaA11yProps;
12480 let titleA11yProps;
12481 if (isItemClickable(item) && onClickItem) {
12482 if (renderedTitleField) {
12483 mediaA11yProps = {
12484 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12485 };
12486 titleA11yProps = {
12487 id: `dataviews-view-grid__title-field-${instanceId}`
12488 };
12489 } else {
12490 mediaA11yProps = {
12491 "aria-label": (0, import_i18n12.__)("Navigate to item")
12492 };
12493 }
12494 }
12495 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12496 Stack,
12497 {
12498 direction: "column",
12499 ...props,
12500 ref: setRefs,
12501 "aria-setsize": setsize,
12502 "aria-posinset": posinset,
12503 className: clsx_default(
12504 props.className,
12505 "dataviews-view-grid__row__gridcell",
12506 "dataviews-view-grid__card",
12507 {
12508 "is-selected": hasBulkAction && isSelected2
12509 }
12510 ),
12511 onClickCapture: (event) => {
12512 props.onClickCapture?.(event);
12513 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12514 event.stopPropagation();
12515 event.preventDefault();
12516 if (!hasBulkAction) {
12517 return;
12518 }
12519 onChangeSelection(
12520 isSelected2 ? selection.filter(
12521 (itemId) => id !== itemId
12522 ) : [...selection, id]
12523 );
12524 }
12525 },
12526 children: [
12527 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12528 ItemClickWrapper,
12529 {
12530 item,
12531 isItemClickable,
12532 onClickItem,
12533 renderItemLink,
12534 className: clsx_default("dataviews-view-grid__media", {
12535 "dataviews-view-grid__media--placeholder": !rendersMediaField
12536 }),
12537 ...mediaA11yProps,
12538 children: renderedMediaField
12539 }
12540 ),
12541 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12542 DataViewsSelectionCheckbox,
12543 {
12544 item,
12545 selection,
12546 onChangeSelection,
12547 getItemId,
12548 titleField,
12549 disabled: !hasBulkAction
12550 }
12551 ),
12552 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12553 ItemActions,
12554 {
12555 item,
12556 actions,
12557 isCompact: true
12558 }
12559 ) }),
12560 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12561 ItemClickWrapper,
12562 {
12563 item,
12564 isItemClickable,
12565 onClickItem,
12566 renderItemLink,
12567 className: "dataviews-view-grid__title-field dataviews-title-field",
12568 ...titleA11yProps,
12569 title: titleField?.getValueFormatted({
12570 item,
12571 field: titleField
12572 }) || void 0,
12573 children: renderedTitleField
12574 }
12575 ) }),
12576 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12577 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12578 descriptionField.render,
12579 {
12580 item,
12581 field: descriptionField
12582 }
12583 ),
12584 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12585 Stack,
12586 {
12587 direction: "row",
12588 className: "dataviews-view-grid__badge-fields",
12589 gap: "sm",
12590 wrap: "wrap",
12591 align: "top",
12592 justify: "flex-start",
12593 children: badgeFields.map((field) => {
12594 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12595 WCBadge,
12596 {
12597 className: "dataviews-view-grid__field-value",
12598 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12599 field.render,
12600 {
12601 item,
12602 field
12603 }
12604 )
12605 },
12606 field.id
12607 );
12608 })
12609 }
12610 ),
12611 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12612 Stack,
12613 {
12614 direction: "column",
12615 className: "dataviews-view-grid__fields",
12616 gap: "xs",
12617 children: regularFields.map((field) => {
12618 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12619 import_components8.Flex,
12620 {
12621 className: "dataviews-view-grid__field",
12622 gap: 1,
12623 justify: "flex-start",
12624 expanded: true,
12625 style: { height: "auto" },
12626 direction: "row",
12627 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12628 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12629 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12630 tooltip_exports.Trigger,
12631 {
12632 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12633 }
12634 ),
12635 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12636 ] }),
12637 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12638 import_components8.FlexItem,
12639 {
12640 className: "dataviews-view-grid__field-value",
12641 style: { maxHeight: "none" },
12642 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12643 field.render,
12644 {
12645 item,
12646 field
12647 }
12648 )
12649 }
12650 )
12651 ] })
12652 },
12653 field.id
12654 );
12655 })
12656 }
12657 )
12658 ] })
12659 ]
12660 }
12661 );
12662 }
12663 );
12664 function CompositeGrid({
12665 data,
12666 isInfiniteScroll,
12667 className,
12668 inert,
12669 isLoading,
12670 view,
12671 fields,
12672 selection,
12673 onChangeSelection,
12674 onClickItem,
12675 isItemClickable,
12676 renderItemLink,
12677 getItemId,
12678 actions
12679 }) {
12680 const { paginationInfo, resizeObserverRef } = (0, import_element38.useContext)(dataviews_context_default);
12681 const gridColumns = useGridColumns();
12682 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12683 const titleField = fields.find(
12684 (field) => field.id === view?.titleField
12685 );
12686 const mediaField = fields.find(
12687 (field) => field.id === view?.mediaField
12688 );
12689 const descriptionField = fields.find(
12690 (field) => field.id === view?.descriptionField
12691 );
12692 const otherFields = view.fields ?? [];
12693 const { regularFields, badgeFields } = otherFields.reduce(
12694 (accumulator, fieldId) => {
12695 const field = fields.find((f2) => f2.id === fieldId);
12696 if (!field) {
12697 return accumulator;
12698 }
12699 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12700 accumulator[key].push(field);
12701 return accumulator;
12702 },
12703 { regularFields: [], badgeFields: [] }
12704 );
12705 const size4 = "900px";
12706 const totalRows = Math.ceil(data.length / gridColumns);
12707 const placeholdersNeeded = usePlaceholdersNeeded(
12708 data,
12709 isInfiniteScroll,
12710 gridColumns
12711 );
12712 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12713 // Render infinite scroll layout (no rows, feed semantics)
12714 children: [
12715 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12716 import_components8.Composite,
12717 {
12718 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12719 GridItems,
12720 {
12721 className: clsx_default(
12722 "dataviews-view-grid-infinite-scroll",
12723 className,
12724 {
12725 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12726 "compact",
12727 "comfortable"
12728 ].includes(view.layout.density)
12729 }
12730 ),
12731 previewSize: view.layout?.previewSize,
12732 "aria-busy": isLoading,
12733 ref: resizeObserverRef
12734 }
12735 ),
12736 role: "feed",
12737 focusWrap: true,
12738 inert,
12739 children: [
12740 Array.from({ length: placeholdersNeeded }).map(
12741 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12742 import_components8.Composite.Item,
12743 {
12744 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12745 Stack,
12746 {
12747 ...props,
12748 direction: "column",
12749 role: "article",
12750 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12751 }
12752 ),
12753 "aria-hidden": true,
12754 tabIndex: -1
12755 },
12756 `placeholder-${index2}`
12757 )
12758 ),
12759 data.map((item) => {
12760 const itemId = getItemId(item);
12761 const stablePosition = item.position;
12762 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12763 import_components8.Composite.Item,
12764 {
12765 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12766 GridItem,
12767 {
12768 ...props,
12769 id: itemId,
12770 role: "article",
12771 view,
12772 selection,
12773 onChangeSelection,
12774 onClickItem,
12775 isItemClickable,
12776 renderItemLink,
12777 getItemId,
12778 item,
12779 actions,
12780 mediaField,
12781 titleField,
12782 descriptionField,
12783 regularFields,
12784 badgeFields,
12785 hasBulkActions,
12786 posinset: stablePosition,
12787 setsize: paginationInfo.totalItems,
12788 config: {
12789 sizes: size4
12790 }
12791 }
12792 )
12793 },
12794 itemId
12795 );
12796 })
12797 ]
12798 }
12799 ),
12800 // Render standard grid layout (with rows, grid semantics)
12801 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12802 import_components8.Composite,
12803 {
12804 role: "grid",
12805 className: clsx_default("dataviews-view-grid", className, {
12806 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12807 view.layout.density
12808 )
12809 }),
12810 focusWrap: true,
12811 "aria-busy": isLoading,
12812 "aria-rowcount": totalRows,
12813 ref: resizeObserverRef,
12814 inert,
12815 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12816 import_components8.Composite.Row,
12817 {
12818 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12819 "div",
12820 {
12821 role: "row",
12822 "aria-rowindex": i2 + 1,
12823 "aria-label": (0, import_i18n12.sprintf)(
12824 /* translators: %d: The row number in the grid */
12825 (0, import_i18n12.__)("Row %d"),
12826 i2 + 1
12827 ),
12828 className: "dataviews-view-grid__row",
12829 style: {
12830 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12831 }
12832 }
12833 ),
12834 children: row.map((item) => {
12835 const itemId = getItemId(item);
12836 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12837 import_components8.Composite.Item,
12838 {
12839 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12840 GridItem,
12841 {
12842 ...props,
12843 id: itemId,
12844 role: "gridcell",
12845 view,
12846 selection,
12847 onChangeSelection,
12848 onClickItem,
12849 isItemClickable,
12850 renderItemLink,
12851 getItemId,
12852 item,
12853 actions,
12854 mediaField,
12855 titleField,
12856 descriptionField,
12857 regularFields,
12858 badgeFields,
12859 hasBulkActions,
12860 config: {
12861 sizes: size4
12862 }
12863 }
12864 )
12865 },
12866 itemId
12867 );
12868 })
12869 },
12870 i2
12871 ))
12872 }
12873 )
12874 ]
12875 });
12876 }
12877
12878 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12879 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12880 function ViewGrid({
12881 actions,
12882 data,
12883 fields,
12884 getItemId,
12885 isLoading,
12886 onChangeSelection,
12887 onClickItem,
12888 isItemClickable,
12889 renderItemLink,
12890 selection,
12891 view,
12892 className,
12893 empty
12894 }) {
12895 const isDelayedLoading = useDelayedLoading(!!isLoading);
12896 const hasData = !!data?.length;
12897 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12898 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12899 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12900 if (!hasData) {
12901 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12902 "div",
12903 {
12904 className: clsx_default("dataviews-no-results", {
12905 "is-refreshing": isDelayedLoading
12906 }),
12907 children: empty
12908 }
12909 );
12910 }
12911 const gridProps = {
12912 className: clsx_default(className, {
12913 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12914 }),
12915 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12916 isLoading,
12917 view,
12918 fields,
12919 selection,
12920 onChangeSelection,
12921 onClickItem,
12922 isItemClickable,
12923 renderItemLink,
12924 getItemId,
12925 actions
12926 };
12927 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
12928 // Render multiple groups.
12929 children: [
12930 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12931 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12932 Stack,
12933 {
12934 direction: "column",
12935 gap: "sm",
12936 children: [
12937 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12938 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12939 (0, import_i18n13.__)("%1$s: %2$s"),
12940 groupField.label,
12941 groupName
12942 ) }),
12943 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12944 CompositeGrid,
12945 {
12946 ...gridProps,
12947 data: groupItems,
12948 isInfiniteScroll: false
12949 }
12950 )
12951 ]
12952 },
12953 groupName
12954 )
12955 ) }),
12956 // Render a single grid with all data.
12957 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12958 CompositeGrid,
12959 {
12960 ...gridProps,
12961 data,
12962 isInfiniteScroll: !!isInfiniteScroll
12963 }
12964 ),
12965 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
12966 ]
12967 });
12968 }
12969 var grid_default = ViewGrid;
12970
12971 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12972 var import_compose4 = __toESM(require_compose(), 1);
12973 var import_components10 = __toESM(require_components(), 1);
12974 var import_element39 = __toESM(require_element(), 1);
12975 var import_i18n14 = __toESM(require_i18n(), 1);
12976 var import_data3 = __toESM(require_data(), 1);
12977 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
12978 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12979 function generateItemWrapperCompositeId(idPrefix) {
12980 return `${idPrefix}-item-wrapper`;
12981 }
12982 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12983 return `${idPrefix}-primary-action-${primaryActionId}`;
12984 }
12985 function generateDropdownTriggerCompositeId(idPrefix) {
12986 return `${idPrefix}-dropdown`;
12987 }
12988 function PrimaryActionGridCell({
12989 idPrefix,
12990 primaryAction,
12991 item
12992 }) {
12993 const registry = (0, import_data3.useRegistry)();
12994 const [isModalOpen, setIsModalOpen] = (0, import_element39.useState)(false);
12995 const compositeItemId = generatePrimaryActionCompositeId(
12996 idPrefix,
12997 primaryAction.id
12998 );
12999 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13000 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13001 import_components10.Composite.Item,
13002 {
13003 id: compositeItemId,
13004 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13005 import_components10.Button,
13006 {
13007 disabled: !!primaryAction.disabled,
13008 accessibleWhenDisabled: true,
13009 text: label,
13010 size: "small",
13011 onClick: () => setIsModalOpen(true)
13012 }
13013 ),
13014 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13015 ActionModal,
13016 {
13017 action: primaryAction,
13018 items: [item],
13019 closeModal: () => setIsModalOpen(false)
13020 }
13021 )
13022 }
13023 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13024 import_components10.Composite.Item,
13025 {
13026 id: compositeItemId,
13027 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13028 import_components10.Button,
13029 {
13030 disabled: !!primaryAction.disabled,
13031 accessibleWhenDisabled: true,
13032 size: "small",
13033 onClick: () => {
13034 primaryAction.callback([item], { registry });
13035 },
13036 children: label
13037 }
13038 )
13039 }
13040 ) }, primaryAction.id);
13041 }
13042 function ListItem({
13043 view,
13044 actions,
13045 idPrefix,
13046 isSelected: isSelected2,
13047 item,
13048 titleField,
13049 mediaField,
13050 descriptionField,
13051 onSelect,
13052 otherFields,
13053 onDropdownTriggerKeyDown,
13054 posinset
13055 }) {
13056 const {
13057 showTitle = true,
13058 showMedia = true,
13059 showDescription = true,
13060 infiniteScrollEnabled
13061 } = view;
13062 const itemRef = (0, import_element39.useRef)(null);
13063 const labelId = `${idPrefix}-label`;
13064 const descriptionId = `${idPrefix}-description`;
13065 const registry = (0, import_data3.useRegistry)();
13066 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
13067 const [activeModalAction, setActiveModalAction] = (0, import_element39.useState)(
13068 null
13069 );
13070 const handleHover = ({ type }) => {
13071 const isHover = type === "mouseenter";
13072 setIsHovered(isHover);
13073 };
13074 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
13075 (0, import_element39.useEffect)(() => {
13076 if (isSelected2) {
13077 itemRef.current?.scrollIntoView({
13078 behavior: "auto",
13079 block: "nearest",
13080 inline: "nearest"
13081 });
13082 }
13083 }, [isSelected2]);
13084 const { primaryAction, eligibleActions } = (0, import_element39.useMemo)(() => {
13085 const _eligibleActions = actions.filter(
13086 (action) => !action.isEligible || action.isEligible(item)
13087 );
13088 const _primaryActions = _eligibleActions.filter(
13089 (action) => action.isPrimary
13090 );
13091 return {
13092 primaryAction: _primaryActions[0],
13093 eligibleActions: _eligibleActions
13094 };
13095 }, [actions, item]);
13096 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13097 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13098 mediaField.render,
13099 {
13100 item,
13101 field: mediaField,
13102 config: { sizes: "52px" }
13103 }
13104 ) }) : null;
13105 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13106 const renderDescription = showDescription && descriptionField?.render;
13107 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13108 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13109 Stack,
13110 {
13111 direction: "row",
13112 gap: "md",
13113 className: "dataviews-view-list__item-actions",
13114 children: [
13115 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13116 PrimaryActionGridCell,
13117 {
13118 idPrefix,
13119 primaryAction,
13120 item
13121 }
13122 ),
13123 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13124 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13125 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13126 Menu3.TriggerButton,
13127 {
13128 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13129 import_components10.Composite.Item,
13130 {
13131 id: generateDropdownTriggerCompositeId(
13132 idPrefix
13133 ),
13134 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13135 import_components10.Button,
13136 {
13137 size: "small",
13138 icon: more_vertical_default,
13139 label: (0, import_i18n14.__)("Actions"),
13140 accessibleWhenDisabled: true,
13141 disabled: !actions.length,
13142 onKeyDown: onDropdownTriggerKeyDown
13143 }
13144 )
13145 }
13146 )
13147 }
13148 ),
13149 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13150 ActionsMenuGroup,
13151 {
13152 actions: eligibleActions,
13153 item,
13154 registry,
13155 setActiveModalAction
13156 }
13157 ) })
13158 ] }),
13159 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13160 ActionModal,
13161 {
13162 action: activeModalAction,
13163 items: [item],
13164 closeModal: () => setActiveModalAction(null)
13165 }
13166 )
13167 ] })
13168 ]
13169 }
13170 );
13171 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13172 import_components10.Composite.Row,
13173 {
13174 ref: itemRef,
13175 render: (
13176 /* aria-posinset breaks Composite.Row if passed to it directly. */
13177 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13178 "div",
13179 {
13180 "aria-posinset": posinset,
13181 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13182 }
13183 )
13184 ),
13185 role: infiniteScrollEnabled ? "article" : "row",
13186 className: clsx_default({
13187 "is-selected": isSelected2,
13188 "is-hovered": isHovered
13189 }),
13190 onMouseEnter: handleHover,
13191 onMouseLeave: handleHover,
13192 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13193 Stack,
13194 {
13195 direction: "row",
13196 className: "dataviews-view-list__item-wrapper",
13197 children: [
13198 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13199 import_components10.Composite.Item,
13200 {
13201 id: generateItemWrapperCompositeId(idPrefix),
13202 "aria-pressed": isSelected2,
13203 "aria-labelledby": labelId,
13204 "aria-describedby": descriptionId,
13205 className: "dataviews-view-list__item",
13206 onClick: () => onSelect(item)
13207 }
13208 ) }),
13209 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13210 Stack,
13211 {
13212 direction: "row",
13213 gap: "md",
13214 justify: "start",
13215 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13216 style: { flex: 1, minWidth: 0 },
13217 children: [
13218 renderedMediaField,
13219 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13220 Stack,
13221 {
13222 direction: "column",
13223 gap: "xs",
13224 className: "dataviews-view-list__field-wrapper",
13225 children: [
13226 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13227 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13228 "div",
13229 {
13230 className: "dataviews-title-field dataviews-view-list__title-field",
13231 id: labelId,
13232 children: renderedTitleField
13233 }
13234 ),
13235 usedActions
13236 ] }),
13237 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13238 descriptionField.render,
13239 {
13240 item,
13241 field: descriptionField
13242 }
13243 ) }),
13244 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13245 "div",
13246 {
13247 className: "dataviews-view-list__fields",
13248 id: descriptionId,
13249 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13250 "div",
13251 {
13252 className: "dataviews-view-list__field",
13253 children: [
13254 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13255 VisuallyHidden,
13256 {
13257 className: "dataviews-view-list__field-label",
13258 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13259 children: field.label
13260 }
13261 ),
13262 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13263 field.render,
13264 {
13265 item,
13266 field
13267 }
13268 ) })
13269 ]
13270 },
13271 field.id
13272 ))
13273 }
13274 )
13275 ]
13276 }
13277 )
13278 ]
13279 }
13280 )
13281 ]
13282 }
13283 )
13284 }
13285 );
13286 }
13287 function isDefined2(item) {
13288 return !!item;
13289 }
13290 function ViewList(props) {
13291 const {
13292 actions,
13293 data,
13294 fields,
13295 getItemId,
13296 isLoading,
13297 onChangeSelection,
13298 selection,
13299 view,
13300 className,
13301 empty
13302 } = props;
13303 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13304 const isDelayedLoading = useDelayedLoading(!!isLoading);
13305 const selectedItem = data?.findLast(
13306 (item) => selection.includes(getItemId(item))
13307 );
13308 const titleField = fields.find((field) => field.id === view.titleField);
13309 const mediaField = fields.find((field) => field.id === view.mediaField);
13310 const descriptionField = fields.find(
13311 (field) => field.id === view.descriptionField
13312 );
13313 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13314 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13315 const generateCompositeItemIdPrefix = (0, import_element39.useCallback)(
13316 (item) => `${baseId}-${getItemId(item)}`,
13317 [baseId, getItemId]
13318 );
13319 const isActiveCompositeItem = (0, import_element39.useCallback)(
13320 (item, idToCheck) => {
13321 return idToCheck.startsWith(
13322 generateCompositeItemIdPrefix(item)
13323 );
13324 },
13325 [generateCompositeItemIdPrefix]
13326 );
13327 const [activeCompositeId, setActiveCompositeId] = (0, import_element39.useState)(void 0);
13328 const compositeRef = (0, import_element39.useRef)(null);
13329 (0, import_element39.useEffect)(() => {
13330 if (selectedItem) {
13331 setActiveCompositeId(
13332 generateItemWrapperCompositeId(
13333 generateCompositeItemIdPrefix(selectedItem)
13334 )
13335 );
13336 }
13337 }, [selectedItem, generateCompositeItemIdPrefix]);
13338 const activeItemIndex = data.findIndex(
13339 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13340 );
13341 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13342 const isActiveIdInList = activeItemIndex !== -1;
13343 const selectCompositeItem = (0, import_element39.useCallback)(
13344 (targetIndex, generateCompositeId) => {
13345 const clampedIndex = Math.min(
13346 data.length - 1,
13347 Math.max(0, targetIndex)
13348 );
13349 if (!data[clampedIndex]) {
13350 return;
13351 }
13352 const itemIdPrefix = generateCompositeItemIdPrefix(
13353 data[clampedIndex]
13354 );
13355 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13356 setActiveCompositeId(targetCompositeItemId);
13357 if (compositeRef.current?.contains(
13358 compositeRef.current.ownerDocument.activeElement
13359 )) {
13360 document.getElementById(targetCompositeItemId)?.focus();
13361 }
13362 },
13363 [data, generateCompositeItemIdPrefix]
13364 );
13365 (0, import_element39.useEffect)(() => {
13366 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13367 if (!isActiveIdInList && wasActiveIdInList) {
13368 selectCompositeItem(
13369 previousActiveItemIndex,
13370 generateItemWrapperCompositeId
13371 );
13372 }
13373 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13374 const onDropdownTriggerKeyDown = (0, import_element39.useCallback)(
13375 (event) => {
13376 if (event.key === "ArrowDown") {
13377 event.preventDefault();
13378 selectCompositeItem(
13379 activeItemIndex + 1,
13380 generateDropdownTriggerCompositeId
13381 );
13382 }
13383 if (event.key === "ArrowUp") {
13384 event.preventDefault();
13385 selectCompositeItem(
13386 activeItemIndex - 1,
13387 generateDropdownTriggerCompositeId
13388 );
13389 }
13390 },
13391 [selectCompositeItem, activeItemIndex]
13392 );
13393 const hasData = !!data?.length;
13394 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13395 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13396 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13397 if (!hasData) {
13398 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13399 "div",
13400 {
13401 className: clsx_default("dataviews-no-results", {
13402 "is-refreshing": isDelayedLoading
13403 }),
13404 children: empty
13405 }
13406 );
13407 }
13408 if (hasData && groupField && dataByGroup) {
13409 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13410 import_components10.Composite,
13411 {
13412 ref: compositeRef,
13413 id: `${baseId}`,
13414 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13415 className: "dataviews-view-list__group",
13416 role: "grid",
13417 activeId: activeCompositeId,
13418 setActiveId: setActiveCompositeId,
13419 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13420 Stack,
13421 {
13422 direction: "column",
13423 gap: "lg",
13424 className: clsx_default("dataviews-view-list", className),
13425 children: Array.from(dataByGroup.entries()).map(
13426 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13427 Stack,
13428 {
13429 direction: "column",
13430 gap: "sm",
13431 children: [
13432 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13433 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13434 (0, import_i18n14.__)("%1$s: %2$s"),
13435 groupField.label,
13436 groupName
13437 ) }),
13438 groupItems.map((item) => {
13439 const id = generateCompositeItemIdPrefix(item);
13440 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13441 ListItem,
13442 {
13443 view,
13444 idPrefix: id,
13445 actions,
13446 item,
13447 isSelected: item === selectedItem,
13448 onSelect,
13449 mediaField,
13450 titleField,
13451 descriptionField,
13452 otherFields,
13453 onDropdownTriggerKeyDown
13454 },
13455 id
13456 );
13457 })
13458 ]
13459 },
13460 groupName
13461 )
13462 )
13463 }
13464 )
13465 }
13466 );
13467 }
13468 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13469 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13470 import_components10.Composite,
13471 {
13472 ref: compositeRef,
13473 id: baseId,
13474 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13475 className: clsx_default("dataviews-view-list", className, {
13476 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13477 view.layout.density
13478 ),
13479 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13480 }),
13481 role: view.infiniteScrollEnabled ? "feed" : "grid",
13482 activeId: activeCompositeId,
13483 setActiveId: setActiveCompositeId,
13484 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13485 children: data.map((item, index2) => {
13486 const id = generateCompositeItemIdPrefix(item);
13487 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13488 ListItem,
13489 {
13490 view,
13491 idPrefix: id,
13492 actions,
13493 item,
13494 isSelected: item === selectedItem,
13495 onSelect,
13496 mediaField,
13497 titleField,
13498 descriptionField,
13499 otherFields,
13500 onDropdownTriggerKeyDown,
13501 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13502 },
13503 id
13504 );
13505 })
13506 }
13507 ),
13508 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {}) })
13509 ] });
13510 }
13511
13512 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13513 var import_components11 = __toESM(require_components(), 1);
13514
13515 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13516 var import_i18n15 = __toESM(require_i18n(), 1);
13517 var import_element40 = __toESM(require_element(), 1);
13518 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13519 function ActivityGroup({
13520 groupName,
13521 groupData,
13522 groupField,
13523 showLabel = true,
13524 children
13525 }) {
13526 const groupHeader = showLabel ? (0, import_element40.createInterpolateElement)(
13527 // translators: %s: The label of the field e.g. "Status".
13528 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13529 {
13530 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13531 groupField.render,
13532 {
13533 item: groupData[0],
13534 field: groupField
13535 }
13536 )
13537 }
13538 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13539 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13540 Stack,
13541 {
13542 direction: "column",
13543 className: "dataviews-view-activity__group",
13544 children: [
13545 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13546 children
13547 ]
13548 },
13549 groupName
13550 );
13551 }
13552
13553 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13554 var import_element41 = __toESM(require_element(), 1);
13555 var import_data4 = __toESM(require_data(), 1);
13556 var import_compose5 = __toESM(require_compose(), 1);
13557 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13558 function ActivityItem(props) {
13559 const {
13560 view,
13561 actions,
13562 item,
13563 titleField,
13564 mediaField,
13565 descriptionField,
13566 otherFields,
13567 posinset,
13568 onClickItem,
13569 renderItemLink,
13570 isItemClickable
13571 } = props;
13572 const {
13573 showTitle = true,
13574 showMedia = true,
13575 showDescription = true,
13576 infiniteScrollEnabled
13577 } = view;
13578 const itemRef = (0, import_element41.useRef)(null);
13579 const registry = (0, import_data4.useRegistry)();
13580 const { paginationInfo } = (0, import_element41.useContext)(dataviews_context_default);
13581 const { primaryActions, eligibleActions } = (0, import_element41.useMemo)(() => {
13582 const _eligibleActions = actions.filter(
13583 (action) => !action.isEligible || action.isEligible(item)
13584 );
13585 const _primaryActions = _eligibleActions.filter(
13586 (action) => action.isPrimary
13587 );
13588 return {
13589 primaryActions: _primaryActions,
13590 eligibleActions: _eligibleActions
13591 };
13592 }, [actions, item]);
13593 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13594 const density = view.layout?.density ?? "balanced";
13595 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13596 mediaField.render,
13597 {
13598 item,
13599 field: mediaField,
13600 config: {
13601 sizes: density === "comfortable" ? "32px" : "24px"
13602 }
13603 }
13604 ) : null;
13605 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13606 "span",
13607 {
13608 className: "dataviews-view-activity__item-bullet",
13609 "aria-hidden": "true"
13610 }
13611 ) });
13612 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13613 const verticalGap = (0, import_element41.useMemo)(() => {
13614 switch (density) {
13615 case "comfortable":
13616 return "md";
13617 default:
13618 return "sm";
13619 }
13620 }, [density]);
13621 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13622 "div",
13623 {
13624 ref: itemRef,
13625 role: infiniteScrollEnabled ? "article" : void 0,
13626 "aria-posinset": posinset,
13627 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13628 className: clsx_default(
13629 "dataviews-view-activity__item",
13630 density === "compact" && "is-compact",
13631 density === "balanced" && "is-balanced",
13632 density === "comfortable" && "is-comfortable"
13633 ),
13634 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13635 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13636 Stack,
13637 {
13638 direction: "column",
13639 gap: "xs",
13640 align: "center",
13641 className: "dataviews-view-activity__item-type",
13642 children: renderedMediaField
13643 }
13644 ),
13645 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13646 Stack,
13647 {
13648 direction: "column",
13649 gap: verticalGap,
13650 align: "flex-start",
13651 className: "dataviews-view-activity__item-content",
13652 children: [
13653 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13654 ItemClickWrapper,
13655 {
13656 item,
13657 isItemClickable,
13658 onClickItem,
13659 renderItemLink,
13660 className: "dataviews-view-activity__item-title",
13661 children: renderedTitleField
13662 }
13663 ),
13664 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13665 descriptionField.render,
13666 {
13667 item,
13668 field: descriptionField
13669 }
13670 ) }),
13671 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13672 "div",
13673 {
13674 className: "dataviews-view-activity__item-field",
13675 children: [
13676 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13677 VisuallyHidden,
13678 {
13679 className: "dataviews-view-activity__item-field-label",
13680 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13681 children: field.label
13682 }
13683 ),
13684 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13685 field.render,
13686 {
13687 item,
13688 field
13689 }
13690 ) })
13691 ]
13692 },
13693 field.id
13694 )) }),
13695 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13696 PrimaryActions,
13697 {
13698 item,
13699 actions: primaryActions,
13700 registry,
13701 buttonVariant: "secondary"
13702 }
13703 )
13704 ]
13705 }
13706 ),
13707 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13708 // there if there are any actions at all.
13709 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13710 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13711 ItemActions,
13712 {
13713 item,
13714 actions: eligibleActions,
13715 isCompact: true
13716 }
13717 ) })
13718 ] })
13719 }
13720 );
13721 }
13722 var activity_item_default = ActivityItem;
13723
13724 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13725 var import_react10 = __toESM(require_react(), 1);
13726 function isDefined3(item) {
13727 return !!item;
13728 }
13729 function ActivityItems(props) {
13730 const { data, fields, getItemId, view } = props;
13731 const titleField = fields.find((field) => field.id === view.titleField);
13732 const mediaField = fields.find((field) => field.id === view.mediaField);
13733 const descriptionField = fields.find(
13734 (field) => field.id === view.descriptionField
13735 );
13736 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13737 return data.map((item, index2) => {
13738 return /* @__PURE__ */ (0, import_react10.createElement)(
13739 activity_item_default,
13740 {
13741 ...props,
13742 key: getItemId(item),
13743 item,
13744 mediaField,
13745 titleField,
13746 descriptionField,
13747 otherFields,
13748 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13749 }
13750 );
13751 });
13752 }
13753
13754 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13755 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13756 function ViewActivity(props) {
13757 const { empty, data, fields, isLoading, view, className } = props;
13758 const isDelayedLoading = useDelayedLoading(!!isLoading);
13759 const hasData = !!data?.length;
13760 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13761 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13762 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13763 if (!hasData) {
13764 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13765 "div",
13766 {
13767 className: clsx_default("dataviews-no-results", {
13768 "is-refreshing": isDelayedLoading
13769 }),
13770 children: empty
13771 }
13772 );
13773 }
13774 const isInert = !isInfiniteScroll && !!isLoading;
13775 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13776 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13777 });
13778 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13779 if (hasData && groupField && dataByGroup) {
13780 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13781 Stack,
13782 {
13783 direction: "column",
13784 gap: "sm",
13785 className: wrapperClassName,
13786 inert: isInert ? "true" : void 0,
13787 children: groupedEntries.map(
13788 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13789 ActivityGroup,
13790 {
13791 groupName,
13792 groupData,
13793 groupField,
13794 showLabel: view.groupBy?.showLabel !== false,
13795 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13796 ActivityItems,
13797 {
13798 ...props,
13799 data: groupData
13800 }
13801 )
13802 },
13803 groupName
13804 )
13805 )
13806 }
13807 );
13808 }
13809 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13810 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13811 "div",
13812 {
13813 className: wrapperClassName,
13814 role: view.infiniteScrollEnabled ? "feed" : void 0,
13815 inert: isInert ? "true" : void 0,
13816 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13817 }
13818 ),
13819 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13820 ] });
13821 }
13822
13823 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13824 var import_components14 = __toESM(require_components(), 1);
13825 var import_i18n18 = __toESM(require_i18n(), 1);
13826 var import_compose6 = __toESM(require_compose(), 1);
13827 var import_element44 = __toESM(require_element(), 1);
13828
13829 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13830 var import_components13 = __toESM(require_components(), 1);
13831 var import_data5 = __toESM(require_data(), 1);
13832 var import_element43 = __toESM(require_element(), 1);
13833 var import_i18n17 = __toESM(require_i18n(), 1);
13834
13835 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13836 var import_components12 = __toESM(require_components(), 1);
13837 var import_element42 = __toESM(require_element(), 1);
13838 var import_i18n16 = __toESM(require_i18n(), 1);
13839 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13840 function DataViewsPagination() {
13841 const {
13842 view,
13843 onChangeView,
13844 paginationInfo: { totalItems = 0, totalPages }
13845 } = (0, import_element42.useContext)(dataviews_context_default);
13846 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13847 return null;
13848 }
13849 const currentPage = view.page ?? 1;
13850 const pageSelectOptions = Array.from(Array(totalPages)).map(
13851 (_, i2) => {
13852 const page = i2 + 1;
13853 return {
13854 value: page.toString(),
13855 label: page.toString(),
13856 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13857 // translators: 1: current page number. 2: total number of pages.
13858 (0, import_i18n16.__)("Page %1$d of %2$d"),
13859 currentPage,
13860 totalPages
13861 ) : page.toString()
13862 };
13863 }
13864 );
13865 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13866 Stack,
13867 {
13868 direction: "row",
13869 className: "dataviews-pagination",
13870 justify: "end",
13871 align: "center",
13872 gap: "xl",
13873 children: [
13874 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13875 Stack,
13876 {
13877 direction: "row",
13878 justify: "flex-start",
13879 align: "center",
13880 gap: "xs",
13881 className: "dataviews-pagination__page-select",
13882 children: (0, import_element42.createInterpolateElement)(
13883 (0, import_i18n16.sprintf)(
13884 // translators: 1: Current page number, 2: Total number of pages.
13885 (0, import_i18n16._x)(
13886 "<div>Page</div>%1$s<div>of %2$d</div>",
13887 "paging"
13888 ),
13889 "<CurrentPage />",
13890 totalPages
13891 ),
13892 {
13893 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13894 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13895 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13896 import_components12.SelectControl,
13897 {
13898 "aria-label": (0, import_i18n16.__)("Current page"),
13899 value: currentPage.toString(),
13900 options: pageSelectOptions,
13901 onChange: (newValue) => {
13902 onChangeView({
13903 ...view,
13904 page: +newValue
13905 });
13906 },
13907 size: "small",
13908 variant: "minimal"
13909 }
13910 )
13911 }
13912 )
13913 }
13914 ),
13915 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13916 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13917 import_components12.Button,
13918 {
13919 onClick: () => onChangeView({
13920 ...view,
13921 page: currentPage - 1
13922 }),
13923 disabled: currentPage === 1,
13924 accessibleWhenDisabled: true,
13925 label: (0, import_i18n16.__)("Previous page"),
13926 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13927 showTooltip: true,
13928 size: "compact",
13929 tooltipPosition: "top"
13930 }
13931 ),
13932 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13933 import_components12.Button,
13934 {
13935 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13936 disabled: currentPage >= totalPages,
13937 accessibleWhenDisabled: true,
13938 label: (0, import_i18n16.__)("Next page"),
13939 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13940 showTooltip: true,
13941 size: "compact",
13942 tooltipPosition: "top"
13943 }
13944 )
13945 ] })
13946 ]
13947 }
13948 );
13949 }
13950 var dataviews_pagination_default = (0, import_element42.memo)(DataViewsPagination);
13951
13952 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13953 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13954 function useIsMultiselectPicker(actions) {
13955 return (0, import_element43.useMemo)(() => {
13956 return !!actions?.length && actions?.every((action) => action.supportsBulk);
13957 }, [actions]);
13958 }
13959
13960 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13961 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13962 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13963 function GridItem3({
13964 view,
13965 multiselect,
13966 selection,
13967 onChangeSelection,
13968 getItemId,
13969 item,
13970 mediaField,
13971 titleField,
13972 descriptionField,
13973 regularFields,
13974 badgeFields,
13975 config,
13976 posinset,
13977 setsize
13978 }) {
13979 const { showTitle = true, showMedia = true, showDescription = true } = view;
13980 const id = getItemId(item);
13981 const elementRef = (0, import_element44.useRef)(null);
13982 const isSelected2 = selection.includes(id);
13983 useIntersectionObserver(elementRef, posinset);
13984 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13985 mediaField.render,
13986 {
13987 item,
13988 field: mediaField,
13989 config
13990 }
13991 ) : null;
13992 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
13993 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13994 import_components14.Composite.Item,
13995 {
13996 ref: elementRef,
13997 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13998 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
13999 role: "option",
14000 "aria-posinset": posinset,
14001 "aria-setsize": setsize,
14002 className: clsx_default("dataviews-view-picker-grid__card", {
14003 "is-selected": isSelected2
14004 }),
14005 "aria-selected": isSelected2,
14006 onClick: () => {
14007 if (isSelected2) {
14008 onChangeSelection(
14009 selection.filter((itemId) => id !== itemId)
14010 );
14011 } else {
14012 const newSelection = multiselect ? [...selection, id] : [id];
14013 onChangeSelection(newSelection);
14014 }
14015 },
14016 children: [
14017 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14018 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14019 DataViewsSelectionCheckbox,
14020 {
14021 item,
14022 selection,
14023 onChangeSelection,
14024 getItemId,
14025 titleField,
14026 disabled: false,
14027 "aria-hidden": true,
14028 tabIndex: -1
14029 }
14030 ),
14031 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14032 Stack,
14033 {
14034 direction: "row",
14035 justify: "space-between",
14036 className: "dataviews-view-picker-grid__title-actions",
14037 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14038 }
14039 ),
14040 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14041 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14042 descriptionField.render,
14043 {
14044 item,
14045 field: descriptionField
14046 }
14047 ),
14048 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14049 Stack,
14050 {
14051 direction: "row",
14052 className: "dataviews-view-picker-grid__badge-fields",
14053 gap: "sm",
14054 wrap: "wrap",
14055 align: "top",
14056 justify: "flex-start",
14057 children: badgeFields.map((field) => {
14058 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14059 WCBadge2,
14060 {
14061 className: "dataviews-view-picker-grid__field-value",
14062 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14063 field.render,
14064 {
14065 item,
14066 field
14067 }
14068 )
14069 },
14070 field.id
14071 );
14072 })
14073 }
14074 ),
14075 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14076 Stack,
14077 {
14078 direction: "column",
14079 className: "dataviews-view-picker-grid__fields",
14080 gap: "xs",
14081 children: regularFields.map((field) => {
14082 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14083 import_components14.Flex,
14084 {
14085 className: "dataviews-view-picker-grid__field",
14086 gap: 1,
14087 justify: "flex-start",
14088 expanded: true,
14089 style: { height: "auto" },
14090 direction: "row",
14091 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14092 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14093 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14094 import_components14.FlexItem,
14095 {
14096 className: "dataviews-view-picker-grid__field-value",
14097 style: { maxHeight: "none" },
14098 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14099 field.render,
14100 {
14101 item,
14102 field
14103 }
14104 )
14105 }
14106 )
14107 ] })
14108 },
14109 field.id
14110 );
14111 })
14112 }
14113 )
14114 ] })
14115 ]
14116 },
14117 id
14118 );
14119 }
14120 function GridGroup({
14121 groupName,
14122 groupField,
14123 showLabel = true,
14124 children
14125 }) {
14126 const headerId = (0, import_compose6.useInstanceId)(
14127 GridGroup,
14128 "dataviews-view-picker-grid-group__header"
14129 );
14130 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14131 Stack,
14132 {
14133 direction: "column",
14134 gap: "sm",
14135 role: "group",
14136 "aria-labelledby": headerId,
14137 children: [
14138 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14139 "h3",
14140 {
14141 className: "dataviews-view-picker-grid-group__header",
14142 id: headerId,
14143 children: showLabel ? (0, import_i18n18.sprintf)(
14144 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14145 (0, import_i18n18.__)("%1$s: %2$s"),
14146 groupField.label,
14147 groupName
14148 ) : groupName
14149 }
14150 ),
14151 children
14152 ]
14153 },
14154 groupName
14155 );
14156 }
14157 function ViewPickerGrid({
14158 actions,
14159 data,
14160 fields,
14161 getItemId,
14162 isLoading,
14163 onChangeSelection,
14164 selection,
14165 view,
14166 className,
14167 empty
14168 }) {
14169 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element44.useContext)(dataviews_context_default);
14170 const titleField = fields.find(
14171 (field) => field.id === view?.titleField
14172 );
14173 const mediaField = fields.find(
14174 (field) => field.id === view?.mediaField
14175 );
14176 const descriptionField = fields.find(
14177 (field) => field.id === view?.descriptionField
14178 );
14179 const otherFields = view.fields ?? [];
14180 const { regularFields, badgeFields } = otherFields.reduce(
14181 (accumulator, fieldId) => {
14182 const field = fields.find((f2) => f2.id === fieldId);
14183 if (!field) {
14184 return accumulator;
14185 }
14186 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14187 accumulator[key].push(field);
14188 return accumulator;
14189 },
14190 { regularFields: [], badgeFields: [] }
14191 );
14192 const hasData = !!data?.length;
14193 const usedPreviewSize = view.layout?.previewSize;
14194 const isMultiselect = useIsMultiselectPicker(actions);
14195 const size4 = "900px";
14196 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14197 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14198 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14199 const currentPage = view?.page ?? 1;
14200 const perPage = view?.perPage ?? 0;
14201 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14202 const gridColumns = useGridColumns();
14203 const placeholdersNeeded = usePlaceholdersNeeded(
14204 data,
14205 isInfiniteScroll,
14206 gridColumns
14207 );
14208 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14209 // Render multiple groups.
14210 children: [
14211 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14212 import_components14.Composite,
14213 {
14214 virtualFocus: true,
14215 orientation: "horizontal",
14216 role: "listbox",
14217 "aria-multiselectable": isMultiselect,
14218 className: clsx_default(
14219 "dataviews-view-picker-grid",
14220 className,
14221 {
14222 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14223 view.layout.density
14224 )
14225 }
14226 ),
14227 "aria-label": itemListLabel,
14228 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14229 Stack,
14230 {
14231 direction: "column",
14232 gap: "lg",
14233 children,
14234 ...props
14235 }
14236 ),
14237 children: Array.from(dataByGroup.entries()).map(
14238 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14239 GridGroup,
14240 {
14241 groupName,
14242 groupField,
14243 showLabel: view.groupBy?.showLabel !== false,
14244 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14245 GridItems,
14246 {
14247 previewSize: usedPreviewSize,
14248 style: {
14249 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14250 },
14251 "aria-busy": isLoading,
14252 ref: resizeObserverRef,
14253 children: groupItems.map((item) => {
14254 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14255 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14256 GridItem3,
14257 {
14258 view,
14259 multiselect: isMultiselect,
14260 selection,
14261 onChangeSelection,
14262 getItemId,
14263 item,
14264 mediaField,
14265 titleField,
14266 descriptionField,
14267 regularFields,
14268 badgeFields,
14269 config: {
14270 sizes: size4
14271 },
14272 posinset: posInSet,
14273 setsize: setSize
14274 },
14275 getItemId(item)
14276 );
14277 })
14278 }
14279 )
14280 },
14281 groupName
14282 )
14283 )
14284 }
14285 ),
14286 // Render a single grid with all data.
14287 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14288 import_components14.Composite,
14289 {
14290 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14291 GridItems,
14292 {
14293 className: clsx_default(
14294 "dataviews-view-picker-grid",
14295 className,
14296 {
14297 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14298 "compact",
14299 "comfortable"
14300 ].includes(view.layout.density)
14301 }
14302 ),
14303 previewSize: usedPreviewSize,
14304 "aria-busy": isLoading,
14305 ref: resizeObserverRef
14306 }
14307 ),
14308 virtualFocus: true,
14309 orientation: "horizontal",
14310 role: "listbox",
14311 "aria-multiselectable": isMultiselect,
14312 "aria-label": itemListLabel,
14313 children: [
14314 Array.from({ length: placeholdersNeeded }).map(
14315 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14316 import_components14.Composite.Item,
14317 {
14318 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14319 Stack,
14320 {
14321 direction: "column",
14322 children,
14323 ...props
14324 }
14325 ),
14326 role: "option",
14327 "aria-hidden": true,
14328 tabIndex: -1,
14329 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14330 },
14331 `placeholder-${index2}`
14332 )
14333 ),
14334 data.map((item) => {
14335 const posinset = item.position;
14336 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14337 GridItem3,
14338 {
14339 view,
14340 multiselect: isMultiselect,
14341 selection,
14342 onChangeSelection,
14343 getItemId,
14344 item,
14345 mediaField,
14346 titleField,
14347 descriptionField,
14348 regularFields,
14349 badgeFields,
14350 config: {
14351 sizes: size4
14352 },
14353 posinset,
14354 setsize: setSize
14355 },
14356 getItemId(item)
14357 );
14358 })
14359 ]
14360 }
14361 ),
14362 // Render empty state.
14363 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14364 "div",
14365 {
14366 className: clsx_default({
14367 "dataviews-loading": isLoading,
14368 "dataviews-no-results": !isLoading
14369 }),
14370 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14371 }
14372 ),
14373 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14374 ]
14375 });
14376 }
14377 var picker_grid_default = ViewPickerGrid;
14378
14379 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14380 var import_i18n19 = __toESM(require_i18n(), 1);
14381 var import_components15 = __toESM(require_components(), 1);
14382 var import_element45 = __toESM(require_element(), 1);
14383 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14384 function TableColumnField2({
14385 item,
14386 fields,
14387 column,
14388 align
14389 }) {
14390 const field = fields.find((f2) => f2.id === column);
14391 if (!field) {
14392 return null;
14393 }
14394 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14395 "dataviews-view-table__cell-align-end": align === "end",
14396 "dataviews-view-table__cell-align-center": align === "center"
14397 });
14398 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14399 }
14400 function TableRow2({
14401 item,
14402 fields,
14403 id,
14404 view,
14405 titleField,
14406 mediaField,
14407 descriptionField,
14408 selection,
14409 getItemId,
14410 onChangeSelection,
14411 multiselect,
14412 posinset
14413 }) {
14414 const { paginationInfo } = (0, import_element45.useContext)(dataviews_context_default);
14415 const isSelected2 = selection.includes(id);
14416 const [isHovered, setIsHovered] = (0, import_element45.useState)(false);
14417 const elementRef = (0, import_element45.useRef)(null);
14418 useIntersectionObserver(elementRef, posinset);
14419 const {
14420 showTitle = true,
14421 showMedia = true,
14422 showDescription = true,
14423 infiniteScrollEnabled
14424 } = view;
14425 const handleMouseEnter = () => {
14426 setIsHovered(true);
14427 };
14428 const handleMouseLeave = () => {
14429 setIsHovered(false);
14430 };
14431 const columns = view.fields ?? [];
14432 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14433 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14434 import_components15.Composite.Item,
14435 {
14436 ref: elementRef,
14437 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14438 "tr",
14439 {
14440 className: clsx_default("dataviews-view-table__row", {
14441 "is-selected": isSelected2,
14442 "is-hovered": isHovered
14443 }),
14444 onMouseEnter: handleMouseEnter,
14445 onMouseLeave: handleMouseLeave,
14446 children,
14447 ...props
14448 }
14449 ),
14450 "aria-selected": isSelected2,
14451 "aria-setsize": paginationInfo.totalItems || void 0,
14452 "aria-posinset": posinset,
14453 role: infiniteScrollEnabled ? "article" : "option",
14454 onMouseDown: (event) => {
14455 if (event.button !== 0) {
14456 return;
14457 }
14458 event.currentTarget.parentElement?.focus({
14459 preventScroll: true
14460 });
14461 },
14462 onClick: () => {
14463 if (isSelected2) {
14464 onChangeSelection(
14465 selection.filter((itemId) => id !== itemId)
14466 );
14467 } else {
14468 const newSelection = multiselect ? [...selection, id] : [id];
14469 onChangeSelection(newSelection);
14470 }
14471 },
14472 children: [
14473 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14474 "td",
14475 {
14476 className: "dataviews-view-table__checkbox-column",
14477 role: "presentation",
14478 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14479 DataViewsSelectionCheckbox,
14480 {
14481 item,
14482 selection,
14483 onChangeSelection,
14484 getItemId,
14485 titleField,
14486 disabled: false,
14487 "aria-hidden": true,
14488 tabIndex: -1
14489 }
14490 ) })
14491 }
14492 ),
14493 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14494 "td",
14495 {
14496 role: "presentation",
14497 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14498 column_primary_default,
14499 {
14500 item,
14501 titleField: showTitle ? titleField : void 0,
14502 mediaField: showMedia ? mediaField : void 0,
14503 descriptionField: showDescription ? descriptionField : void 0,
14504 isItemClickable: () => false
14505 }
14506 )
14507 }
14508 ),
14509 columns.map((column) => {
14510 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14511 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14512 "td",
14513 {
14514 style: {
14515 width,
14516 maxWidth,
14517 minWidth
14518 },
14519 role: "presentation",
14520 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14521 TableColumnField2,
14522 {
14523 fields,
14524 item,
14525 column,
14526 align
14527 }
14528 )
14529 },
14530 column
14531 );
14532 })
14533 ]
14534 },
14535 id
14536 );
14537 }
14538 function ViewPickerTable({
14539 actions,
14540 data,
14541 fields,
14542 getItemId,
14543 isLoading = false,
14544 onChangeView,
14545 onChangeSelection,
14546 selection,
14547 setOpenedFilter,
14548 view,
14549 className,
14550 empty
14551 }) {
14552 const headerMenuRefs = (0, import_element45.useRef)(/* @__PURE__ */ new Map());
14553 const headerMenuToFocusRef = (0, import_element45.useRef)(void 0);
14554 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element45.useState)();
14555 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14556 (0, import_element45.useEffect)(() => {
14557 if (headerMenuToFocusRef.current) {
14558 headerMenuToFocusRef.current.focus();
14559 headerMenuToFocusRef.current = void 0;
14560 }
14561 });
14562 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14563 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14564 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14565 const tableNoticeId = (0, import_element45.useId)();
14566 if (nextHeaderMenuToFocus) {
14567 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14568 setNextHeaderMenuToFocus(void 0);
14569 return;
14570 }
14571 const onHide = (field) => {
14572 const hidden = headerMenuRefs.current.get(field.id);
14573 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14574 setNextHeaderMenuToFocus(fallback?.node);
14575 };
14576 const hasData = !!data?.length;
14577 const titleField = fields.find((field) => field.id === view.titleField);
14578 const mediaField = fields.find((field) => field.id === view.mediaField);
14579 const descriptionField = fields.find(
14580 (field) => field.id === view.descriptionField
14581 );
14582 const { showTitle = true, showMedia = true, showDescription = true } = view;
14583 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14584 const columns = view.fields ?? [];
14585 const headerMenuRef = (column, index2) => (node) => {
14586 if (node) {
14587 headerMenuRefs.current.set(column, {
14588 node,
14589 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14590 });
14591 } else {
14592 headerMenuRefs.current.delete(column);
14593 }
14594 };
14595 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14596 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14597 "table",
14598 {
14599 className: clsx_default(
14600 "dataviews-view-table",
14601 "dataviews-view-picker-table",
14602 className,
14603 {
14604 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14605 view.layout.density
14606 )
14607 }
14608 ),
14609 "aria-busy": isLoading,
14610 "aria-describedby": tableNoticeId,
14611 role: isInfiniteScroll ? "feed" : "listbox",
14612 children: [
14613 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14614 "tr",
14615 {
14616 className: "dataviews-view-table__row",
14617 role: "presentation",
14618 children: [
14619 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14620 BulkSelectionCheckbox,
14621 {
14622 selection,
14623 onChangeSelection,
14624 data,
14625 actions,
14626 getItemId,
14627 disableSelectAll: isInfiniteScroll
14628 }
14629 ) }),
14630 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14631 column_header_menu_default,
14632 {
14633 ref: headerMenuRef(
14634 titleField.id,
14635 0
14636 ),
14637 fieldId: titleField.id,
14638 view,
14639 fields,
14640 onChangeView,
14641 onHide,
14642 setOpenedFilter,
14643 canMove: false
14644 }
14645 ) }),
14646 columns.map((column, index2) => {
14647 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14648 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14649 "th",
14650 {
14651 style: {
14652 width,
14653 maxWidth,
14654 minWidth,
14655 textAlign: align
14656 },
14657 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14658 scope: "col",
14659 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14660 column_header_menu_default,
14661 {
14662 ref: headerMenuRef(column, index2),
14663 fieldId: column,
14664 view,
14665 fields,
14666 onChangeView,
14667 onHide,
14668 setOpenedFilter,
14669 canMove: view.layout?.enableMoving ?? true
14670 }
14671 )
14672 },
14673 column
14674 );
14675 })
14676 ]
14677 }
14678 ) }),
14679 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14680 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14681 import_components15.Composite,
14682 {
14683 virtualFocus: true,
14684 orientation: "vertical",
14685 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14686 children: [
14687 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14688 "tr",
14689 {
14690 className: "dataviews-view-table__group-header-row",
14691 role: "presentation",
14692 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14693 "td",
14694 {
14695 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14696 className: "dataviews-view-table__group-header-cell",
14697 role: "presentation",
14698 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14699 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14700 (0, import_i18n19.__)("%1$s: %2$s"),
14701 groupField.label,
14702 groupName
14703 )
14704 }
14705 )
14706 }
14707 ),
14708 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14709 TableRow2,
14710 {
14711 item,
14712 fields,
14713 id: getItemId(item) || index2.toString(),
14714 view,
14715 titleField,
14716 mediaField,
14717 descriptionField,
14718 selection,
14719 getItemId,
14720 onChangeSelection,
14721 multiselect: isMultiselect
14722 },
14723 getItemId(item)
14724 ))
14725 ]
14726 },
14727 `group-${groupName}`
14728 )
14729 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14730 import_components15.Composite,
14731 {
14732 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
14733 virtualFocus: true,
14734 orientation: "vertical",
14735 children: hasData && data.map((item, index2) => {
14736 const itemId = getItemId(item);
14737 const posinset = item.position;
14738 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14739 TableRow2,
14740 {
14741 item,
14742 fields,
14743 id: itemId || index2.toString(),
14744 view,
14745 titleField,
14746 mediaField,
14747 descriptionField,
14748 selection,
14749 getItemId,
14750 onChangeSelection,
14751 multiselect: isMultiselect,
14752 posinset
14753 },
14754 itemId
14755 );
14756 })
14757 }
14758 )
14759 ]
14760 }
14761 ),
14762 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14763 "div",
14764 {
14765 className: clsx_default({
14766 "dataviews-loading": isLoading,
14767 "dataviews-no-results": !hasData && !isLoading
14768 }),
14769 id: tableNoticeId,
14770 children: [
14771 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
14772 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
14773 ]
14774 }
14775 )
14776 ] });
14777 }
14778 var picker_table_default = ViewPickerTable;
14779
14780 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14781 var import_components16 = __toESM(require_components(), 1);
14782 var import_element46 = __toESM(require_element(), 1);
14783 var import_compose7 = __toESM(require_compose(), 1);
14784 var import_i18n20 = __toESM(require_i18n(), 1);
14785 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14786 function isDefined4(item) {
14787 return !!item;
14788 }
14789 function PickerActivityItem({
14790 view,
14791 multiselect,
14792 selection,
14793 onChangeSelection,
14794 getItemId,
14795 item,
14796 titleField,
14797 mediaField,
14798 descriptionField,
14799 otherFields,
14800 posinset,
14801 setsize
14802 }) {
14803 const elementRef = (0, import_element46.useRef)(null);
14804 useIntersectionObserver(elementRef, posinset);
14805 const { showTitle = true, showMedia = true, showDescription = true } = view;
14806 const id = getItemId(item);
14807 const isSelected2 = selection.includes(id);
14808 const density = view.layout?.density ?? "balanced";
14809 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14810 mediaField.render,
14811 {
14812 item,
14813 field: mediaField,
14814 config: {
14815 sizes: density === "comfortable" ? "32px" : "24px"
14816 }
14817 }
14818 ) : null;
14819 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14820 "span",
14821 {
14822 className: "dataviews-view-picker-activity__item-bullet",
14823 "aria-hidden": "true"
14824 }
14825 ) });
14826 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
14827 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14828 const verticalGap = (0, import_element46.useMemo)(() => {
14829 switch (density) {
14830 case "comfortable":
14831 return "md";
14832 default:
14833 return "sm";
14834 }
14835 }, [density]);
14836 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14837 import_components16.Composite.Item,
14838 {
14839 ref: elementRef,
14840 role: "option",
14841 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14842 "aria-posinset": posinset,
14843 "aria-setsize": setsize,
14844 "aria-selected": isSelected2,
14845 className: clsx_default(
14846 "dataviews-view-picker-activity__item",
14847 density === "compact" && "is-compact",
14848 density === "balanced" && "is-balanced",
14849 density === "comfortable" && "is-comfortable",
14850 isSelected2 && "is-selected"
14851 ),
14852 onClick: () => {
14853 if (isSelected2) {
14854 onChangeSelection(
14855 selection.filter((itemId) => id !== itemId)
14856 );
14857 } else {
14858 const newSelection = multiselect ? [...selection, id] : [id];
14859 onChangeSelection(newSelection);
14860 }
14861 },
14862 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
14863 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14864 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14865 Stack,
14866 {
14867 direction: "column",
14868 gap: "xs",
14869 align: "center",
14870 className: "dataviews-view-picker-activity__item-type",
14871 children: renderedMediaField
14872 }
14873 ),
14874 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14875 Stack,
14876 {
14877 direction: "column",
14878 gap: verticalGap,
14879 align: "flex-start",
14880 className: "dataviews-view-picker-activity__item-content",
14881 children: [
14882 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14883 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14884 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14885 "div",
14886 {
14887 className: "dataviews-view-picker-activity__item-field",
14888 children: [
14889 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14890 VisuallyHidden,
14891 {
14892 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
14893 className: "dataviews-view-picker-activity__item-field-label",
14894 children: field.label
14895 }
14896 ),
14897 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14898 field.render,
14899 {
14900 item,
14901 field
14902 }
14903 ) })
14904 ]
14905 },
14906 field.id
14907 )) })
14908 ]
14909 }
14910 )
14911 ] })
14912 }
14913 );
14914 }
14915 function PickerActivityGroup({
14916 groupName,
14917 groupField,
14918 showLabel = true,
14919 children
14920 }) {
14921 const headerId = (0, import_compose7.useInstanceId)(
14922 PickerActivityGroup,
14923 "dataviews-view-picker-activity-group__header"
14924 );
14925 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14926 Stack,
14927 {
14928 direction: "column",
14929 role: "group",
14930 "aria-labelledby": headerId,
14931 className: "dataviews-view-picker-activity-group",
14932 children: [
14933 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14934 "h3",
14935 {
14936 className: "dataviews-view-picker-activity-group__header",
14937 id: headerId,
14938 children: showLabel ? (0, import_i18n20.sprintf)(
14939 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14940 (0, import_i18n20.__)("%1$s: %2$s"),
14941 groupField.label,
14942 groupName
14943 ) : groupName
14944 }
14945 ),
14946 children
14947 ]
14948 }
14949 );
14950 }
14951 function ViewPickerActivity({
14952 data,
14953 fields,
14954 getItemId,
14955 isLoading,
14956 onChangeSelection,
14957 selection,
14958 view,
14959 actions,
14960 className,
14961 empty
14962 }) {
14963 const { itemListLabel, paginationInfo } = (0, import_element46.useContext)(dataviews_context_default);
14964 const isMultiselect = useIsMultiselectPicker(actions);
14965 const titleField = fields.find(
14966 (field) => field.id === view?.titleField
14967 );
14968 const mediaField = fields.find(
14969 (field) => field.id === view?.mediaField
14970 );
14971 const descriptionField = fields.find(
14972 (field) => field.id === view?.descriptionField
14973 );
14974 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14975 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14976 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14977 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14978 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14979 const hasData = !!data?.length;
14980 const isGrouped = !!(groupField && dataByGroup);
14981 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14982 PickerActivityItem,
14983 {
14984 view,
14985 multiselect: isMultiselect,
14986 selection,
14987 onChangeSelection,
14988 getItemId,
14989 item,
14990 titleField,
14991 mediaField,
14992 descriptionField,
14993 otherFields,
14994 posinset: item.position,
14995 setsize
14996 },
14997 getItemId(item)
14998 );
14999 if (!hasData) {
15000 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15001 "div",
15002 {
15003 className: clsx_default({
15004 "dataviews-loading": isLoading,
15005 "dataviews-no-results": !isLoading
15006 }),
15007 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
15008 }
15009 );
15010 }
15011 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
15012 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15013 import_components16.Composite,
15014 {
15015 virtualFocus: true,
15016 orientation: "vertical",
15017 role: "listbox",
15018 "aria-multiselectable": isMultiselect,
15019 "aria-label": itemListLabel,
15020 "aria-busy": isLoading,
15021 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15022 className: clsx_default(
15023 "dataviews-view-picker-activity",
15024 className
15025 ),
15026 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15027 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15028 PickerActivityGroup,
15029 {
15030 groupName,
15031 groupField,
15032 showLabel: view.groupBy?.showLabel !== false,
15033 children: groupItems.map(renderItem)
15034 },
15035 groupName
15036 )
15037 ) : data.map(renderItem)
15038 }
15039 ),
15040 isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15041 ] });
15042 }
15043
15044 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15045 var import_components17 = __toESM(require_components(), 1);
15046 var import_i18n21 = __toESM(require_i18n(), 1);
15047 var import_element47 = __toESM(require_element(), 1);
15048 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15049 function DensityPicker() {
15050 const context = (0, import_element47.useContext)(dataviews_context_default);
15051 const view = context.view;
15052 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15053 import_components17.__experimentalToggleGroupControl,
15054 {
15055 size: "__unstable-large",
15056 label: (0, import_i18n21.__)("Density"),
15057 value: view.layout?.density || "balanced",
15058 onChange: (value) => {
15059 context.onChangeView({
15060 ...view,
15061 layout: {
15062 ...view.layout,
15063 density: value
15064 }
15065 });
15066 },
15067 isBlock: true,
15068 children: [
15069 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15070 import_components17.__experimentalToggleGroupControlOption,
15071 {
15072 value: "comfortable",
15073 label: (0, import_i18n21._x)(
15074 "Comfortable",
15075 "Density option for DataView layout"
15076 )
15077 },
15078 "comfortable"
15079 ),
15080 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15081 import_components17.__experimentalToggleGroupControlOption,
15082 {
15083 value: "balanced",
15084 label: (0, import_i18n21._x)("Balanced", "Density option for DataView layout")
15085 },
15086 "balanced"
15087 ),
15088 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15089 import_components17.__experimentalToggleGroupControlOption,
15090 {
15091 value: "compact",
15092 label: (0, import_i18n21._x)("Compact", "Density option for DataView layout")
15093 },
15094 "compact"
15095 )
15096 ]
15097 }
15098 );
15099 }
15100
15101 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15102 var import_components18 = __toESM(require_components(), 1);
15103 var import_i18n22 = __toESM(require_i18n(), 1);
15104 var import_element48 = __toESM(require_element(), 1);
15105 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15106 var imageSizes2 = [
15107 {
15108 value: 120,
15109 breakpoint: 1
15110 },
15111 {
15112 value: 170,
15113 breakpoint: 1
15114 },
15115 {
15116 value: 230,
15117 breakpoint: 1
15118 },
15119 {
15120 value: 290,
15121 breakpoint: 1112
15122 // at minimum image width, 4 images display at this container size
15123 },
15124 {
15125 value: 350,
15126 breakpoint: 1636
15127 // at minimum image width, 6 images display at this container size
15128 },
15129 {
15130 value: 430,
15131 breakpoint: 588
15132 // at minimum image width, 2 images display at this container size
15133 }
15134 ];
15135 function PreviewSizePicker() {
15136 const context = (0, import_element48.useContext)(dataviews_context_default);
15137 const view = context.view;
15138 const breakValues = imageSizes2.filter((size4) => {
15139 return context.containerWidth >= size4.breakpoint;
15140 });
15141 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15142 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15143 const marks = breakValues.map((size4, index2) => {
15144 return {
15145 value: index2
15146 };
15147 });
15148 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15149 import_components18.RangeControl,
15150 {
15151 __next40pxDefaultSize: true,
15152 showTooltip: false,
15153 label: (0, import_i18n22.__)("Preview size"),
15154 value: previewSizeToUse,
15155 min: 0,
15156 max: breakValues.length - 1,
15157 withInputField: false,
15158 onChange: (value = 0) => {
15159 context.onChangeView({
15160 ...view,
15161 layout: {
15162 ...view.layout,
15163 previewSize: breakValues[value].value
15164 }
15165 });
15166 },
15167 step: 1,
15168 marks
15169 }
15170 );
15171 }
15172
15173 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15174 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15175 function GridConfigOptions() {
15176 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15177 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15178 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15179 ] });
15180 }
15181
15182 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15183 var VIEW_LAYOUTS = [
15184 {
15185 type: LAYOUT_TABLE,
15186 label: (0, import_i18n23.__)("Table"),
15187 component: table_default,
15188 icon: block_table_default,
15189 viewConfigOptions: DensityPicker
15190 },
15191 {
15192 type: LAYOUT_GRID,
15193 label: (0, import_i18n23.__)("Grid"),
15194 component: grid_default,
15195 icon: category_default,
15196 viewConfigOptions: GridConfigOptions
15197 },
15198 {
15199 type: LAYOUT_LIST,
15200 label: (0, import_i18n23.__)("List"),
15201 component: ViewList,
15202 icon: (0, import_i18n23.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15203 viewConfigOptions: DensityPicker
15204 },
15205 {
15206 type: LAYOUT_ACTIVITY,
15207 label: (0, import_i18n23.__)("Activity"),
15208 component: ViewActivity,
15209 icon: scheduled_default,
15210 viewConfigOptions: DensityPicker
15211 },
15212 {
15213 type: LAYOUT_PICKER_GRID,
15214 label: (0, import_i18n23.__)("Grid"),
15215 component: picker_grid_default,
15216 icon: category_default,
15217 viewConfigOptions: GridConfigOptions,
15218 isPicker: true
15219 },
15220 {
15221 type: LAYOUT_PICKER_TABLE,
15222 label: (0, import_i18n23.__)("Table"),
15223 component: picker_table_default,
15224 icon: block_table_default,
15225 viewConfigOptions: DensityPicker,
15226 isPicker: true
15227 },
15228 {
15229 type: LAYOUT_PICKER_ACTIVITY,
15230 label: (0, import_i18n23.__)("Activity"),
15231 component: ViewPickerActivity,
15232 icon: scheduled_default,
15233 viewConfigOptions: DensityPicker,
15234 isPicker: true
15235 }
15236 ];
15237
15238 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15239 var import_element56 = __toESM(require_element(), 1);
15240
15241 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15242 var import_components21 = __toESM(require_components(), 1);
15243 var import_i18n26 = __toESM(require_i18n(), 1);
15244 var import_element53 = __toESM(require_element(), 1);
15245
15246 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15247 var import_react11 = __toESM(require_react(), 1);
15248 var FocusableContext = (0, import_react11.createContext)(true);
15249
15250 // node_modules/@ariakit/utils/dist/index.js
15251 function toArray(arg) {
15252 if (Array.isArray(arg)) return arg;
15253 return typeof arg !== "undefined" ? [arg] : [];
15254 }
15255 function flatten2DArray(array) {
15256 const flattened = [];
15257 for (const row of array) flattened.push(...row);
15258 return flattened;
15259 }
15260 function reverseArray(array) {
15261 return array.slice().reverse();
15262 }
15263 var canUseDOM = checkIsBrowser();
15264 function checkIsBrowser() {
15265 return typeof window !== "undefined" && !!window.document?.createElement;
15266 }
15267 function getDocument(node) {
15268 if (!node) return document;
15269 if ("self" in node) return node.document;
15270 return node.ownerDocument || document;
15271 }
15272 function getActiveElement(node, activeDescendant = false) {
15273 const { activeElement: activeElement2 } = getDocument(node);
15274 if (!activeElement2?.nodeName) return null;
15275 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15276 if (activeDescendant) {
15277 const id = activeElement2.getAttribute("aria-activedescendant");
15278 if (id) {
15279 const element = getDocument(activeElement2).getElementById(id);
15280 if (element) return element;
15281 }
15282 }
15283 return activeElement2;
15284 }
15285 function contains2(parent, child) {
15286 return parent === child || parent.contains(child);
15287 }
15288 function isElement2(target) {
15289 return target?.nodeType === 1;
15290 }
15291 function isNode2(target) {
15292 return typeof target?.nodeType === "number";
15293 }
15294 function isFrame(element) {
15295 return element.tagName === "IFRAME";
15296 }
15297 function isButton(element) {
15298 const tagName = element.tagName.toLowerCase();
15299 if (tagName === "button") return true;
15300 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15301 return false;
15302 }
15303 var buttonInputTypes = [
15304 "button",
15305 "color",
15306 "file",
15307 "image",
15308 "reset",
15309 "submit"
15310 ];
15311 function isVisible(element) {
15312 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15313 const htmlElement = element;
15314 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15315 }
15316 function isTextField(element) {
15317 try {
15318 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15319 const isTextArea = element.tagName === "TEXTAREA";
15320 return isTextInput || isTextArea || false;
15321 } catch (_error) {
15322 return false;
15323 }
15324 }
15325 function isTextbox(element) {
15326 return element.isContentEditable || isTextField(element);
15327 }
15328 function getTextboxValue(element) {
15329 if (isTextField(element)) return element.value;
15330 if (element.isContentEditable) {
15331 const range = getDocument(element).createRange();
15332 range.selectNodeContents(element);
15333 return range.toString();
15334 }
15335 return "";
15336 }
15337 function getTextboxSelection(element) {
15338 let start = 0;
15339 let end = 0;
15340 if (isTextField(element)) {
15341 start = element.selectionStart || 0;
15342 end = element.selectionEnd || 0;
15343 } else if (element.isContentEditable) {
15344 const selection = getDocument(element).getSelection();
15345 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15346 const range = selection.getRangeAt(0);
15347 const nextRange = range.cloneRange();
15348 nextRange.selectNodeContents(element);
15349 nextRange.setEnd(range.startContainer, range.startOffset);
15350 start = nextRange.toString().length;
15351 nextRange.setEnd(range.endContainer, range.endOffset);
15352 end = nextRange.toString().length;
15353 }
15354 }
15355 return {
15356 start,
15357 end
15358 };
15359 }
15360 function getPopupRole(element, fallback) {
15361 const allowedPopupRoles = [
15362 "dialog",
15363 "menu",
15364 "listbox",
15365 "tree",
15366 "grid"
15367 ];
15368 const role = element?.getAttribute("role");
15369 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15370 return fallback;
15371 }
15372 function getScrollingElement(element) {
15373 if (!element) return null;
15374 const isScrollableOverflow = (overflow) => {
15375 if (overflow === "auto") return true;
15376 if (overflow === "scroll") return true;
15377 return false;
15378 };
15379 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15380 const { overflowY } = getComputedStyle(element);
15381 if (isScrollableOverflow(overflowY)) return element;
15382 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15383 const { overflowX } = getComputedStyle(element);
15384 if (isScrollableOverflow(overflowX)) return element;
15385 }
15386 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15387 }
15388 function setSelectionRange(element, ...args) {
15389 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15390 }
15391 function sortBasedOnDOMPosition(items, getElement) {
15392 const pairs = items.map((item, index2) => [index2, item]);
15393 let isOrderDifferent = false;
15394 pairs.sort(([indexA, a2], [indexB, b2]) => {
15395 const elementA = getElement(a2);
15396 const elementB = getElement(b2);
15397 if (elementA === elementB) return 0;
15398 if (!elementA || !elementB) return 0;
15399 if (isElementPreceding(elementA, elementB)) {
15400 if (indexA > indexB) isOrderDifferent = true;
15401 return -1;
15402 }
15403 if (indexA < indexB) isOrderDifferent = true;
15404 return 1;
15405 });
15406 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15407 return items;
15408 }
15409 function isElementPreceding(a2, b2) {
15410 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15411 }
15412 function isTouchDevice() {
15413 return canUseDOM && !!navigator.maxTouchPoints;
15414 }
15415 function isApple() {
15416 if (!canUseDOM) return false;
15417 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15418 }
15419 function isSafari2() {
15420 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15421 }
15422 function isFirefox2() {
15423 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15424 }
15425 function isPortalEvent(event) {
15426 const { currentTarget, target } = event;
15427 if (!currentTarget) return false;
15428 if (!isNode2(target)) return true;
15429 return !contains2(currentTarget, target);
15430 }
15431 function isSelfTarget(event) {
15432 return event.target === event.currentTarget;
15433 }
15434 function isOpeningInNewTab(event) {
15435 const element = event.currentTarget;
15436 if (!element) return false;
15437 const isAppleDevice = isApple();
15438 if (isAppleDevice && !event.metaKey) return false;
15439 if (!isAppleDevice && !event.ctrlKey) return false;
15440 const tagName = element.tagName.toLowerCase();
15441 if (tagName === "a") return true;
15442 if (tagName === "button" && element.type === "submit") return true;
15443 if (tagName === "input" && element.type === "submit") return true;
15444 return false;
15445 }
15446 function isDownloading(event) {
15447 const element = event.currentTarget;
15448 if (!element) return false;
15449 const tagName = element.tagName.toLowerCase();
15450 if (!event.altKey) return false;
15451 if (tagName === "a") return true;
15452 if (tagName === "button" && element.type === "submit") return true;
15453 if (tagName === "input" && element.type === "submit") return true;
15454 return false;
15455 }
15456 function fireBlurEvent(element, eventInit) {
15457 const event = new FocusEvent("blur", eventInit);
15458 const defaultAllowed = element.dispatchEvent(event);
15459 const bubbleInit = {
15460 ...eventInit,
15461 bubbles: true
15462 };
15463 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15464 return defaultAllowed;
15465 }
15466 function fireKeyboardEvent(element, type, eventInit) {
15467 const event = new KeyboardEvent(type, eventInit);
15468 return element.dispatchEvent(event);
15469 }
15470 function fireClickEvent(element, eventInit) {
15471 const event = new MouseEvent("click", eventInit);
15472 return element.dispatchEvent(event);
15473 }
15474 function isFocusEventOutside(event, container) {
15475 const containerElement = container || event.currentTarget;
15476 const relatedTarget = event.relatedTarget;
15477 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15478 }
15479 function queueBeforeEvent(element, type, callback, timeout) {
15480 const createTimer = (callback2) => {
15481 if (timeout) {
15482 const timerId2 = setTimeout(callback2, timeout);
15483 return () => clearTimeout(timerId2);
15484 }
15485 const timerId = requestAnimationFrame(callback2);
15486 return () => cancelAnimationFrame(timerId);
15487 };
15488 const cancelTimer = createTimer(() => {
15489 element.removeEventListener(type, callSync, true);
15490 callback();
15491 });
15492 const callSync = () => {
15493 cancelTimer();
15494 callback();
15495 };
15496 element.addEventListener(type, callSync, {
15497 once: true,
15498 capture: true
15499 });
15500 return cancelTimer;
15501 }
15502 function addGlobalEventListener(type, listener, options, scope = window) {
15503 const children = [];
15504 try {
15505 scope.document.addEventListener(type, listener, options);
15506 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15507 } catch {
15508 }
15509 const removeEventListener = () => {
15510 try {
15511 scope.document.removeEventListener(type, listener, options);
15512 } catch {
15513 }
15514 for (const remove of children) remove();
15515 };
15516 return removeEventListener;
15517 }
15518 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'])";
15519 function isFocusable(element) {
15520 if (!element.matches(selector)) return false;
15521 if (!isVisible(element)) return false;
15522 if (element.closest("[inert]")) return false;
15523 return true;
15524 }
15525 function hasFocus(element) {
15526 const activeElement2 = getActiveElement(element);
15527 if (!activeElement2) return false;
15528 if (activeElement2 === element) return true;
15529 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15530 if (!activeDescendant) return false;
15531 return activeDescendant === element.id;
15532 }
15533 function hasFocusWithin(element) {
15534 const activeElement2 = getActiveElement(element);
15535 if (!activeElement2) return false;
15536 if (contains2(element, activeElement2)) return true;
15537 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15538 if (!activeDescendant) return false;
15539 if (!("id" in element)) return false;
15540 if (activeDescendant === element.id) return true;
15541 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15542 }
15543 function focusIntoView(element, options) {
15544 if (!("scrollIntoView" in element)) element.focus();
15545 else {
15546 element.focus({ preventScroll: true });
15547 element.scrollIntoView({
15548 block: "nearest",
15549 inline: "nearest",
15550 ...options
15551 });
15552 }
15553 }
15554 function noop4(..._) {
15555 }
15556 function hasOwnProperty(object, prop) {
15557 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15558 return Object.prototype.hasOwnProperty.call(object, prop);
15559 }
15560 function chain(...fns) {
15561 return (...args) => {
15562 for (const fn of fns) if (typeof fn === "function") fn(...args);
15563 };
15564 }
15565 function normalizeString(str) {
15566 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15567 }
15568 function omit(object, keys) {
15569 const result = { ...object };
15570 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15571 return result;
15572 }
15573 function pick(object, paths) {
15574 const result = {};
15575 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15576 return result;
15577 }
15578 function identity(value) {
15579 return value;
15580 }
15581 function invariant(condition, message2) {
15582 if (condition) return;
15583 if (typeof message2 !== "string") throw new Error("Invariant failed");
15584 throw new Error(message2);
15585 }
15586 function getKeys(obj) {
15587 return Object.keys(obj);
15588 }
15589 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15590 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15591 if (result == null) return false;
15592 return !result;
15593 }
15594 function disabledFromProps(props) {
15595 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15596 }
15597 function removeUndefinedValues(obj) {
15598 const result = {};
15599 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15600 return result;
15601 }
15602 function defaultValue(...values) {
15603 for (const value of values) if (value !== void 0) return value;
15604 }
15605 function createUndoCallback(callback) {
15606 return async () => {
15607 const redo = await callback?.();
15608 return createUndoCallback(async () => {
15609 await redo?.();
15610 return callback;
15611 });
15612 };
15613 }
15614 var UndoManager = createUndoManager();
15615 function createUndoManager({ limit = 100 } = {}) {
15616 const undoStack = [];
15617 let redoStack = [];
15618 let currentGroup = null;
15619 const canUndo = () => undoStack.length > 0;
15620 const canRedo = () => redoStack.length > 0;
15621 const undo = async () => {
15622 if (!canUndo()) return;
15623 currentGroup = null;
15624 redoStack.push(await undoStack.pop()?.());
15625 };
15626 const redo = async () => {
15627 if (!canRedo()) return;
15628 currentGroup = null;
15629 undoStack.push(await redoStack.pop()?.());
15630 };
15631 const execute = async (callback, group) => {
15632 if (!callback) return;
15633 while (undoStack.length > limit) undoStack.shift();
15634 const sameGroup = group === currentGroup;
15635 currentGroup = group ?? null;
15636 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15637 const undoCallback = await callback();
15638 if (!undoCallback) return;
15639 redoStack = [];
15640 const currentUndo = undoStack[nextIndex];
15641 undoStack[nextIndex] = createUndoCallback(async () => {
15642 await undoCallback?.();
15643 const currentRedo = await currentUndo?.();
15644 return async () => {
15645 await currentRedo?.();
15646 await callback?.();
15647 };
15648 });
15649 };
15650 return {
15651 canUndo,
15652 canRedo,
15653 undo,
15654 redo,
15655 execute
15656 };
15657 }
15658
15659 // node_modules/@ariakit/react-utils/dist/index.js
15660 var React47 = __toESM(require_react(), 1);
15661 var import_react12 = __toESM(require_react(), 1);
15662 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15663 function setRef(ref, value) {
15664 if (typeof ref === "function") ref(value);
15665 else if (ref) ref.current = value;
15666 }
15667 function isValidElementWithRef(element) {
15668 if (!element) return false;
15669 if (!(0, import_react12.isValidElement)(element)) return false;
15670 if ("ref" in element.props) return true;
15671 if ("ref" in element) return true;
15672 return false;
15673 }
15674 function getRefProperty(element) {
15675 if (!isValidElementWithRef(element)) return null;
15676 return { ...element.props }.ref || element.ref;
15677 }
15678 function mergeProps2(base, overrides) {
15679 const props = { ...base };
15680 for (const key in overrides) {
15681 if (!hasOwnProperty(overrides, key)) continue;
15682 if (key === "className") {
15683 const prop = "className";
15684 const baseClass = base[prop];
15685 const overrideClass = overrides[prop];
15686 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15687 else props[prop] = overrideClass || baseClass;
15688 continue;
15689 }
15690 if (key === "style") {
15691 const prop = "style";
15692 props[prop] = base[prop] ? {
15693 ...base[prop],
15694 ...overrides[prop]
15695 } : overrides[prop];
15696 continue;
15697 }
15698 const overrideValue = overrides[key];
15699 if (key.startsWith("on")) {
15700 if (typeof overrideValue !== "function") continue;
15701 const baseValue = base[key];
15702 if (typeof baseValue === "function") {
15703 props[key] = (...args) => {
15704 overrideValue(...args);
15705 baseValue(...args);
15706 };
15707 continue;
15708 }
15709 }
15710 props[key] = overrideValue;
15711 }
15712 return props;
15713 }
15714 var _React = { ...React47 };
15715 var useReactId = _React.useId;
15716 var useReactDeferredValue = _React.useDeferredValue;
15717 var useReactInsertionEffect = _React.useInsertionEffect;
15718 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15719 function useInitialValue(value) {
15720 const [initialValue] = (0, import_react12.useState)(value);
15721 return initialValue;
15722 }
15723 function useLiveRef(value) {
15724 const ref = (0, import_react12.useRef)(value);
15725 useSafeLayoutEffect(() => {
15726 ref.current = value;
15727 });
15728 return ref;
15729 }
15730 function useEvent(callback) {
15731 const ref = (0, import_react12.useRef)(() => {
15732 throw new Error("Cannot call an event handler while rendering.");
15733 });
15734 if (useReactInsertionEffect) useReactInsertionEffect(() => {
15735 ref.current = callback;
15736 });
15737 else ref.current = callback;
15738 return (0, import_react12.useCallback)((...args) => ref.current?.(...args), []);
15739 }
15740 function useTransactionState(callback) {
15741 const [state, setState] = (0, import_react12.useState)(null);
15742 useSafeLayoutEffect(() => {
15743 if (state == null) return;
15744 if (!callback) return;
15745 let prevState = null;
15746 callback((prev) => {
15747 prevState = prev;
15748 return state;
15749 });
15750 return () => {
15751 callback(prevState);
15752 };
15753 }, [state, callback]);
15754 return [state, setState];
15755 }
15756 function useMergeRefs(...refs) {
15757 return (0, import_react12.useMemo)(() => {
15758 if (!refs.some(Boolean)) return;
15759 return (value) => {
15760 for (const ref of refs) setRef(ref, value);
15761 };
15762 }, refs);
15763 }
15764 function useId4(defaultId) {
15765 if (useReactId) {
15766 const reactId = useReactId();
15767 if (defaultId) return defaultId;
15768 return reactId;
15769 }
15770 const [id, setId] = (0, import_react12.useState)(defaultId);
15771 useSafeLayoutEffect(() => {
15772 if (defaultId || id) return;
15773 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
15774 }, [defaultId, id]);
15775 return defaultId || id;
15776 }
15777 function useTagName(refOrElement, type) {
15778 const stringOrUndefined = (type2) => {
15779 if (typeof type2 !== "string") return;
15780 return type2;
15781 };
15782 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15783 useSafeLayoutEffect(() => {
15784 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
15785 }, [refOrElement, type]);
15786 return tagName;
15787 }
15788 function useAttribute(refOrElement, attributeName, defaultValue2) {
15789 const initialValue = useInitialValue(defaultValue2);
15790 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15791 (0, import_react12.useEffect)(() => {
15792 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15793 if (!element) return;
15794 const callback = () => {
15795 const value = element.getAttribute(attributeName);
15796 setAttribute(value == null ? initialValue : value);
15797 };
15798 const observer = new MutationObserver(callback);
15799 observer.observe(element, { attributeFilter: [attributeName] });
15800 callback();
15801 return () => observer.disconnect();
15802 }, [
15803 refOrElement,
15804 attributeName,
15805 initialValue
15806 ]);
15807 return attribute;
15808 }
15809 function useUpdateEffect(effect, deps) {
15810 const mounted = (0, import_react12.useRef)(false);
15811 (0, import_react12.useEffect)(() => {
15812 if (mounted.current) return effect();
15813 mounted.current = true;
15814 }, deps);
15815 (0, import_react12.useEffect)(() => () => {
15816 mounted.current = false;
15817 }, []);
15818 }
15819 function useUpdateLayoutEffect(effect, deps) {
15820 const mounted = (0, import_react12.useRef)(false);
15821 useSafeLayoutEffect(() => {
15822 if (mounted.current) return effect();
15823 mounted.current = true;
15824 }, deps);
15825 useSafeLayoutEffect(() => () => {
15826 mounted.current = false;
15827 }, []);
15828 }
15829 function useForceUpdate() {
15830 return (0, import_react12.useReducer)(() => [], []);
15831 }
15832 function useBooleanEvent(booleanOrCallback) {
15833 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
15834 }
15835 function useWrapElement(props, callback, deps = []) {
15836 const wrapElement = (0, import_react12.useCallback)((element) => {
15837 if (props.wrapElement) element = props.wrapElement(element);
15838 return callback(element);
15839 }, [...deps, props.wrapElement]);
15840 return {
15841 ...props,
15842 wrapElement
15843 };
15844 }
15845 function useMetadataProps(props, key, value) {
15846 const parent = props.onLoadedMetadataCapture;
15847 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15848 return Object.assign(() => {
15849 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
15850 }, [
15851 parent,
15852 key,
15853 value
15854 ]);
15855 return [parent?.[key], { onLoadedMetadataCapture }];
15856 }
15857 var hasInstalledGlobalEventListeners = false;
15858 function useIsMouseMoving() {
15859 (0, import_react12.useEffect)(() => {
15860 if (hasInstalledGlobalEventListeners) return;
15861 addGlobalEventListener("mousemove", setMouseMoving, true);
15862 addGlobalEventListener("mousedown", resetMouseMoving, true);
15863 addGlobalEventListener("mouseup", resetMouseMoving, true);
15864 addGlobalEventListener("keydown", resetMouseMoving, true);
15865 addGlobalEventListener("scroll", resetMouseMoving, true);
15866 hasInstalledGlobalEventListeners = true;
15867 }, []);
15868 return useEvent(() => mouseMoving);
15869 }
15870 var mouseMoving = false;
15871 var previousScreenX = 0;
15872 var previousScreenY = 0;
15873 function hasMouseMovement(event) {
15874 const movementX = event.movementX || event.screenX - previousScreenX;
15875 const movementY = event.movementY || event.screenY - previousScreenY;
15876 previousScreenX = event.screenX;
15877 previousScreenY = event.screenY;
15878 return movementX || movementY || false;
15879 }
15880 function setMouseMoving(event) {
15881 if (!hasMouseMovement(event)) return;
15882 mouseMoving = true;
15883 }
15884 function resetMouseMoving() {
15885 mouseMoving = false;
15886 }
15887 function forwardRef29(render4) {
15888 const Role = React47.forwardRef((props, ref) => render4({
15889 ...props,
15890 ref
15891 }));
15892 Role.displayName = render4.displayName || render4.name;
15893 return Role;
15894 }
15895 function memo3(Component, propsAreEqual) {
15896 return React47.memo(Component, propsAreEqual);
15897 }
15898 function createElement3(Type, props) {
15899 const { wrapElement, render: render4, ...rest } = props;
15900 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15901 let element;
15902 if (React47.isValidElement(render4)) {
15903 const renderProps = {
15904 ...render4.props,
15905 ref: mergedRef
15906 };
15907 element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
15908 } else if (render4) element = render4(rest);
15909 else element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
15910 if (wrapElement) return wrapElement(element);
15911 return element;
15912 }
15913 function createHook(useProps) {
15914 const useRole = (props = {}) => {
15915 return useProps(props);
15916 };
15917 useRole.displayName = useProps.name;
15918 return useRole;
15919 }
15920 function createStoreContext(providers = [], scopedProviders = []) {
15921 const context = React47.createContext(void 0);
15922 const scopedContext = React47.createContext(void 0);
15923 const useContext38 = () => React47.useContext(context);
15924 const useScopedContext = (onlyScoped = false) => {
15925 const scoped = React47.useContext(scopedContext);
15926 const store = useContext38();
15927 if (onlyScoped) return scoped;
15928 return scoped || store;
15929 };
15930 const useProviderContext = () => {
15931 const scoped = React47.useContext(scopedContext);
15932 const store = useContext38();
15933 if (scoped && scoped === store) return;
15934 return store;
15935 };
15936 const ContextProvider = (props) => {
15937 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
15938 ...props,
15939 children
15940 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props }));
15941 };
15942 const ScopedContextProvider = (props) => {
15943 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, {
15944 ...props,
15945 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
15946 ...props,
15947 children
15948 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props }))
15949 });
15950 };
15951 return {
15952 context,
15953 scopedContext,
15954 useContext: useContext38,
15955 useScopedContext,
15956 useProviderContext,
15957 ContextProvider,
15958 ScopedContextProvider
15959 };
15960 }
15961
15962 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
15963 var import_react13 = __toESM(require_react(), 1);
15964 var TagName = "div";
15965 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
15966 var isSafariBrowser = isSafari2();
15967 var alwaysFocusVisibleInputTypes = [
15968 "text",
15969 "search",
15970 "url",
15971 "tel",
15972 "email",
15973 "password",
15974 "number",
15975 "date",
15976 "month",
15977 "week",
15978 "time",
15979 "datetime",
15980 "datetime-local"
15981 ];
15982 function isAlwaysFocusVisible(element) {
15983 const { tagName, readOnly, type } = element;
15984 if (tagName === "TEXTAREA" && !readOnly) return true;
15985 if (tagName === "SELECT" && !readOnly) return true;
15986 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
15987 if (element.isContentEditable) return true;
15988 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
15989 return false;
15990 }
15991 function isNativeTabbable(tagName) {
15992 if (!tagName) return true;
15993 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15994 }
15995 function supportsDisabledAttribute(tagName) {
15996 if (!tagName) return true;
15997 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15998 }
15999 var buttonInputTypes2 = [
16000 "button",
16001 "color",
16002 "file",
16003 "image",
16004 "reset",
16005 "submit"
16006 ];
16007 function needsSafariTabIndex(tagName, inputType) {
16008 if (tagName === "button") return true;
16009 if (tagName === "input" && inputType) {
16010 if (inputType === "checkbox" || inputType === "radio") return true;
16011 return buttonInputTypes2.includes(inputType);
16012 }
16013 return false;
16014 }
16015 function isNativeSubmitControl(element) {
16016 if (element.tagName === "BUTTON") {
16017 const { type } = element;
16018 return type === "submit";
16019 }
16020 if (element.tagName === "INPUT") {
16021 const { type } = element;
16022 return type === "submit" || type === "image";
16023 }
16024 return false;
16025 }
16026 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16027 if (!focusable2) return tabIndexProp;
16028 if (trulyDisabled) {
16029 if (nativeTabbable && !supportsDisabled) return -1;
16030 return;
16031 }
16032 if (nativeTabbable) {
16033 if (safariTabIndex && tabIndexProp == null) return 0;
16034 return tabIndexProp;
16035 }
16036 return tabIndexProp ?? 0;
16037 }
16038 function useDisableEvent(onEvent, disabled2) {
16039 return useEvent((event) => {
16040 onEvent?.(event);
16041 if (event.defaultPrevented) return;
16042 if (disabled2) {
16043 event.stopPropagation();
16044 event.preventDefault();
16045 }
16046 });
16047 }
16048 var hasInstalledGlobalEventListeners2 = false;
16049 var isKeyboardModality = true;
16050 function onGlobalMouseDown(event) {
16051 const target = event.target;
16052 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16053 }
16054 function onGlobalKeyDown(event) {
16055 if (event.metaKey) return;
16056 if (event.ctrlKey) return;
16057 if (event.altKey) return;
16058 isKeyboardModality = true;
16059 }
16060 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16061 const ref = (0, import_react13.useRef)(null);
16062 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16063 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16064 (0, import_react13.useEffect)(() => {
16065 if (!focusable2) return;
16066 if (hasInstalledGlobalEventListeners2) return;
16067 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16068 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16069 hasInstalledGlobalEventListeners2 = true;
16070 }, [focusable2]);
16071 const disabled2 = focusable2 && disabledFromProps(props);
16072 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16073 const [focusVisible, setFocusVisible] = (0, import_react13.useState)(false);
16074 const focusVisibleRef = (0, import_react13.useRef)(false);
16075 const nativeSubmitObserverCleanupRef = (0, import_react13.useRef)(null);
16076 const cleanupFocusVisible = useEvent((element) => {
16077 nativeSubmitObserverCleanupRef.current?.();
16078 nativeSubmitObserverCleanupRef.current = null;
16079 focusVisibleRef.current = false;
16080 element?.removeAttribute("data-focus-visible");
16081 });
16082 (0, import_react13.useEffect)(() => {
16083 if (!focusable2) return;
16084 if (!trulyDisabled) return;
16085 cleanupFocusVisible(ref.current);
16086 if (focusVisible) setFocusVisible(false);
16087 }, [
16088 focusable2,
16089 trulyDisabled,
16090 focusVisible,
16091 cleanupFocusVisible
16092 ]);
16093 (0, import_react13.useEffect)(() => {
16094 if (!focusable2) return;
16095 if (!focusVisible) return;
16096 const element = ref.current;
16097 if (!element) return;
16098 if (typeof IntersectionObserver === "undefined") return;
16099 const observer = new IntersectionObserver(() => {
16100 if (!isFocusable(element)) {
16101 focusVisibleRef.current = false;
16102 setFocusVisible(false);
16103 }
16104 });
16105 observer.observe(element);
16106 return () => observer.disconnect();
16107 }, [focusable2, focusVisible]);
16108 (0, import_react13.useEffect)(() => {
16109 return () => nativeSubmitObserverCleanupRef.current?.();
16110 }, []);
16111 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16112 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16113 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16114 const handleFocusVisible = (event, currentTarget) => {
16115 if (currentTarget) event.currentTarget = currentTarget;
16116 if (!focusable2) return;
16117 const element = event.currentTarget;
16118 if (!element) return;
16119 if (!hasFocus(element)) return;
16120 onFocusVisible?.(event);
16121 if (event.defaultPrevented) return;
16122 element.dataset.focusVisible = "true";
16123 focusVisibleRef.current = true;
16124 if (isNativeSubmitControl(element)) {
16125 nativeSubmitObserverCleanupRef.current?.();
16126 nativeSubmitObserverCleanupRef.current = null;
16127 if (typeof IntersectionObserver !== "undefined") {
16128 const observer = new IntersectionObserver(() => {
16129 if (isFocusable(element)) return;
16130 cleanupFocusVisible(element);
16131 });
16132 observer.observe(element);
16133 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16134 }
16135 return;
16136 }
16137 setFocusVisible(true);
16138 };
16139 const onKeyDownCaptureProp = props.onKeyDownCapture;
16140 const onKeyDownCapture = useEvent((event) => {
16141 onKeyDownCaptureProp?.(event);
16142 if (event.defaultPrevented) return;
16143 if (!focusable2) return;
16144 if (focusVisible) return;
16145 if (focusVisibleRef.current) return;
16146 if (event.metaKey) return;
16147 if (event.altKey) return;
16148 if (event.ctrlKey) return;
16149 if (!isSelfTarget(event)) return;
16150 const element = event.currentTarget;
16151 const applyFocusVisible = () => handleFocusVisible(event, element);
16152 queueBeforeEvent(element, "focusout", applyFocusVisible);
16153 });
16154 const onFocusCaptureProp = props.onFocusCapture;
16155 const onFocusCapture = useEvent((event) => {
16156 onFocusCaptureProp?.(event);
16157 if (event.defaultPrevented) return;
16158 if (!focusable2) return;
16159 if (!isSelfTarget(event)) {
16160 setFocusVisible(false);
16161 return;
16162 }
16163 const element = event.currentTarget;
16164 const applyFocusVisible = () => handleFocusVisible(event, element);
16165 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16166 else setFocusVisible(false);
16167 });
16168 const onBlurProp = props.onBlur;
16169 const onBlur = useEvent((event) => {
16170 onBlurProp?.(event);
16171 if (!focusable2) return;
16172 if (!isFocusEventOutside(event)) return;
16173 cleanupFocusVisible(event.currentTarget);
16174 setFocusVisible(false);
16175 });
16176 const autoFocusOnShow = (0, import_react13.useContext)(FocusableContext);
16177 const autoFocusRef = useEvent((element) => {
16178 if (!focusable2) return;
16179 if (!autoFocus) return;
16180 if (!element) return;
16181 if (!autoFocusOnShow) return;
16182 queueMicrotask(() => {
16183 if (hasFocus(element)) return;
16184 if (!isFocusable(element)) return;
16185 element.focus();
16186 });
16187 });
16188 const tagName = useTagName(ref);
16189 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16190 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16191 const [safariTabIndex, setSafariTabIndex] = (0, import_react13.useState)(false);
16192 if (isSafariBrowser) (0, import_react13.useEffect)(() => {
16193 if (!focusable2) return;
16194 const element = ref.current;
16195 if (!element) return;
16196 const tag = element.tagName.toLowerCase();
16197 const type = element.type;
16198 setSafariTabIndex(needsSafariTabIndex(tag, type));
16199 }, [focusable2]);
16200 const styleProp = props.style;
16201 const style = (0, import_react13.useMemo)(() => {
16202 if (trulyDisabled) return {
16203 pointerEvents: "none",
16204 ...styleProp
16205 };
16206 return styleProp;
16207 }, [trulyDisabled, styleProp]);
16208 props = {
16209 "data-focus-visible": focusable2 && focusVisible || void 0,
16210 "data-autofocus": autoFocus || void 0,
16211 "aria-disabled": disabled2 || void 0,
16212 ...props,
16213 ...metadataProps,
16214 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16215 style,
16216 tabIndex: getTabIndex2({
16217 focusable: focusable2,
16218 trulyDisabled,
16219 nativeTabbable,
16220 supportsDisabled,
16221 safariTabIndex,
16222 tabIndexProp: props.tabIndex
16223 }),
16224 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16225 contentEditable: disabled2 ? void 0 : props.contentEditable,
16226 onKeyPressCapture,
16227 onClickCapture,
16228 onMouseDownCapture,
16229 onKeyDownCapture,
16230 onFocusCapture,
16231 onBlur
16232 };
16233 return removeUndefinedValues(props);
16234 });
16235 var Focusable = forwardRef29(function Focusable2(props) {
16236 return createElement3(TagName, useFocusable(props));
16237 });
16238
16239 // node_modules/@ariakit/react-components/dist/command/command.js
16240 var import_react14 = __toESM(require_react(), 1);
16241 var TagName2 = "button";
16242 function isNativeClick(event) {
16243 if (!event.isTrusted) return false;
16244 const element = event.currentTarget;
16245 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16246 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16247 return false;
16248 }
16249 var symbol = /* @__PURE__ */ Symbol("command");
16250 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16251 const ref = (0, import_react14.useRef)(null);
16252 const [isNativeButton, setIsNativeButton] = (0, import_react14.useState)(false);
16253 (0, import_react14.useEffect)(() => {
16254 if (!ref.current) return;
16255 setIsNativeButton(isButton(ref.current));
16256 }, []);
16257 const [active, setActive] = (0, import_react14.useState)(false);
16258 const activeRef = (0, import_react14.useRef)(false);
16259 const disabled2 = disabledFromProps(props);
16260 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16261 const onKeyDownProp = props.onKeyDown;
16262 const onKeyDown = useEvent((event) => {
16263 onKeyDownProp?.(event);
16264 const element = event.currentTarget;
16265 if (event.defaultPrevented) return;
16266 if (isDuplicate) return;
16267 if (disabled2) return;
16268 if (!isSelfTarget(event)) return;
16269 if (isTextField(element)) return;
16270 if (element.isContentEditable) return;
16271 const isEnter = clickOnEnter && event.key === "Enter";
16272 const isSpace = clickOnSpace && event.key === " ";
16273 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16274 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16275 if (shouldPreventEnter || shouldPreventSpace) {
16276 event.preventDefault();
16277 return;
16278 }
16279 if (isEnter || isSpace) {
16280 const nativeClick = isNativeClick(event);
16281 if (isEnter) {
16282 if (!nativeClick) {
16283 event.preventDefault();
16284 const { view, ...eventInit } = event;
16285 const click = () => fireClickEvent(element, eventInit);
16286 if (isFirefox2()) queueBeforeEvent(element, "keyup", click);
16287 else queueMicrotask(click);
16288 }
16289 } else if (isSpace) {
16290 activeRef.current = true;
16291 if (!nativeClick) {
16292 event.preventDefault();
16293 setActive(true);
16294 }
16295 }
16296 }
16297 });
16298 const onKeyUpProp = props.onKeyUp;
16299 const onKeyUp = useEvent((event) => {
16300 onKeyUpProp?.(event);
16301 if (event.defaultPrevented) return;
16302 if (isDuplicate) return;
16303 if (disabled2) return;
16304 if (event.metaKey) return;
16305 const isSpace = clickOnSpace && event.key === " ";
16306 if (activeRef.current && isSpace) {
16307 activeRef.current = false;
16308 if (!isNativeClick(event)) {
16309 event.preventDefault();
16310 setActive(false);
16311 const element = event.currentTarget;
16312 const { view, ...eventInit } = event;
16313 queueMicrotask(() => fireClickEvent(element, eventInit));
16314 }
16315 }
16316 });
16317 props = {
16318 "data-active": active || void 0,
16319 type: isNativeButton ? "button" : void 0,
16320 ...metadataProps,
16321 ...props,
16322 ref: useMergeRefs(ref, props.ref),
16323 onKeyDown,
16324 onKeyUp
16325 };
16326 props = useFocusable(props);
16327 return props;
16328 });
16329 var Command = forwardRef29(function Command2(props) {
16330 return createElement3(TagName2, useCommand(props));
16331 });
16332
16333 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16334 var ctx = createStoreContext();
16335 var useCollectionContext = ctx.useContext;
16336 var useCollectionScopedContext = ctx.useScopedContext;
16337 var useCollectionProviderContext = ctx.useProviderContext;
16338 var CollectionContextProvider = ctx.ContextProvider;
16339 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16340
16341 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16342 var import_react15 = __toESM(require_react(), 1);
16343 var TagName3 = "div";
16344 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16345 const context = useCollectionContext();
16346 store = store || context;
16347 const id = useId4(props.id);
16348 const ref = (0, import_react15.useRef)(element);
16349 (0, import_react15.useEffect)(() => {
16350 const element2 = ref.current;
16351 if (!id) return;
16352 if (!element2) return;
16353 if (!shouldRegisterItem) return;
16354 const item = getItem({
16355 id,
16356 element: element2
16357 });
16358 return store?.renderItem(item);
16359 }, [
16360 id,
16361 shouldRegisterItem,
16362 getItem,
16363 store
16364 ]);
16365 props = {
16366 ...props,
16367 ref: useMergeRefs(ref, props.ref)
16368 };
16369 return removeUndefinedValues(props);
16370 });
16371 var CollectionItem = forwardRef29(function CollectionItem2(props) {
16372 return createElement3(TagName3, useCollectionItem(props));
16373 });
16374
16375 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16376 var import_react16 = __toESM(require_react(), 1);
16377 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16378 var useCompositeContext = ctx2.useContext;
16379 var useCompositeScopedContext = ctx2.useScopedContext;
16380 var useCompositeProviderContext = ctx2.useProviderContext;
16381 var CompositeContextProvider = ctx2.ContextProvider;
16382 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16383 var CompositeItemContext = (0, import_react16.createContext)(void 0);
16384 var CompositeRowContext = (0, import_react16.createContext)(void 0);
16385
16386 // node_modules/@ariakit/react-components/dist/composite/utils.js
16387 function findFirstEnabledItem(items, excludeId) {
16388 return items.find((item) => {
16389 if (excludeId) return !item.disabled && item.id !== excludeId;
16390 return !item.disabled;
16391 });
16392 }
16393 function getEnabledItem(store, id) {
16394 if (!id) return null;
16395 return store.item(id) || null;
16396 }
16397 function groupItemsByRows(items) {
16398 const rows = [];
16399 for (const item of items) {
16400 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
16401 if (row) row.push(item);
16402 else rows.push([item]);
16403 }
16404 return rows;
16405 }
16406 function selectTextField(element, collapseToEnd = false) {
16407 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
16408 else if (element.isContentEditable) {
16409 const selection = getDocument(element).getSelection();
16410 selection?.selectAllChildren(element);
16411 if (collapseToEnd) selection?.collapseToEnd();
16412 }
16413 }
16414 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
16415 function focusSilently(element) {
16416 element[FOCUS_SILENTLY] = true;
16417 element.focus({ preventScroll: true });
16418 }
16419 function silentlyFocused(element) {
16420 const isSilentlyFocused = element[FOCUS_SILENTLY];
16421 delete element[FOCUS_SILENTLY];
16422 return isSilentlyFocused;
16423 }
16424 function isItem(store, element, exclude) {
16425 if (!element) return false;
16426 if (element === exclude) return false;
16427 const item = store.item(element.id);
16428 if (!item) return false;
16429 if (exclude && item.element === exclude) return false;
16430 return true;
16431 }
16432
16433 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
16434 var import_react17 = __toESM(require_react(), 1);
16435 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
16436
16437 // node_modules/@ariakit/store/dist/index.js
16438 function getInternal(store, key) {
16439 const internals = store.__unstableInternals;
16440 invariant(internals, "Invalid store");
16441 return internals[key];
16442 }
16443 function hasUpdatedKey(keys, updatedKey) {
16444 if (!keys) return true;
16445 for (const currentKey of keys) if (updatedKey instanceof Set) {
16446 if (updatedKey.has(currentKey)) return true;
16447 } else if (currentKey === updatedKey) return true;
16448 return false;
16449 }
16450 function addKeyedListener(map, keys, listener) {
16451 if (!keys) return;
16452 for (const key of keys) {
16453 let listeners = map.get(key);
16454 if (!listeners) {
16455 listeners = /* @__PURE__ */ new Set();
16456 map.set(key, listeners);
16457 }
16458 listeners.add(listener);
16459 }
16460 }
16461 function deleteKeyedListener(map, keys, listener) {
16462 if (!map) return;
16463 if (!keys) return;
16464 for (const key of keys) {
16465 const listeners = map.get(key);
16466 if (!listeners) continue;
16467 listeners.delete(listener);
16468 if (!listeners.size) map.delete(key);
16469 }
16470 }
16471 function createStore(initialState, ...stores) {
16472 let state = initialState;
16473 let prevStateBatch = state;
16474 let destroy = noop4;
16475 let batchPending = false;
16476 let inDispatch = false;
16477 let updatedKeys = /* @__PURE__ */ new Set();
16478 const instances = /* @__PURE__ */ new Set();
16479 const setups = /* @__PURE__ */ new Set();
16480 const syncListenerGroup = {
16481 listeners: /* @__PURE__ */ new Set(),
16482 disposables: /* @__PURE__ */ new Map(),
16483 listenerKeys: /* @__PURE__ */ new WeakMap()
16484 };
16485 const batchListenerGroup = {
16486 listeners: /* @__PURE__ */ new Set(),
16487 disposables: /* @__PURE__ */ new Map(),
16488 listenerKeys: /* @__PURE__ */ new WeakMap()
16489 };
16490 const storeSetup = (callback) => {
16491 setups.add(callback);
16492 return () => setups.delete(callback);
16493 };
16494 const storeInit = () => {
16495 const initializedInstances = instances.size;
16496 const instance = /* @__PURE__ */ Symbol();
16497 instances.add(instance);
16498 const maybeDestroy = () => {
16499 instances.delete(instance);
16500 if (instances.size) return;
16501 destroy();
16502 };
16503 if (initializedInstances) return maybeDestroy;
16504 const stateKeys = getKeys(state);
16505 const desyncs = [];
16506 for (const store of stores) {
16507 const storeState = store?.getState?.();
16508 if (!storeState) continue;
16509 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16510 if (!keys.length) continue;
16511 if (stores.length === 1 || keys.length === stateKeys.length) {
16512 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16513 setState(key, state2[key], true);
16514 }));
16515 continue;
16516 }
16517 let didSyncInitialState = false;
16518 desyncs.push(sync(store, keys, (state2, prevState) => {
16519 for (const key of keys) {
16520 if (didSyncInitialState && state2[key] === prevState[key]) continue;
16521 setState(key, state2[key], true);
16522 }
16523 didSyncInitialState = true;
16524 }));
16525 }
16526 const teardowns = [];
16527 for (const setup2 of setups) teardowns.push(setup2());
16528 const cleanups = stores.map(init);
16529 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16530 return maybeDestroy;
16531 };
16532 const deleteListenerIndexes = (group, listener, keys) => {
16533 if (keys === void 0) return;
16534 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16535 else group.allKeysListeners?.delete(listener);
16536 };
16537 const registerListener = (keys, listener, group = syncListenerGroup) => {
16538 const listenerKeysValue = keys ? [...keys] : null;
16539 if (group.listeners.has(listener)) deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16540 group.listeners.add(listener);
16541 if (listenerKeysValue) {
16542 group.listenersByKey ??= /* @__PURE__ */ new Map();
16543 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16544 } else {
16545 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16546 group.allKeysListeners.add(listener);
16547 }
16548 group.listenerKeys.set(listener, listenerKeysValue);
16549 return () => {
16550 group.disposables.get(listener)?.();
16551 group.disposables.delete(listener);
16552 const currentKeys = group.listenerKeys.get(listener);
16553 deleteListenerIndexes(group, listener, listenerKeysValue);
16554 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16555 group.listenerKeys.delete(listener);
16556 group.listeners.delete(listener);
16557 };
16558 };
16559 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16560 const reconcileInitialCleanup = (group, listener, cleanup) => {
16561 if (cleanup) group.disposables.set(listener, cleanup);
16562 else group.disposables.delete(listener);
16563 };
16564 const storeSync = (keys, listener) => {
16565 reconcileInitialCleanup(syncListenerGroup, listener, listener(state, state));
16566 return registerListener(keys, listener);
16567 };
16568 const storeBatch = (keys, listener) => {
16569 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
16570 reconcileInitialCleanup(batchListenerGroup, listener, listener(state, prevStateBatch));
16571 return registerListener(keys, listener, batchListenerGroup);
16572 };
16573 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16574 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16575 const getState = () => state;
16576 const runListeners = (group, prevState, updatedKey) => {
16577 const { disposables } = group;
16578 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
16579 const keyedListeners = group.listenersByKey?.get(updatedKey);
16580 if (!keyedListeners) return;
16581 for (const listener of keyedListeners) {
16582 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16583 if (cleanup) cleanup();
16584 const result = listener(state, prevState);
16585 if (result) disposables.set(listener, result);
16586 else if (cleanup) disposables.delete(listener);
16587 }
16588 return;
16589 }
16590 const allKeysListeners = group.allKeysListeners;
16591 for (const listener of group.listeners) {
16592 if (!allKeysListeners?.has(listener)) {
16593 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16594 }
16595 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16596 if (cleanup) cleanup();
16597 const result = listener(state, prevState);
16598 if (result) disposables.set(listener, result);
16599 else if (cleanup) disposables.delete(listener);
16600 }
16601 };
16602 const setState = (key, value, fromStores = false) => {
16603 if (!hasOwnProperty(state, key)) return;
16604 const currentValue = state[key];
16605 const nextValue = typeof value === "function" ? value(currentValue) : value;
16606 if (nextValue === currentValue) return;
16607 if (!fromStores && stores.length) for (const store of stores) store?.setState?.(key, nextValue);
16608 const prevState = state;
16609 state = {
16610 ...state,
16611 [key]: nextValue
16612 };
16613 const wasInDispatch = inDispatch;
16614 inDispatch = true;
16615 try {
16616 runListeners(syncListenerGroup, prevState, key);
16617 } finally {
16618 inDispatch = wasInDispatch;
16619 }
16620 if (!batchListenerGroup.listeners.size) {
16621 if (!inDispatch) prevStateBatch = state;
16622 return;
16623 }
16624 updatedKeys.add(key);
16625 if (batchPending) return;
16626 batchPending = true;
16627 queueMicrotask(() => {
16628 batchPending = false;
16629 const snapshot = state;
16630 const updatedKeysSnapshot = updatedKeys;
16631 updatedKeys = /* @__PURE__ */ new Set();
16632 const prevStateBatchBefore = prevStateBatch;
16633 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
16634 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
16635 });
16636 };
16637 const finalStore = {
16638 getState,
16639 setState,
16640 __unstableInternals: {
16641 setup: storeSetup,
16642 init: storeInit,
16643 subscribe: storeSubscribe,
16644 sync: storeSync,
16645 batch: storeBatch,
16646 pick: storePick,
16647 omit: storeOmit
16648 }
16649 };
16650 return finalStore;
16651 }
16652 function setup(store, ...args) {
16653 if (!store) return;
16654 return getInternal(store, "setup")(...args);
16655 }
16656 function init(store, ...args) {
16657 if (!store) return;
16658 return getInternal(store, "init")(...args);
16659 }
16660 function subscribe(store, ...args) {
16661 if (!store) return;
16662 return getInternal(store, "subscribe")(...args);
16663 }
16664 function sync(store, ...args) {
16665 if (!store) return;
16666 return getInternal(store, "sync")(...args);
16667 }
16668 function batch(store, ...args) {
16669 if (!store) return;
16670 return getInternal(store, "batch")(...args);
16671 }
16672 function omit2(store, ...args) {
16673 if (!store) return;
16674 return getInternal(store, "omit")(...args);
16675 }
16676 function pick2(store, ...args) {
16677 if (!store) return;
16678 return getInternal(store, "pick")(...args);
16679 }
16680 function mergeStore(...stores) {
16681 const initialState = {};
16682 for (const store2 of stores) {
16683 const nextState = store2?.getState?.();
16684 if (nextState) Object.assign(initialState, nextState);
16685 }
16686 const store = createStore(initialState, ...stores);
16687 return Object.assign({}, ...stores, store);
16688 }
16689 function throwOnConflictingProps(props, store) {
16690 if (false) return;
16691 if (!store) return;
16692 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16693 const stateKey = key.replace("default", "");
16694 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
16695 });
16696 if (!defaultKeys.length) return;
16697 const storeState = store.getState();
16698 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
16699 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
16700
16701 const store = useSelectStore();
16702 <SelectProvider store={store} defaultValue="Apple" />
16703 ^ ^
16704
16705 Instead, pass the default state to the topmost store:
16706
16707 const store = useSelectStore({ defaultValue: "Apple" });
16708 <SelectProvider store={store} />
16709
16710 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16711
16712 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16713 `);
16714 }
16715
16716 // node_modules/@ariakit/react-store/dist/index.js
16717 var React48 = __toESM(require_react(), 1);
16718 var import_shim2 = __toESM(require_shim(), 1);
16719 var noopSubscribe = () => () => {
16720 };
16721 function useStoreState(store, keyOrSelector = identity) {
16722 const storeSubscribe = React48.useCallback((callback) => {
16723 if (!store) return noopSubscribe();
16724 return subscribe(store, null, callback);
16725 }, [store]);
16726 const getSnapshot = () => {
16727 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16728 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16729 const state = store?.getState();
16730 if (selector2) return selector2(state);
16731 if (!state) return;
16732 if (!key) return;
16733 if (!hasOwnProperty(state, key)) return;
16734 return state[key];
16735 };
16736 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16737 }
16738 function useStoreStateObject(store, object) {
16739 const objRef = React48.useRef({});
16740 const storeSubscribe = React48.useCallback((callback) => {
16741 if (!store) return noopSubscribe();
16742 return subscribe(store, null, callback);
16743 }, [store]);
16744 const getSnapshot = () => {
16745 const state = store?.getState();
16746 let updated = false;
16747 const obj = objRef.current;
16748 for (const prop in object) {
16749 const keyOrSelector = object[prop];
16750 if (typeof keyOrSelector === "function") {
16751 const value = keyOrSelector(state);
16752 if (value !== obj[prop]) {
16753 obj[prop] = value;
16754 updated = true;
16755 }
16756 }
16757 if (typeof keyOrSelector === "string") {
16758 if (!state) continue;
16759 if (!hasOwnProperty(state, keyOrSelector)) continue;
16760 const value = state[keyOrSelector];
16761 if (value !== obj[prop]) {
16762 obj[prop] = value;
16763 updated = true;
16764 }
16765 }
16766 }
16767 if (updated) objRef.current = { ...obj };
16768 return objRef.current;
16769 };
16770 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
16771 }
16772 function useStoreProps(store, props, key, setKey) {
16773 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16774 const propsRef = useLiveRef({
16775 value,
16776 setValue: setKey ? props[setKey] : void 0
16777 });
16778 useSafeLayoutEffect(() => {
16779 return sync(store, [key], (state, prev) => {
16780 const { value: value2, setValue } = propsRef.current;
16781 if (!setValue) return;
16782 if (state[key] === prev[key]) return;
16783 if (state[key] === value2) return;
16784 setValue(state[key]);
16785 });
16786 }, [store, key]);
16787 useSafeLayoutEffect(() => {
16788 if (value === void 0) return;
16789 store.setState(key, value);
16790 return batch(store, [key], () => {
16791 if (value === void 0) return;
16792 store.setState(key, value);
16793 });
16794 });
16795 }
16796 function useStore2(createStore2, props) {
16797 const [store, setStore] = React48.useState(() => createStore2(props));
16798 useSafeLayoutEffect(() => init(store), [store]);
16799 const useState36 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
16800 return [React48.useMemo(() => ({
16801 ...store,
16802 useState: useState36
16803 }), [store, useState36]), useEvent(() => {
16804 setStore((store2) => createStore2({
16805 ...props,
16806 ...store2.getState()
16807 }));
16808 })];
16809 }
16810
16811 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
16812 var TagName4 = "button";
16813 function isEditableElement(element) {
16814 if (isTextbox(element)) return true;
16815 return element.tagName === "INPUT" && !isButton(element);
16816 }
16817 function getNextPageOffset(scrollingElement, pageUp = false) {
16818 const height = scrollingElement.clientHeight;
16819 const { top } = scrollingElement.getBoundingClientRect();
16820 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16821 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16822 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
16823 return pageOffset;
16824 }
16825 function getItemOffset(itemElement, pageUp = false) {
16826 const { top } = itemElement.getBoundingClientRect();
16827 if (pageUp) return top + itemElement.clientHeight;
16828 return top;
16829 }
16830 function findNextPageItemId(element, store, next, pageUp = false) {
16831 if (!store) return;
16832 if (!next) return;
16833 const { renderedItems } = store.getState();
16834 const scrollingElement = getScrollingElement(element);
16835 if (!scrollingElement) return;
16836 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16837 let id;
16838 let prevDifference;
16839 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16840 const previousId = id;
16841 id = next(i2);
16842 if (!id) break;
16843 if (id === previousId) continue;
16844 const itemElement = getEnabledItem(store, id)?.element;
16845 if (!itemElement) continue;
16846 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
16847 const absDifference = Math.abs(difference);
16848 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16849 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
16850 break;
16851 }
16852 prevDifference = absDifference;
16853 }
16854 return id;
16855 }
16856 function targetIsAnotherItem(event, store) {
16857 if (isSelfTarget(event)) return false;
16858 return isItem(store, event.target);
16859 }
16860 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
16861 const context = useCompositeScopedContext();
16862 store = store || context;
16863 const id = useId4(props.id);
16864 const ref = (0, import_react17.useRef)(null);
16865 const row = (0, import_react17.useContext)(CompositeRowContext);
16866 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
16867 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
16868 rowId(state) {
16869 if (rowIdProp) return rowIdProp;
16870 if (!state) return;
16871 if (!row?.baseElement) return;
16872 if (row.baseElement !== state.baseElement) return;
16873 return row.id;
16874 },
16875 baseElement(state) {
16876 return state?.baseElement || void 0;
16877 },
16878 isActiveItem(state) {
16879 return !!state && state.activeId === id;
16880 },
16881 ariaSetSize(state) {
16882 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16883 if (!state) return;
16884 if (!row?.ariaSetSize) return;
16885 if (row.baseElement !== state.baseElement) return;
16886 return row.ariaSetSize;
16887 },
16888 ariaPosInSet(state) {
16889 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16890 if (!state) return;
16891 if (!row?.ariaPosInSet) return;
16892 if (row.baseElement !== state.baseElement) return;
16893 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId);
16894 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16895 },
16896 isTabbable(state) {
16897 if (!state?.renderedItems.length) return true;
16898 if (state.virtualFocus) return false;
16899 if (tabbable2) return true;
16900 if (state.activeId === null) return false;
16901 const item = store?.item(state.activeId);
16902 if (item?.disabled) return true;
16903 if (!item?.element) return true;
16904 return state.activeId === id;
16905 }
16906 });
16907 const getItem = (0, import_react17.useCallback)((item) => {
16908 const nextItem = {
16909 ...item,
16910 id: id || item.id,
16911 rowId,
16912 disabled: trulyDisabled,
16913 children: item.element?.textContent
16914 };
16915 if (getItemProp) return getItemProp(nextItem);
16916 return nextItem;
16917 }, [
16918 id,
16919 rowId,
16920 trulyDisabled,
16921 getItemProp
16922 ]);
16923 const onFocusProp = props.onFocus;
16924 const hasFocusedComposite = (0, import_react17.useRef)(false);
16925 const onFocus = useEvent((event) => {
16926 onFocusProp?.(event);
16927 if (event.defaultPrevented) return;
16928 if (isPortalEvent(event)) return;
16929 if (!id) return;
16930 if (!store) return;
16931 if (targetIsAnotherItem(event, store)) return;
16932 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16933 store.setActiveId(id);
16934 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
16935 if (!virtualFocus) return;
16936 if (!isSelfTarget(event)) return;
16937 if (isEditableElement(event.currentTarget)) return;
16938 if (!baseElement2?.isConnected) return;
16939 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) event.currentTarget.scrollIntoView({
16940 block: "nearest",
16941 inline: "nearest"
16942 });
16943 hasFocusedComposite.current = true;
16944 if (event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget)) focusSilently(baseElement2);
16945 else baseElement2.focus();
16946 });
16947 const onBlurCaptureProp = props.onBlurCapture;
16948 const onBlurCapture = useEvent((event) => {
16949 onBlurCaptureProp?.(event);
16950 if (event.defaultPrevented) return;
16951 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
16952 hasFocusedComposite.current = false;
16953 event.preventDefault();
16954 event.stopPropagation();
16955 }
16956 });
16957 const onKeyDownProp = props.onKeyDown;
16958 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16959 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16960 const onKeyDown = useEvent((event) => {
16961 onKeyDownProp?.(event);
16962 if (event.defaultPrevented) return;
16963 if (!isSelfTarget(event)) return;
16964 if (!store) return;
16965 const { currentTarget } = event;
16966 const state = store.getState();
16967 const isGrid2 = !!store.item(id)?.rowId;
16968 const isVertical = state.orientation !== "horizontal";
16969 const isHorizontal = state.orientation !== "vertical";
16970 const canHomeEnd = () => {
16971 if (isGrid2) return true;
16972 if (isHorizontal) return true;
16973 if (!state.baseElement) return true;
16974 if (!isTextField(state.baseElement)) return true;
16975 return false;
16976 };
16977 const action = {
16978 ArrowUp: (isGrid2 || isVertical) && store.up,
16979 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16980 ArrowDown: (isGrid2 || isVertical) && store.down,
16981 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16982 Home: () => {
16983 if (!canHomeEnd()) return;
16984 if (!isGrid2 || event.ctrlKey) return store?.first();
16985 return store?.previous(-1);
16986 },
16987 End: () => {
16988 if (!canHomeEnd()) return;
16989 if (!isGrid2 || event.ctrlKey) return store?.last();
16990 return store?.next(-1);
16991 },
16992 PageUp: () => {
16993 return findNextPageItemId(currentTarget, store, store?.up, true);
16994 },
16995 PageDown: () => {
16996 return findNextPageItemId(currentTarget, store, store?.down);
16997 }
16998 }[event.key];
16999 if (action) {
17000 if (isTextbox(currentTarget)) {
17001 const selection = getTextboxSelection(currentTarget);
17002 const isLeft = isHorizontal && event.key === "ArrowLeft";
17003 const isRight = isHorizontal && event.key === "ArrowRight";
17004 const isUp = isVertical && event.key === "ArrowUp";
17005 const isDown = isVertical && event.key === "ArrowDown";
17006 if (isRight || isDown) {
17007 const { length: valueLength } = getTextboxValue(currentTarget);
17008 if (selection.end !== valueLength) return;
17009 } else if ((isLeft || isUp) && selection.start !== 0) return;
17010 }
17011 const nextId = action();
17012 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17013 if (!moveOnKeyPressProp(event)) return;
17014 event.preventDefault();
17015 store.move(nextId);
17016 }
17017 }
17018 });
17019 const providerValue = (0, import_react17.useMemo)(() => ({
17020 id,
17021 baseElement
17022 }), [id, baseElement]);
17023 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, {
17024 value: providerValue,
17025 children: element
17026 }), [providerValue]);
17027 props = {
17028 "data-active-item": isActiveItem || void 0,
17029 ...props,
17030 id,
17031 ref: useMergeRefs(ref, props.ref),
17032 tabIndex: isTabbable ? props.tabIndex : -1,
17033 onFocus,
17034 onBlurCapture,
17035 onKeyDown
17036 };
17037 props = useCommand(props);
17038 props = useCollectionItem({
17039 store,
17040 ...props,
17041 getItem,
17042 shouldRegisterItem: id ? props.shouldRegisterItem : false
17043 });
17044 return removeUndefinedValues({
17045 ...props,
17046 "aria-setsize": ariaSetSize,
17047 "aria-posinset": ariaPosInSet
17048 });
17049 });
17050 var CompositeItem = memo3(forwardRef29(function CompositeItem2(props) {
17051 return createElement3(TagName4, useCompositeItem(props));
17052 }));
17053
17054 // node_modules/@ariakit/react-components/dist/composite/composite.js
17055 var import_react18 = __toESM(require_react(), 1);
17056 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17057 var TagName5 = "div";
17058 function isGrid(items) {
17059 return items.some((item) => !!item.rowId);
17060 }
17061 function isPrintableKey(event) {
17062 const target = event.target;
17063 if (target && !isTextField(target)) return false;
17064 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17065 }
17066 function isModifierKey(event) {
17067 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17068 }
17069 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17070 return useEvent((event) => {
17071 onKeyboardEvent?.(event);
17072 if (event.defaultPrevented) return;
17073 if (event.isPropagationStopped()) return;
17074 if (!isSelfTarget(event)) return;
17075 if (isModifierKey(event)) return;
17076 if (isPrintableKey(event)) return;
17077 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17078 if (!activeElement2) return;
17079 const { view, ...eventInit } = event;
17080 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17081 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17082 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17083 });
17084 }
17085 function findFirstEnabledItemInTheLastRow(items) {
17086 return findFirstEnabledItem(flatten2DArray(reverseArray(groupItemsByRows(items))));
17087 }
17088 function withBaseScrollPreserved(store, callback) {
17089 const { virtualFocus, baseElement } = store.getState();
17090 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17091 callback();
17092 return;
17093 }
17094 const savedScrollLeft = baseElement.scrollLeft;
17095 const savedScrollTop = baseElement.scrollTop;
17096 callback();
17097 baseElement.scrollLeft = savedScrollLeft;
17098 baseElement.scrollTop = savedScrollTop;
17099 }
17100 function useScheduleFocus(store) {
17101 const [scheduled, setScheduled] = (0, import_react18.useState)(false);
17102 const schedule = (0, import_react18.useCallback)(() => setScheduled(true), []);
17103 const activeItem = useStoreState(store, (state) => getEnabledItem(store, state.activeId));
17104 (0, import_react18.useEffect)(() => {
17105 const activeElement2 = activeItem?.element;
17106 if (!scheduled) return;
17107 if (!activeElement2) return;
17108 setScheduled(false);
17109 withBaseScrollPreserved(store, () => {
17110 activeElement2.focus({ preventScroll: true });
17111 });
17112 }, [
17113 store,
17114 activeItem,
17115 scheduled
17116 ]);
17117 return schedule;
17118 }
17119 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
17120 const context = useCompositeProviderContext();
17121 store = store || context;
17122 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
17123 const ref = (0, import_react18.useRef)(null);
17124 const previousElementRef = (0, import_react18.useRef)(null);
17125 const scheduleFocus = useScheduleFocus(store);
17126 const moves = useStoreState(store, "moves");
17127 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
17128 (0, import_react18.useEffect)(() => {
17129 if (!store) return;
17130 if (!moves) return;
17131 if (!composite) return;
17132 if (!focusOnMove) return;
17133 const { activeId: activeId2 } = store.getState();
17134 const itemElement = getEnabledItem(store, activeId2)?.element;
17135 if (!itemElement) return;
17136 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
17137 }, [
17138 store,
17139 moves,
17140 composite,
17141 focusOnMove
17142 ]);
17143 useSafeLayoutEffect(() => {
17144 if (!store) return;
17145 if (!moves) return;
17146 if (!composite) return;
17147 const { baseElement, activeId: activeId2 } = store.getState();
17148 if (!(activeId2 === null)) return;
17149 if (!baseElement) return;
17150 const previousElement = previousElementRef.current;
17151 previousElementRef.current = null;
17152 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
17153 if (!hasFocus(baseElement)) baseElement.focus();
17154 }, [
17155 store,
17156 moves,
17157 composite
17158 ]);
17159 const activeId = useStoreState(store, "activeId");
17160 const virtualFocus = useStoreState(store, "virtualFocus");
17161 useSafeLayoutEffect(() => {
17162 if (!store) return;
17163 if (!composite) return;
17164 if (!virtualFocus) return;
17165 const previousElement = previousElementRef.current;
17166 previousElementRef.current = null;
17167 if (!previousElement) return;
17168 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
17169 if (relatedTarget === previousElement) return;
17170 fireBlurEvent(previousElement, { relatedTarget });
17171 }, [
17172 store,
17173 activeId,
17174 virtualFocus,
17175 composite
17176 ]);
17177 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
17178 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
17179 const onFocusCaptureProp = props.onFocusCapture;
17180 const onFocusCapture = useEvent((event) => {
17181 onFocusCaptureProp?.(event);
17182 if (event.defaultPrevented) return;
17183 if (!store) return;
17184 const { virtualFocus: virtualFocus2 } = store.getState();
17185 if (!virtualFocus2) return;
17186 const previousActiveElement = event.relatedTarget;
17187 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17188 if (isSelfTarget(event) && isSilentlyFocused) {
17189 event.stopPropagation();
17190 previousElementRef.current = previousActiveElement;
17191 }
17192 });
17193 const onFocusProp = props.onFocus;
17194 const onFocus = useEvent((event) => {
17195 onFocusProp?.(event);
17196 if (event.defaultPrevented) return;
17197 if (!composite) return;
17198 if (!store) return;
17199 const { relatedTarget } = event;
17200 const { virtualFocus: virtualFocus2 } = store.getState();
17201 if (virtualFocus2) {
17202 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
17203 } else if (isSelfTarget(event)) store.setActiveId(null);
17204 });
17205 const onBlurCaptureProp = props.onBlurCapture;
17206 const onBlurCapture = useEvent((event) => {
17207 onBlurCaptureProp?.(event);
17208 if (event.defaultPrevented) return;
17209 if (!store) return;
17210 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17211 if (!virtualFocus2) return;
17212 const activeElement2 = getEnabledItem(store, activeId2)?.element;
17213 const nextActiveElement = event.relatedTarget;
17214 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17215 const previousElement = previousElementRef.current;
17216 previousElementRef.current = null;
17217 if (isSelfTarget(event) && nextActiveElementIsItem) {
17218 if (nextActiveElement === activeElement2) {
17219 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
17220 } else if (activeElement2) fireBlurEvent(activeElement2, event);
17221 else if (previousElement) fireBlurEvent(previousElement, event);
17222 event.stopPropagation();
17223 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
17224 });
17225 const onKeyDownProp = props.onKeyDown;
17226 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17227 const onKeyDown = useEvent((event) => {
17228 onKeyDownProp?.(event);
17229 if (event.nativeEvent.isComposing) return;
17230 if (event.defaultPrevented) return;
17231 if (!store) return;
17232 if (!isSelfTarget(event)) return;
17233 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
17234 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
17235 const isVertical = orientation !== "horizontal";
17236 const isHorizontal = orientation !== "vertical";
17237 const grid = isGrid(renderedItems);
17238 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
17239 const up = () => {
17240 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
17241 return store?.last();
17242 };
17243 const action = {
17244 ArrowUp: (grid || isVertical) && up,
17245 ArrowRight: (grid || isHorizontal) && store.first,
17246 ArrowDown: (grid || isVertical) && store.first,
17247 ArrowLeft: (grid || isHorizontal) && store.last,
17248 Home: store.first,
17249 End: store.last,
17250 PageUp: store.first,
17251 PageDown: store.last
17252 }[event.key];
17253 if (action) {
17254 const id = action();
17255 if (id !== void 0) {
17256 if (!moveOnKeyPressProp(event)) return;
17257 event.preventDefault();
17258 store.move(id);
17259 }
17260 }
17261 });
17262 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeScopedContextProvider, {
17263 value: store,
17264 children: element
17265 }), [store]);
17266 props = {
17267 "aria-activedescendant": useStoreState(store, (state) => {
17268 if (!store) return;
17269 if (!composite) return;
17270 if (!state.virtualFocus) return;
17271 return getEnabledItem(store, state.activeId)?.id;
17272 }),
17273 ...props,
17274 ref: useMergeRefs(ref, setBaseElement, props.ref),
17275 onKeyDownCapture,
17276 onKeyUpCapture,
17277 onFocusCapture,
17278 onFocus,
17279 onBlurCapture,
17280 onKeyDown
17281 };
17282 props = useFocusable({
17283 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
17284 ...props
17285 });
17286 return props;
17287 });
17288 var Composite6 = forwardRef29(function Composite7(props) {
17289 return createElement3(TagName5, useComposite(props));
17290 });
17291
17292 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
17293 var ctx3 = createStoreContext();
17294 var useDisclosureContext = ctx3.useContext;
17295 var useDisclosureScopedContext = ctx3.useScopedContext;
17296 var useDisclosureProviderContext = ctx3.useProviderContext;
17297 var DisclosureContextProvider = ctx3.ContextProvider;
17298 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17299
17300 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
17301 var import_react19 = __toESM(require_react(), 1);
17302 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
17303 var useDialogContext = ctx4.useContext;
17304 var useDialogScopedContext = ctx4.useScopedContext;
17305 var useDialogProviderContext = ctx4.useProviderContext;
17306 var DialogContextProvider = ctx4.ContextProvider;
17307 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17308 var DialogHeadingContext = (0, import_react19.createContext)(void 0);
17309 var DialogDescriptionContext = (0, import_react19.createContext)(void 0);
17310
17311 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
17312 var import_react20 = __toESM(require_react(), 1);
17313 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
17314 var import_react_dom4 = __toESM(require_react_dom(), 1);
17315 var TagName6 = "div";
17316 function afterTimeout(timeoutMs, cb) {
17317 const timeoutId = setTimeout(cb, timeoutMs);
17318 return () => clearTimeout(timeoutId);
17319 }
17320 function afterPaint(cb) {
17321 let raf = requestAnimationFrame(() => {
17322 raf = requestAnimationFrame(cb);
17323 });
17324 return () => cancelAnimationFrame(raf);
17325 }
17326 function parseCSSTime(...times) {
17327 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17328 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17329 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17330 if (currentTime > longestTime) return currentTime;
17331 return longestTime;
17332 }, 0);
17333 }
17334 function isHidden(mounted, hidden, alwaysVisible) {
17335 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17336 }
17337 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17338 const context = useDisclosureProviderContext();
17339 store = store || context;
17340 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
17341 const ref = (0, import_react20.useRef)(null);
17342 const id = useId4(props.id);
17343 const [transition, setTransition] = (0, import_react20.useState)(null);
17344 const open = useStoreState(store, "open");
17345 const mounted = useStoreState(store, "mounted");
17346 const animated = useStoreState(store, "animated");
17347 const contentElement = useStoreState(store, "contentElement");
17348 const otherElement = useStoreState(store.disclosure, "contentElement");
17349 const hasClosedRef = (0, import_react20.useRef)(false);
17350 useSafeLayoutEffect(() => {
17351 if (!ref.current) return;
17352 store?.setContentElement(ref.current);
17353 }, [store]);
17354 useSafeLayoutEffect(() => {
17355 let previousAnimated;
17356 store?.setState("animated", (animated2) => {
17357 previousAnimated = animated2;
17358 return true;
17359 });
17360 return () => {
17361 if (previousAnimated === void 0) return;
17362 store?.setState("animated", previousAnimated);
17363 };
17364 }, [store]);
17365 useSafeLayoutEffect(() => {
17366 if (!animated) {
17367 if (!open) {
17368 hasClosedRef.current = true;
17369 setTransition(null);
17370 } else if (hasClosedRef.current) {
17371 hasClosedRef.current = false;
17372 setTransition("enter");
17373 }
17374 return;
17375 }
17376 if (!contentElement?.isConnected) {
17377 setTransition(null);
17378 return;
17379 }
17380 return afterPaint(() => {
17381 setTransition(open ? "enter" : mounted ? "leave" : null);
17382 });
17383 }, [
17384 animated,
17385 contentElement,
17386 open,
17387 mounted
17388 ]);
17389 useSafeLayoutEffect(() => {
17390 if (!store) return;
17391 if (!animated) return;
17392 if (!transition) return;
17393 if (!contentElement) return;
17394 const stopAnimation = () => store?.setState("animating", false);
17395 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17396 if (transition === "leave" && open) return;
17397 if (transition === "enter" && !open) return;
17398 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
17399 const { transitionDuration, animationDuration, transitionDelay, animationDelay } = getComputedStyle(contentElement);
17400 const { transitionDuration: transitionDuration2 = "0", animationDuration: animationDuration2 = "0", transitionDelay: transitionDelay2 = "0", animationDelay: animationDelay2 = "0" } = otherElement ? getComputedStyle(otherElement) : {};
17401 const timeout = parseCSSTime(transitionDelay, animationDelay, transitionDelay2, animationDelay2) + parseCSSTime(transitionDuration, animationDuration, transitionDuration2, animationDuration2);
17402 if (!timeout) {
17403 if (transition === "enter") store.setState("animated", false);
17404 stopAnimation();
17405 return;
17406 }
17407 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
17408 }, [
17409 store,
17410 animated,
17411 contentElement,
17412 otherElement,
17413 open,
17414 transition
17415 ]);
17416 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, {
17417 value: store,
17418 children: element
17419 }), [store]);
17420 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17421 const styleProp = props.style;
17422 const style = (0, import_react20.useMemo)(() => {
17423 if (hidden) return {
17424 ...styleProp,
17425 display: "none"
17426 };
17427 return styleProp;
17428 }, [hidden, styleProp]);
17429 props = {
17430 "data-open": open || void 0,
17431 "data-enter": transition === "enter" || void 0,
17432 "data-leave": transition === "leave" || void 0,
17433 hidden,
17434 ...props,
17435 id,
17436 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17437 style
17438 };
17439 return removeUndefinedValues(props);
17440 });
17441 var DisclosureContentImpl = forwardRef29(function DisclosureContentImpl2(props) {
17442 return createElement3(TagName6, useDisclosureContent(props));
17443 });
17444 var DisclosureContent = forwardRef29(function DisclosureContent2({ unmountOnHide, ...props }) {
17445 const context = useDisclosureProviderContext();
17446 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
17447 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
17448 });
17449
17450 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
17451 function createDisclosureStore(props = {}) {
17452 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
17453 throwOnConflictingProps(props, store);
17454 const syncState = store?.getState();
17455 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
17456 const animated = defaultValue(props.animated, syncState?.animated, false);
17457 const disclosure = createStore({
17458 open,
17459 animated,
17460 animating: !!animated && open,
17461 mounted: open,
17462 contentElement: defaultValue(syncState?.contentElement, null),
17463 disclosureElement: defaultValue(syncState?.disclosureElement, null)
17464 }, store);
17465 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
17466 if (state.animated) return;
17467 disclosure.setState("animating", false);
17468 }));
17469 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
17470 if (!disclosure.getState().animated) return;
17471 disclosure.setState("animating", true);
17472 }));
17473 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
17474 disclosure.setState("mounted", state.open || state.animating);
17475 }));
17476 return {
17477 ...disclosure,
17478 disclosure: props.disclosure,
17479 setOpen: (value) => disclosure.setState("open", value),
17480 show: () => disclosure.setState("open", true),
17481 hide: () => disclosure.setState("open", false),
17482 toggle: () => disclosure.setState("open", (open2) => !open2),
17483 stopAnimation: () => disclosure.setState("animating", false),
17484 setContentElement: (value) => disclosure.setState("contentElement", value),
17485 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17486 };
17487 }
17488
17489 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
17490 function useDisclosureStoreProps(store, update2, props) {
17491 useUpdateEffect(update2, [props.store, props.disclosure]);
17492 useStoreProps(store, props, "open", "setOpen");
17493 useStoreProps(store, props, "mounted", "setMounted");
17494 useStoreProps(store, props, "animated");
17495 return Object.assign(store, { disclosure: props.disclosure });
17496 }
17497
17498 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
17499 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
17500 var usePopoverContext = ctx5.useContext;
17501 var usePopoverScopedContext = ctx5.useScopedContext;
17502 var usePopoverProviderContext = ctx5.useProviderContext;
17503 var PopoverContextProvider = ctx5.ContextProvider;
17504 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17505
17506 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
17507 var import_react21 = __toESM(require_react(), 1);
17508 var ComboboxListRoleContext = (0, import_react21.createContext)(void 0);
17509 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
17510 var useComboboxContext = ctx6.useContext;
17511 var useComboboxScopedContext = ctx6.useScopedContext;
17512 var useComboboxProviderContext = ctx6.useProviderContext;
17513 var ComboboxContextProvider = ctx6.ContextProvider;
17514 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17515 var ComboboxItemValueContext = (0, import_react21.createContext)(void 0);
17516 var ComboboxItemCheckedContext = (0, import_react21.createContext)(false);
17517
17518 // node_modules/@ariakit/components/dist/collection/collection-store.js
17519 function getCommonParent(items) {
17520 const firstItem = items.find((item) => !!item.element);
17521 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17522 let parentElement = firstItem?.element?.parentElement;
17523 if (!lastElement) return getDocument(parentElement).body;
17524 while (parentElement) {
17525 if (parentElement.contains(lastElement)) return parentElement;
17526 parentElement = parentElement.parentElement;
17527 }
17528 return getDocument(parentElement).body;
17529 }
17530 function getPrivateStore(store) {
17531 return store?.__unstablePrivateStore;
17532 }
17533 function createCollectionStore(props = {}) {
17534 throwOnConflictingProps(props, props.store);
17535 const syncState = props.store?.getState();
17536 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17537 const itemsMap = new Map(items.map((item) => [item.id, item]));
17538 const initialState = {
17539 items,
17540 renderedItems: defaultValue(syncState?.renderedItems, [])
17541 };
17542 const syncPrivateStore = getPrivateStore(props.store);
17543 const privateStore = createStore({
17544 items,
17545 renderedItems: initialState.renderedItems
17546 }, syncPrivateStore);
17547 const collection = createStore(initialState, props.store);
17548 const sortItems = (renderedItems) => {
17549 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17550 privateStore.setState("renderedItems", sortedItems);
17551 collection.setState("renderedItems", sortedItems);
17552 };
17553 setup(collection, () => init(privateStore));
17554 setup(privateStore, () => {
17555 return batch(privateStore, ["items"], (state) => {
17556 collection.setState("items", state.items);
17557 });
17558 });
17559 setup(privateStore, () => {
17560 return batch(privateStore, ["renderedItems"], (state) => {
17561 let firstRun = true;
17562 let raf = requestAnimationFrame(() => {
17563 const { renderedItems } = collection.getState();
17564 if (state.renderedItems === renderedItems) return;
17565 sortItems(state.renderedItems);
17566 });
17567 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17568 const ioCallback = () => {
17569 if (firstRun) {
17570 firstRun = false;
17571 return;
17572 }
17573 cancelAnimationFrame(raf);
17574 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17575 };
17576 const root = getCommonParent(state.renderedItems);
17577 const observer = new IntersectionObserver(ioCallback, { root });
17578 for (const item of state.renderedItems) {
17579 if (!item.element) continue;
17580 observer.observe(item.element);
17581 }
17582 return () => {
17583 cancelAnimationFrame(raf);
17584 observer.disconnect();
17585 };
17586 });
17587 });
17588 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17589 let prevItem;
17590 setItems((items2) => {
17591 const index2 = items2.findIndex(({ id }) => id === item.id);
17592 const nextItems = items2.slice();
17593 if (index2 !== -1) {
17594 prevItem = items2[index2];
17595 const nextItem = {
17596 ...prevItem,
17597 ...item
17598 };
17599 nextItems[index2] = nextItem;
17600 itemsMap.set(item.id, nextItem);
17601 } else {
17602 nextItems.push(item);
17603 itemsMap.set(item.id, item);
17604 }
17605 return nextItems;
17606 });
17607 const unmergeItem = () => {
17608 setItems((items2) => {
17609 if (!prevItem) {
17610 if (canDeleteFromMap) itemsMap.delete(item.id);
17611 return items2.filter(({ id }) => id !== item.id);
17612 }
17613 const index2 = items2.findIndex(({ id }) => id === item.id);
17614 if (index2 === -1) return items2;
17615 const nextItems = items2.slice();
17616 nextItems[index2] = prevItem;
17617 itemsMap.set(item.id, prevItem);
17618 return nextItems;
17619 });
17620 };
17621 return unmergeItem;
17622 };
17623 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17624 return {
17625 ...collection,
17626 registerItem,
17627 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17628 item: (id) => {
17629 if (!id) return null;
17630 let item = itemsMap.get(id);
17631 if (!item) {
17632 const { items: items2 } = privateStore.getState();
17633 item = items2.find((item2) => item2.id === id);
17634 if (item) itemsMap.set(id, item);
17635 }
17636 return item || null;
17637 },
17638 __unstablePrivateStore: privateStore
17639 };
17640 }
17641
17642 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
17643 function useCollectionStoreProps(store, update2, props) {
17644 useUpdateEffect(update2, [props.store]);
17645 useStoreProps(store, props, "items", "setItems");
17646 return store;
17647 }
17648
17649 // node_modules/@ariakit/components/dist/composite/composite-store.js
17650 var NULL_ITEM = { id: null };
17651 function findFirstEnabledItem2(items, excludeId) {
17652 return items.find((item) => {
17653 if (excludeId) return !item.disabled && item.id !== excludeId;
17654 return !item.disabled;
17655 });
17656 }
17657 function getEnabledItems(items, excludeId) {
17658 return items.filter((item) => {
17659 if (excludeId) return !item.disabled && item.id !== excludeId;
17660 return !item.disabled;
17661 });
17662 }
17663 function getItemsInRow(items, rowId) {
17664 return items.filter((item) => item.rowId === rowId);
17665 }
17666 function flipItems(items, activeId, shouldInsertNullItem = false) {
17667 const index2 = items.findIndex((item) => item.id === activeId);
17668 return [
17669 ...items.slice(index2 + 1),
17670 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17671 ...items.slice(0, index2)
17672 ];
17673 }
17674 function groupItemsByRows2(items) {
17675 const rows = [];
17676 for (const item of items) {
17677 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17678 if (row) row.push(item);
17679 else rows.push([item]);
17680 }
17681 return rows;
17682 }
17683 function getMaxRowLength(array) {
17684 let maxLength = 0;
17685 for (const { length } of array) if (length > maxLength) maxLength = length;
17686 return maxLength;
17687 }
17688 function createEmptyItem(rowId) {
17689 return {
17690 id: "__EMPTY_ITEM__",
17691 disabled: true,
17692 rowId
17693 };
17694 }
17695 function normalizeRows(rows, activeId, focusShift) {
17696 const maxLength = getMaxRowLength(rows);
17697 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17698 const item = row[i2];
17699 if (!item || focusShift && item.disabled) {
17700 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17701 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17702 }
17703 }
17704 return rows;
17705 }
17706 function verticalizeItems(items) {
17707 const rows = groupItemsByRows2(items);
17708 const maxLength = getMaxRowLength(rows);
17709 const verticalized = [];
17710 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17711 const item = row[i2];
17712 if (item) verticalized.push({
17713 ...item,
17714 rowId: item.rowId ? `${i2}` : void 0
17715 });
17716 }
17717 return verticalized;
17718 }
17719 function createCompositeStore(props = {}) {
17720 const syncState = props.store?.getState();
17721 const collection = createCollectionStore(props);
17722 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17723 const composite = createStore({
17724 ...collection.getState(),
17725 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17726 activeId,
17727 baseElement: defaultValue(syncState?.baseElement, null),
17728 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17729 moves: defaultValue(syncState?.moves, 0),
17730 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17731 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17732 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17733 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17734 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17735 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17736 }, collection, props.store);
17737 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17738 composite.setState("activeId", (activeId2) => {
17739 if (activeId2 !== void 0) return activeId2;
17740 return findFirstEnabledItem2(state.renderedItems)?.id;
17741 });
17742 }));
17743 const getNextId = (direction = "next", options = {}) => {
17744 const defaultState = composite.getState();
17745 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;
17746 const isVerticalDirection = direction === "up" || direction === "down";
17747 const isNextDirection = direction === "next" || direction === "down";
17748 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17749 const canShift = focusShift && !skip;
17750 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift));
17751 items = canReverse ? reverseArray(items) : items;
17752 items = isVerticalDirection ? verticalizeItems(items) : items;
17753 if (activeId2 == null) return findFirstEnabledItem2(items)?.id;
17754 const activeItem = items.find((item) => item.id === activeId2);
17755 if (!activeItem) return findFirstEnabledItem2(items)?.id;
17756 const isGrid2 = items.some((item) => item.rowId);
17757 const activeIndex = items.indexOf(activeItem);
17758 const nextItems = items.slice(activeIndex + 1);
17759 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17760 if (skip) {
17761 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17762 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17763 }
17764 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17765 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17766 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17767 if (canLoop) return findFirstEnabledItem2(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17768 if (canWrap) {
17769 const nextItem2 = findFirstEnabledItem2(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17770 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17771 }
17772 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17773 if (!nextItem && hasNullItem) return null;
17774 return nextItem?.id;
17775 };
17776 return {
17777 ...collection,
17778 ...composite,
17779 setBaseElement: (element) => composite.setState("baseElement", element),
17780 setActiveId: (id) => composite.setState("activeId", id),
17781 move: (id) => {
17782 if (id === void 0) return;
17783 composite.setState("activeId", id);
17784 composite.setState("moves", (moves) => moves + 1);
17785 },
17786 first: () => findFirstEnabledItem2(composite.getState().renderedItems)?.id,
17787 last: () => findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))?.id,
17788 next: (options) => {
17789 if (options !== void 0 && typeof options === "number") options = { skip: options };
17790 return getNextId("next", options);
17791 },
17792 previous: (options) => {
17793 if (options !== void 0 && typeof options === "number") options = { skip: options };
17794 return getNextId("previous", options);
17795 },
17796 down: (options) => {
17797 if (options !== void 0 && typeof options === "number") options = { skip: options };
17798 return getNextId("down", options);
17799 },
17800 up: (options) => {
17801 if (options !== void 0 && typeof options === "number") options = { skip: options };
17802 return getNextId("up", options);
17803 }
17804 };
17805 }
17806
17807 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
17808 function useCompositeStoreOptions(props) {
17809 return {
17810 id: useId4(props.id),
17811 ...props
17812 };
17813 }
17814 function useCompositeStoreProps(store, update2, props) {
17815 store = useCollectionStoreProps(store, update2, props);
17816 useStoreProps(store, props, "activeId", "setActiveId");
17817 useStoreProps(store, props, "includesBaseElement");
17818 useStoreProps(store, props, "virtualFocus");
17819 useStoreProps(store, props, "orientation");
17820 useStoreProps(store, props, "rtl");
17821 useStoreProps(store, props, "focusLoop");
17822 useStoreProps(store, props, "focusWrap");
17823 useStoreProps(store, props, "focusShift");
17824 return store;
17825 }
17826
17827 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
17828 function createDialogStore(props = {}) {
17829 return createDisclosureStore(props);
17830 }
17831
17832 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
17833 function useDialogStoreProps(store, update2, props) {
17834 return useDisclosureStoreProps(store, update2, props);
17835 }
17836
17837 // node_modules/@ariakit/components/dist/popover/popover-store.js
17838 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
17839 const store = mergeStore(props.store, omit2(otherPopover, [
17840 "arrowElement",
17841 "anchorElement",
17842 "contentElement",
17843 "popoverElement",
17844 "disclosureElement"
17845 ]));
17846 throwOnConflictingProps(props, store);
17847 const syncState = store?.getState();
17848 const dialog = createDialogStore({
17849 ...props,
17850 store
17851 });
17852 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
17853 const popover = createStore({
17854 ...dialog.getState(),
17855 placement,
17856 currentPlacement: placement,
17857 anchorElement: defaultValue(syncState?.anchorElement, null),
17858 popoverElement: defaultValue(syncState?.popoverElement, null),
17859 arrowElement: defaultValue(syncState?.arrowElement, null),
17860 rendered: /* @__PURE__ */ Symbol("rendered")
17861 }, dialog, store);
17862 return {
17863 ...dialog,
17864 ...popover,
17865 setAnchorElement: (element) => popover.setState("anchorElement", element),
17866 setPopoverElement: (element) => popover.setState("popoverElement", element),
17867 setArrowElement: (element) => popover.setState("arrowElement", element),
17868 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17869 };
17870 }
17871
17872 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
17873 function usePopoverStoreProps(store, update2, props) {
17874 useUpdateEffect(update2, [props.popover]);
17875 useStoreProps(store, props, "placement");
17876 return useDialogStoreProps(store, update2, props);
17877 }
17878
17879 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
17880 var TagName7 = "div";
17881 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
17882 const context = usePopoverProviderContext();
17883 store = store || context;
17884 props = {
17885 ...props,
17886 ref: useMergeRefs(store?.setAnchorElement, props.ref)
17887 };
17888 return props;
17889 });
17890 var PopoverAnchor = forwardRef29(function PopoverAnchor2(props) {
17891 return createElement3(TagName7, usePopoverAnchor(props));
17892 });
17893
17894 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
17895 var import_react22 = __toESM(require_react(), 1);
17896 var TagName8 = "div";
17897 function hoveringInside(event) {
17898 const nextElement = event.relatedTarget;
17899 if (!isElement2(nextElement)) return false;
17900 return contains2(event.currentTarget, nextElement);
17901 }
17902 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17903 function movingToAnotherItem(event) {
17904 const { relatedTarget } = event;
17905 if (!isElement2(relatedTarget)) return false;
17906 let dest = relatedTarget;
17907 do {
17908 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17909 dest = dest.parentElement;
17910 } while (dest);
17911 return false;
17912 }
17913 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
17914 const context = useCompositeScopedContext();
17915 store = store || context;
17916 invariant(store, "CompositeHover must be wrapped in a Composite component.");
17917 const isMouseMoving = useIsMouseMoving();
17918 const onMouseMoveProp = props.onMouseMove;
17919 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17920 const onMouseMove = useEvent((event) => {
17921 onMouseMoveProp?.(event);
17922 if (event.defaultPrevented) return;
17923 if (!isMouseMoving()) return;
17924 if (!focusOnHoverProp(event)) return;
17925 if (!hasFocusWithin(event.currentTarget)) {
17926 const baseElement = store?.getState().baseElement;
17927 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
17928 }
17929 store?.setActiveId(event.currentTarget.id);
17930 });
17931 const onMouseLeaveProp = props.onMouseLeave;
17932 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17933 const onMouseLeave = useEvent((event) => {
17934 onMouseLeaveProp?.(event);
17935 if (event.defaultPrevented) return;
17936 if (!isMouseMoving()) return;
17937 if (hoveringInside(event)) return;
17938 if (movingToAnotherItem(event)) return;
17939 if (!focusOnHoverProp(event)) return;
17940 if (!blurOnHoverEndProp(event)) return;
17941 store?.setActiveId(null);
17942 store?.getState().baseElement?.focus();
17943 });
17944 const ref = (0, import_react22.useCallback)((element) => {
17945 if (!element) return;
17946 element[symbol2] = true;
17947 }, []);
17948 props = {
17949 ...props,
17950 ref: useMergeRefs(ref, props.ref),
17951 onMouseMove,
17952 onMouseLeave
17953 };
17954 return removeUndefinedValues(props);
17955 });
17956 var CompositeHover = memo3(forwardRef29(function CompositeHover2(props) {
17957 return createElement3(TagName8, useCompositeHover(props));
17958 }));
17959
17960 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
17961 var import_react23 = __toESM(require_react(), 1);
17962 var TagName9 = "input";
17963 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17964 if (!autoSelect) return false;
17965 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
17966 }
17967 function hasCompletionString(value, activeValue) {
17968 if (!activeValue) return false;
17969 if (value == null) return false;
17970 value = normalizeString(value);
17971 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17972 }
17973 function isInputEvent(event) {
17974 return event.type === "input";
17975 }
17976 function isAriaAutoCompleteValue(value) {
17977 return value === "inline" || value === "list" || value === "both" || value === "none";
17978 }
17979 function getDefaultAutoSelectId(items) {
17980 return items.find((item) => {
17981 if (item.disabled) return false;
17982 return item.element?.getAttribute("role") !== "tab";
17983 })?.id;
17984 }
17985 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 }) {
17986 const context = useComboboxProviderContext();
17987 store = store || context;
17988 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
17989 const ref = (0, import_react23.useRef)(null);
17990 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17991 const canAutoSelectRef = (0, import_react23.useRef)(false);
17992 const composingRef = (0, import_react23.useRef)(false);
17993 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
17994 const inline4 = autoComplete === "inline" || autoComplete === "both";
17995 const [canInline, setCanInline] = (0, import_react23.useState)(inline4);
17996 useUpdateLayoutEffect(() => {
17997 if (!inline4) return;
17998 setCanInline(true);
17999 }, [inline4]);
18000 const storeValue = useStoreState(store, "value");
18001 const prevSelectedValueRef = (0, import_react23.useRef)(void 0);
18002 (0, import_react23.useEffect)(() => {
18003 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18004 prevSelectedValueRef.current = prev.selectedValue;
18005 });
18006 }, [store]);
18007 const inlineActiveValue = useStoreState(store, (state) => {
18008 if (!inline4) return;
18009 if (!canInline) return;
18010 if (state.activeValue && Array.isArray(state.selectedValue)) {
18011 if (state.selectedValue.includes(state.activeValue)) return;
18012 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18013 }
18014 return state.activeValue;
18015 });
18016 const items = useStoreState(store, "renderedItems");
18017 const open = useStoreState(store, "open");
18018 const contentElement = useStoreState(store, "contentElement");
18019 const value = (0, import_react23.useMemo)(() => {
18020 if (!inline4) return storeValue;
18021 if (!canInline) return storeValue;
18022 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18023 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18024 return storeValue;
18025 }
18026 return inlineActiveValue || storeValue;
18027 }, [
18028 inline4,
18029 canInline,
18030 items,
18031 inlineActiveValue,
18032 autoSelect,
18033 storeValue
18034 ]);
18035 (0, import_react23.useEffect)(() => {
18036 const element = ref.current;
18037 if (!element) return;
18038 const onCompositeItemMove = () => setCanInline(true);
18039 element.addEventListener("combobox-item-move", onCompositeItemMove);
18040 return () => {
18041 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18042 };
18043 }, []);
18044 (0, import_react23.useEffect)(() => {
18045 if (!inline4) return;
18046 if (!canInline) return;
18047 if (!inlineActiveValue) return;
18048 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18049 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18050 let cleanup = noop4;
18051 queueMicrotask(() => {
18052 const element = ref.current;
18053 if (!element) return;
18054 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18055 const nextStart = storeValue.length;
18056 const nextEnd = inlineActiveValue.length;
18057 setSelectionRange(element, nextStart, nextEnd);
18058 cleanup = () => {
18059 if (!hasFocus(element)) return;
18060 const { start, end } = getTextboxSelection(element);
18061 if (start !== nextStart) return;
18062 if (end !== nextEnd) return;
18063 setSelectionRange(element, prevStart, prevEnd);
18064 };
18065 });
18066 return () => cleanup();
18067 }, [
18068 valueUpdated,
18069 inline4,
18070 canInline,
18071 inlineActiveValue,
18072 items,
18073 autoSelect,
18074 storeValue
18075 ]);
18076 const scrollingElementRef = (0, import_react23.useRef)(null);
18077 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18078 const autoSelectIdRef = (0, import_react23.useRef)(null);
18079 const autoSelectMovedRef = (0, import_react23.useRef)(void 0);
18080 const userScrolledRef = (0, import_react23.useRef)(false);
18081 const isAutoScrollingRef = (0, import_react23.useRef)(false);
18082 (0, import_react23.useEffect)(() => {
18083 if (!open) return;
18084 if (!contentElement) return;
18085 const scrollingElement = getScrollingElement(contentElement);
18086 if (!scrollingElement) return;
18087 scrollingElementRef.current = scrollingElement;
18088 const onUserScroll = () => {
18089 canAutoSelectRef.current = false;
18090 userScrolledRef.current = true;
18091 };
18092 const onScroll = () => {
18093 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18094 if (!store) return;
18095 if (!canAutoSelectRef.current) return;
18096 const { activeId } = store.getState();
18097 if (activeId === null) return;
18098 if (activeId === autoSelectIdRef.current) return;
18099 canAutoSelectRef.current = false;
18100 };
18101 const options = {
18102 passive: true,
18103 capture: true
18104 };
18105 scrollingElement.addEventListener("wheel", onUserScroll, options);
18106 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18107 scrollingElement.addEventListener("scroll", onScroll, options);
18108 return () => {
18109 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18110 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18111 scrollingElement.removeEventListener("scroll", onScroll, true);
18112 };
18113 }, [
18114 open,
18115 contentElement,
18116 store
18117 ]);
18118 useSafeLayoutEffect(() => {
18119 userScrolledRef.current = false;
18120 if (!storeValue) return;
18121 if (composingRef.current) return;
18122 canAutoSelectRef.current = true;
18123 }, [storeValue]);
18124 useSafeLayoutEffect(() => {
18125 if (autoSelect !== "always" && open) return;
18126 canAutoSelectRef.current = open;
18127 }, [autoSelect, open]);
18128 useSafeLayoutEffect(() => {
18129 if (open) return;
18130 autoSelectMovedRef.current = void 0;
18131 }, [open]);
18132 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18133 useUpdateEffect(() => {
18134 const canAutoSelect = canAutoSelectRef.current;
18135 if (!store) return;
18136 if (!open) return;
18137 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18138 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18139 if (baseElement && !hasFocus(baseElement)) return;
18140 if (contentElement2?.hasAttribute("data-placing")) {
18141 const observer = new MutationObserver(forceValueUpdate);
18142 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18143 return () => observer.disconnect();
18144 }
18145 if (autoSelect && canAutoSelect) {
18146 const userAutoSelectId = getAutoSelectIdProp(items);
18147 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18148 autoSelectIdRef.current = autoSelectId;
18149 const nextActiveId = autoSelectId ?? null;
18150 const nextActiveValue = store.item(nextActiveId)?.value;
18151 const moved = autoSelectMovedRef.current;
18152 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18153 autoSelectMovedRef.current = {
18154 id: nextActiveId,
18155 value: nextActiveValue
18156 };
18157 store.move(nextActiveId);
18158 } else store.setState("activeValue", nextActiveValue);
18159 } else {
18160 const element = store.item(activeId || store.first())?.element;
18161 if (element && "scrollIntoView" in element) {
18162 isAutoScrollingRef.current = true;
18163 element.scrollIntoView({
18164 block: "nearest",
18165 inline: "nearest"
18166 });
18167 requestAnimationFrame(() => {
18168 isAutoScrollingRef.current = false;
18169 });
18170 }
18171 }
18172 }, [
18173 store,
18174 open,
18175 valueUpdated,
18176 storeValue,
18177 autoSelect,
18178 resetValueOnSelect,
18179 getAutoSelectIdProp,
18180 items
18181 ]);
18182 (0, import_react23.useEffect)(() => {
18183 if (!inline4) return;
18184 const combobox = ref.current;
18185 if (!combobox) return;
18186 const elements = [combobox, contentElement].filter((value2) => !!value2);
18187 const onBlur2 = (event) => {
18188 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18189 };
18190 for (const element of elements) element.addEventListener("focusout", onBlur2);
18191 return () => {
18192 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18193 };
18194 }, [
18195 inline4,
18196 contentElement,
18197 store,
18198 value
18199 ]);
18200 const canShow = (event) => {
18201 return event.currentTarget.value.length >= showMinLength;
18202 };
18203 const onChangeProp = props.onChange;
18204 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18205 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18206 const onChange = useEvent((event) => {
18207 onChangeProp?.(event);
18208 if (event.defaultPrevented) return;
18209 if (!store) return;
18210 const currentTarget = event.currentTarget;
18211 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18212 const nativeEvent = event.nativeEvent;
18213 canAutoSelectRef.current = true;
18214 if (isInputEvent(nativeEvent)) {
18215 if (nativeEvent.isComposing) {
18216 canAutoSelectRef.current = false;
18217 composingRef.current = true;
18218 }
18219 if (inline4) {
18220 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18221 const caretAtEnd = selectionStart === value2.length;
18222 setCanInline(textInserted && caretAtEnd);
18223 }
18224 }
18225 if (setValueOnChangeProp(event)) {
18226 const isSameValue = value2 === store.getState().value;
18227 store.setValue(value2);
18228 queueMicrotask(() => {
18229 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18230 });
18231 if (inline4 && autoSelect && isSameValue) forceValueUpdate();
18232 }
18233 if (showOnChangeProp(event)) store.show();
18234 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18235 });
18236 const onCompositionEndProp = props.onCompositionEnd;
18237 const onCompositionEnd = useEvent((event) => {
18238 canAutoSelectRef.current = true;
18239 composingRef.current = false;
18240 onCompositionEndProp?.(event);
18241 if (event.defaultPrevented) return;
18242 if (!autoSelect) return;
18243 forceValueUpdate();
18244 });
18245 const onMouseDownProp = props.onMouseDown;
18246 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18247 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18248 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18249 const onMouseDown = useEvent((event) => {
18250 onMouseDownProp?.(event);
18251 if (event.defaultPrevented) return;
18252 if (event.button) return;
18253 if (event.ctrlKey) return;
18254 if (!store) return;
18255 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18256 if (setValueOnClickProp(event)) store.setValue(value);
18257 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18258 });
18259 const onKeyDownProp = props.onKeyDown;
18260 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18261 const onKeyDown = useEvent((event) => {
18262 onKeyDownProp?.(event);
18263 if (!event.repeat) canAutoSelectRef.current = false;
18264 if (event.defaultPrevented) return;
18265 if (!store) return;
18266 const { open: open2 } = store.getState();
18267 if (open2 && event.key === "Enter") {
18268 event.preventDefault();
18269 return;
18270 }
18271 if (event.ctrlKey) return;
18272 if (event.altKey) return;
18273 if (event.shiftKey) return;
18274 if (event.metaKey) return;
18275 if (open2) return;
18276 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18277 if (showOnKeyPressProp(event)) {
18278 event.preventDefault();
18279 store.show();
18280 }
18281 }
18282 });
18283 const onBlurProp = props.onBlur;
18284 const onBlur = useEvent((event) => {
18285 canAutoSelectRef.current = false;
18286 onBlurProp?.(event);
18287 if (event.defaultPrevented) return;
18288 });
18289 const id = useId4(props.id);
18290 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18291 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18292 props = {
18293 role: "combobox",
18294 "aria-autocomplete": ariaAutoComplete,
18295 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18296 "aria-expanded": open,
18297 "aria-controls": contentElement?.id,
18298 "data-active-item": isActiveItem || void 0,
18299 value,
18300 ...props,
18301 id,
18302 ref: useMergeRefs(ref, props.ref),
18303 onChange,
18304 onCompositionEnd,
18305 onMouseDown,
18306 onKeyDown,
18307 onBlur
18308 };
18309 props = useComposite({
18310 store,
18311 focusable: focusable2,
18312 ...props,
18313 moveOnKeyPress: (event) => {
18314 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18315 if (inline4) setCanInline(true);
18316 return true;
18317 }
18318 });
18319 props = usePopoverAnchor({
18320 store,
18321 ...props
18322 });
18323 return {
18324 autoComplete: "off",
18325 ...props
18326 };
18327 });
18328 var Combobox = forwardRef29(function Combobox2(props) {
18329 return createElement3(TagName9, useCombobox(props));
18330 });
18331
18332 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18333 var import_react24 = __toESM(require_react(), 1);
18334 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18335 var TagName10 = "div";
18336 function isSelected(storeValue, itemValue) {
18337 if (itemValue == null) return;
18338 if (storeValue == null) return false;
18339 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18340 return storeValue === itemValue;
18341 }
18342 function getItemRole(popupRole) {
18343 return {
18344 menu: "menuitem",
18345 listbox: "option",
18346 tree: "treeitem"
18347 }[popupRole] ?? "option";
18348 }
18349 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18350 const context = useComboboxScopedContext();
18351 store = store || context;
18352 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18353 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18354 resetValueOnSelectState: "resetValueOnSelect",
18355 multiSelectable(state) {
18356 return Array.isArray(state.selectedValue);
18357 },
18358 selected(state) {
18359 return isSelected(state.selectedValue, value);
18360 }
18361 });
18362 const getItem = (0, import_react24.useCallback)((item) => {
18363 const nextItem = {
18364 ...item,
18365 value
18366 };
18367 if (getItemProp) return getItemProp(nextItem);
18368 return nextItem;
18369 }, [value, getItemProp]);
18370 setValueOnClick = setValueOnClick ?? !multiSelectable;
18371 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18372 const onClickProp = props.onClick;
18373 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18374 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18375 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18376 const hideOnClickProp = useBooleanEvent(hideOnClick);
18377 const onClick = useEvent((event) => {
18378 onClickProp?.(event);
18379 if (event.defaultPrevented) return;
18380 if (isDownloading(event)) return;
18381 if (isOpeningInNewTab(event)) return;
18382 if (value != null) {
18383 if (selectValueOnClickProp(event)) {
18384 if (resetValueOnSelectProp(event)) store?.resetValue();
18385 store?.setSelectedValue((prevValue) => {
18386 if (!Array.isArray(prevValue)) return value;
18387 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18388 return [...prevValue, value];
18389 });
18390 }
18391 if (setValueOnClickProp(event)) store?.setValue(value);
18392 }
18393 if (hideOnClickProp(event)) store?.hide();
18394 });
18395 const onKeyDownProp = props.onKeyDown;
18396 const onKeyDown = useEvent((event) => {
18397 onKeyDownProp?.(event);
18398 if (event.defaultPrevented) return;
18399 const baseElement = store?.getState().baseElement;
18400 if (!baseElement) return;
18401 if (hasFocus(baseElement)) return;
18402 if (event.key.length === 1 || event.key === "Backspace" || event.key === "Delete") {
18403 queueMicrotask(() => baseElement.focus());
18404 if (isTextField(baseElement)) store?.setValue(baseElement.value);
18405 }
18406 });
18407 if (multiSelectable && selected != null) props = {
18408 "aria-selected": selected,
18409 ...props
18410 };
18411 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, {
18412 value,
18413 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, {
18414 value: selected ?? false,
18415 children: element
18416 })
18417 }), [value, selected]);
18418 props = {
18419 role: getItemRole((0, import_react24.useContext)(ComboboxListRoleContext)),
18420 children: value,
18421 ...props,
18422 onClick,
18423 onKeyDown
18424 };
18425 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18426 props = useCompositeItem({
18427 store,
18428 ...props,
18429 getItem,
18430 moveOnKeyPress: (event) => {
18431 if (!moveOnKeyPressProp(event)) return false;
18432 const moveEvent = new Event("combobox-item-move");
18433 store?.getState().baseElement?.dispatchEvent(moveEvent);
18434 return true;
18435 }
18436 });
18437 props = useCompositeHover({
18438 store,
18439 focusOnHover,
18440 ...props
18441 });
18442 return props;
18443 });
18444 var ComboboxItem = memo3(forwardRef29(function ComboboxItem2(props) {
18445 return createElement3(TagName10, useComboboxItem(props));
18446 }));
18447
18448 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
18449 var import_react25 = __toESM(require_react(), 1);
18450 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18451 var TagName11 = "span";
18452 function normalizeValue(value) {
18453 return normalizeString(value).toLowerCase();
18454 }
18455 function getOffsets(string, values) {
18456 const offsets = [];
18457 for (const value of values) {
18458 let pos = 0;
18459 const length = value.length;
18460 while (string.indexOf(value, pos) !== -1) {
18461 const index2 = string.indexOf(value, pos);
18462 if (index2 !== -1) offsets.push([index2, length]);
18463 pos = index2 + 1;
18464 }
18465 }
18466 return offsets;
18467 }
18468 function filterOverlappingOffsets(offsets) {
18469 return offsets.filter(([offset4, length], i2, arr) => {
18470 return !arr.some(([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length);
18471 });
18472 }
18473 function sortOffsets(offsets) {
18474 return offsets.sort(([a2], [b2]) => a2 - b2);
18475 }
18476 function splitValue(itemValue, userValue) {
18477 if (!itemValue) return itemValue;
18478 if (!userValue) return itemValue;
18479 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18480 const parts = [];
18481 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {
18482 "data-autocomplete-value": autocomplete ? "" : void 0,
18483 "data-user-value": autocomplete ? void 0 : "",
18484 children: value
18485 }, parts.length);
18486 const offsets = sortOffsets(filterOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
18487 const firstEntry = offsets[0];
18488 if (!firstEntry) {
18489 parts.push(span(itemValue, true));
18490 return parts;
18491 }
18492 const [firstOffset] = firstEntry;
18493 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
18494 const value = itemValue.slice(offset4, offset4 + length);
18495 const nextOffset = offsets[i2 + 1]?.[0];
18496 return [value, itemValue.slice(offset4 + length, nextOffset)];
18497 })].forEach((value, i2) => {
18498 if (!value) return;
18499 parts.push(span(value, i2 % 2 === 0));
18500 });
18501 return parts;
18502 }
18503 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18504 const context = useComboboxScopedContext();
18505 store = store || context;
18506 const itemContext = (0, import_react25.useContext)(ComboboxItemValueContext);
18507 const itemValue = value ?? itemContext;
18508 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
18509 props = {
18510 children: (0, import_react25.useMemo)(() => {
18511 if (!itemValue) return;
18512 if (!inputValue) return itemValue;
18513 return splitValue(itemValue, inputValue);
18514 }, [itemValue, inputValue]),
18515 ...props
18516 };
18517 return removeUndefinedValues(props);
18518 });
18519 var ComboboxItemValue = forwardRef29(function ComboboxItemValue2(props) {
18520 return createElement3(TagName11, useComboboxItemValue(props));
18521 });
18522
18523 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
18524 var TagName12 = "label";
18525 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
18526 const context = useComboboxProviderContext();
18527 store = store || context;
18528 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18529 props = {
18530 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
18531 ...props
18532 };
18533 return removeUndefinedValues(props);
18534 });
18535 var ComboboxLabel = memo3(forwardRef29(function ComboboxLabel2(props) {
18536 return createElement3(TagName12, useComboboxLabel(props));
18537 }));
18538
18539 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
18540 var import_react26 = __toESM(require_react(), 1);
18541 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18542 var TagName13 = "div";
18543 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
18544 const scopedContext = useComboboxScopedContext(true);
18545 const context = useComboboxContext();
18546 store = store || context;
18547 const scopedContextSameStore = !!store && store === scopedContext;
18548 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18549 const ref = (0, import_react26.useRef)(null);
18550 const id = useId4(props.id);
18551 const mounted = useStoreState(store, "mounted");
18552 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18553 const style = hidden ? {
18554 ...props.style,
18555 display: "none"
18556 } : props.style;
18557 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
18558 const role = useAttribute(ref, "role", props.role);
18559 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
18560 const [hasListboxInside, setHasListboxInside] = (0, import_react26.useState)(false);
18561 const contentElement = useStoreState(store, "contentElement");
18562 useSafeLayoutEffect(() => {
18563 if (!mounted) return;
18564 const element = ref.current;
18565 if (!element) return;
18566 if (contentElement !== element) return;
18567 const callback = () => {
18568 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18569 };
18570 const observer = new MutationObserver(callback);
18571 observer.observe(element, {
18572 subtree: true,
18573 childList: true,
18574 attributeFilter: ["role"]
18575 });
18576 callback();
18577 return () => observer.disconnect();
18578 }, [mounted, contentElement]);
18579 if (!hasListboxInside) props = {
18580 role: "listbox",
18581 "aria-multiselectable": ariaMultiSelectable,
18582 ...props
18583 };
18584 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, {
18585 value: store,
18586 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, {
18587 value: role,
18588 children: element
18589 })
18590 }), [store, role]);
18591 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18592 props = {
18593 hidden,
18594 ...props,
18595 id,
18596 ref: useMergeRefs(setContentElement, ref, props.ref),
18597 style
18598 };
18599 return removeUndefinedValues(props);
18600 });
18601 var ComboboxList = forwardRef29(function ComboboxList2(props) {
18602 return createElement3(TagName13, useComboboxList(props));
18603 });
18604
18605 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
18606 var import_react27 = __toESM(require_react(), 1);
18607 var TagValueContext = (0, import_react27.createContext)(null);
18608 var TagRemoveIdContext = (0, import_react27.createContext)(null);
18609 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
18610 var useTagContext = ctx7.useContext;
18611 var useTagScopedContext = ctx7.useScopedContext;
18612 var useTagProviderContext = ctx7.useProviderContext;
18613 var TagContextProvider = ctx7.ContextProvider;
18614 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18615
18616 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
18617 var isTouchSafari = isSafari2() && isTouchDevice();
18618 function createComboboxStore({ tag, ...props } = {}) {
18619 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18620 throwOnConflictingProps(props, store);
18621 const tagState = tag?.getState();
18622 const syncState = store?.getState();
18623 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
18624 const composite = createCompositeStore({
18625 ...props,
18626 activeId,
18627 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
18628 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
18629 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
18630 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
18631 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
18632 });
18633 const popover = createPopoverStore({
18634 ...props,
18635 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
18636 });
18637 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
18638 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
18639 const multiSelectable = Array.isArray(selectedValue);
18640 const initialState = {
18641 ...composite.getState(),
18642 ...popover.getState(),
18643 value,
18644 selectedValue,
18645 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
18646 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
18647 activeValue: syncState?.activeValue
18648 };
18649 const combobox = createStore(initialState, composite, popover, store);
18650 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
18651 combobox.setState("virtualFocus", false);
18652 }));
18653 setup(combobox, () => {
18654 if (!tag) return;
18655 return chain(sync(combobox, ["selectedValue"], (state) => {
18656 if (!Array.isArray(state.selectedValue)) return;
18657 tag.setValues(state.selectedValue);
18658 }), sync(tag, ["values"], (state) => {
18659 combobox.setState("selectedValue", state.values);
18660 }));
18661 });
18662 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18663 if (!state.resetValueOnHide) return;
18664 if (state.mounted) return;
18665 combobox.setState("value", value);
18666 }));
18667 setup(combobox, () => sync(combobox, ["open"], (state) => {
18668 if (state.open) return;
18669 combobox.setState("activeId", activeId);
18670 combobox.setState("moves", 0);
18671 }));
18672 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18673 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
18674 }));
18675 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18676 if (state.moves === prev.moves) return;
18677 const { activeId: activeId2 } = combobox.getState();
18678 const activeItem = composite.item(activeId2);
18679 combobox.setState("activeValue", activeItem?.value);
18680 }));
18681 return {
18682 ...popover,
18683 ...composite,
18684 ...combobox,
18685 tag,
18686 setValue: (value2) => combobox.setState("value", value2),
18687 resetValue: () => combobox.setState("value", initialState.value),
18688 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18689 };
18690 }
18691
18692 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
18693 function useComboboxStoreOptions(props) {
18694 const tag = useTagContext();
18695 props = {
18696 ...props,
18697 tag: props.tag !== void 0 ? props.tag : tag
18698 };
18699 return useCompositeStoreOptions(props);
18700 }
18701 function useComboboxStoreProps(store, update2, props) {
18702 useUpdateEffect(update2, [props.tag]);
18703 useStoreProps(store, props, "value", "setValue");
18704 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18705 useStoreProps(store, props, "resetValueOnHide");
18706 useStoreProps(store, props, "resetValueOnSelect");
18707 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
18708 }
18709 function useComboboxStore(props = {}) {
18710 props = useComboboxStoreOptions(props);
18711 const [store, update2] = useStore2(createComboboxStore, props);
18712 return useComboboxStoreProps(store, update2, props);
18713 }
18714
18715 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
18716 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
18717 function ComboboxProvider(props = {}) {
18718 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, {
18719 value: useComboboxStore(props),
18720 children: props.children
18721 });
18722 }
18723
18724 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18725 var import_remove_accents = __toESM(require_remove_accents(), 1);
18726 var import_compose8 = __toESM(require_compose(), 1);
18727 var import_i18n24 = __toESM(require_i18n(), 1);
18728 var import_element50 = __toESM(require_element(), 1);
18729 var import_components19 = __toESM(require_components(), 1);
18730
18731 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18732 var EMPTY_ARRAY3 = [];
18733 var getCurrentValue = (filterDefinition, currentFilter) => {
18734 if (filterDefinition.singleSelection) {
18735 return currentFilter?.value;
18736 }
18737 if (Array.isArray(currentFilter?.value)) {
18738 return currentFilter.value;
18739 }
18740 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18741 return [currentFilter.value];
18742 }
18743 return EMPTY_ARRAY3;
18744 };
18745
18746 // packages/dataviews/build-module/hooks/use-elements.mjs
18747 var import_element49 = __toESM(require_element(), 1);
18748 var EMPTY_ARRAY4 = [];
18749 function useElements({
18750 elements,
18751 getElements
18752 }) {
18753 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18754 const [records, setRecords] = (0, import_element49.useState)(staticElements);
18755 const [isLoading, setIsLoading] = (0, import_element49.useState)(false);
18756 (0, import_element49.useEffect)(() => {
18757 if (!getElements) {
18758 setRecords(staticElements);
18759 return;
18760 }
18761 let cancelled = false;
18762 setIsLoading(true);
18763 getElements().then((fetchedElements) => {
18764 if (!cancelled) {
18765 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18766 setRecords(dynamicElements);
18767 }
18768 }).catch(() => {
18769 if (!cancelled) {
18770 setRecords(staticElements);
18771 }
18772 }).finally(() => {
18773 if (!cancelled) {
18774 setIsLoading(false);
18775 }
18776 });
18777 return () => {
18778 cancelled = true;
18779 };
18780 }, [getElements, staticElements]);
18781 return {
18782 elements: records,
18783 isLoading
18784 };
18785 }
18786
18787 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18788 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
18789 function normalizeSearchInput(input = "") {
18790 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18791 }
18792 var getNewValue = (filterDefinition, currentFilter, value) => {
18793 if (filterDefinition.singleSelection) {
18794 return value;
18795 }
18796 if (Array.isArray(currentFilter?.value)) {
18797 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18798 }
18799 return [value];
18800 };
18801 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18802 return `${prefix}-${filterElementValue}`;
18803 }
18804 var MultiSelectionOption = ({ selected }) => {
18805 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18806 "span",
18807 {
18808 className: clsx_default(
18809 "dataviews-filters__search-widget-listitem-multi-selection",
18810 { "is-selected": selected }
18811 ),
18812 children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
18813 }
18814 );
18815 };
18816 var SingleSelectionOption = ({ selected }) => {
18817 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18818 "span",
18819 {
18820 className: clsx_default(
18821 "dataviews-filters__search-widget-listitem-single-selection",
18822 { "is-selected": selected }
18823 )
18824 }
18825 );
18826 };
18827 function ListBox({ view, filter, onChangeView }) {
18828 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
18829 const [activeCompositeId, setActiveCompositeId] = (0, import_element50.useState)(
18830 // When there are one or less operators, the first item is set as active
18831 // (by setting the initial `activeId` to `undefined`).
18832 // With 2 or more operators, the focus is moved on the operators control
18833 // (by setting the initial `activeId` to `null`), meaning that there won't
18834 // be an active item initially. Focus is then managed via the
18835 // `onFocusVisible` callback.
18836 filter.operators?.length === 1 ? void 0 : null
18837 );
18838 const currentFilter = view.filters?.find(
18839 (f2) => f2.field === filter.field
18840 );
18841 const currentValue = getCurrentValue(filter, currentFilter);
18842 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18843 import_components19.Composite,
18844 {
18845 virtualFocus: true,
18846 focusLoop: true,
18847 activeId: activeCompositeId,
18848 setActiveId: setActiveCompositeId,
18849 role: "listbox",
18850 className: "dataviews-filters__search-widget-listbox",
18851 "aria-label": (0, import_i18n24.sprintf)(
18852 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18853 (0, import_i18n24.__)("List of: %1$s"),
18854 filter.name
18855 ),
18856 onFocusVisible: () => {
18857 if (!activeCompositeId && filter.elements.length) {
18858 setActiveCompositeId(
18859 generateFilterElementCompositeItemId(
18860 baseId,
18861 filter.elements[0].value
18862 )
18863 );
18864 }
18865 },
18866 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
18867 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
18868 import_components19.Composite.Hover,
18869 {
18870 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18871 import_components19.Composite.Item,
18872 {
18873 id: generateFilterElementCompositeItemId(
18874 baseId,
18875 element.value
18876 ),
18877 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18878 "div",
18879 {
18880 "aria-label": element.label,
18881 role: "option",
18882 className: "dataviews-filters__search-widget-listitem"
18883 }
18884 ),
18885 onClick: () => {
18886 const newFilters = currentFilter ? [
18887 ...(view.filters ?? []).map(
18888 (_filter) => {
18889 if (_filter.field === filter.field) {
18890 return {
18891 ..._filter,
18892 operator: currentFilter.operator || filter.operators[0],
18893 value: getNewValue(
18894 filter,
18895 currentFilter,
18896 element.value
18897 )
18898 };
18899 }
18900 return _filter;
18901 }
18902 )
18903 ] : [
18904 ...view.filters ?? [],
18905 {
18906 field: filter.field,
18907 operator: filter.operators[0],
18908 value: getNewValue(
18909 filter,
18910 currentFilter,
18911 element.value
18912 )
18913 }
18914 ];
18915 onChangeView({
18916 ...view,
18917 page: 1,
18918 filters: newFilters
18919 });
18920 }
18921 }
18922 ),
18923 children: [
18924 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18925 SingleSelectionOption,
18926 {
18927 selected: currentValue === element.value
18928 }
18929 ),
18930 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18931 MultiSelectionOption,
18932 {
18933 selected: currentValue.includes(element.value)
18934 }
18935 ),
18936 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18937 "span",
18938 {
18939 className: "dataviews-filters__search-widget-listitem-value",
18940 title: element.label,
18941 children: element.label
18942 }
18943 )
18944 ]
18945 },
18946 element.value
18947 ))
18948 }
18949 );
18950 }
18951 function ComboboxList22({ view, filter, onChangeView }) {
18952 const [searchValue, setSearchValue] = (0, import_element50.useState)("");
18953 const deferredSearchValue = (0, import_element50.useDeferredValue)(searchValue);
18954 const currentFilter = view.filters?.find(
18955 (_filter) => _filter.field === filter.field
18956 );
18957 const currentValue = getCurrentValue(filter, currentFilter);
18958 const matches = (0, import_element50.useMemo)(() => {
18959 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18960 return filter.elements.filter(
18961 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18962 );
18963 }, [filter.elements, deferredSearchValue]);
18964 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
18965 ComboboxProvider,
18966 {
18967 selectedValue: currentValue,
18968 setSelectedValue: (value) => {
18969 const newFilters = currentFilter ? [
18970 ...(view.filters ?? []).map((_filter) => {
18971 if (_filter.field === filter.field) {
18972 return {
18973 ..._filter,
18974 operator: currentFilter.operator || filter.operators[0],
18975 value
18976 };
18977 }
18978 return _filter;
18979 })
18980 ] : [
18981 ...view.filters ?? [],
18982 {
18983 field: filter.field,
18984 operator: filter.operators[0],
18985 value
18986 }
18987 ];
18988 onChangeView({
18989 ...view,
18990 page: 1,
18991 filters: newFilters
18992 });
18993 },
18994 setValue: setSearchValue,
18995 children: [
18996 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
18997 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n24.__)("Search items") }),
18998 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
18999 Combobox,
19000 {
19001 autoSelect: "always",
19002 placeholder: (0, import_i18n24.__)("Search"),
19003 className: "dataviews-filters__search-widget-filter-combobox__input"
19004 }
19005 ),
19006 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: search_default }) })
19007 ] }),
19008 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19009 ComboboxList,
19010 {
19011 className: "dataviews-filters__search-widget-filter-combobox-list",
19012 alwaysVisible: true,
19013 children: [
19014 matches.map((element) => {
19015 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19016 ComboboxItem,
19017 {
19018 resetValueOnSelect: false,
19019 value: element.value,
19020 className: "dataviews-filters__search-widget-listitem",
19021 hideOnClick: false,
19022 setValueOnClick: false,
19023 focusOnHover: true,
19024 children: [
19025 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19026 SingleSelectionOption,
19027 {
19028 selected: currentValue === element.value
19029 }
19030 ),
19031 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19032 MultiSelectionOption,
19033 {
19034 selected: currentValue.includes(
19035 element.value
19036 )
19037 }
19038 ),
19039 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19040 "span",
19041 {
19042 className: "dataviews-filters__search-widget-listitem-value",
19043 title: element.label,
19044 children: [
19045 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19046 ComboboxItemValue,
19047 {
19048 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19049 value: element.label
19050 }
19051 ),
19052 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19053 ]
19054 }
19055 )
19056 ]
19057 },
19058 element.value
19059 );
19060 }),
19061 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n24.__)("No results found") })
19062 ]
19063 }
19064 )
19065 ]
19066 }
19067 );
19068 }
19069 function SearchWidget(props) {
19070 const { elements, isLoading } = useElements({
19071 elements: props.filter.elements,
19072 getElements: props.filter.getElements
19073 });
19074 if (isLoading) {
19075 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Spinner, {}) });
19076 }
19077 if (elements.length === 0) {
19078 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n24.__)("No elements found") });
19079 }
19080 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19081 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19082 }
19083
19084 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19085 var import_es6 = __toESM(require_es6(), 1);
19086 var import_compose9 = __toESM(require_compose(), 1);
19087 var import_element51 = __toESM(require_element(), 1);
19088 var import_components20 = __toESM(require_components(), 1);
19089 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19090 function InputWidget({
19091 filter,
19092 view,
19093 onChangeView,
19094 fields
19095 }) {
19096 const currentFilter = view.filters?.find(
19097 (f2) => f2.field === filter.field
19098 );
19099 const currentValue = getCurrentValue(filter, currentFilter);
19100 const field = (0, import_element51.useMemo)(() => {
19101 const currentField = fields.find((f2) => f2.id === filter.field);
19102 if (currentField) {
19103 return {
19104 ...currentField,
19105 // Deactivate validation for filters.
19106 isValid: {},
19107 // Filter controls are always enabled.
19108 isDisabled: () => false,
19109 // Filter controls are always visible.
19110 isVisible: () => true,
19111 // Configure getValue/setValue as if Item was a plain object.
19112 getValue: ({ item }) => item[currentField.id],
19113 setValue: ({ value }) => ({
19114 [currentField.id]: value
19115 })
19116 };
19117 }
19118 return currentField;
19119 }, [fields, filter.field]);
19120 const data = (0, import_element51.useMemo)(() => {
19121 return (view.filters ?? []).reduce(
19122 (acc, activeFilter) => {
19123 acc[activeFilter.field] = activeFilter.value;
19124 return acc;
19125 },
19126 {}
19127 );
19128 }, [view.filters]);
19129 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19130 if (!field || !currentFilter) {
19131 return;
19132 }
19133 const nextValue = field.getValue({ item: updatedData });
19134 if ((0, import_es6.default)(nextValue, currentValue)) {
19135 return;
19136 }
19137 onChangeView({
19138 ...view,
19139 filters: (view.filters ?? []).map(
19140 (_filter) => _filter.field === filter.field ? {
19141 ..._filter,
19142 operator: currentFilter.operator || filter.operators[0],
19143 // Consider empty strings as undefined:
19144 //
19145 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19146 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19147 //
19148 // In practice, this means the filter will not be able to find an empty string as the value.
19149 value: nextValue === "" ? void 0 : nextValue
19150 } : _filter
19151 )
19152 });
19153 });
19154 if (!field || !field.Edit || !currentFilter) {
19155 return null;
19156 }
19157 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19158 import_components20.Flex,
19159 {
19160 className: "dataviews-filters__user-input-widget",
19161 gap: 2.5,
19162 direction: "column",
19163 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19164 field.Edit,
19165 {
19166 hideLabelFromVision: true,
19167 data,
19168 field,
19169 operator: currentFilter.operator,
19170 onChange: handleChange
19171 }
19172 )
19173 }
19174 );
19175 }
19176
19177 // node_modules/date-fns/constants.js
19178 var daysInYear = 365.2425;
19179 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19180 var minTime = -maxTime;
19181 var millisecondsInWeek = 6048e5;
19182 var millisecondsInDay = 864e5;
19183 var secondsInHour = 3600;
19184 var secondsInDay = secondsInHour * 24;
19185 var secondsInWeek = secondsInDay * 7;
19186 var secondsInYear = secondsInDay * daysInYear;
19187 var secondsInMonth = secondsInYear / 12;
19188 var secondsInQuarter = secondsInMonth * 3;
19189 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19190
19191 // node_modules/date-fns/constructFrom.js
19192 function constructFrom(date, value) {
19193 if (typeof date === "function") return date(value);
19194 if (date && typeof date === "object" && constructFromSymbol in date)
19195 return date[constructFromSymbol](value);
19196 if (date instanceof Date) return new date.constructor(value);
19197 return new Date(value);
19198 }
19199
19200 // node_modules/date-fns/toDate.js
19201 function toDate(argument, context) {
19202 return constructFrom(context || argument, argument);
19203 }
19204
19205 // node_modules/date-fns/addDays.js
19206 function addDays(date, amount, options) {
19207 const _date = toDate(date, options?.in);
19208 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19209 if (!amount) return _date;
19210 _date.setDate(_date.getDate() + amount);
19211 return _date;
19212 }
19213
19214 // node_modules/date-fns/addMonths.js
19215 function addMonths(date, amount, options) {
19216 const _date = toDate(date, options?.in);
19217 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19218 if (!amount) {
19219 return _date;
19220 }
19221 const dayOfMonth = _date.getDate();
19222 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19223 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19224 const daysInMonth = endOfDesiredMonth.getDate();
19225 if (dayOfMonth >= daysInMonth) {
19226 return endOfDesiredMonth;
19227 } else {
19228 _date.setFullYear(
19229 endOfDesiredMonth.getFullYear(),
19230 endOfDesiredMonth.getMonth(),
19231 dayOfMonth
19232 );
19233 return _date;
19234 }
19235 }
19236
19237 // node_modules/date-fns/_lib/defaultOptions.js
19238 var defaultOptions = {};
19239 function getDefaultOptions() {
19240 return defaultOptions;
19241 }
19242
19243 // node_modules/date-fns/startOfWeek.js
19244 function startOfWeek(date, options) {
19245 const defaultOptions2 = getDefaultOptions();
19246 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19247 const _date = toDate(date, options?.in);
19248 const day = _date.getDay();
19249 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19250 _date.setDate(_date.getDate() - diff);
19251 _date.setHours(0, 0, 0, 0);
19252 return _date;
19253 }
19254
19255 // node_modules/date-fns/startOfISOWeek.js
19256 function startOfISOWeek(date, options) {
19257 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19258 }
19259
19260 // node_modules/date-fns/getISOWeekYear.js
19261 function getISOWeekYear(date, options) {
19262 const _date = toDate(date, options?.in);
19263 const year = _date.getFullYear();
19264 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19265 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19266 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19267 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19268 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19269 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19270 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19271 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19272 if (_date.getTime() >= startOfNextYear.getTime()) {
19273 return year + 1;
19274 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19275 return year;
19276 } else {
19277 return year - 1;
19278 }
19279 }
19280
19281 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19282 function getTimezoneOffsetInMilliseconds(date) {
19283 const _date = toDate(date);
19284 const utcDate = new Date(
19285 Date.UTC(
19286 _date.getFullYear(),
19287 _date.getMonth(),
19288 _date.getDate(),
19289 _date.getHours(),
19290 _date.getMinutes(),
19291 _date.getSeconds(),
19292 _date.getMilliseconds()
19293 )
19294 );
19295 utcDate.setUTCFullYear(_date.getFullYear());
19296 return +date - +utcDate;
19297 }
19298
19299 // node_modules/date-fns/_lib/normalizeDates.js
19300 function normalizeDates(context, ...dates) {
19301 const normalize = constructFrom.bind(
19302 null,
19303 context || dates.find((date) => typeof date === "object")
19304 );
19305 return dates.map(normalize);
19306 }
19307
19308 // node_modules/date-fns/startOfDay.js
19309 function startOfDay(date, options) {
19310 const _date = toDate(date, options?.in);
19311 _date.setHours(0, 0, 0, 0);
19312 return _date;
19313 }
19314
19315 // node_modules/date-fns/differenceInCalendarDays.js
19316 function differenceInCalendarDays(laterDate, earlierDate, options) {
19317 const [laterDate_, earlierDate_] = normalizeDates(
19318 options?.in,
19319 laterDate,
19320 earlierDate
19321 );
19322 const laterStartOfDay = startOfDay(laterDate_);
19323 const earlierStartOfDay = startOfDay(earlierDate_);
19324 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19325 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19326 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19327 }
19328
19329 // node_modules/date-fns/startOfISOWeekYear.js
19330 function startOfISOWeekYear(date, options) {
19331 const year = getISOWeekYear(date, options);
19332 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19333 fourthOfJanuary.setFullYear(year, 0, 4);
19334 fourthOfJanuary.setHours(0, 0, 0, 0);
19335 return startOfISOWeek(fourthOfJanuary);
19336 }
19337
19338 // node_modules/date-fns/addWeeks.js
19339 function addWeeks(date, amount, options) {
19340 return addDays(date, amount * 7, options);
19341 }
19342
19343 // node_modules/date-fns/addYears.js
19344 function addYears(date, amount, options) {
19345 return addMonths(date, amount * 12, options);
19346 }
19347
19348 // node_modules/date-fns/isDate.js
19349 function isDate(value) {
19350 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19351 }
19352
19353 // node_modules/date-fns/isValid.js
19354 function isValid(date) {
19355 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19356 }
19357
19358 // node_modules/date-fns/startOfMonth.js
19359 function startOfMonth(date, options) {
19360 const _date = toDate(date, options?.in);
19361 _date.setDate(1);
19362 _date.setHours(0, 0, 0, 0);
19363 return _date;
19364 }
19365
19366 // node_modules/date-fns/startOfYear.js
19367 function startOfYear(date, options) {
19368 const date_ = toDate(date, options?.in);
19369 date_.setFullYear(date_.getFullYear(), 0, 1);
19370 date_.setHours(0, 0, 0, 0);
19371 return date_;
19372 }
19373
19374 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19375 var formatDistanceLocale = {
19376 lessThanXSeconds: {
19377 one: "less than a second",
19378 other: "less than {{count}} seconds"
19379 },
19380 xSeconds: {
19381 one: "1 second",
19382 other: "{{count}} seconds"
19383 },
19384 halfAMinute: "half a minute",
19385 lessThanXMinutes: {
19386 one: "less than a minute",
19387 other: "less than {{count}} minutes"
19388 },
19389 xMinutes: {
19390 one: "1 minute",
19391 other: "{{count}} minutes"
19392 },
19393 aboutXHours: {
19394 one: "about 1 hour",
19395 other: "about {{count}} hours"
19396 },
19397 xHours: {
19398 one: "1 hour",
19399 other: "{{count}} hours"
19400 },
19401 xDays: {
19402 one: "1 day",
19403 other: "{{count}} days"
19404 },
19405 aboutXWeeks: {
19406 one: "about 1 week",
19407 other: "about {{count}} weeks"
19408 },
19409 xWeeks: {
19410 one: "1 week",
19411 other: "{{count}} weeks"
19412 },
19413 aboutXMonths: {
19414 one: "about 1 month",
19415 other: "about {{count}} months"
19416 },
19417 xMonths: {
19418 one: "1 month",
19419 other: "{{count}} months"
19420 },
19421 aboutXYears: {
19422 one: "about 1 year",
19423 other: "about {{count}} years"
19424 },
19425 xYears: {
19426 one: "1 year",
19427 other: "{{count}} years"
19428 },
19429 overXYears: {
19430 one: "over 1 year",
19431 other: "over {{count}} years"
19432 },
19433 almostXYears: {
19434 one: "almost 1 year",
19435 other: "almost {{count}} years"
19436 }
19437 };
19438 var formatDistance = (token, count, options) => {
19439 let result;
19440 const tokenValue = formatDistanceLocale[token];
19441 if (typeof tokenValue === "string") {
19442 result = tokenValue;
19443 } else if (count === 1) {
19444 result = tokenValue.one;
19445 } else {
19446 result = tokenValue.other.replace("{{count}}", count.toString());
19447 }
19448 if (options?.addSuffix) {
19449 if (options.comparison && options.comparison > 0) {
19450 return "in " + result;
19451 } else {
19452 return result + " ago";
19453 }
19454 }
19455 return result;
19456 };
19457
19458 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19459 function buildFormatLongFn(args) {
19460 return (options = {}) => {
19461 const width = options.width ? String(options.width) : args.defaultWidth;
19462 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19463 return format6;
19464 };
19465 }
19466
19467 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19468 var dateFormats = {
19469 full: "EEEE, MMMM do, y",
19470 long: "MMMM do, y",
19471 medium: "MMM d, y",
19472 short: "MM/dd/yyyy"
19473 };
19474 var timeFormats = {
19475 full: "h:mm:ss a zzzz",
19476 long: "h:mm:ss a z",
19477 medium: "h:mm:ss a",
19478 short: "h:mm a"
19479 };
19480 var dateTimeFormats = {
19481 full: "{{date}} 'at' {{time}}",
19482 long: "{{date}} 'at' {{time}}",
19483 medium: "{{date}}, {{time}}",
19484 short: "{{date}}, {{time}}"
19485 };
19486 var formatLong = {
19487 date: buildFormatLongFn({
19488 formats: dateFormats,
19489 defaultWidth: "full"
19490 }),
19491 time: buildFormatLongFn({
19492 formats: timeFormats,
19493 defaultWidth: "full"
19494 }),
19495 dateTime: buildFormatLongFn({
19496 formats: dateTimeFormats,
19497 defaultWidth: "full"
19498 })
19499 };
19500
19501 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19502 var formatRelativeLocale = {
19503 lastWeek: "'last' eeee 'at' p",
19504 yesterday: "'yesterday at' p",
19505 today: "'today at' p",
19506 tomorrow: "'tomorrow at' p",
19507 nextWeek: "eeee 'at' p",
19508 other: "P"
19509 };
19510 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19511
19512 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19513 function buildLocalizeFn(args) {
19514 return (value, options) => {
19515 const context = options?.context ? String(options.context) : "standalone";
19516 let valuesArray;
19517 if (context === "formatting" && args.formattingValues) {
19518 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19519 const width = options?.width ? String(options.width) : defaultWidth;
19520 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19521 } else {
19522 const defaultWidth = args.defaultWidth;
19523 const width = options?.width ? String(options.width) : args.defaultWidth;
19524 valuesArray = args.values[width] || args.values[defaultWidth];
19525 }
19526 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19527 return valuesArray[index2];
19528 };
19529 }
19530
19531 // node_modules/date-fns/locale/en-US/_lib/localize.js
19532 var eraValues = {
19533 narrow: ["B", "A"],
19534 abbreviated: ["BC", "AD"],
19535 wide: ["Before Christ", "Anno Domini"]
19536 };
19537 var quarterValues = {
19538 narrow: ["1", "2", "3", "4"],
19539 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19540 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19541 };
19542 var monthValues = {
19543 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19544 abbreviated: [
19545 "Jan",
19546 "Feb",
19547 "Mar",
19548 "Apr",
19549 "May",
19550 "Jun",
19551 "Jul",
19552 "Aug",
19553 "Sep",
19554 "Oct",
19555 "Nov",
19556 "Dec"
19557 ],
19558 wide: [
19559 "January",
19560 "February",
19561 "March",
19562 "April",
19563 "May",
19564 "June",
19565 "July",
19566 "August",
19567 "September",
19568 "October",
19569 "November",
19570 "December"
19571 ]
19572 };
19573 var dayValues = {
19574 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19575 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19576 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19577 wide: [
19578 "Sunday",
19579 "Monday",
19580 "Tuesday",
19581 "Wednesday",
19582 "Thursday",
19583 "Friday",
19584 "Saturday"
19585 ]
19586 };
19587 var dayPeriodValues = {
19588 narrow: {
19589 am: "a",
19590 pm: "p",
19591 midnight: "mi",
19592 noon: "n",
19593 morning: "morning",
19594 afternoon: "afternoon",
19595 evening: "evening",
19596 night: "night"
19597 },
19598 abbreviated: {
19599 am: "AM",
19600 pm: "PM",
19601 midnight: "midnight",
19602 noon: "noon",
19603 morning: "morning",
19604 afternoon: "afternoon",
19605 evening: "evening",
19606 night: "night"
19607 },
19608 wide: {
19609 am: "a.m.",
19610 pm: "p.m.",
19611 midnight: "midnight",
19612 noon: "noon",
19613 morning: "morning",
19614 afternoon: "afternoon",
19615 evening: "evening",
19616 night: "night"
19617 }
19618 };
19619 var formattingDayPeriodValues = {
19620 narrow: {
19621 am: "a",
19622 pm: "p",
19623 midnight: "mi",
19624 noon: "n",
19625 morning: "in the morning",
19626 afternoon: "in the afternoon",
19627 evening: "in the evening",
19628 night: "at night"
19629 },
19630 abbreviated: {
19631 am: "AM",
19632 pm: "PM",
19633 midnight: "midnight",
19634 noon: "noon",
19635 morning: "in the morning",
19636 afternoon: "in the afternoon",
19637 evening: "in the evening",
19638 night: "at night"
19639 },
19640 wide: {
19641 am: "a.m.",
19642 pm: "p.m.",
19643 midnight: "midnight",
19644 noon: "noon",
19645 morning: "in the morning",
19646 afternoon: "in the afternoon",
19647 evening: "in the evening",
19648 night: "at night"
19649 }
19650 };
19651 var ordinalNumber = (dirtyNumber, _options) => {
19652 const number = Number(dirtyNumber);
19653 const rem100 = number % 100;
19654 if (rem100 > 20 || rem100 < 10) {
19655 switch (rem100 % 10) {
19656 case 1:
19657 return number + "st";
19658 case 2:
19659 return number + "nd";
19660 case 3:
19661 return number + "rd";
19662 }
19663 }
19664 return number + "th";
19665 };
19666 var localize = {
19667 ordinalNumber,
19668 era: buildLocalizeFn({
19669 values: eraValues,
19670 defaultWidth: "wide"
19671 }),
19672 quarter: buildLocalizeFn({
19673 values: quarterValues,
19674 defaultWidth: "wide",
19675 argumentCallback: (quarter) => quarter - 1
19676 }),
19677 month: buildLocalizeFn({
19678 values: monthValues,
19679 defaultWidth: "wide"
19680 }),
19681 day: buildLocalizeFn({
19682 values: dayValues,
19683 defaultWidth: "wide"
19684 }),
19685 dayPeriod: buildLocalizeFn({
19686 values: dayPeriodValues,
19687 defaultWidth: "wide",
19688 formattingValues: formattingDayPeriodValues,
19689 defaultFormattingWidth: "wide"
19690 })
19691 };
19692
19693 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19694 function buildMatchFn(args) {
19695 return (string, options = {}) => {
19696 const width = options.width;
19697 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19698 const matchResult = string.match(matchPattern);
19699 if (!matchResult) {
19700 return null;
19701 }
19702 const matchedString = matchResult[0];
19703 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19704 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19705 // [TODO] -- I challenge you to fix the type
19706 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19707 );
19708 let value;
19709 value = args.valueCallback ? args.valueCallback(key) : key;
19710 value = options.valueCallback ? (
19711 // [TODO] -- I challenge you to fix the type
19712 options.valueCallback(value)
19713 ) : value;
19714 const rest = string.slice(matchedString.length);
19715 return { value, rest };
19716 };
19717 }
19718 function findKey(object, predicate) {
19719 for (const key in object) {
19720 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19721 return key;
19722 }
19723 }
19724 return void 0;
19725 }
19726 function findIndex(array, predicate) {
19727 for (let key = 0; key < array.length; key++) {
19728 if (predicate(array[key])) {
19729 return key;
19730 }
19731 }
19732 return void 0;
19733 }
19734
19735 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19736 function buildMatchPatternFn(args) {
19737 return (string, options = {}) => {
19738 const matchResult = string.match(args.matchPattern);
19739 if (!matchResult) return null;
19740 const matchedString = matchResult[0];
19741 const parseResult = string.match(args.parsePattern);
19742 if (!parseResult) return null;
19743 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19744 value = options.valueCallback ? options.valueCallback(value) : value;
19745 const rest = string.slice(matchedString.length);
19746 return { value, rest };
19747 };
19748 }
19749
19750 // node_modules/date-fns/locale/en-US/_lib/match.js
19751 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19752 var parseOrdinalNumberPattern = /\d+/i;
19753 var matchEraPatterns = {
19754 narrow: /^(b|a)/i,
19755 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19756 wide: /^(before christ|before common era|anno domini|common era)/i
19757 };
19758 var parseEraPatterns = {
19759 any: [/^b/i, /^(a|c)/i]
19760 };
19761 var matchQuarterPatterns = {
19762 narrow: /^[1234]/i,
19763 abbreviated: /^q[1234]/i,
19764 wide: /^[1234](th|st|nd|rd)? quarter/i
19765 };
19766 var parseQuarterPatterns = {
19767 any: [/1/i, /2/i, /3/i, /4/i]
19768 };
19769 var matchMonthPatterns = {
19770 narrow: /^[jfmasond]/i,
19771 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19772 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19773 };
19774 var parseMonthPatterns = {
19775 narrow: [
19776 /^j/i,
19777 /^f/i,
19778 /^m/i,
19779 /^a/i,
19780 /^m/i,
19781 /^j/i,
19782 /^j/i,
19783 /^a/i,
19784 /^s/i,
19785 /^o/i,
19786 /^n/i,
19787 /^d/i
19788 ],
19789 any: [
19790 /^ja/i,
19791 /^f/i,
19792 /^mar/i,
19793 /^ap/i,
19794 /^may/i,
19795 /^jun/i,
19796 /^jul/i,
19797 /^au/i,
19798 /^s/i,
19799 /^o/i,
19800 /^n/i,
19801 /^d/i
19802 ]
19803 };
19804 var matchDayPatterns = {
19805 narrow: /^[smtwf]/i,
19806 short: /^(su|mo|tu|we|th|fr|sa)/i,
19807 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19808 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19809 };
19810 var parseDayPatterns = {
19811 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19812 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19813 };
19814 var matchDayPeriodPatterns = {
19815 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19816 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19817 };
19818 var parseDayPeriodPatterns = {
19819 any: {
19820 am: /^a/i,
19821 pm: /^p/i,
19822 midnight: /^mi/i,
19823 noon: /^no/i,
19824 morning: /morning/i,
19825 afternoon: /afternoon/i,
19826 evening: /evening/i,
19827 night: /night/i
19828 }
19829 };
19830 var match = {
19831 ordinalNumber: buildMatchPatternFn({
19832 matchPattern: matchOrdinalNumberPattern,
19833 parsePattern: parseOrdinalNumberPattern,
19834 valueCallback: (value) => parseInt(value, 10)
19835 }),
19836 era: buildMatchFn({
19837 matchPatterns: matchEraPatterns,
19838 defaultMatchWidth: "wide",
19839 parsePatterns: parseEraPatterns,
19840 defaultParseWidth: "any"
19841 }),
19842 quarter: buildMatchFn({
19843 matchPatterns: matchQuarterPatterns,
19844 defaultMatchWidth: "wide",
19845 parsePatterns: parseQuarterPatterns,
19846 defaultParseWidth: "any",
19847 valueCallback: (index2) => index2 + 1
19848 }),
19849 month: buildMatchFn({
19850 matchPatterns: matchMonthPatterns,
19851 defaultMatchWidth: "wide",
19852 parsePatterns: parseMonthPatterns,
19853 defaultParseWidth: "any"
19854 }),
19855 day: buildMatchFn({
19856 matchPatterns: matchDayPatterns,
19857 defaultMatchWidth: "wide",
19858 parsePatterns: parseDayPatterns,
19859 defaultParseWidth: "any"
19860 }),
19861 dayPeriod: buildMatchFn({
19862 matchPatterns: matchDayPeriodPatterns,
19863 defaultMatchWidth: "any",
19864 parsePatterns: parseDayPeriodPatterns,
19865 defaultParseWidth: "any"
19866 })
19867 };
19868
19869 // node_modules/date-fns/locale/en-US.js
19870 var enUS = {
19871 code: "en-US",
19872 formatDistance,
19873 formatLong,
19874 formatRelative,
19875 localize,
19876 match,
19877 options: {
19878 weekStartsOn: 0,
19879 firstWeekContainsDate: 1
19880 }
19881 };
19882
19883 // node_modules/date-fns/getDayOfYear.js
19884 function getDayOfYear(date, options) {
19885 const _date = toDate(date, options?.in);
19886 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19887 const dayOfYear = diff + 1;
19888 return dayOfYear;
19889 }
19890
19891 // node_modules/date-fns/getISOWeek.js
19892 function getISOWeek(date, options) {
19893 const _date = toDate(date, options?.in);
19894 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19895 return Math.round(diff / millisecondsInWeek) + 1;
19896 }
19897
19898 // node_modules/date-fns/getWeekYear.js
19899 function getWeekYear(date, options) {
19900 const _date = toDate(date, options?.in);
19901 const year = _date.getFullYear();
19902 const defaultOptions2 = getDefaultOptions();
19903 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19904 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19905 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19906 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19907 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19908 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19909 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19910 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19911 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19912 if (+_date >= +startOfNextYear) {
19913 return year + 1;
19914 } else if (+_date >= +startOfThisYear) {
19915 return year;
19916 } else {
19917 return year - 1;
19918 }
19919 }
19920
19921 // node_modules/date-fns/startOfWeekYear.js
19922 function startOfWeekYear(date, options) {
19923 const defaultOptions2 = getDefaultOptions();
19924 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19925 const year = getWeekYear(date, options);
19926 const firstWeek = constructFrom(options?.in || date, 0);
19927 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19928 firstWeek.setHours(0, 0, 0, 0);
19929 const _date = startOfWeek(firstWeek, options);
19930 return _date;
19931 }
19932
19933 // node_modules/date-fns/getWeek.js
19934 function getWeek(date, options) {
19935 const _date = toDate(date, options?.in);
19936 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19937 return Math.round(diff / millisecondsInWeek) + 1;
19938 }
19939
19940 // node_modules/date-fns/_lib/addLeadingZeros.js
19941 function addLeadingZeros(number, targetLength) {
19942 const sign = number < 0 ? "-" : "";
19943 const output = Math.abs(number).toString().padStart(targetLength, "0");
19944 return sign + output;
19945 }
19946
19947 // node_modules/date-fns/_lib/format/lightFormatters.js
19948 var lightFormatters = {
19949 // Year
19950 y(date, token) {
19951 const signedYear = date.getFullYear();
19952 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19953 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19954 },
19955 // Month
19956 M(date, token) {
19957 const month = date.getMonth();
19958 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19959 },
19960 // Day of the month
19961 d(date, token) {
19962 return addLeadingZeros(date.getDate(), token.length);
19963 },
19964 // AM or PM
19965 a(date, token) {
19966 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19967 switch (token) {
19968 case "a":
19969 case "aa":
19970 return dayPeriodEnumValue.toUpperCase();
19971 case "aaa":
19972 return dayPeriodEnumValue;
19973 case "aaaaa":
19974 return dayPeriodEnumValue[0];
19975 case "aaaa":
19976 default:
19977 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
19978 }
19979 },
19980 // Hour [1-12]
19981 h(date, token) {
19982 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
19983 },
19984 // Hour [0-23]
19985 H(date, token) {
19986 return addLeadingZeros(date.getHours(), token.length);
19987 },
19988 // Minute
19989 m(date, token) {
19990 return addLeadingZeros(date.getMinutes(), token.length);
19991 },
19992 // Second
19993 s(date, token) {
19994 return addLeadingZeros(date.getSeconds(), token.length);
19995 },
19996 // Fraction of second
19997 S(date, token) {
19998 const numberOfDigits = token.length;
19999 const milliseconds = date.getMilliseconds();
20000 const fractionalSeconds = Math.trunc(
20001 milliseconds * Math.pow(10, numberOfDigits - 3)
20002 );
20003 return addLeadingZeros(fractionalSeconds, token.length);
20004 }
20005 };
20006
20007 // node_modules/date-fns/_lib/format/formatters.js
20008 var dayPeriodEnum = {
20009 am: "am",
20010 pm: "pm",
20011 midnight: "midnight",
20012 noon: "noon",
20013 morning: "morning",
20014 afternoon: "afternoon",
20015 evening: "evening",
20016 night: "night"
20017 };
20018 var formatters = {
20019 // Era
20020 G: function(date, token, localize2) {
20021 const era = date.getFullYear() > 0 ? 1 : 0;
20022 switch (token) {
20023 // AD, BC
20024 case "G":
20025 case "GG":
20026 case "GGG":
20027 return localize2.era(era, { width: "abbreviated" });
20028 // A, B
20029 case "GGGGG":
20030 return localize2.era(era, { width: "narrow" });
20031 // Anno Domini, Before Christ
20032 case "GGGG":
20033 default:
20034 return localize2.era(era, { width: "wide" });
20035 }
20036 },
20037 // Year
20038 y: function(date, token, localize2) {
20039 if (token === "yo") {
20040 const signedYear = date.getFullYear();
20041 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20042 return localize2.ordinalNumber(year, { unit: "year" });
20043 }
20044 return lightFormatters.y(date, token);
20045 },
20046 // Local week-numbering year
20047 Y: function(date, token, localize2, options) {
20048 const signedWeekYear = getWeekYear(date, options);
20049 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20050 if (token === "YY") {
20051 const twoDigitYear = weekYear % 100;
20052 return addLeadingZeros(twoDigitYear, 2);
20053 }
20054 if (token === "Yo") {
20055 return localize2.ordinalNumber(weekYear, { unit: "year" });
20056 }
20057 return addLeadingZeros(weekYear, token.length);
20058 },
20059 // ISO week-numbering year
20060 R: function(date, token) {
20061 const isoWeekYear = getISOWeekYear(date);
20062 return addLeadingZeros(isoWeekYear, token.length);
20063 },
20064 // Extended year. This is a single number designating the year of this calendar system.
20065 // The main difference between `y` and `u` localizers are B.C. years:
20066 // | Year | `y` | `u` |
20067 // |------|-----|-----|
20068 // | AC 1 | 1 | 1 |
20069 // | BC 1 | 1 | 0 |
20070 // | BC 2 | 2 | -1 |
20071 // Also `yy` always returns the last two digits of a year,
20072 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20073 u: function(date, token) {
20074 const year = date.getFullYear();
20075 return addLeadingZeros(year, token.length);
20076 },
20077 // Quarter
20078 Q: function(date, token, localize2) {
20079 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20080 switch (token) {
20081 // 1, 2, 3, 4
20082 case "Q":
20083 return String(quarter);
20084 // 01, 02, 03, 04
20085 case "QQ":
20086 return addLeadingZeros(quarter, 2);
20087 // 1st, 2nd, 3rd, 4th
20088 case "Qo":
20089 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20090 // Q1, Q2, Q3, Q4
20091 case "QQQ":
20092 return localize2.quarter(quarter, {
20093 width: "abbreviated",
20094 context: "formatting"
20095 });
20096 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20097 case "QQQQQ":
20098 return localize2.quarter(quarter, {
20099 width: "narrow",
20100 context: "formatting"
20101 });
20102 // 1st quarter, 2nd quarter, ...
20103 case "QQQQ":
20104 default:
20105 return localize2.quarter(quarter, {
20106 width: "wide",
20107 context: "formatting"
20108 });
20109 }
20110 },
20111 // Stand-alone quarter
20112 q: function(date, token, localize2) {
20113 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20114 switch (token) {
20115 // 1, 2, 3, 4
20116 case "q":
20117 return String(quarter);
20118 // 01, 02, 03, 04
20119 case "qq":
20120 return addLeadingZeros(quarter, 2);
20121 // 1st, 2nd, 3rd, 4th
20122 case "qo":
20123 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20124 // Q1, Q2, Q3, Q4
20125 case "qqq":
20126 return localize2.quarter(quarter, {
20127 width: "abbreviated",
20128 context: "standalone"
20129 });
20130 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20131 case "qqqqq":
20132 return localize2.quarter(quarter, {
20133 width: "narrow",
20134 context: "standalone"
20135 });
20136 // 1st quarter, 2nd quarter, ...
20137 case "qqqq":
20138 default:
20139 return localize2.quarter(quarter, {
20140 width: "wide",
20141 context: "standalone"
20142 });
20143 }
20144 },
20145 // Month
20146 M: function(date, token, localize2) {
20147 const month = date.getMonth();
20148 switch (token) {
20149 case "M":
20150 case "MM":
20151 return lightFormatters.M(date, token);
20152 // 1st, 2nd, ..., 12th
20153 case "Mo":
20154 return localize2.ordinalNumber(month + 1, { unit: "month" });
20155 // Jan, Feb, ..., Dec
20156 case "MMM":
20157 return localize2.month(month, {
20158 width: "abbreviated",
20159 context: "formatting"
20160 });
20161 // J, F, ..., D
20162 case "MMMMM":
20163 return localize2.month(month, {
20164 width: "narrow",
20165 context: "formatting"
20166 });
20167 // January, February, ..., December
20168 case "MMMM":
20169 default:
20170 return localize2.month(month, { width: "wide", context: "formatting" });
20171 }
20172 },
20173 // Stand-alone month
20174 L: function(date, token, localize2) {
20175 const month = date.getMonth();
20176 switch (token) {
20177 // 1, 2, ..., 12
20178 case "L":
20179 return String(month + 1);
20180 // 01, 02, ..., 12
20181 case "LL":
20182 return addLeadingZeros(month + 1, 2);
20183 // 1st, 2nd, ..., 12th
20184 case "Lo":
20185 return localize2.ordinalNumber(month + 1, { unit: "month" });
20186 // Jan, Feb, ..., Dec
20187 case "LLL":
20188 return localize2.month(month, {
20189 width: "abbreviated",
20190 context: "standalone"
20191 });
20192 // J, F, ..., D
20193 case "LLLLL":
20194 return localize2.month(month, {
20195 width: "narrow",
20196 context: "standalone"
20197 });
20198 // January, February, ..., December
20199 case "LLLL":
20200 default:
20201 return localize2.month(month, { width: "wide", context: "standalone" });
20202 }
20203 },
20204 // Local week of year
20205 w: function(date, token, localize2, options) {
20206 const week = getWeek(date, options);
20207 if (token === "wo") {
20208 return localize2.ordinalNumber(week, { unit: "week" });
20209 }
20210 return addLeadingZeros(week, token.length);
20211 },
20212 // ISO week of year
20213 I: function(date, token, localize2) {
20214 const isoWeek = getISOWeek(date);
20215 if (token === "Io") {
20216 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20217 }
20218 return addLeadingZeros(isoWeek, token.length);
20219 },
20220 // Day of the month
20221 d: function(date, token, localize2) {
20222 if (token === "do") {
20223 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20224 }
20225 return lightFormatters.d(date, token);
20226 },
20227 // Day of year
20228 D: function(date, token, localize2) {
20229 const dayOfYear = getDayOfYear(date);
20230 if (token === "Do") {
20231 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20232 }
20233 return addLeadingZeros(dayOfYear, token.length);
20234 },
20235 // Day of week
20236 E: function(date, token, localize2) {
20237 const dayOfWeek = date.getDay();
20238 switch (token) {
20239 // Tue
20240 case "E":
20241 case "EE":
20242 case "EEE":
20243 return localize2.day(dayOfWeek, {
20244 width: "abbreviated",
20245 context: "formatting"
20246 });
20247 // T
20248 case "EEEEE":
20249 return localize2.day(dayOfWeek, {
20250 width: "narrow",
20251 context: "formatting"
20252 });
20253 // Tu
20254 case "EEEEEE":
20255 return localize2.day(dayOfWeek, {
20256 width: "short",
20257 context: "formatting"
20258 });
20259 // Tuesday
20260 case "EEEE":
20261 default:
20262 return localize2.day(dayOfWeek, {
20263 width: "wide",
20264 context: "formatting"
20265 });
20266 }
20267 },
20268 // Local day of week
20269 e: function(date, token, localize2, options) {
20270 const dayOfWeek = date.getDay();
20271 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20272 switch (token) {
20273 // Numerical value (Nth day of week with current locale or weekStartsOn)
20274 case "e":
20275 return String(localDayOfWeek);
20276 // Padded numerical value
20277 case "ee":
20278 return addLeadingZeros(localDayOfWeek, 2);
20279 // 1st, 2nd, ..., 7th
20280 case "eo":
20281 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20282 case "eee":
20283 return localize2.day(dayOfWeek, {
20284 width: "abbreviated",
20285 context: "formatting"
20286 });
20287 // T
20288 case "eeeee":
20289 return localize2.day(dayOfWeek, {
20290 width: "narrow",
20291 context: "formatting"
20292 });
20293 // Tu
20294 case "eeeeee":
20295 return localize2.day(dayOfWeek, {
20296 width: "short",
20297 context: "formatting"
20298 });
20299 // Tuesday
20300 case "eeee":
20301 default:
20302 return localize2.day(dayOfWeek, {
20303 width: "wide",
20304 context: "formatting"
20305 });
20306 }
20307 },
20308 // Stand-alone local day of week
20309 c: function(date, token, localize2, options) {
20310 const dayOfWeek = date.getDay();
20311 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20312 switch (token) {
20313 // Numerical value (same as in `e`)
20314 case "c":
20315 return String(localDayOfWeek);
20316 // Padded numerical value
20317 case "cc":
20318 return addLeadingZeros(localDayOfWeek, token.length);
20319 // 1st, 2nd, ..., 7th
20320 case "co":
20321 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20322 case "ccc":
20323 return localize2.day(dayOfWeek, {
20324 width: "abbreviated",
20325 context: "standalone"
20326 });
20327 // T
20328 case "ccccc":
20329 return localize2.day(dayOfWeek, {
20330 width: "narrow",
20331 context: "standalone"
20332 });
20333 // Tu
20334 case "cccccc":
20335 return localize2.day(dayOfWeek, {
20336 width: "short",
20337 context: "standalone"
20338 });
20339 // Tuesday
20340 case "cccc":
20341 default:
20342 return localize2.day(dayOfWeek, {
20343 width: "wide",
20344 context: "standalone"
20345 });
20346 }
20347 },
20348 // ISO day of week
20349 i: function(date, token, localize2) {
20350 const dayOfWeek = date.getDay();
20351 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20352 switch (token) {
20353 // 2
20354 case "i":
20355 return String(isoDayOfWeek);
20356 // 02
20357 case "ii":
20358 return addLeadingZeros(isoDayOfWeek, token.length);
20359 // 2nd
20360 case "io":
20361 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20362 // Tue
20363 case "iii":
20364 return localize2.day(dayOfWeek, {
20365 width: "abbreviated",
20366 context: "formatting"
20367 });
20368 // T
20369 case "iiiii":
20370 return localize2.day(dayOfWeek, {
20371 width: "narrow",
20372 context: "formatting"
20373 });
20374 // Tu
20375 case "iiiiii":
20376 return localize2.day(dayOfWeek, {
20377 width: "short",
20378 context: "formatting"
20379 });
20380 // Tuesday
20381 case "iiii":
20382 default:
20383 return localize2.day(dayOfWeek, {
20384 width: "wide",
20385 context: "formatting"
20386 });
20387 }
20388 },
20389 // AM or PM
20390 a: function(date, token, localize2) {
20391 const hours = date.getHours();
20392 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20393 switch (token) {
20394 case "a":
20395 case "aa":
20396 return localize2.dayPeriod(dayPeriodEnumValue, {
20397 width: "abbreviated",
20398 context: "formatting"
20399 });
20400 case "aaa":
20401 return localize2.dayPeriod(dayPeriodEnumValue, {
20402 width: "abbreviated",
20403 context: "formatting"
20404 }).toLowerCase();
20405 case "aaaaa":
20406 return localize2.dayPeriod(dayPeriodEnumValue, {
20407 width: "narrow",
20408 context: "formatting"
20409 });
20410 case "aaaa":
20411 default:
20412 return localize2.dayPeriod(dayPeriodEnumValue, {
20413 width: "wide",
20414 context: "formatting"
20415 });
20416 }
20417 },
20418 // AM, PM, midnight, noon
20419 b: function(date, token, localize2) {
20420 const hours = date.getHours();
20421 let dayPeriodEnumValue;
20422 if (hours === 12) {
20423 dayPeriodEnumValue = dayPeriodEnum.noon;
20424 } else if (hours === 0) {
20425 dayPeriodEnumValue = dayPeriodEnum.midnight;
20426 } else {
20427 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20428 }
20429 switch (token) {
20430 case "b":
20431 case "bb":
20432 return localize2.dayPeriod(dayPeriodEnumValue, {
20433 width: "abbreviated",
20434 context: "formatting"
20435 });
20436 case "bbb":
20437 return localize2.dayPeriod(dayPeriodEnumValue, {
20438 width: "abbreviated",
20439 context: "formatting"
20440 }).toLowerCase();
20441 case "bbbbb":
20442 return localize2.dayPeriod(dayPeriodEnumValue, {
20443 width: "narrow",
20444 context: "formatting"
20445 });
20446 case "bbbb":
20447 default:
20448 return localize2.dayPeriod(dayPeriodEnumValue, {
20449 width: "wide",
20450 context: "formatting"
20451 });
20452 }
20453 },
20454 // in the morning, in the afternoon, in the evening, at night
20455 B: function(date, token, localize2) {
20456 const hours = date.getHours();
20457 let dayPeriodEnumValue;
20458 if (hours >= 17) {
20459 dayPeriodEnumValue = dayPeriodEnum.evening;
20460 } else if (hours >= 12) {
20461 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20462 } else if (hours >= 4) {
20463 dayPeriodEnumValue = dayPeriodEnum.morning;
20464 } else {
20465 dayPeriodEnumValue = dayPeriodEnum.night;
20466 }
20467 switch (token) {
20468 case "B":
20469 case "BB":
20470 case "BBB":
20471 return localize2.dayPeriod(dayPeriodEnumValue, {
20472 width: "abbreviated",
20473 context: "formatting"
20474 });
20475 case "BBBBB":
20476 return localize2.dayPeriod(dayPeriodEnumValue, {
20477 width: "narrow",
20478 context: "formatting"
20479 });
20480 case "BBBB":
20481 default:
20482 return localize2.dayPeriod(dayPeriodEnumValue, {
20483 width: "wide",
20484 context: "formatting"
20485 });
20486 }
20487 },
20488 // Hour [1-12]
20489 h: function(date, token, localize2) {
20490 if (token === "ho") {
20491 let hours = date.getHours() % 12;
20492 if (hours === 0) hours = 12;
20493 return localize2.ordinalNumber(hours, { unit: "hour" });
20494 }
20495 return lightFormatters.h(date, token);
20496 },
20497 // Hour [0-23]
20498 H: function(date, token, localize2) {
20499 if (token === "Ho") {
20500 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20501 }
20502 return lightFormatters.H(date, token);
20503 },
20504 // Hour [0-11]
20505 K: function(date, token, localize2) {
20506 const hours = date.getHours() % 12;
20507 if (token === "Ko") {
20508 return localize2.ordinalNumber(hours, { unit: "hour" });
20509 }
20510 return addLeadingZeros(hours, token.length);
20511 },
20512 // Hour [1-24]
20513 k: function(date, token, localize2) {
20514 let hours = date.getHours();
20515 if (hours === 0) hours = 24;
20516 if (token === "ko") {
20517 return localize2.ordinalNumber(hours, { unit: "hour" });
20518 }
20519 return addLeadingZeros(hours, token.length);
20520 },
20521 // Minute
20522 m: function(date, token, localize2) {
20523 if (token === "mo") {
20524 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20525 }
20526 return lightFormatters.m(date, token);
20527 },
20528 // Second
20529 s: function(date, token, localize2) {
20530 if (token === "so") {
20531 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20532 }
20533 return lightFormatters.s(date, token);
20534 },
20535 // Fraction of second
20536 S: function(date, token) {
20537 return lightFormatters.S(date, token);
20538 },
20539 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20540 X: function(date, token, _localize) {
20541 const timezoneOffset = date.getTimezoneOffset();
20542 if (timezoneOffset === 0) {
20543 return "Z";
20544 }
20545 switch (token) {
20546 // Hours and optional minutes
20547 case "X":
20548 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20549 // Hours, minutes and optional seconds without `:` delimiter
20550 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20551 // so this token always has the same output as `XX`
20552 case "XXXX":
20553 case "XX":
20554 return formatTimezone(timezoneOffset);
20555 // Hours, minutes and optional seconds with `:` delimiter
20556 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20557 // so this token always has the same output as `XXX`
20558 case "XXXXX":
20559 case "XXX":
20560 // Hours and minutes with `:` delimiter
20561 default:
20562 return formatTimezone(timezoneOffset, ":");
20563 }
20564 },
20565 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20566 x: function(date, token, _localize) {
20567 const timezoneOffset = date.getTimezoneOffset();
20568 switch (token) {
20569 // Hours and optional minutes
20570 case "x":
20571 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20572 // Hours, minutes and optional seconds without `:` delimiter
20573 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20574 // so this token always has the same output as `xx`
20575 case "xxxx":
20576 case "xx":
20577 return formatTimezone(timezoneOffset);
20578 // Hours, minutes and optional seconds with `:` delimiter
20579 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20580 // so this token always has the same output as `xxx`
20581 case "xxxxx":
20582 case "xxx":
20583 // Hours and minutes with `:` delimiter
20584 default:
20585 return formatTimezone(timezoneOffset, ":");
20586 }
20587 },
20588 // Timezone (GMT)
20589 O: function(date, token, _localize) {
20590 const timezoneOffset = date.getTimezoneOffset();
20591 switch (token) {
20592 // Short
20593 case "O":
20594 case "OO":
20595 case "OOO":
20596 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20597 // Long
20598 case "OOOO":
20599 default:
20600 return "GMT" + formatTimezone(timezoneOffset, ":");
20601 }
20602 },
20603 // Timezone (specific non-location)
20604 z: function(date, token, _localize) {
20605 const timezoneOffset = date.getTimezoneOffset();
20606 switch (token) {
20607 // Short
20608 case "z":
20609 case "zz":
20610 case "zzz":
20611 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20612 // Long
20613 case "zzzz":
20614 default:
20615 return "GMT" + formatTimezone(timezoneOffset, ":");
20616 }
20617 },
20618 // Seconds timestamp
20619 t: function(date, token, _localize) {
20620 const timestamp = Math.trunc(+date / 1e3);
20621 return addLeadingZeros(timestamp, token.length);
20622 },
20623 // Milliseconds timestamp
20624 T: function(date, token, _localize) {
20625 return addLeadingZeros(+date, token.length);
20626 }
20627 };
20628 function formatTimezoneShort(offset4, delimiter = "") {
20629 const sign = offset4 > 0 ? "-" : "+";
20630 const absOffset = Math.abs(offset4);
20631 const hours = Math.trunc(absOffset / 60);
20632 const minutes = absOffset % 60;
20633 if (minutes === 0) {
20634 return sign + String(hours);
20635 }
20636 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20637 }
20638 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20639 if (offset4 % 60 === 0) {
20640 const sign = offset4 > 0 ? "-" : "+";
20641 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20642 }
20643 return formatTimezone(offset4, delimiter);
20644 }
20645 function formatTimezone(offset4, delimiter = "") {
20646 const sign = offset4 > 0 ? "-" : "+";
20647 const absOffset = Math.abs(offset4);
20648 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20649 const minutes = addLeadingZeros(absOffset % 60, 2);
20650 return sign + hours + delimiter + minutes;
20651 }
20652
20653 // node_modules/date-fns/_lib/format/longFormatters.js
20654 var dateLongFormatter = (pattern, formatLong2) => {
20655 switch (pattern) {
20656 case "P":
20657 return formatLong2.date({ width: "short" });
20658 case "PP":
20659 return formatLong2.date({ width: "medium" });
20660 case "PPP":
20661 return formatLong2.date({ width: "long" });
20662 case "PPPP":
20663 default:
20664 return formatLong2.date({ width: "full" });
20665 }
20666 };
20667 var timeLongFormatter = (pattern, formatLong2) => {
20668 switch (pattern) {
20669 case "p":
20670 return formatLong2.time({ width: "short" });
20671 case "pp":
20672 return formatLong2.time({ width: "medium" });
20673 case "ppp":
20674 return formatLong2.time({ width: "long" });
20675 case "pppp":
20676 default:
20677 return formatLong2.time({ width: "full" });
20678 }
20679 };
20680 var dateTimeLongFormatter = (pattern, formatLong2) => {
20681 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20682 const datePattern = matchResult[1];
20683 const timePattern = matchResult[2];
20684 if (!timePattern) {
20685 return dateLongFormatter(pattern, formatLong2);
20686 }
20687 let dateTimeFormat;
20688 switch (datePattern) {
20689 case "P":
20690 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20691 break;
20692 case "PP":
20693 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20694 break;
20695 case "PPP":
20696 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20697 break;
20698 case "PPPP":
20699 default:
20700 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20701 break;
20702 }
20703 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20704 };
20705 var longFormatters = {
20706 p: timeLongFormatter,
20707 P: dateTimeLongFormatter
20708 };
20709
20710 // node_modules/date-fns/_lib/protectedTokens.js
20711 var dayOfYearTokenRE = /^D+$/;
20712 var weekYearTokenRE = /^Y+$/;
20713 var throwTokens = ["D", "DD", "YY", "YYYY"];
20714 function isProtectedDayOfYearToken(token) {
20715 return dayOfYearTokenRE.test(token);
20716 }
20717 function isProtectedWeekYearToken(token) {
20718 return weekYearTokenRE.test(token);
20719 }
20720 function warnOrThrowProtectedError(token, format6, input) {
20721 const _message = message(token, format6, input);
20722 console.warn(_message);
20723 if (throwTokens.includes(token)) throw new RangeError(_message);
20724 }
20725 function message(token, format6, input) {
20726 const subject = token[0] === "Y" ? "years" : "days of the month";
20727 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`;
20728 }
20729
20730 // node_modules/date-fns/format.js
20731 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20732 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20733 var escapedStringRegExp = /^'([^]*?)'?$/;
20734 var doubleQuoteRegExp = /''/g;
20735 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20736 function format(date, formatStr, options) {
20737 const defaultOptions2 = getDefaultOptions();
20738 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20739 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20740 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20741 const originalDate = toDate(date, options?.in);
20742 if (!isValid(originalDate)) {
20743 throw new RangeError("Invalid time value");
20744 }
20745 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20746 const firstCharacter = substring[0];
20747 if (firstCharacter === "p" || firstCharacter === "P") {
20748 const longFormatter = longFormatters[firstCharacter];
20749 return longFormatter(substring, locale.formatLong);
20750 }
20751 return substring;
20752 }).join("").match(formattingTokensRegExp).map((substring) => {
20753 if (substring === "''") {
20754 return { isToken: false, value: "'" };
20755 }
20756 const firstCharacter = substring[0];
20757 if (firstCharacter === "'") {
20758 return { isToken: false, value: cleanEscapedString(substring) };
20759 }
20760 if (formatters[firstCharacter]) {
20761 return { isToken: true, value: substring };
20762 }
20763 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20764 throw new RangeError(
20765 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20766 );
20767 }
20768 return { isToken: false, value: substring };
20769 });
20770 if (locale.localize.preprocessor) {
20771 parts = locale.localize.preprocessor(originalDate, parts);
20772 }
20773 const formatterOptions = {
20774 firstWeekContainsDate,
20775 weekStartsOn,
20776 locale
20777 };
20778 return parts.map((part) => {
20779 if (!part.isToken) return part.value;
20780 const token = part.value;
20781 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20782 warnOrThrowProtectedError(token, formatStr, String(date));
20783 }
20784 const formatter = formatters[token[0]];
20785 return formatter(originalDate, token, locale.localize, formatterOptions);
20786 }).join("");
20787 }
20788 function cleanEscapedString(input) {
20789 const matched = input.match(escapedStringRegExp);
20790 if (!matched) {
20791 return input;
20792 }
20793 return matched[1].replace(doubleQuoteRegExp, "'");
20794 }
20795
20796 // node_modules/date-fns/subDays.js
20797 function subDays(date, amount, options) {
20798 return addDays(date, -amount, options);
20799 }
20800
20801 // node_modules/date-fns/subMonths.js
20802 function subMonths(date, amount, options) {
20803 return addMonths(date, -amount, options);
20804 }
20805
20806 // node_modules/date-fns/subWeeks.js
20807 function subWeeks(date, amount, options) {
20808 return addWeeks(date, -amount, options);
20809 }
20810
20811 // node_modules/date-fns/subYears.js
20812 function subYears(date, amount, options) {
20813 return addYears(date, -amount, options);
20814 }
20815
20816 // packages/dataviews/build-module/utils/operators.mjs
20817 var import_i18n25 = __toESM(require_i18n(), 1);
20818 var import_element52 = __toESM(require_element(), 1);
20819 var import_date = __toESM(require_date(), 1);
20820 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
20821 var filterTextWrappers = {
20822 Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20823 Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20824 };
20825 function getRelativeDate(value, unit) {
20826 switch (unit) {
20827 case "days":
20828 return subDays(/* @__PURE__ */ new Date(), value);
20829 case "weeks":
20830 return subWeeks(/* @__PURE__ */ new Date(), value);
20831 case "months":
20832 return subMonths(/* @__PURE__ */ new Date(), value);
20833 case "years":
20834 return subYears(/* @__PURE__ */ new Date(), value);
20835 default:
20836 return /* @__PURE__ */ new Date();
20837 }
20838 }
20839 var isNoneOperatorDefinition = {
20840 /* translators: DataViews operator name */
20841 label: (0, import_i18n25.__)("Is none of"),
20842 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20843 (0, import_i18n25.sprintf)(
20844 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20845 (0, import_i18n25.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20846 filter.name,
20847 activeElements.map((element) => element.label).join(", ")
20848 ),
20849 filterTextWrappers
20850 ),
20851 filter: ((item, field, filterValue) => {
20852 if (!filterValue?.length) {
20853 return true;
20854 }
20855 const fieldValue = field.getValue({ item });
20856 if (Array.isArray(fieldValue)) {
20857 return !filterValue.some(
20858 (fv) => fieldValue.includes(fv)
20859 );
20860 } else if (typeof fieldValue === "string") {
20861 return !filterValue.includes(fieldValue);
20862 }
20863 return false;
20864 }),
20865 selection: "multi"
20866 };
20867 var OPERATORS = [
20868 {
20869 name: OPERATOR_IS_ANY,
20870 /* translators: DataViews operator name */
20871 label: (0, import_i18n25.__)("Includes"),
20872 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20873 (0, import_i18n25.sprintf)(
20874 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20875 (0, import_i18n25.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20876 filter.name,
20877 activeElements.map((element) => element.label).join(", ")
20878 ),
20879 filterTextWrappers
20880 ),
20881 filter(item, field, filterValue) {
20882 if (!filterValue?.length) {
20883 return true;
20884 }
20885 const fieldValue = field.getValue({ item });
20886 if (Array.isArray(fieldValue)) {
20887 return filterValue.some(
20888 (fv) => fieldValue.includes(fv)
20889 );
20890 } else if (typeof fieldValue === "string") {
20891 return filterValue.includes(fieldValue);
20892 }
20893 return false;
20894 },
20895 selection: "multi"
20896 },
20897 {
20898 name: OPERATOR_IS_NONE,
20899 ...isNoneOperatorDefinition
20900 },
20901 {
20902 name: OPERATOR_IS_ALL,
20903 /* translators: DataViews operator name */
20904 label: (0, import_i18n25.__)("Includes all"),
20905 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20906 (0, import_i18n25.sprintf)(
20907 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20908 (0, import_i18n25.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20909 filter.name,
20910 activeElements.map((element) => element.label).join(", ")
20911 ),
20912 filterTextWrappers
20913 ),
20914 filter(item, field, filterValue) {
20915 if (!filterValue?.length) {
20916 return true;
20917 }
20918 return filterValue.every((value) => {
20919 return field.getValue({ item })?.includes(value);
20920 });
20921 },
20922 selection: "multi"
20923 },
20924 {
20925 name: OPERATOR_IS_NOT_ALL,
20926 ...isNoneOperatorDefinition
20927 },
20928 {
20929 name: OPERATOR_BETWEEN,
20930 /* translators: DataViews operator name */
20931 label: (0, import_i18n25.__)("Between (inc)"),
20932 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20933 (0, import_i18n25.sprintf)(
20934 /* 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". */
20935 (0, import_i18n25.__)(
20936 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20937 ),
20938 filter.name,
20939 activeElements[0].label[0],
20940 activeElements[0].label[1]
20941 ),
20942 filterTextWrappers
20943 ),
20944 filter(item, field, filterValue) {
20945 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20946 return true;
20947 }
20948 const fieldValue = field.getValue({ item });
20949 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20950 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20951 }
20952 return false;
20953 },
20954 selection: "custom"
20955 },
20956 {
20957 name: OPERATOR_IN_THE_PAST,
20958 /* translators: DataViews operator name */
20959 label: (0, import_i18n25.__)("In the past"),
20960 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20961 (0, import_i18n25.sprintf)(
20962 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20963 (0, import_i18n25.__)(
20964 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20965 ),
20966 filter.name,
20967 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20968 ),
20969 filterTextWrappers
20970 ),
20971 filter(item, field, filterValue) {
20972 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20973 return true;
20974 }
20975 const targetDate = getRelativeDate(
20976 filterValue.value,
20977 filterValue.unit
20978 );
20979 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20980 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
20981 },
20982 selection: "custom"
20983 },
20984 {
20985 name: OPERATOR_OVER,
20986 /* translators: DataViews operator name */
20987 label: (0, import_i18n25.__)("Over"),
20988 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
20989 (0, import_i18n25.sprintf)(
20990 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
20991 (0, import_i18n25.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
20992 filter.name,
20993 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20994 ),
20995 filterTextWrappers
20996 ),
20997 filter(item, field, filterValue) {
20998 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20999 return true;
21000 }
21001 const targetDate = getRelativeDate(
21002 filterValue.value,
21003 filterValue.unit
21004 );
21005 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21006 return fieldValue < targetDate;
21007 },
21008 selection: "custom"
21009 },
21010 {
21011 name: OPERATOR_IS,
21012 /* translators: DataViews operator name */
21013 label: (0, import_i18n25.__)("Is"),
21014 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21015 (0, import_i18n25.sprintf)(
21016 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21017 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21018 filter.name,
21019 activeElements[0].label
21020 ),
21021 filterTextWrappers
21022 ),
21023 filter(item, field, filterValue) {
21024 return filterValue === field.getValue({ item }) || filterValue === void 0;
21025 },
21026 selection: "single"
21027 },
21028 {
21029 name: OPERATOR_IS_NOT,
21030 /* translators: DataViews operator name */
21031 label: (0, import_i18n25.__)("Is not"),
21032 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21033 (0, import_i18n25.sprintf)(
21034 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21035 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21036 filter.name,
21037 activeElements[0].label
21038 ),
21039 filterTextWrappers
21040 ),
21041 filter(item, field, filterValue) {
21042 return filterValue !== field.getValue({ item });
21043 },
21044 selection: "single"
21045 },
21046 {
21047 name: OPERATOR_LESS_THAN,
21048 /* translators: DataViews operator name */
21049 label: (0, import_i18n25.__)("Less than"),
21050 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21051 (0, import_i18n25.sprintf)(
21052 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21053 (0, import_i18n25.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21054 filter.name,
21055 activeElements[0].label
21056 ),
21057 filterTextWrappers
21058 ),
21059 filter(item, field, filterValue) {
21060 if (filterValue === void 0) {
21061 return true;
21062 }
21063 const fieldValue = field.getValue({ item });
21064 return fieldValue < filterValue;
21065 },
21066 selection: "single"
21067 },
21068 {
21069 name: OPERATOR_GREATER_THAN,
21070 /* translators: DataViews operator name */
21071 label: (0, import_i18n25.__)("Greater than"),
21072 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21073 (0, import_i18n25.sprintf)(
21074 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21075 (0, import_i18n25.__)(
21076 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21077 ),
21078 filter.name,
21079 activeElements[0].label
21080 ),
21081 filterTextWrappers
21082 ),
21083 filter(item, field, filterValue) {
21084 if (filterValue === void 0) {
21085 return true;
21086 }
21087 const fieldValue = field.getValue({ item });
21088 return fieldValue > filterValue;
21089 },
21090 selection: "single"
21091 },
21092 {
21093 name: OPERATOR_LESS_THAN_OR_EQUAL,
21094 /* translators: DataViews operator name */
21095 label: (0, import_i18n25.__)("Less than or equal"),
21096 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21097 (0, import_i18n25.sprintf)(
21098 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21099 (0, import_i18n25.__)(
21100 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21101 ),
21102 filter.name,
21103 activeElements[0].label
21104 ),
21105 filterTextWrappers
21106 ),
21107 filter(item, field, filterValue) {
21108 if (filterValue === void 0) {
21109 return true;
21110 }
21111 const fieldValue = field.getValue({ item });
21112 return fieldValue <= filterValue;
21113 },
21114 selection: "single"
21115 },
21116 {
21117 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21118 /* translators: DataViews operator name */
21119 label: (0, import_i18n25.__)("Greater than or equal"),
21120 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21121 (0, import_i18n25.sprintf)(
21122 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21123 (0, import_i18n25.__)(
21124 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21125 ),
21126 filter.name,
21127 activeElements[0].label
21128 ),
21129 filterTextWrappers
21130 ),
21131 filter(item, field, filterValue) {
21132 if (filterValue === void 0) {
21133 return true;
21134 }
21135 const fieldValue = field.getValue({ item });
21136 return fieldValue >= filterValue;
21137 },
21138 selection: "single"
21139 },
21140 {
21141 name: OPERATOR_BEFORE,
21142 /* translators: DataViews operator name */
21143 label: (0, import_i18n25.__)("Before"),
21144 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21145 (0, import_i18n25.sprintf)(
21146 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21147 (0, import_i18n25.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21148 filter.name,
21149 activeElements[0].label
21150 ),
21151 filterTextWrappers
21152 ),
21153 filter(item, field, filterValue) {
21154 if (filterValue === void 0) {
21155 return true;
21156 }
21157 const filterDate = (0, import_date.getDate)(filterValue);
21158 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21159 return fieldDate < filterDate;
21160 },
21161 selection: "single"
21162 },
21163 {
21164 name: OPERATOR_AFTER,
21165 /* translators: DataViews operator name */
21166 label: (0, import_i18n25.__)("After"),
21167 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21168 (0, import_i18n25.sprintf)(
21169 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21170 (0, import_i18n25.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21171 filter.name,
21172 activeElements[0].label
21173 ),
21174 filterTextWrappers
21175 ),
21176 filter(item, field, filterValue) {
21177 if (filterValue === void 0) {
21178 return true;
21179 }
21180 const filterDate = (0, import_date.getDate)(filterValue);
21181 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21182 return fieldDate > filterDate;
21183 },
21184 selection: "single"
21185 },
21186 {
21187 name: OPERATOR_BEFORE_INC,
21188 /* translators: DataViews operator name */
21189 label: (0, import_i18n25.__)("Before (inc)"),
21190 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21191 (0, import_i18n25.sprintf)(
21192 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21193 (0, import_i18n25.__)(
21194 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21195 ),
21196 filter.name,
21197 activeElements[0].label
21198 ),
21199 filterTextWrappers
21200 ),
21201 filter(item, field, filterValue) {
21202 if (filterValue === void 0) {
21203 return true;
21204 }
21205 const filterDate = (0, import_date.getDate)(filterValue);
21206 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21207 return fieldDate <= filterDate;
21208 },
21209 selection: "single"
21210 },
21211 {
21212 name: OPERATOR_AFTER_INC,
21213 /* translators: DataViews operator name */
21214 label: (0, import_i18n25.__)("After (inc)"),
21215 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21216 (0, import_i18n25.sprintf)(
21217 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21218 (0, import_i18n25.__)(
21219 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21220 ),
21221 filter.name,
21222 activeElements[0].label
21223 ),
21224 filterTextWrappers
21225 ),
21226 filter(item, field, filterValue) {
21227 if (filterValue === void 0) {
21228 return true;
21229 }
21230 const filterDate = (0, import_date.getDate)(filterValue);
21231 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21232 return fieldDate >= filterDate;
21233 },
21234 selection: "single"
21235 },
21236 {
21237 name: OPERATOR_CONTAINS,
21238 /* translators: DataViews operator name */
21239 label: (0, import_i18n25.__)("Contains"),
21240 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21241 (0, import_i18n25.sprintf)(
21242 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21243 (0, import_i18n25.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21244 filter.name,
21245 activeElements[0].label
21246 ),
21247 filterTextWrappers
21248 ),
21249 filter(item, field, filterValue) {
21250 if (filterValue === void 0) {
21251 return true;
21252 }
21253 const fieldValue = field.getValue({ item });
21254 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21255 },
21256 selection: "single"
21257 },
21258 {
21259 name: OPERATOR_NOT_CONTAINS,
21260 /* translators: DataViews operator name */
21261 label: (0, import_i18n25.__)("Doesn't contain"),
21262 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21263 (0, import_i18n25.sprintf)(
21264 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21265 (0, import_i18n25.__)(
21266 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21267 ),
21268 filter.name,
21269 activeElements[0].label
21270 ),
21271 filterTextWrappers
21272 ),
21273 filter(item, field, filterValue) {
21274 if (filterValue === void 0) {
21275 return true;
21276 }
21277 const fieldValue = field.getValue({ item });
21278 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21279 },
21280 selection: "single"
21281 },
21282 {
21283 name: OPERATOR_STARTS_WITH,
21284 /* translators: DataViews operator name */
21285 label: (0, import_i18n25.__)("Starts with"),
21286 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21287 (0, import_i18n25.sprintf)(
21288 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21289 (0, import_i18n25.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21290 filter.name,
21291 activeElements[0].label
21292 ),
21293 filterTextWrappers
21294 ),
21295 filter(item, field, filterValue) {
21296 if (filterValue === void 0) {
21297 return true;
21298 }
21299 const fieldValue = field.getValue({ item });
21300 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21301 },
21302 selection: "single"
21303 },
21304 {
21305 name: OPERATOR_ON,
21306 /* translators: DataViews operator name */
21307 label: (0, import_i18n25.__)("On"),
21308 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21309 (0, import_i18n25.sprintf)(
21310 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21311 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21312 filter.name,
21313 activeElements[0].label
21314 ),
21315 filterTextWrappers
21316 ),
21317 filter(item, field, filterValue) {
21318 if (filterValue === void 0) {
21319 return true;
21320 }
21321 const filterDate = (0, import_date.getDate)(filterValue);
21322 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21323 return filterDate.getTime() === fieldDate.getTime();
21324 },
21325 selection: "single"
21326 },
21327 {
21328 name: OPERATOR_NOT_ON,
21329 /* translators: DataViews operator name */
21330 label: (0, import_i18n25.__)("Not on"),
21331 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21332 (0, import_i18n25.sprintf)(
21333 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21334 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21335 filter.name,
21336 activeElements[0].label
21337 ),
21338 filterTextWrappers
21339 ),
21340 filter(item, field, filterValue) {
21341 if (filterValue === void 0) {
21342 return true;
21343 }
21344 const filterDate = (0, import_date.getDate)(filterValue);
21345 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21346 return filterDate.getTime() !== fieldDate.getTime();
21347 },
21348 selection: "single"
21349 }
21350 ];
21351 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21352 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21353 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21354 (op) => op.name === name
21355 );
21356 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21357
21358 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21359 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21360 var ENTER = "Enter";
21361 var SPACE = " ";
21362 var FilterText = ({
21363 activeElements,
21364 filterInView,
21365 filter
21366 }) => {
21367 if (activeElements === void 0 || activeElements.length === 0) {
21368 return filter.name;
21369 }
21370 const operator = getOperatorByName(filterInView?.operator);
21371 if (operator !== void 0) {
21372 return operator.filterText(filter, activeElements);
21373 }
21374 return (0, import_i18n26.sprintf)(
21375 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21376 (0, import_i18n26.__)("Unknown status for %1$s"),
21377 filter.name
21378 );
21379 };
21380 function OperatorSelector({
21381 filter,
21382 view,
21383 onChangeView
21384 }) {
21385 const operatorOptions = filter.operators?.map((operator) => ({
21386 value: operator,
21387 label: getOperatorByName(operator)?.label || operator
21388 }));
21389 const currentFilter = view.filters?.find(
21390 (_filter) => _filter.field === filter.field
21391 );
21392 const value = currentFilter?.operator || filter.operators[0];
21393 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
21394 Stack,
21395 {
21396 direction: "row",
21397 gap: "sm",
21398 justify: "flex-start",
21399 className: "dataviews-filters__summary-operators-container",
21400 align: "center",
21401 children: [
21402 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21403 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21404 import_components21.SelectControl,
21405 {
21406 className: "dataviews-filters__summary-operators-filter-select",
21407 label: (0, import_i18n26.__)("Conditions"),
21408 value,
21409 options: operatorOptions,
21410 onChange: (newValue) => {
21411 const newOperator = newValue;
21412 const currentOperator = currentFilter?.operator;
21413 const newFilters = currentFilter ? [
21414 ...(view.filters ?? []).map(
21415 (_filter) => {
21416 if (_filter.field === filter.field) {
21417 const currentOpSelectionModel = getOperatorByName(
21418 currentOperator
21419 )?.selection;
21420 const newOpSelectionModel = getOperatorByName(
21421 newOperator
21422 )?.selection;
21423 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21424 currentOpSelectionModel,
21425 newOpSelectionModel
21426 ].includes("custom");
21427 return {
21428 ..._filter,
21429 value: shouldResetValue ? void 0 : _filter.value,
21430 operator: newOperator
21431 };
21432 }
21433 return _filter;
21434 }
21435 )
21436 ] : [
21437 ...view.filters ?? [],
21438 {
21439 field: filter.field,
21440 operator: newOperator,
21441 value: void 0
21442 }
21443 ];
21444 onChangeView({
21445 ...view,
21446 page: 1,
21447 filters: newFilters
21448 });
21449 },
21450 size: "small",
21451 variant: "minimal",
21452 hideLabelFromVision: true
21453 }
21454 )
21455 ]
21456 }
21457 );
21458 }
21459 function Filter({
21460 addFilterRef,
21461 openedFilter,
21462 fields,
21463 ...commonProps
21464 }) {
21465 const toggleRef = (0, import_element53.useRef)(null);
21466 const { filter, view, onChangeView } = commonProps;
21467 const filterInView = view.filters?.find(
21468 (f2) => f2.field === filter.field
21469 );
21470 let activeElements = [];
21471 const field = (0, import_element53.useMemo)(() => {
21472 const currentField = fields.find((f2) => f2.id === filter.field);
21473 if (currentField) {
21474 return {
21475 ...currentField,
21476 // Configure getValue as if Item was a plain object.
21477 // See related input-widget.tsx
21478 getValue: ({ item }) => item[currentField.id]
21479 };
21480 }
21481 return currentField;
21482 }, [fields, filter.field]);
21483 const { elements } = useElements({
21484 elements: filter.elements,
21485 getElements: filter.getElements
21486 });
21487 if (elements.length > 0) {
21488 activeElements = elements.filter((element) => {
21489 if (filter.singleSelection) {
21490 return element.value === filterInView?.value;
21491 }
21492 return filterInView?.value?.includes(element.value);
21493 });
21494 } else if (Array.isArray(filterInView?.value)) {
21495 const label = filterInView.value.map((v2) => {
21496 const formattedValue = field?.getValueFormatted({
21497 item: { [field.id]: v2 },
21498 field
21499 });
21500 return formattedValue || String(v2);
21501 });
21502 activeElements = [
21503 {
21504 value: filterInView.value,
21505 // @ts-ignore
21506 label
21507 }
21508 ];
21509 } else if (typeof filterInView?.value === "object") {
21510 activeElements = [
21511 { value: filterInView.value, label: filterInView.value }
21512 ];
21513 } else if (filterInView?.value !== void 0) {
21514 const label = field !== void 0 ? field.getValueFormatted({
21515 item: { [field.id]: filterInView.value },
21516 field
21517 }) : String(filterInView.value);
21518 activeElements = [
21519 {
21520 value: filterInView.value,
21521 label
21522 }
21523 ];
21524 }
21525 const isPrimary = filter.isPrimary;
21526 const isLocked = filterInView?.isLocked;
21527 const hasValues = !isLocked && filterInView?.value !== void 0;
21528 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21529 const resetOrRemoveLabel = isPrimary ? (0, import_i18n26.__)("Reset") : (0, import_i18n26.__)("Remove");
21530 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21531 import_components21.Dropdown,
21532 {
21533 defaultOpen: openedFilter === filter.field,
21534 contentClassName: "dataviews-filters__summary-popover",
21535 popoverProps: { placement: "bottom-start", role: "dialog" },
21536 onClose: () => {
21537 toggleRef.current?.focus();
21538 },
21539 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21540 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
21541 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21542 tooltip_exports.Trigger,
21543 {
21544 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21545 "div",
21546 {
21547 className: clsx_default(
21548 "dataviews-filters__summary-chip",
21549 {
21550 "has-reset": canResetOrRemove,
21551 "has-values": hasValues,
21552 "is-not-clickable": isLocked
21553 }
21554 ),
21555 role: "button",
21556 tabIndex: isLocked ? -1 : 0,
21557 onClick: () => {
21558 if (!isLocked) {
21559 onToggle();
21560 }
21561 },
21562 onKeyDown: (event) => {
21563 if (!isLocked && [ENTER, SPACE].includes(
21564 event.key
21565 )) {
21566 onToggle();
21567 event.preventDefault();
21568 }
21569 },
21570 "aria-disabled": isLocked,
21571 "aria-pressed": isOpen,
21572 "aria-expanded": isOpen,
21573 ref: toggleRef,
21574 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21575 FilterText,
21576 {
21577 activeElements,
21578 filterInView,
21579 filter
21580 }
21581 )
21582 }
21583 )
21584 }
21585 ),
21586 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n26.sprintf)(
21587 /* translators: 1: Filter name. */
21588 (0, import_i18n26.__)("Filter by: %1$s"),
21589 filter.name.toLowerCase()
21590 ) })
21591 ] }),
21592 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
21593 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21594 tooltip_exports.Trigger,
21595 {
21596 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21597 "button",
21598 {
21599 className: clsx_default(
21600 "dataviews-filters__summary-chip-remove",
21601 { "has-values": hasValues }
21602 ),
21603 "aria-label": resetOrRemoveLabel,
21604 onClick: () => {
21605 onChangeView({
21606 ...view,
21607 page: 1,
21608 filters: view.filters?.filter(
21609 (_filter) => _filter.field !== filter.field
21610 )
21611 });
21612 if (!isPrimary) {
21613 addFilterRef.current?.focus();
21614 } else {
21615 toggleRef.current?.focus();
21616 }
21617 },
21618 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
21619 }
21620 )
21621 }
21622 ),
21623 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21624 ] })
21625 ] }),
21626 renderContent: () => {
21627 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21628 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
21629 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21630 SearchWidget,
21631 {
21632 ...commonProps,
21633 filter: {
21634 ...commonProps.filter,
21635 elements
21636 }
21637 }
21638 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
21639 ] });
21640 }
21641 }
21642 );
21643 }
21644
21645 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21646 var import_components22 = __toESM(require_components(), 1);
21647 var import_i18n27 = __toESM(require_i18n(), 1);
21648 var import_element54 = __toESM(require_element(), 1);
21649 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21650 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
21651 function AddFilterMenu({
21652 filters,
21653 view,
21654 onChangeView,
21655 setOpenedFilter,
21656 triggerProps
21657 }) {
21658 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21659 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
21660 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21661 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21662 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21663 Menu4.Item,
21664 {
21665 onClick: () => {
21666 setOpenedFilter(filter.field);
21667 onChangeView({
21668 ...view,
21669 page: 1,
21670 filters: [
21671 ...view.filters || [],
21672 {
21673 field: filter.field,
21674 value: void 0,
21675 operator: filter.operators[0]
21676 }
21677 ]
21678 });
21679 },
21680 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
21681 },
21682 filter.field
21683 );
21684 }) })
21685 ] });
21686 }
21687 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21688 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21689 return null;
21690 }
21691 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21692 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21693 AddFilterMenu,
21694 {
21695 triggerProps: {
21696 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21697 import_components22.Button,
21698 {
21699 accessibleWhenDisabled: true,
21700 size: "compact",
21701 className: "dataviews-filters-button",
21702 variant: "tertiary",
21703 disabled: !inactiveFilters.length,
21704 ref
21705 }
21706 ),
21707 children: (0, import_i18n27.__)("Add filter")
21708 },
21709 ...{ filters, view, onChangeView, setOpenedFilter }
21710 }
21711 );
21712 }
21713 var add_filter_default = (0, import_element54.forwardRef)(AddFilter);
21714
21715 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21716 var import_components23 = __toESM(require_components(), 1);
21717 var import_i18n28 = __toESM(require_i18n(), 1);
21718 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21719 function ResetFilter({
21720 filters,
21721 view,
21722 onChangeView
21723 }) {
21724 const isPrimary = (field) => filters.some(
21725 (_filter) => _filter.field === field && _filter.isPrimary
21726 );
21727 const isDisabled = !view.search && !view.filters?.some(
21728 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21729 );
21730 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21731 import_components23.Button,
21732 {
21733 disabled: isDisabled,
21734 accessibleWhenDisabled: true,
21735 size: "compact",
21736 variant: "tertiary",
21737 className: "dataviews-filters__reset-button",
21738 onClick: () => {
21739 onChangeView({
21740 ...view,
21741 page: 1,
21742 search: "",
21743 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21744 });
21745 },
21746 children: (0, import_i18n28.__)("Reset")
21747 }
21748 );
21749 }
21750
21751 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21752 var import_element55 = __toESM(require_element(), 1);
21753 function useFilters(fields, view) {
21754 return (0, import_element55.useMemo)(() => {
21755 const filters = [];
21756 fields.forEach((field) => {
21757 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21758 return;
21759 }
21760 const operators = field.filterBy.operators;
21761 const isPrimary = !!field.filterBy?.isPrimary;
21762 const isLocked = view.filters?.some(
21763 (f2) => f2.field === field.id && !!f2.isLocked
21764 ) ?? false;
21765 filters.push({
21766 field: field.id,
21767 name: field.label,
21768 elements: field.elements,
21769 getElements: field.getElements,
21770 hasElements: field.hasElements,
21771 singleSelection: operators.some(
21772 (op) => isSingleSelectionOperator(op)
21773 ),
21774 operators,
21775 isVisible: isLocked || isPrimary || !!view.filters?.some(
21776 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21777 ),
21778 isPrimary,
21779 isLocked
21780 });
21781 });
21782 filters.sort((a2, b2) => {
21783 if (a2.isLocked && !b2.isLocked) {
21784 return -1;
21785 }
21786 if (!a2.isLocked && b2.isLocked) {
21787 return 1;
21788 }
21789 if (a2.isPrimary && !b2.isPrimary) {
21790 return -1;
21791 }
21792 if (!a2.isPrimary && b2.isPrimary) {
21793 return 1;
21794 }
21795 return a2.name.localeCompare(b2.name);
21796 });
21797 return filters;
21798 }, [fields, view]);
21799 }
21800 var use_filters_default = useFilters;
21801
21802 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21803 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
21804 function Filters({ className }) {
21805 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element56.useContext)(dataviews_context_default);
21806 const addFilterRef = (0, import_element56.useRef)(null);
21807 const filters = use_filters_default(fields, view);
21808 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21809 add_filter_default,
21810 {
21811 filters,
21812 view,
21813 onChangeView,
21814 ref: addFilterRef,
21815 setOpenedFilter
21816 },
21817 "add-filter"
21818 );
21819 const visibleFilters = filters.filter((filter) => filter.isVisible);
21820 if (visibleFilters.length === 0) {
21821 return null;
21822 }
21823 const filterComponents = [
21824 ...visibleFilters.map((filter) => {
21825 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21826 Filter,
21827 {
21828 filter,
21829 view,
21830 fields,
21831 onChangeView,
21832 addFilterRef,
21833 openedFilter
21834 },
21835 filter.field
21836 );
21837 }),
21838 addFilter
21839 ];
21840 filterComponents.push(
21841 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21842 ResetFilter,
21843 {
21844 filters,
21845 view,
21846 onChangeView
21847 },
21848 "reset-filters"
21849 )
21850 );
21851 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21852 Stack,
21853 {
21854 direction: "row",
21855 justify: "flex-start",
21856 gap: "sm",
21857 style: { width: "fit-content" },
21858 wrap: "wrap",
21859 className,
21860 children: filterComponents
21861 }
21862 );
21863 }
21864 var filters_default = (0, import_element56.memo)(Filters);
21865
21866 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21867 var import_element57 = __toESM(require_element(), 1);
21868 var import_components24 = __toESM(require_components(), 1);
21869 var import_i18n29 = __toESM(require_i18n(), 1);
21870 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
21871 function FiltersToggle() {
21872 const {
21873 filters,
21874 view,
21875 onChangeView,
21876 setOpenedFilter,
21877 isShowingFilter,
21878 setIsShowingFilter
21879 } = (0, import_element57.useContext)(dataviews_context_default);
21880 const buttonRef = (0, import_element57.useRef)(null);
21881 const onChangeViewWithFilterVisibility = (0, import_element57.useCallback)(
21882 (_view) => {
21883 onChangeView(_view);
21884 setIsShowingFilter(true);
21885 },
21886 [onChangeView, setIsShowingFilter]
21887 );
21888 if (filters.length === 0) {
21889 return null;
21890 }
21891 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21892 const addFilterButtonProps = {
21893 label: (0, import_i18n29.__)("Add filter"),
21894 "aria-expanded": false,
21895 isPressed: false
21896 };
21897 const toggleFiltersButtonProps = {
21898 label: (0, import_i18n29._x)("Filter", "verb"),
21899 "aria-expanded": isShowingFilter,
21900 isPressed: isShowingFilter,
21901 onClick: () => {
21902 if (!isShowingFilter) {
21903 setOpenedFilter(null);
21904 }
21905 setIsShowingFilter(!isShowingFilter);
21906 }
21907 };
21908 const hasPrimaryOrLockedFilters = filters.some(
21909 (filter) => filter.isPrimary || filter.isLocked
21910 );
21911 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
21912 import_components24.Button,
21913 {
21914 ref: buttonRef,
21915 className: "dataviews-filters__visibility-toggle",
21916 size: "compact",
21917 icon: funnel_default,
21918 disabled: hasPrimaryOrLockedFilters,
21919 accessibleWhenDisabled: true,
21920 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21921 }
21922 );
21923 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
21924 AddFilterMenu,
21925 {
21926 filters,
21927 view,
21928 onChangeView: onChangeViewWithFilterVisibility,
21929 setOpenedFilter,
21930 triggerProps: { render: buttonComponent }
21931 }
21932 ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
21933 FilterVisibilityToggle,
21934 {
21935 buttonRef,
21936 filtersCount: view.filters?.length,
21937 children: buttonComponent
21938 }
21939 ) });
21940 }
21941 function FilterVisibilityToggle({
21942 buttonRef,
21943 filtersCount,
21944 children
21945 }) {
21946 (0, import_element57.useEffect)(
21947 () => () => {
21948 buttonRef.current?.focus();
21949 },
21950 [buttonRef]
21951 );
21952 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
21953 children,
21954 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21955 ] });
21956 }
21957 var toggle_default = FiltersToggle;
21958
21959 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21960 var import_element58 = __toESM(require_element(), 1);
21961 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
21962 function FiltersToggled(props) {
21963 const { isShowingFilter } = (0, import_element58.useContext)(dataviews_context_default);
21964 if (!isShowingFilter) {
21965 return null;
21966 }
21967 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
21968 }
21969 var filters_toggled_default = FiltersToggled;
21970
21971 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
21972 var import_element59 = __toESM(require_element(), 1);
21973 var import_components25 = __toESM(require_components(), 1);
21974 var import_i18n30 = __toESM(require_i18n(), 1);
21975 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
21976 function DataViewsLayout({ className }) {
21977 const {
21978 actions = [],
21979 data,
21980 fields,
21981 getItemId,
21982 getItemLevel,
21983 hasInitiallyLoaded,
21984 isLoading,
21985 view,
21986 onChangeView,
21987 selection,
21988 onChangeSelection,
21989 setOpenedFilter,
21990 onClickItem,
21991 isItemClickable,
21992 renderItemLink,
21993 defaultLayouts,
21994 containerRef,
21995 empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n30.__)("No results") })
21996 } = (0, import_element59.useContext)(dataviews_context_default);
21997 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
21998 delay: 200
21999 });
22000 if (!hasInitiallyLoaded) {
22001 if (!isDelayedInitialLoading) {
22002 return null;
22003 }
22004 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components25.Spinner, {}) }) });
22005 }
22006 const ViewComponent = VIEW_LAYOUTS.find(
22007 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22008 )?.component;
22009 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22010 ViewComponent,
22011 {
22012 className,
22013 actions,
22014 data,
22015 fields,
22016 getItemId,
22017 getItemLevel,
22018 isLoading,
22019 onChangeView,
22020 onChangeSelection,
22021 selection,
22022 setOpenedFilter,
22023 onClickItem,
22024 renderItemLink,
22025 isItemClickable,
22026 view,
22027 empty
22028 }
22029 ) });
22030 }
22031
22032 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22033 var import_element60 = __toESM(require_element(), 1);
22034 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22035 var EMPTY_ARRAY5 = [];
22036 function DataViewsFooter() {
22037 const {
22038 view,
22039 paginationInfo: { totalItems = 0, totalPages },
22040 data,
22041 actions = EMPTY_ARRAY5,
22042 isLoading,
22043 hasInitiallyLoaded
22044 } = (0, import_element60.useContext)(dataviews_context_default);
22045 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22046 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22047 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22048 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22049 return null;
22050 }
22051 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22052 "div",
22053 {
22054 className: "dataviews-footer",
22055 inert: isRefreshing ? "true" : void 0,
22056 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22057 Stack,
22058 {
22059 direction: "row",
22060 justify: "end",
22061 align: "center",
22062 className: clsx_default("dataviews-footer__content", {
22063 "is-refreshing": isDelayedRefreshing
22064 }),
22065 gap: "sm",
22066 children: [
22067 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BulkActionsFooter, {}),
22068 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(dataviews_pagination_default, {})
22069 ]
22070 }
22071 )
22072 }
22073 );
22074 }
22075
22076 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22077 var import_i18n31 = __toESM(require_i18n(), 1);
22078 var import_element61 = __toESM(require_element(), 1);
22079 var import_components26 = __toESM(require_components(), 1);
22080 var import_compose10 = __toESM(require_compose(), 1);
22081 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22082 var DataViewsSearch = (0, import_element61.memo)(function Search({ label }) {
22083 const { view, onChangeView } = (0, import_element61.useContext)(dataviews_context_default);
22084 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22085 view.search
22086 );
22087 (0, import_element61.useEffect)(() => {
22088 if (view.search !== debouncedSearch) {
22089 setSearch(view.search ?? "");
22090 }
22091 }, [view.search, setSearch]);
22092 const onChangeViewRef = (0, import_element61.useRef)(onChangeView);
22093 const viewRef = (0, import_element61.useRef)(view);
22094 (0, import_element61.useEffect)(() => {
22095 onChangeViewRef.current = onChangeView;
22096 viewRef.current = view;
22097 }, [onChangeView, view]);
22098 (0, import_element61.useEffect)(() => {
22099 if (debouncedSearch !== viewRef.current?.search) {
22100 onChangeViewRef.current({
22101 ...viewRef.current,
22102 page: view.page ? 1 : void 0,
22103 startPosition: view.startPosition ? 1 : void 0,
22104 search: debouncedSearch
22105 });
22106 }
22107 }, [debouncedSearch]);
22108 const searchLabel = label || (0, import_i18n31.__)("Search");
22109 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22110 import_components26.SearchControl,
22111 {
22112 className: "dataviews-search",
22113 onChange: setSearch,
22114 value: search,
22115 label: searchLabel,
22116 placeholder: searchLabel,
22117 size: "compact"
22118 }
22119 );
22120 });
22121 var dataviews_search_default = DataViewsSearch;
22122
22123 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22124 var import_components27 = __toESM(require_components(), 1);
22125 var import_i18n32 = __toESM(require_i18n(), 1);
22126 var import_element62 = __toESM(require_element(), 1);
22127 var import_warning = __toESM(require_warning(), 1);
22128 var import_compose11 = __toESM(require_compose(), 1);
22129 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22130 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22131 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22132 className: "dataviews-config__popover",
22133 placement: "bottom-end",
22134 offset: 9
22135 };
22136 function ViewTypeMenu() {
22137 const { view, onChangeView, defaultLayouts } = (0, import_element62.useContext)(dataviews_context_default);
22138 const availableLayouts = Object.keys(defaultLayouts);
22139 if (availableLayouts.length <= 1) {
22140 return null;
22141 }
22142 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22143 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu5, { children: [
22144 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22145 Menu5.TriggerButton,
22146 {
22147 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22148 import_components27.Button,
22149 {
22150 size: "compact",
22151 icon: activeView?.icon,
22152 label: (0, import_i18n32.__)("Layout")
22153 }
22154 )
22155 }
22156 ),
22157 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22158 const config = VIEW_LAYOUTS.find(
22159 (v2) => v2.type === layout
22160 );
22161 if (!config) {
22162 return null;
22163 }
22164 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22165 Menu5.RadioItem,
22166 {
22167 value: layout,
22168 name: "view-actions-available-view",
22169 checked: layout === view.type,
22170 hideOnClick: true,
22171 onChange: (e2) => {
22172 switch (e2.target.value) {
22173 case "list":
22174 case "grid":
22175 case "table":
22176 case "pickerGrid":
22177 case "pickerTable":
22178 case "pickerActivity":
22179 case "activity":
22180 const viewWithoutLayout = { ...view };
22181 if ("layout" in viewWithoutLayout) {
22182 delete viewWithoutLayout.layout;
22183 }
22184 return onChangeView({
22185 ...viewWithoutLayout,
22186 type: e2.target.value,
22187 ...defaultLayouts[e2.target.value]
22188 });
22189 }
22190 (0, import_warning.default)("Invalid dataview");
22191 },
22192 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.ItemLabel, { children: config.label })
22193 },
22194 layout
22195 );
22196 }) })
22197 ] });
22198 }
22199 function SortFieldControl() {
22200 const { view, fields, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22201 const orderOptions = (0, import_element62.useMemo)(() => {
22202 const sortableFields = fields.filter(
22203 (field) => field.enableSorting !== false
22204 );
22205 return sortableFields.map((field) => {
22206 return {
22207 label: field.label,
22208 value: field.id
22209 };
22210 });
22211 }, [fields]);
22212 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22213 import_components27.SelectControl,
22214 {
22215 __next40pxDefaultSize: true,
22216 label: (0, import_i18n32.__)("Sort by"),
22217 value: view.sort?.field,
22218 options: orderOptions,
22219 onChange: (value) => {
22220 onChangeView({
22221 ...view,
22222 sort: {
22223 direction: view?.sort?.direction || "desc",
22224 field: value
22225 },
22226 showLevels: false
22227 });
22228 }
22229 }
22230 );
22231 }
22232 function SortDirectionControl() {
22233 const { view, fields, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22234 const sortableFields = fields.filter(
22235 (field) => field.enableSorting !== false
22236 );
22237 if (sortableFields.length === 0) {
22238 return null;
22239 }
22240 let value = view.sort?.direction;
22241 if (!value && view.sort?.field) {
22242 value = "desc";
22243 }
22244 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22245 import_components27.__experimentalToggleGroupControl,
22246 {
22247 className: "dataviews-view-config__sort-direction",
22248 __next40pxDefaultSize: true,
22249 isBlock: true,
22250 label: (0, import_i18n32.__)("Order"),
22251 value,
22252 onChange: (newDirection) => {
22253 if (newDirection === "asc" || newDirection === "desc") {
22254 onChangeView({
22255 ...view,
22256 sort: {
22257 direction: newDirection,
22258 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22259 fields.find(
22260 (field) => field.enableSorting !== false
22261 )?.id || ""
22262 },
22263 showLevels: false
22264 });
22265 return;
22266 }
22267 (0, import_warning.default)("Invalid direction");
22268 },
22269 children: SORTING_DIRECTIONS.map((direction) => {
22270 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22271 import_components27.__experimentalToggleGroupControlOptionIcon,
22272 {
22273 value: direction,
22274 icon: sortIcons[direction],
22275 label: sortLabels[direction]
22276 },
22277 direction
22278 );
22279 })
22280 }
22281 );
22282 }
22283 function ItemsPerPageControl() {
22284 const { view, config, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22285 const { infiniteScrollEnabled } = view;
22286 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22287 return null;
22288 }
22289 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22290 import_components27.__experimentalToggleGroupControl,
22291 {
22292 __next40pxDefaultSize: true,
22293 isBlock: true,
22294 label: (0, import_i18n32.__)("Items per page"),
22295 value: view.perPage || 10,
22296 disabled: !view?.sort?.field,
22297 onChange: (newItemsPerPage) => {
22298 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22299 onChangeView({
22300 ...view,
22301 perPage: newItemsPerPageNumber,
22302 page: 1
22303 });
22304 },
22305 children: config.perPageSizes.map((value) => {
22306 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22307 import_components27.__experimentalToggleGroupControlOption,
22308 {
22309 value,
22310 label: value.toString()
22311 },
22312 value
22313 );
22314 })
22315 }
22316 );
22317 }
22318 function ResetViewButton() {
22319 const { onReset } = (0, import_element62.useContext)(dataviews_context_default);
22320 if (onReset === void 0) {
22321 return null;
22322 }
22323 const isDisabled = onReset === false;
22324 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22325 import_components27.Button,
22326 {
22327 variant: "tertiary",
22328 size: "compact",
22329 disabled: isDisabled,
22330 accessibleWhenDisabled: true,
22331 className: "dataviews-view-config__reset-button",
22332 onClick: () => {
22333 if (typeof onReset === "function") {
22334 onReset();
22335 }
22336 },
22337 children: (0, import_i18n32.__)("Reset view")
22338 }
22339 );
22340 }
22341 function DataviewsViewConfigDropdown() {
22342 const { view, onReset } = (0, import_element62.useContext)(dataviews_context_default);
22343 const popoverId = (0, import_compose11.useInstanceId)(
22344 _DataViewsViewConfig,
22345 "dataviews-view-config-dropdown"
22346 );
22347 const activeLayout = VIEW_LAYOUTS.find(
22348 (layout) => layout.type === view.type
22349 );
22350 const isModified = typeof onReset === "function";
22351 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22352 import_components27.Dropdown,
22353 {
22354 expandOnMobile: true,
22355 popoverProps: {
22356 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22357 id: popoverId
22358 },
22359 renderToggle: ({ onToggle, isOpen }) => {
22360 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22361 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22362 import_components27.Button,
22363 {
22364 size: "compact",
22365 icon: cog_default,
22366 label: (0, import_i18n32._x)(
22367 "View options",
22368 "View is used as a noun"
22369 ),
22370 onClick: onToggle,
22371 "aria-expanded": isOpen ? "true" : "false",
22372 "aria-controls": popoverId
22373 }
22374 ),
22375 isModified && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22376 ] });
22377 },
22378 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22379 import_components27.__experimentalDropdownContentWrapper,
22380 {
22381 paddingSize: "medium",
22382 className: "dataviews-config__popover-content-wrapper",
22383 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22384 Stack,
22385 {
22386 direction: "column",
22387 className: "dataviews-view-config",
22388 gap: "xl",
22389 children: [
22390 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22391 Stack,
22392 {
22393 direction: "row",
22394 justify: "space-between",
22395 align: "center",
22396 className: "dataviews-view-config__header",
22397 children: [
22398 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22399 import_components27.__experimentalHeading,
22400 {
22401 level: 2,
22402 className: "dataviews-settings-section__title",
22403 children: (0, import_i18n32.__)("Appearance")
22404 }
22405 ),
22406 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ResetViewButton, {})
22407 ]
22408 }
22409 ),
22410 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22411 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22412 Stack,
22413 {
22414 direction: "row",
22415 gap: "sm",
22416 className: "dataviews-view-config__sort-controls",
22417 children: [
22418 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortFieldControl, {}),
22419 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortDirectionControl, {})
22420 ]
22421 }
22422 ),
22423 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(activeLayout.viewConfigOptions, {}),
22424 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ItemsPerPageControl, {}),
22425 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(PropertiesSection, {})
22426 ] })
22427 ]
22428 }
22429 )
22430 }
22431 )
22432 }
22433 );
22434 }
22435 function _DataViewsViewConfig() {
22436 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
22437 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ViewTypeMenu, {}),
22438 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DataviewsViewConfigDropdown, {})
22439 ] });
22440 }
22441 var DataViewsViewConfig = (0, import_element62.memo)(_DataViewsViewConfig);
22442 var dataviews_view_config_default = DataViewsViewConfig;
22443
22444 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22445 var import_components28 = __toESM(require_components(), 1);
22446 var import_element63 = __toESM(require_element(), 1);
22447
22448 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22449 function getCustomValidity(isValid2, validity) {
22450 let customValidity;
22451 if (isValid2?.required && validity?.required) {
22452 customValidity = validity?.required?.message ? validity.required : void 0;
22453 } else if (isValid2?.pattern && validity?.pattern) {
22454 customValidity = validity.pattern;
22455 } else if (isValid2?.min && validity?.min) {
22456 customValidity = validity.min;
22457 } else if (isValid2?.max && validity?.max) {
22458 customValidity = validity.max;
22459 } else if (isValid2?.minLength && validity?.minLength) {
22460 customValidity = validity.minLength;
22461 } else if (isValid2?.maxLength && validity?.maxLength) {
22462 customValidity = validity.maxLength;
22463 } else if (isValid2?.elements && validity?.elements) {
22464 customValidity = validity.elements;
22465 } else if (validity?.custom) {
22466 customValidity = validity.custom;
22467 }
22468 return customValidity;
22469 }
22470
22471 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22472 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22473 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
22474 function Checkbox({
22475 field,
22476 onChange,
22477 data,
22478 hideLabelFromVision,
22479 markWhenOptional,
22480 validity
22481 }) {
22482 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22483 const disabled2 = field.isDisabled({ item: data, field });
22484 const onChangeControl = (0, import_element63.useCallback)(() => {
22485 onChange(
22486 setValue({ item: data, value: !getValue({ item: data }) })
22487 );
22488 }, [data, getValue, onChange, setValue]);
22489 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22490 ValidatedCheckboxControl,
22491 {
22492 required: !!field.isValid?.required,
22493 markWhenOptional,
22494 customValidity: getCustomValidity(isValid2, validity),
22495 hidden: hideLabelFromVision,
22496 label,
22497 help: description,
22498 checked: getValue({ item: data }),
22499 onChange: onChangeControl,
22500 disabled: disabled2
22501 }
22502 );
22503 }
22504
22505 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22506 var import_components29 = __toESM(require_components(), 1);
22507 var import_element64 = __toESM(require_element(), 1);
22508 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22509 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
22510 function Combobox3({
22511 data,
22512 field,
22513 onChange,
22514 hideLabelFromVision,
22515 validity
22516 }) {
22517 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22518 const value = getValue({ item: data }) ?? "";
22519 const onChangeControl = (0, import_element64.useCallback)(
22520 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22521 [data, onChange, setValue]
22522 );
22523 const { elements, isLoading } = useElements({
22524 elements: field.elements,
22525 getElements: field.getElements
22526 });
22527 if (isLoading) {
22528 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components29.Spinner, {});
22529 }
22530 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22531 ValidatedComboboxControl,
22532 {
22533 required: !!field.isValid?.required,
22534 customValidity: getCustomValidity(isValid2, validity),
22535 label,
22536 value,
22537 help: description,
22538 placeholder,
22539 options: elements,
22540 onChange: onChangeControl,
22541 hideLabelFromVision,
22542 allowReset: true,
22543 expandOnFocus: true
22544 }
22545 );
22546 }
22547
22548 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22549 var import_components31 = __toESM(require_components(), 1);
22550 var import_element67 = __toESM(require_element(), 1);
22551 var import_i18n34 = __toESM(require_i18n(), 1);
22552 var import_date3 = __toESM(require_date(), 1);
22553
22554 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22555 var import_components30 = __toESM(require_components(), 1);
22556 var import_element65 = __toESM(require_element(), 1);
22557 var import_i18n33 = __toESM(require_i18n(), 1);
22558 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22559 var TIME_UNITS_OPTIONS = {
22560 [OPERATOR_IN_THE_PAST]: [
22561 { value: "days", label: (0, import_i18n33.__)("Days") },
22562 { value: "weeks", label: (0, import_i18n33.__)("Weeks") },
22563 { value: "months", label: (0, import_i18n33.__)("Months") },
22564 { value: "years", label: (0, import_i18n33.__)("Years") }
22565 ],
22566 [OPERATOR_OVER]: [
22567 { value: "days", label: (0, import_i18n33.__)("Days ago") },
22568 { value: "weeks", label: (0, import_i18n33.__)("Weeks ago") },
22569 { value: "months", label: (0, import_i18n33.__)("Months ago") },
22570 { value: "years", label: (0, import_i18n33.__)("Years ago") }
22571 ]
22572 };
22573 function RelativeDateControl({
22574 className,
22575 data,
22576 field,
22577 onChange,
22578 hideLabelFromVision,
22579 operator
22580 }) {
22581 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22582 const { id, label, description, getValue, setValue } = field;
22583 const disabled2 = field.isDisabled({ item: data, field });
22584 const fieldValue = getValue({ item: data });
22585 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22586 const onChangeValue = (0, import_element65.useCallback)(
22587 (newValue) => onChange(
22588 setValue({
22589 item: data,
22590 value: { value: Number(newValue), unit }
22591 })
22592 ),
22593 [onChange, setValue, data, unit]
22594 );
22595 const onChangeUnit = (0, import_element65.useCallback)(
22596 (newUnit) => onChange(
22597 setValue({
22598 item: data,
22599 value: { value: relValue, unit: newUnit }
22600 })
22601 ),
22602 [onChange, setValue, data, relValue]
22603 );
22604 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22605 import_components30.BaseControl,
22606 {
22607 id,
22608 className: clsx_default(className, "dataviews-controls__relative-date"),
22609 label,
22610 hideLabelFromVision,
22611 help: description,
22612 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22613 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22614 import_components30.__experimentalNumberControl,
22615 {
22616 __next40pxDefaultSize: true,
22617 className: "dataviews-controls__relative-date-number",
22618 spinControls: "none",
22619 min: 1,
22620 step: 1,
22621 value: relValue,
22622 onChange: onChangeValue,
22623 disabled: disabled2
22624 }
22625 ),
22626 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22627 import_components30.SelectControl,
22628 {
22629 className: "dataviews-controls__relative-date-unit",
22630 __next40pxDefaultSize: true,
22631 label: (0, import_i18n33.__)("Unit"),
22632 value: unit,
22633 options,
22634 onChange: onChangeUnit,
22635 hideLabelFromVision: true,
22636 disabled: disabled2
22637 }
22638 )
22639 ] })
22640 }
22641 );
22642 }
22643
22644 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22645 var import_element66 = __toESM(require_element(), 1);
22646 function useDisabledDateMatchers(isValid2, parseDateFn) {
22647 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22648 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22649 const disabledMatchers = (0, import_element66.useMemo)(() => {
22650 const matchers = [];
22651 if (minConstraint) {
22652 const minDate = parseDateFn(minConstraint);
22653 if (minDate) {
22654 matchers.push({ before: minDate });
22655 }
22656 }
22657 if (maxConstraint) {
22658 const maxDate = parseDateFn(maxConstraint);
22659 if (maxDate) {
22660 matchers.push({ after: maxDate });
22661 }
22662 }
22663 return matchers.length > 0 ? matchers : void 0;
22664 }, [minConstraint, maxConstraint, parseDateFn]);
22665 return { minConstraint, maxConstraint, disabledMatchers };
22666 }
22667
22668 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22669 var import_date2 = __toESM(require_date(), 1);
22670 function parseDateTime(dateTimeString) {
22671 if (!dateTimeString) {
22672 return null;
22673 }
22674 const parsed = (0, import_date2.getDate)(dateTimeString);
22675 return parsed && isValid(parsed) ? parsed : null;
22676 }
22677
22678 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22679 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
22680 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
22681 var formatDateTime = (value) => {
22682 if (!value) {
22683 return "";
22684 }
22685 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22686 };
22687 function CalendarDateTimeControl({
22688 data,
22689 field,
22690 onChange,
22691 hideLabelFromVision,
22692 markWhenOptional,
22693 validity,
22694 config
22695 }) {
22696 const { compact } = config || {};
22697 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22698 const disabled2 = field.isDisabled({ item: data, field });
22699 const fieldValue = getValue({ item: data });
22700 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22701 const [calendarMonth, setCalendarMonth] = (0, import_element67.useState)(() => {
22702 const parsedDate = parseDateTime(value);
22703 return parsedDate || /* @__PURE__ */ new Date();
22704 });
22705 const inputControlRef = (0, import_element67.useRef)(null);
22706 const validationTimeoutRef = (0, import_element67.useRef)(void 0);
22707 const previousFocusRef = (0, import_element67.useRef)(null);
22708 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22709 const onChangeCallback = (0, import_element67.useCallback)(
22710 (newValue) => onChange(setValue({ item: data, value: newValue })),
22711 [data, onChange, setValue]
22712 );
22713 (0, import_element67.useEffect)(() => {
22714 return () => {
22715 if (validationTimeoutRef.current) {
22716 clearTimeout(validationTimeoutRef.current);
22717 }
22718 };
22719 }, []);
22720 const onSelectDate = (0, import_element67.useCallback)(
22721 (newDate) => {
22722 let dateTimeValue;
22723 if (newDate) {
22724 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22725 let wpTime;
22726 if (value) {
22727 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22728 } else {
22729 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22730 }
22731 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22732 dateTimeValue = finalDateTime.toISOString();
22733 onChangeCallback(dateTimeValue);
22734 if (validationTimeoutRef.current) {
22735 clearTimeout(validationTimeoutRef.current);
22736 }
22737 } else {
22738 onChangeCallback(void 0);
22739 }
22740 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22741 validationTimeoutRef.current = setTimeout(() => {
22742 if (inputControlRef.current) {
22743 inputControlRef.current.focus();
22744 inputControlRef.current.blur();
22745 onChangeCallback(dateTimeValue);
22746 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22747 previousFocusRef.current.focus();
22748 }
22749 }
22750 }, 0);
22751 },
22752 [onChangeCallback, value]
22753 );
22754 const handleManualDateTimeChange = (0, import_element67.useCallback)(
22755 (newValue) => {
22756 if (newValue) {
22757 const dateTime = (0, import_date3.getDate)(newValue);
22758 onChangeCallback(dateTime.toISOString());
22759 const parsedDate = parseDateTime(dateTime.toISOString());
22760 if (parsedDate) {
22761 setCalendarMonth(parsedDate);
22762 }
22763 } else {
22764 onChangeCallback(void 0);
22765 }
22766 },
22767 [onChangeCallback]
22768 );
22769 const { format: fieldFormat } = field;
22770 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22771 const {
22772 timezone: { string: timezoneString }
22773 } = (0, import_date3.getSettings)();
22774 let displayLabel = label;
22775 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22776 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
22777 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22778 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
22779 }
22780 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
22781 import_components31.BaseControl,
22782 {
22783 id,
22784 label: displayLabel,
22785 help: description,
22786 hideLabelFromVision,
22787 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22788 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
22789 ValidatedInputControl,
22790 {
22791 ref: inputControlRef,
22792 __next40pxDefaultSize: true,
22793 required: !!isValid2?.required,
22794 customValidity: getCustomValidity(isValid2, validity),
22795 type: "datetime-local",
22796 label: (0, import_i18n34.__)("Date time"),
22797 hideLabelFromVision: true,
22798 value: formatDateTime(value),
22799 onChange: handleManualDateTimeChange,
22800 disabled: disabled2,
22801 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22802 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22803 }
22804 ),
22805 !compact && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
22806 DateCalendar,
22807 {
22808 style: { width: "100%" },
22809 selected: value ? parseDateTime(value) || void 0 : void 0,
22810 onSelect: onSelectDate,
22811 month: calendarMonth,
22812 onMonthChange: setCalendarMonth,
22813 timeZone: timezoneString || void 0,
22814 weekStartsOn,
22815 disabled: disabled2 || disabledMatchers
22816 }
22817 )
22818 ] })
22819 }
22820 );
22821 }
22822 function DateTime({
22823 data,
22824 field,
22825 onChange,
22826 hideLabelFromVision,
22827 markWhenOptional,
22828 operator,
22829 validity,
22830 config
22831 }) {
22832 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22833 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
22834 RelativeDateControl,
22835 {
22836 className: "dataviews-controls__datetime",
22837 data,
22838 field,
22839 onChange,
22840 hideLabelFromVision,
22841 operator
22842 }
22843 );
22844 }
22845 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
22846 CalendarDateTimeControl,
22847 {
22848 data,
22849 field,
22850 onChange,
22851 hideLabelFromVision,
22852 markWhenOptional,
22853 validity,
22854 config
22855 }
22856 );
22857 }
22858
22859 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22860 var import_components32 = __toESM(require_components(), 1);
22861 var import_element68 = __toESM(require_element(), 1);
22862 var import_i18n35 = __toESM(require_i18n(), 1);
22863 var import_date4 = __toESM(require_date(), 1);
22864 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
22865 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
22866 var DATE_PRESETS = [
22867 {
22868 id: "today",
22869 label: (0, import_i18n35.__)("Today"),
22870 getValue: () => (0, import_date4.getDate)(null)
22871 },
22872 {
22873 id: "yesterday",
22874 label: (0, import_i18n35.__)("Yesterday"),
22875 getValue: () => {
22876 const today = (0, import_date4.getDate)(null);
22877 return subDays(today, 1);
22878 }
22879 },
22880 {
22881 id: "past-week",
22882 label: (0, import_i18n35.__)("Past week"),
22883 getValue: () => {
22884 const today = (0, import_date4.getDate)(null);
22885 return subDays(today, 7);
22886 }
22887 },
22888 {
22889 id: "past-month",
22890 label: (0, import_i18n35.__)("Past month"),
22891 getValue: () => {
22892 const today = (0, import_date4.getDate)(null);
22893 return subMonths(today, 1);
22894 }
22895 }
22896 ];
22897 var DATE_RANGE_PRESETS = [
22898 {
22899 id: "last-7-days",
22900 label: (0, import_i18n35.__)("Last 7 days"),
22901 getValue: () => {
22902 const today = (0, import_date4.getDate)(null);
22903 return [subDays(today, 7), today];
22904 }
22905 },
22906 {
22907 id: "last-30-days",
22908 label: (0, import_i18n35.__)("Last 30 days"),
22909 getValue: () => {
22910 const today = (0, import_date4.getDate)(null);
22911 return [subDays(today, 30), today];
22912 }
22913 },
22914 {
22915 id: "month-to-date",
22916 label: (0, import_i18n35.__)("Month to date"),
22917 getValue: () => {
22918 const today = (0, import_date4.getDate)(null);
22919 return [startOfMonth(today), today];
22920 }
22921 },
22922 {
22923 id: "last-year",
22924 label: (0, import_i18n35.__)("Last year"),
22925 getValue: () => {
22926 const today = (0, import_date4.getDate)(null);
22927 return [subYears(today, 1), today];
22928 }
22929 },
22930 {
22931 id: "year-to-date",
22932 label: (0, import_i18n35.__)("Year to date"),
22933 getValue: () => {
22934 const today = (0, import_date4.getDate)(null);
22935 return [startOfYear(today), today];
22936 }
22937 }
22938 ];
22939 var parseDate = (dateString) => {
22940 if (!dateString) {
22941 return null;
22942 }
22943 const parsed = (0, import_date4.getDate)(dateString);
22944 return parsed && isValid(parsed) ? parsed : null;
22945 };
22946 var formatDate = (date) => {
22947 if (!date) {
22948 return "";
22949 }
22950 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22951 };
22952 function ValidatedDateControl({
22953 field,
22954 validity,
22955 inputRefs,
22956 isTouched,
22957 setIsTouched,
22958 children
22959 }) {
22960 const { isValid: isValid2 } = field;
22961 const [customValidity, setCustomValidity] = (0, import_element68.useState)(void 0);
22962 const validateRefs = (0, import_element68.useCallback)(() => {
22963 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22964 for (const ref of refs) {
22965 const input = ref.current;
22966 if (input && !input.validity.valid) {
22967 setCustomValidity({
22968 type: "invalid",
22969 message: input.validationMessage
22970 });
22971 return;
22972 }
22973 }
22974 setCustomValidity(void 0);
22975 }, [inputRefs]);
22976 (0, import_element68.useEffect)(() => {
22977 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22978 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22979 for (const ref of refs) {
22980 const input = ref.current;
22981 if (input) {
22982 input.setCustomValidity(
22983 result?.type === "invalid" && result.message ? result.message : ""
22984 );
22985 }
22986 }
22987 }, [inputRefs, isValid2, validity]);
22988 (0, import_element68.useEffect)(() => {
22989 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22990 const handleInvalid = (event) => {
22991 event.preventDefault();
22992 setIsTouched(true);
22993 };
22994 for (const ref of refs) {
22995 ref.current?.addEventListener("invalid", handleInvalid);
22996 }
22997 return () => {
22998 for (const ref of refs) {
22999 ref.current?.removeEventListener("invalid", handleInvalid);
23000 }
23001 };
23002 }, [inputRefs, setIsTouched]);
23003 (0, import_element68.useEffect)(() => {
23004 if (!isTouched) {
23005 return;
23006 }
23007 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23008 if (result) {
23009 setCustomValidity(result);
23010 } else {
23011 validateRefs();
23012 }
23013 }, [isTouched, isValid2, validity, validateRefs]);
23014 const onBlur = (event) => {
23015 if (isTouched) {
23016 return;
23017 }
23018 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23019 setIsTouched(true);
23020 }
23021 };
23022 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { onBlur, children: [
23023 children,
23024 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23025 "p",
23026 {
23027 className: clsx_default(
23028 "components-validated-control__indicator",
23029 customValidity.type === "invalid" ? "is-invalid" : void 0
23030 ),
23031 children: [
23032 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23033 import_components32.Icon,
23034 {
23035 className: "components-validated-control__indicator-icon",
23036 icon: error_default,
23037 size: 16,
23038 fill: "currentColor"
23039 }
23040 ),
23041 customValidity.message
23042 ]
23043 }
23044 ) })
23045 ] });
23046 }
23047 function CalendarDateControl({
23048 data,
23049 field,
23050 onChange,
23051 hideLabelFromVision,
23052 markWhenOptional,
23053 validity
23054 }) {
23055 const {
23056 id,
23057 label,
23058 description,
23059 setValue,
23060 getValue,
23061 isValid: isValid2,
23062 format: fieldFormat
23063 } = field;
23064 const disabled2 = field.isDisabled({ item: data, field });
23065 const [selectedPresetId, setSelectedPresetId] = (0, import_element68.useState)(
23066 null
23067 );
23068 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23069 const fieldValue = getValue({ item: data });
23070 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23071 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23072 const parsedDate = parseDate(value);
23073 return parsedDate || /* @__PURE__ */ new Date();
23074 });
23075 const [isTouched, setIsTouched] = (0, import_element68.useState)(false);
23076 const validityTargetRef = (0, import_element68.useRef)(null);
23077 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23078 const onChangeCallback = (0, import_element68.useCallback)(
23079 (newValue) => onChange(setValue({ item: data, value: newValue })),
23080 [data, onChange, setValue]
23081 );
23082 const onSelectDate = (0, import_element68.useCallback)(
23083 (newDate) => {
23084 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23085 onChangeCallback(dateValue);
23086 setSelectedPresetId(null);
23087 setIsTouched(true);
23088 },
23089 [onChangeCallback]
23090 );
23091 const handlePresetClick = (0, import_element68.useCallback)(
23092 (preset) => {
23093 const presetDate = preset.getValue();
23094 const dateValue = formatDate(presetDate);
23095 setCalendarMonth(presetDate);
23096 onChangeCallback(dateValue);
23097 setSelectedPresetId(preset.id);
23098 setIsTouched(true);
23099 },
23100 [onChangeCallback]
23101 );
23102 const handleManualDateChange = (0, import_element68.useCallback)(
23103 (newValue) => {
23104 onChangeCallback(newValue);
23105 if (newValue) {
23106 const parsedDate = parseDate(newValue);
23107 if (parsedDate) {
23108 setCalendarMonth(parsedDate);
23109 }
23110 }
23111 setSelectedPresetId(null);
23112 setIsTouched(true);
23113 },
23114 [onChangeCallback]
23115 );
23116 const {
23117 timezone: { string: timezoneString }
23118 } = (0, import_date4.getSettings)();
23119 let displayLabel = label;
23120 if (isValid2?.required && !markWhenOptional) {
23121 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23122 } else if (!isValid2?.required && markWhenOptional) {
23123 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23124 }
23125 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23126 ValidatedDateControl,
23127 {
23128 field,
23129 validity,
23130 inputRefs: validityTargetRef,
23131 isTouched,
23132 setIsTouched,
23133 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23134 import_components32.BaseControl,
23135 {
23136 id,
23137 className: "dataviews-controls__date",
23138 label: displayLabel,
23139 help: description,
23140 hideLabelFromVision,
23141 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23142 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23143 Stack,
23144 {
23145 direction: "row",
23146 gap: "sm",
23147 wrap: "wrap",
23148 justify: "flex-start",
23149 children: [
23150 DATE_PRESETS.map((preset) => {
23151 const isSelected2 = selectedPresetId === preset.id;
23152 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23153 import_components32.Button,
23154 {
23155 className: "dataviews-controls__date-preset",
23156 variant: "tertiary",
23157 isPressed: isSelected2,
23158 size: "small",
23159 disabled: disabled2,
23160 accessibleWhenDisabled: true,
23161 onClick: () => handlePresetClick(preset),
23162 children: preset.label
23163 },
23164 preset.id
23165 );
23166 }),
23167 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23168 import_components32.Button,
23169 {
23170 className: "dataviews-controls__date-preset",
23171 variant: "tertiary",
23172 isPressed: !selectedPresetId,
23173 size: "small",
23174 disabled: !!selectedPresetId || disabled2,
23175 accessibleWhenDisabled: true,
23176 children: (0, import_i18n35.__)("Custom")
23177 }
23178 )
23179 ]
23180 }
23181 ),
23182 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23183 import_components32.__experimentalInputControl,
23184 {
23185 __next40pxDefaultSize: true,
23186 ref: validityTargetRef,
23187 type: "date",
23188 label: (0, import_i18n35.__)("Date"),
23189 hideLabelFromVision: true,
23190 value,
23191 onChange: handleManualDateChange,
23192 required: !!field.isValid?.required,
23193 disabled: disabled2,
23194 min: minConstraint,
23195 max: maxConstraint
23196 }
23197 ),
23198 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23199 DateCalendar2,
23200 {
23201 style: { width: "100%" },
23202 selected: value ? parseDate(value) || void 0 : void 0,
23203 onSelect: onSelectDate,
23204 month: calendarMonth,
23205 onMonthChange: setCalendarMonth,
23206 timeZone: timezoneString || void 0,
23207 weekStartsOn,
23208 disabled: disabled2 || disabledMatchers,
23209 disableNavigation: disabled2
23210 }
23211 )
23212 ] })
23213 }
23214 )
23215 }
23216 );
23217 }
23218 function CalendarDateRangeControl({
23219 data,
23220 field,
23221 onChange,
23222 hideLabelFromVision,
23223 markWhenOptional,
23224 validity
23225 }) {
23226 const {
23227 id,
23228 label,
23229 description,
23230 getValue,
23231 setValue,
23232 isValid: isValid2,
23233 format: fieldFormat
23234 } = field;
23235 const disabled2 = field.isDisabled({ item: data, field });
23236 let value;
23237 const fieldValue = getValue({ item: data });
23238 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23239 value = fieldValue;
23240 }
23241 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23242 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23243 const onChangeCallback = (0, import_element68.useCallback)(
23244 (newValue) => {
23245 onChange(
23246 setValue({
23247 item: data,
23248 value: newValue
23249 })
23250 );
23251 },
23252 [data, onChange, setValue]
23253 );
23254 const [selectedPresetId, setSelectedPresetId] = (0, import_element68.useState)(
23255 null
23256 );
23257 const selectedRange = (0, import_element68.useMemo)(() => {
23258 if (!value) {
23259 return { from: void 0, to: void 0 };
23260 }
23261 const [from, to] = value;
23262 return {
23263 from: parseDate(from) || void 0,
23264 to: parseDate(to) || void 0
23265 };
23266 }, [value]);
23267 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23268 return selectedRange.from || /* @__PURE__ */ new Date();
23269 });
23270 const [isTouched, setIsTouched] = (0, import_element68.useState)(false);
23271 const fromInputRef = (0, import_element68.useRef)(null);
23272 const toInputRef = (0, import_element68.useRef)(null);
23273 const updateDateRange = (0, import_element68.useCallback)(
23274 (fromDate, toDate2) => {
23275 if (fromDate && toDate2) {
23276 onChangeCallback([
23277 formatDate(fromDate),
23278 formatDate(toDate2)
23279 ]);
23280 } else if (!fromDate && !toDate2) {
23281 onChangeCallback(void 0);
23282 }
23283 },
23284 [onChangeCallback]
23285 );
23286 const onSelectCalendarRange = (0, import_element68.useCallback)(
23287 (newRange) => {
23288 updateDateRange(newRange?.from, newRange?.to);
23289 setSelectedPresetId(null);
23290 setIsTouched(true);
23291 },
23292 [updateDateRange]
23293 );
23294 const handlePresetClick = (0, import_element68.useCallback)(
23295 (preset) => {
23296 const [startDate, endDate] = preset.getValue();
23297 setCalendarMonth(startDate);
23298 updateDateRange(startDate, endDate);
23299 setSelectedPresetId(preset.id);
23300 setIsTouched(true);
23301 },
23302 [updateDateRange]
23303 );
23304 const handleManualDateChange = (0, import_element68.useCallback)(
23305 (fromOrTo, newValue) => {
23306 const [currentFrom, currentTo] = value || [
23307 void 0,
23308 void 0
23309 ];
23310 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23311 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23312 updateDateRange(updatedFrom, updatedTo);
23313 if (newValue) {
23314 const parsedDate = parseDate(newValue);
23315 if (parsedDate) {
23316 setCalendarMonth(parsedDate);
23317 }
23318 }
23319 setSelectedPresetId(null);
23320 setIsTouched(true);
23321 },
23322 [value, updateDateRange]
23323 );
23324 const { timezone } = (0, import_date4.getSettings)();
23325 let displayLabel = label;
23326 if (field.isValid?.required && !markWhenOptional) {
23327 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23328 } else if (!field.isValid?.required && markWhenOptional) {
23329 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23330 }
23331 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23332 ValidatedDateControl,
23333 {
23334 field,
23335 validity,
23336 inputRefs: [fromInputRef, toInputRef],
23337 isTouched,
23338 setIsTouched,
23339 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23340 import_components32.BaseControl,
23341 {
23342 id,
23343 className: "dataviews-controls__date",
23344 label: displayLabel,
23345 help: description,
23346 hideLabelFromVision,
23347 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23348 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23349 Stack,
23350 {
23351 direction: "row",
23352 gap: "sm",
23353 wrap: "wrap",
23354 justify: "flex-start",
23355 children: [
23356 DATE_RANGE_PRESETS.map((preset) => {
23357 const isSelected2 = selectedPresetId === preset.id;
23358 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23359 import_components32.Button,
23360 {
23361 className: "dataviews-controls__date-preset",
23362 variant: "tertiary",
23363 isPressed: isSelected2,
23364 size: "small",
23365 disabled: disabled2,
23366 accessibleWhenDisabled: true,
23367 onClick: () => handlePresetClick(preset),
23368 children: preset.label
23369 },
23370 preset.id
23371 );
23372 }),
23373 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23374 import_components32.Button,
23375 {
23376 className: "dataviews-controls__date-preset",
23377 variant: "tertiary",
23378 isPressed: !selectedPresetId,
23379 size: "small",
23380 accessibleWhenDisabled: true,
23381 disabled: !!selectedPresetId || disabled2,
23382 children: (0, import_i18n35.__)("Custom")
23383 }
23384 )
23385 ]
23386 }
23387 ),
23388 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23389 Stack,
23390 {
23391 direction: "row",
23392 gap: "sm",
23393 justify: "space-between",
23394 className: "dataviews-controls__date-range-inputs",
23395 children: [
23396 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23397 import_components32.__experimentalInputControl,
23398 {
23399 __next40pxDefaultSize: true,
23400 ref: fromInputRef,
23401 type: "date",
23402 label: (0, import_i18n35.__)("From"),
23403 hideLabelFromVision: true,
23404 value: value?.[0],
23405 onChange: (newValue) => handleManualDateChange("from", newValue),
23406 required: !!field.isValid?.required,
23407 disabled: disabled2,
23408 min: minConstraint,
23409 max: maxConstraint
23410 }
23411 ),
23412 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23413 import_components32.__experimentalInputControl,
23414 {
23415 __next40pxDefaultSize: true,
23416 ref: toInputRef,
23417 type: "date",
23418 label: (0, import_i18n35.__)("To"),
23419 hideLabelFromVision: true,
23420 value: value?.[1],
23421 onChange: (newValue) => handleManualDateChange("to", newValue),
23422 required: !!field.isValid?.required,
23423 disabled: disabled2,
23424 min: minConstraint,
23425 max: maxConstraint
23426 }
23427 )
23428 ]
23429 }
23430 ),
23431 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23432 DateRangeCalendar,
23433 {
23434 style: { width: "100%" },
23435 selected: selectedRange,
23436 onSelect: onSelectCalendarRange,
23437 month: calendarMonth,
23438 onMonthChange: setCalendarMonth,
23439 timeZone: timezone.string || void 0,
23440 weekStartsOn,
23441 disabled: disabled2 || disabledMatchers
23442 }
23443 )
23444 ] })
23445 }
23446 )
23447 }
23448 );
23449 }
23450 function DateControl({
23451 data,
23452 field,
23453 onChange,
23454 hideLabelFromVision,
23455 markWhenOptional,
23456 operator,
23457 validity
23458 }) {
23459 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23460 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23461 RelativeDateControl,
23462 {
23463 className: "dataviews-controls__date",
23464 data,
23465 field,
23466 onChange,
23467 hideLabelFromVision,
23468 operator
23469 }
23470 );
23471 }
23472 if (operator === OPERATOR_BETWEEN) {
23473 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23474 CalendarDateRangeControl,
23475 {
23476 data,
23477 field,
23478 onChange,
23479 hideLabelFromVision,
23480 markWhenOptional,
23481 validity
23482 }
23483 );
23484 }
23485 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23486 CalendarDateControl,
23487 {
23488 data,
23489 field,
23490 onChange,
23491 hideLabelFromVision,
23492 markWhenOptional,
23493 validity
23494 }
23495 );
23496 }
23497
23498 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23499 var import_components33 = __toESM(require_components(), 1);
23500 var import_element69 = __toESM(require_element(), 1);
23501 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23502 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
23503 function Select({
23504 data,
23505 field,
23506 onChange,
23507 hideLabelFromVision,
23508 markWhenOptional,
23509 validity
23510 }) {
23511 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23512 const disabled2 = field.isDisabled({ item: data, field });
23513 const isMultiple = type === "array";
23514 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23515 const onChangeControl = (0, import_element69.useCallback)(
23516 (newValue) => onChange(setValue({ item: data, value: newValue })),
23517 [data, onChange, setValue]
23518 );
23519 const { elements, isLoading } = useElements({
23520 elements: field.elements,
23521 getElements: field.getElements
23522 });
23523 if (isLoading) {
23524 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components33.Spinner, {});
23525 }
23526 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23527 ValidatedSelectControl,
23528 {
23529 required: !!field.isValid?.required,
23530 markWhenOptional,
23531 customValidity: getCustomValidity(isValid2, validity),
23532 label,
23533 value,
23534 help: description,
23535 options: elements,
23536 onChange: onChangeControl,
23537 __next40pxDefaultSize: true,
23538 hideLabelFromVision,
23539 multiple: isMultiple,
23540 disabled: disabled2
23541 }
23542 );
23543 }
23544
23545 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23546 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23547 var ELEMENTS_THRESHOLD = 10;
23548 function AdaptiveSelect(props) {
23549 const { field } = props;
23550 const { elements } = useElements({
23551 elements: field.elements,
23552 getElements: field.getElements
23553 });
23554 if (elements.length >= ELEMENTS_THRESHOLD) {
23555 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Combobox3, { ...props });
23556 }
23557 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Select, { ...props });
23558 }
23559
23560 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23561 var import_components35 = __toESM(require_components(), 1);
23562
23563 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23564 var import_components34 = __toESM(require_components(), 1);
23565 var import_element70 = __toESM(require_element(), 1);
23566 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23567 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
23568 function ValidatedText({
23569 data,
23570 field,
23571 onChange,
23572 hideLabelFromVision,
23573 markWhenOptional,
23574 type,
23575 prefix,
23576 suffix,
23577 validity
23578 }) {
23579 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23580 const value = getValue({ item: data });
23581 const disabled2 = field.isDisabled({ item: data, field });
23582 const onChangeControl = (0, import_element70.useCallback)(
23583 (newValue) => onChange(
23584 setValue({
23585 item: data,
23586 value: newValue
23587 })
23588 ),
23589 [data, setValue, onChange]
23590 );
23591 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23592 ValidatedInputControl2,
23593 {
23594 required: !!isValid2.required,
23595 markWhenOptional,
23596 customValidity: getCustomValidity(isValid2, validity),
23597 label,
23598 placeholder,
23599 value: value ?? "",
23600 help: description,
23601 onChange: onChangeControl,
23602 hideLabelFromVision,
23603 type,
23604 prefix,
23605 suffix,
23606 disabled: disabled2,
23607 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23608 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23609 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23610 __next40pxDefaultSize: true
23611 }
23612 );
23613 }
23614
23615 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23616 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23617 function Email({
23618 data,
23619 field,
23620 onChange,
23621 hideLabelFromVision,
23622 markWhenOptional,
23623 validity
23624 }) {
23625 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23626 ValidatedText,
23627 {
23628 ...{
23629 data,
23630 field,
23631 onChange,
23632 hideLabelFromVision,
23633 markWhenOptional,
23634 validity,
23635 type: "email",
23636 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.Icon, { icon: envelope_default }) })
23637 }
23638 }
23639 );
23640 }
23641
23642 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23643 var import_components36 = __toESM(require_components(), 1);
23644 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23645 function Telephone({
23646 data,
23647 field,
23648 onChange,
23649 hideLabelFromVision,
23650 markWhenOptional,
23651 validity
23652 }) {
23653 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23654 ValidatedText,
23655 {
23656 ...{
23657 data,
23658 field,
23659 onChange,
23660 hideLabelFromVision,
23661 markWhenOptional,
23662 validity,
23663 type: "tel",
23664 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.Icon, { icon: mobile_default }) })
23665 }
23666 }
23667 );
23668 }
23669
23670 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23671 var import_components37 = __toESM(require_components(), 1);
23672 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23673 function Url({
23674 data,
23675 field,
23676 onChange,
23677 hideLabelFromVision,
23678 markWhenOptional,
23679 validity
23680 }) {
23681 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23682 ValidatedText,
23683 {
23684 ...{
23685 data,
23686 field,
23687 onChange,
23688 hideLabelFromVision,
23689 markWhenOptional,
23690 validity,
23691 type: "url",
23692 prefix: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.Icon, { icon: link_default }) })
23693 }
23694 }
23695 );
23696 }
23697
23698 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23699 var import_components38 = __toESM(require_components(), 1);
23700 var import_element71 = __toESM(require_element(), 1);
23701 var import_i18n36 = __toESM(require_i18n(), 1);
23702 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23703 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
23704 function toNumberOrEmpty(value) {
23705 if (value === "" || value === void 0) {
23706 return "";
23707 }
23708 const number = Number(value);
23709 return Number.isFinite(number) ? number : "";
23710 }
23711 function BetweenControls({
23712 value,
23713 onChange,
23714 hideLabelFromVision,
23715 step
23716 }) {
23717 const [min2 = "", max2 = ""] = value;
23718 const onChangeMin = (0, import_element71.useCallback)(
23719 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23720 [onChange, max2]
23721 );
23722 const onChangeMax = (0, import_element71.useCallback)(
23723 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23724 [onChange, min2]
23725 );
23726 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23727 import_components38.BaseControl,
23728 {
23729 help: (0, import_i18n36.__)("The max. value must be greater than the min. value."),
23730 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23731 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23732 import_components38.__experimentalNumberControl,
23733 {
23734 label: (0, import_i18n36.__)("Min."),
23735 value: min2,
23736 max: max2 ? Number(max2) - step : void 0,
23737 onChange: onChangeMin,
23738 __next40pxDefaultSize: true,
23739 hideLabelFromVision,
23740 step
23741 }
23742 ),
23743 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23744 import_components38.__experimentalNumberControl,
23745 {
23746 label: (0, import_i18n36.__)("Max."),
23747 value: max2,
23748 min: min2 ? Number(min2) + step : void 0,
23749 onChange: onChangeMax,
23750 __next40pxDefaultSize: true,
23751 hideLabelFromVision,
23752 step
23753 }
23754 )
23755 ] })
23756 }
23757 );
23758 }
23759 function ValidatedNumber({
23760 data,
23761 field,
23762 onChange,
23763 hideLabelFromVision,
23764 markWhenOptional,
23765 operator,
23766 validity
23767 }) {
23768 const decimals = field.format?.decimals ?? 0;
23769 const step = Math.pow(10, Math.abs(decimals) * -1);
23770 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23771 const value = getValue({ item: data }) ?? "";
23772 const disabled2 = field.isDisabled({ item: data, field });
23773 const onChangeControl = (0, import_element71.useCallback)(
23774 (newValue) => {
23775 onChange(
23776 setValue({
23777 item: data,
23778 // Do not convert an empty string or undefined to a number,
23779 // otherwise there's a mismatch between the UI control (empty)
23780 // and the data relied by onChange (0).
23781 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23782 })
23783 );
23784 },
23785 [data, onChange, setValue]
23786 );
23787 const onChangeBetweenControls = (0, import_element71.useCallback)(
23788 (newValue) => {
23789 onChange(
23790 setValue({
23791 item: data,
23792 value: newValue
23793 })
23794 );
23795 },
23796 [data, onChange, setValue]
23797 );
23798 if (operator === OPERATOR_BETWEEN) {
23799 let valueBetween = ["", ""];
23800 if (Array.isArray(value) && value.length === 2 && value.every(
23801 (element) => typeof element === "number" || element === ""
23802 )) {
23803 valueBetween = value;
23804 }
23805 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23806 BetweenControls,
23807 {
23808 value: valueBetween,
23809 onChange: onChangeBetweenControls,
23810 hideLabelFromVision,
23811 step
23812 }
23813 );
23814 }
23815 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23816 ValidatedNumberControl,
23817 {
23818 required: !!isValid2.required,
23819 markWhenOptional,
23820 customValidity: getCustomValidity(isValid2, validity),
23821 label,
23822 help: description,
23823 value,
23824 onChange: onChangeControl,
23825 __next40pxDefaultSize: true,
23826 hideLabelFromVision,
23827 step,
23828 min: isValid2.min ? isValid2.min.constraint : void 0,
23829 max: isValid2.max ? isValid2.max.constraint : void 0,
23830 disabled: disabled2
23831 }
23832 );
23833 }
23834
23835 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23836 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23837 function Integer(props) {
23838 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
23839 }
23840
23841 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23842 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23843 function Number2(props) {
23844 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ValidatedNumber, { ...props });
23845 }
23846
23847 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23848 var import_components39 = __toESM(require_components(), 1);
23849 var import_element72 = __toESM(require_element(), 1);
23850 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
23851 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
23852 function Radio({
23853 data,
23854 field,
23855 onChange,
23856 hideLabelFromVision,
23857 markWhenOptional,
23858 validity
23859 }) {
23860 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23861 const disabled2 = field.isDisabled({ item: data, field });
23862 const { elements, isLoading } = useElements({
23863 elements: field.elements,
23864 getElements: field.getElements
23865 });
23866 const value = getValue({ item: data });
23867 const onChangeControl = (0, import_element72.useCallback)(
23868 (newValue) => onChange(setValue({ item: data, value: newValue })),
23869 [data, onChange, setValue]
23870 );
23871 if (isLoading) {
23872 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components39.Spinner, {});
23873 }
23874 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
23875 ValidatedRadioControl,
23876 {
23877 required: !!field.isValid?.required,
23878 markWhenOptional,
23879 customValidity: getCustomValidity(isValid2, validity),
23880 label,
23881 help: description,
23882 onChange: onChangeControl,
23883 options: elements,
23884 selected: value,
23885 hideLabelFromVision,
23886 disabled: disabled2
23887 }
23888 );
23889 }
23890
23891 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23892 var import_element73 = __toESM(require_element(), 1);
23893 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
23894 function Text3({
23895 data,
23896 field,
23897 onChange,
23898 hideLabelFromVision,
23899 markWhenOptional,
23900 config,
23901 validity
23902 }) {
23903 const { prefix, suffix } = config || {};
23904 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23905 ValidatedText,
23906 {
23907 ...{
23908 data,
23909 field,
23910 onChange,
23911 hideLabelFromVision,
23912 markWhenOptional,
23913 validity,
23914 prefix: prefix ? (0, import_element73.createElement)(prefix) : void 0,
23915 suffix: suffix ? (0, import_element73.createElement)(suffix) : void 0
23916 }
23917 }
23918 );
23919 }
23920
23921 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23922 var import_components40 = __toESM(require_components(), 1);
23923 var import_element74 = __toESM(require_element(), 1);
23924 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
23925 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
23926 function Toggle({
23927 field,
23928 onChange,
23929 data,
23930 hideLabelFromVision,
23931 markWhenOptional,
23932 validity
23933 }) {
23934 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23935 const disabled2 = field.isDisabled({ item: data, field });
23936 const onChangeControl = (0, import_element74.useCallback)(() => {
23937 onChange(
23938 setValue({ item: data, value: !getValue({ item: data }) })
23939 );
23940 }, [onChange, setValue, data, getValue]);
23941 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
23942 ValidatedToggleControl,
23943 {
23944 required: !!isValid2.required,
23945 markWhenOptional,
23946 customValidity: getCustomValidity(isValid2, validity),
23947 hidden: hideLabelFromVision,
23948 label,
23949 help: description,
23950 checked: getValue({ item: data }),
23951 onChange: onChangeControl,
23952 disabled: disabled2
23953 }
23954 );
23955 }
23956
23957 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23958 var import_components41 = __toESM(require_components(), 1);
23959 var import_element75 = __toESM(require_element(), 1);
23960 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
23961 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
23962 function Textarea({
23963 data,
23964 field,
23965 onChange,
23966 hideLabelFromVision,
23967 markWhenOptional,
23968 config,
23969 validity
23970 }) {
23971 const { rows = 4 } = config || {};
23972 const disabled2 = field.isDisabled({ item: data, field });
23973 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23974 const value = field.getValue({ item: data });
23975 const onChangeControl = (0, import_element75.useCallback)(
23976 (newValue) => onChange(setValue({ item: data, value: newValue })),
23977 [data, onChange, setValue]
23978 );
23979 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
23980 ValidatedTextareaControl,
23981 {
23982 required: !!isValid2.required,
23983 markWhenOptional,
23984 customValidity: getCustomValidity(isValid2, validity),
23985 label,
23986 placeholder,
23987 value: value ?? "",
23988 help: description,
23989 onChange: onChangeControl,
23990 rows,
23991 disabled: disabled2,
23992 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23993 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23994 __next40pxDefaultSize: true,
23995 hideLabelFromVision
23996 }
23997 );
23998 }
23999
24000 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24001 var import_components42 = __toESM(require_components(), 1);
24002 var import_element76 = __toESM(require_element(), 1);
24003 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24004 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
24005 function ToggleGroup({
24006 data,
24007 field,
24008 onChange,
24009 hideLabelFromVision,
24010 markWhenOptional,
24011 validity
24012 }) {
24013 const { getValue, setValue, isValid: isValid2 } = field;
24014 const disabled2 = field.isDisabled({ item: data, field });
24015 const value = getValue({ item: data });
24016 const onChangeControl = (0, import_element76.useCallback)(
24017 (newValue) => onChange(setValue({ item: data, value: newValue })),
24018 [data, onChange, setValue]
24019 );
24020 const { elements, isLoading } = useElements({
24021 elements: field.elements,
24022 getElements: field.getElements
24023 });
24024 if (isLoading) {
24025 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components42.Spinner, {});
24026 }
24027 if (elements.length === 0) {
24028 return null;
24029 }
24030 const selectedOption = elements.find((el) => el.value === value);
24031 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24032 ValidatedToggleGroupControl,
24033 {
24034 required: !!field.isValid?.required,
24035 markWhenOptional,
24036 customValidity: getCustomValidity(isValid2, validity),
24037 __next40pxDefaultSize: true,
24038 isBlock: true,
24039 label: field.label,
24040 help: selectedOption?.description || field.description,
24041 onChange: onChangeControl,
24042 value,
24043 hideLabelFromVision,
24044 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24045 import_components42.__experimentalToggleGroupControlOption,
24046 {
24047 label: el.label,
24048 value: el.value,
24049 disabled: disabled2
24050 },
24051 el.value
24052 ))
24053 }
24054 );
24055 }
24056
24057 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24058 var import_components43 = __toESM(require_components(), 1);
24059 var import_element77 = __toESM(require_element(), 1);
24060 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24061 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
24062 function ArrayControl({
24063 data,
24064 field,
24065 onChange,
24066 hideLabelFromVision,
24067 markWhenOptional,
24068 validity
24069 }) {
24070 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24071 const value = getValue({ item: data });
24072 const disabled2 = field.isDisabled({ item: data, field });
24073 const { elements, isLoading } = useElements({
24074 elements: field.elements,
24075 getElements: field.getElements
24076 });
24077 const arrayValueAsElements = (0, import_element77.useMemo)(
24078 () => Array.isArray(value) ? value.map((token) => {
24079 const element = elements?.find(
24080 (suggestion) => suggestion.value === token
24081 );
24082 return element || { value: token, label: token };
24083 }) : [],
24084 [value, elements]
24085 );
24086 const onChangeControl = (0, import_element77.useCallback)(
24087 (tokens) => {
24088 const valueTokens = tokens.map((token) => {
24089 if (typeof token === "object" && "value" in token) {
24090 return token.value;
24091 }
24092 return token;
24093 });
24094 onChange(setValue({ item: data, value: valueTokens }));
24095 },
24096 [onChange, setValue, data]
24097 );
24098 if (isLoading) {
24099 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.Spinner, {});
24100 }
24101 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24102 ValidatedFormTokenField,
24103 {
24104 required: !!isValid2?.required,
24105 markWhenOptional,
24106 customValidity: getCustomValidity(isValid2, validity),
24107 label: hideLabelFromVision ? void 0 : label,
24108 value: arrayValueAsElements,
24109 onChange: onChangeControl,
24110 placeholder,
24111 suggestions: elements?.map((element) => element.value),
24112 disabled: disabled2,
24113 __experimentalValidateInput: (token) => {
24114 if (field.isValid?.elements && elements) {
24115 return elements.some(
24116 (element) => element.value === token || element.label === token
24117 );
24118 }
24119 return true;
24120 },
24121 __experimentalExpandOnFocus: elements && elements.length > 0,
24122 help: description ?? (field.isValid?.elements ? "" : void 0),
24123 displayTransform: (token) => {
24124 if (typeof token === "object" && "label" in token) {
24125 return token.label;
24126 }
24127 if (typeof token === "string" && elements) {
24128 const element = elements.find(
24129 (el) => el.value === token
24130 );
24131 return element?.label || token;
24132 }
24133 return token;
24134 },
24135 __experimentalRenderItem: ({ item }) => {
24136 if (typeof item === "string" && elements) {
24137 const element = elements.find(
24138 (el) => el.value === item
24139 );
24140 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: element?.label || item });
24141 }
24142 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: item });
24143 }
24144 }
24145 );
24146 }
24147
24148 // node_modules/colord/index.mjs
24149 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24150 var t = function(r3) {
24151 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24152 };
24153 var n = function(r3, t2, n2) {
24154 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24155 };
24156 var e = function(r3, t2, n2) {
24157 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24158 };
24159 var u = function(r3) {
24160 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24161 };
24162 var a = function(r3) {
24163 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24164 };
24165 var o = function(r3) {
24166 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24167 };
24168 var i = /^#([0-9a-f]{3,8})$/i;
24169 var s = function(r3) {
24170 var t2 = r3.toString(16);
24171 return t2.length < 2 ? "0" + t2 : t2;
24172 };
24173 var h = function(r3) {
24174 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;
24175 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24176 };
24177 var b = function(r3) {
24178 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24179 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24180 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;
24181 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 };
24182 };
24183 var g = function(r3) {
24184 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24185 };
24186 var d = function(r3) {
24187 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24188 };
24189 var f = function(r3) {
24190 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 }));
24191 var t2, n2, e2;
24192 };
24193 var c = function(r3) {
24194 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 };
24195 var t2, n2, e2, u2;
24196 };
24197 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24198 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24199 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24200 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24201 var y = { string: [[function(r3) {
24202 var t2 = i.exec(r3);
24203 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;
24204 }, "hex"], [function(r3) {
24205 var t2 = v.exec(r3) || m.exec(r3);
24206 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;
24207 }, "rgb"], [function(t2) {
24208 var n2 = l.exec(t2) || p.exec(t2);
24209 if (!n2) return null;
24210 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) });
24211 return f(a2);
24212 }, "hsl"]], object: [[function(r3) {
24213 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24214 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24215 }, "rgb"], [function(r3) {
24216 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24217 if (!t(n2) || !t(e2) || !t(u2)) return null;
24218 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24219 return f(i2);
24220 }, "hsl"], [function(r3) {
24221 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24222 if (!t(n2) || !t(a2) || !t(o2)) return null;
24223 var h2 = (function(r4) {
24224 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24225 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24226 return b(h2);
24227 }, "hsv"]] };
24228 var N = function(r3, t2) {
24229 for (var n2 = 0; n2 < t2.length; n2++) {
24230 var e2 = t2[n2][0](r3);
24231 if (e2) return [e2, t2[n2][1]];
24232 }
24233 return [null, void 0];
24234 };
24235 var x = function(r3) {
24236 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24237 };
24238 var M = function(r3, t2) {
24239 var n2 = c(r3);
24240 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24241 };
24242 var H = function(r3) {
24243 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24244 };
24245 var $ = function(r3, t2) {
24246 var n2 = c(r3);
24247 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24248 };
24249 var j = (function() {
24250 function r3(r4) {
24251 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24252 }
24253 return r3.prototype.isValid = function() {
24254 return null !== this.parsed;
24255 }, r3.prototype.brightness = function() {
24256 return n(H(this.rgba), 2);
24257 }, r3.prototype.isDark = function() {
24258 return H(this.rgba) < 0.5;
24259 }, r3.prototype.isLight = function() {
24260 return H(this.rgba) >= 0.5;
24261 }, r3.prototype.toHex = function() {
24262 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;
24263 var r4, t2, e2, u2, a2, i2;
24264 }, r3.prototype.toRgb = function() {
24265 return o(this.rgba);
24266 }, r3.prototype.toRgbString = function() {
24267 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 + ")";
24268 var r4, t2, n2, e2, u2;
24269 }, r3.prototype.toHsl = function() {
24270 return d(c(this.rgba));
24271 }, r3.prototype.toHslString = function() {
24272 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 + "%)";
24273 var r4, t2, n2, e2, u2;
24274 }, r3.prototype.toHsv = function() {
24275 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24276 var r4;
24277 }, r3.prototype.invert = function() {
24278 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24279 var r4;
24280 }, r3.prototype.saturate = function(r4) {
24281 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24282 }, r3.prototype.desaturate = function(r4) {
24283 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24284 }, r3.prototype.grayscale = function() {
24285 return w(M(this.rgba, -1));
24286 }, r3.prototype.lighten = function(r4) {
24287 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24288 }, r3.prototype.darken = function(r4) {
24289 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24290 }, r3.prototype.rotate = function(r4) {
24291 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24292 }, r3.prototype.alpha = function(r4) {
24293 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24294 var t2;
24295 }, r3.prototype.hue = function(r4) {
24296 var t2 = c(this.rgba);
24297 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24298 }, r3.prototype.isEqual = function(r4) {
24299 return this.toHex() === w(r4).toHex();
24300 }, r3;
24301 })();
24302 var w = function(r3) {
24303 return r3 instanceof j ? r3 : new j(r3);
24304 };
24305
24306 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24307 var import_components44 = __toESM(require_components(), 1);
24308 var import_element78 = __toESM(require_element(), 1);
24309 var import_i18n37 = __toESM(require_i18n(), 1);
24310 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24311 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
24312 var ColorPickerDropdown = ({
24313 color,
24314 onColorChange,
24315 disabled: disabled2
24316 }) => {
24317 const validColor = color && w(color).isValid() ? color : "#ffffff";
24318 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24319 import_components44.Dropdown,
24320 {
24321 className: "dataviews-controls__color-picker-dropdown",
24322 popoverProps: { resize: false },
24323 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24324 import_components44.Button,
24325 {
24326 onClick: onToggle,
24327 "aria-label": (0, import_i18n37.__)("Open color picker"),
24328 size: "small",
24329 disabled: disabled2,
24330 accessibleWhenDisabled: true,
24331 icon: () => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
24332 }
24333 ),
24334 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24335 import_components44.ColorPicker,
24336 {
24337 color: validColor,
24338 onChange: onColorChange,
24339 enableAlpha: true
24340 }
24341 ) })
24342 }
24343 );
24344 };
24345 function Color({
24346 data,
24347 field,
24348 onChange,
24349 hideLabelFromVision,
24350 markWhenOptional,
24351 validity
24352 }) {
24353 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24354 const disabled2 = field.isDisabled({ item: data, field });
24355 const value = field.getValue({ item: data }) || "";
24356 const handleColorChange = (0, import_element78.useCallback)(
24357 (newColor) => {
24358 onChange(setValue({ item: data, value: newColor }));
24359 },
24360 [data, onChange, setValue]
24361 );
24362 const handleInputChange = (0, import_element78.useCallback)(
24363 (newValue) => {
24364 onChange(setValue({ item: data, value: newValue || "" }));
24365 },
24366 [data, onChange, setValue]
24367 );
24368 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24369 ValidatedInputControl3,
24370 {
24371 required: !!field.isValid?.required,
24372 markWhenOptional,
24373 customValidity: getCustomValidity(isValid2, validity),
24374 label,
24375 placeholder,
24376 value,
24377 help: description,
24378 onChange: handleInputChange,
24379 hideLabelFromVision,
24380 type: "text",
24381 disabled: disabled2,
24382 prefix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24383 ColorPickerDropdown,
24384 {
24385 color: value,
24386 onColorChange: handleColorChange,
24387 disabled: disabled2
24388 }
24389 ) })
24390 }
24391 );
24392 }
24393
24394 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24395 var import_components45 = __toESM(require_components(), 1);
24396 var import_element79 = __toESM(require_element(), 1);
24397 var import_i18n38 = __toESM(require_i18n(), 1);
24398 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24399 function Password({
24400 data,
24401 field,
24402 onChange,
24403 hideLabelFromVision,
24404 markWhenOptional,
24405 validity
24406 }) {
24407 const [isVisible2, setIsVisible] = (0, import_element79.useState)(false);
24408 const disabled2 = field.isDisabled({ item: data, field });
24409 const toggleVisibility = (0, import_element79.useCallback)(() => {
24410 setIsVisible((prev) => !prev);
24411 }, []);
24412 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
24413 ValidatedText,
24414 {
24415 ...{
24416 data,
24417 field,
24418 onChange,
24419 hideLabelFromVision,
24420 markWhenOptional,
24421 validity,
24422 type: isVisible2 ? "text" : "password",
24423 suffix: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
24424 import_components45.Button,
24425 {
24426 icon: isVisible2 ? unseen_default : seen_default,
24427 onClick: toggleVisibility,
24428 size: "small",
24429 label: isVisible2 ? (0, import_i18n38.__)("Hide password") : (0, import_i18n38.__)("Show password"),
24430 disabled: disabled2,
24431 accessibleWhenDisabled: true
24432 }
24433 ) })
24434 }
24435 }
24436 );
24437 }
24438
24439 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24440 function hasElements(field) {
24441 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24442 }
24443
24444 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24445 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24446 var FORM_CONTROLS = {
24447 adaptiveSelect: AdaptiveSelect,
24448 array: ArrayControl,
24449 checkbox: Checkbox,
24450 color: Color,
24451 combobox: Combobox3,
24452 datetime: DateTime,
24453 date: DateControl,
24454 email: Email,
24455 telephone: Telephone,
24456 url: Url,
24457 integer: Integer,
24458 number: Number2,
24459 password: Password,
24460 radio: Radio,
24461 select: Select,
24462 text: Text3,
24463 toggle: Toggle,
24464 textarea: Textarea,
24465 toggleGroup: ToggleGroup
24466 };
24467 function isEditConfig(value) {
24468 return value && typeof value === "object" && typeof value.control === "string";
24469 }
24470 function createConfiguredControl(config) {
24471 const { control, ...controlConfig } = config;
24472 const BaseControlType = getControlByType(control);
24473 if (BaseControlType === null) {
24474 return null;
24475 }
24476 return function ConfiguredControl(props) {
24477 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(BaseControlType, { ...props, config: controlConfig });
24478 };
24479 }
24480 function getControl(field, fallback) {
24481 if (typeof field.Edit === "function") {
24482 return field.Edit;
24483 }
24484 if (typeof field.Edit === "string") {
24485 return getControlByType(field.Edit);
24486 }
24487 if (isEditConfig(field.Edit)) {
24488 return createConfiguredControl(field.Edit);
24489 }
24490 if (hasElements(field) && field.type !== "array") {
24491 return getControlByType("adaptiveSelect");
24492 }
24493 if (fallback === null) {
24494 return null;
24495 }
24496 return getControlByType(fallback);
24497 }
24498 function getControlByType(type) {
24499 if (Object.keys(FORM_CONTROLS).includes(type)) {
24500 return FORM_CONTROLS[type];
24501 }
24502 return null;
24503 }
24504
24505 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24506 function getFilterBy(field, defaultOperators, validOperators) {
24507 if (field.filterBy === false) {
24508 return false;
24509 }
24510 const operators = field.filterBy?.operators?.filter(
24511 (op) => validOperators.includes(op)
24512 ) ?? defaultOperators;
24513 if (operators.length === 0) {
24514 return false;
24515 }
24516 return {
24517 isPrimary: !!field.filterBy?.isPrimary,
24518 operators
24519 };
24520 }
24521 var get_filter_by_default = getFilterBy;
24522
24523 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24524 var getValueFromId = (id) => ({ item }) => {
24525 const path = id.split(".");
24526 let value = item;
24527 for (const segment of path) {
24528 if (value.hasOwnProperty(segment)) {
24529 value = value[segment];
24530 } else {
24531 value = void 0;
24532 }
24533 }
24534 return value;
24535 };
24536 var get_value_from_id_default = getValueFromId;
24537
24538 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24539 var setValueFromId = (id) => ({ value }) => {
24540 const path = id.split(".");
24541 const result = {};
24542 let current = result;
24543 for (const segment of path.slice(0, -1)) {
24544 current[segment] = {};
24545 current = current[segment];
24546 }
24547 current[path.at(-1)] = value;
24548 return result;
24549 };
24550 var set_value_from_id_default = setValueFromId;
24551
24552 // packages/dataviews/build-module/field-types/email.mjs
24553 var import_i18n39 = __toESM(require_i18n(), 1);
24554
24555 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24556 function RenderFromElements({
24557 item,
24558 field
24559 }) {
24560 const { elements, isLoading } = useElements({
24561 elements: field.elements,
24562 getElements: field.getElements
24563 });
24564 const value = field.getValue({ item });
24565 if (isLoading) {
24566 return value;
24567 }
24568 if (elements.length === 0) {
24569 return value;
24570 }
24571 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24572 }
24573
24574 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24575 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
24576 function render({
24577 item,
24578 field
24579 }) {
24580 if (field.hasElements) {
24581 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
24582 }
24583 return field.getValueFormatted({ item, field });
24584 }
24585
24586 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24587 var sort_text_default = (a2, b2, direction) => {
24588 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24589 };
24590
24591 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24592 function isValidRequired(item, field) {
24593 const value = field.getValue({ item });
24594 return ![void 0, "", null].includes(value);
24595 }
24596
24597 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24598 function isValidMinLength(item, field) {
24599 if (typeof field.isValid.minLength?.constraint !== "number") {
24600 return false;
24601 }
24602 const value = field.getValue({ item });
24603 if ([void 0, "", null].includes(value)) {
24604 return true;
24605 }
24606 return String(value).length >= field.isValid.minLength.constraint;
24607 }
24608
24609 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24610 function isValidMaxLength(item, field) {
24611 if (typeof field.isValid.maxLength?.constraint !== "number") {
24612 return false;
24613 }
24614 const value = field.getValue({ item });
24615 if ([void 0, "", null].includes(value)) {
24616 return true;
24617 }
24618 return String(value).length <= field.isValid.maxLength.constraint;
24619 }
24620
24621 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24622 function isValidPattern(item, field) {
24623 if (field.isValid.pattern?.constraint === void 0) {
24624 return true;
24625 }
24626 try {
24627 const regexp = new RegExp(field.isValid.pattern.constraint);
24628 const value = field.getValue({ item });
24629 if ([void 0, "", null].includes(value)) {
24630 return true;
24631 }
24632 return regexp.test(String(value));
24633 } catch {
24634 return false;
24635 }
24636 }
24637
24638 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24639 function isValidElements(item, field) {
24640 const elements = field.elements ?? [];
24641 const validValues = elements.map((el) => el.value);
24642 if (validValues.length === 0) {
24643 return true;
24644 }
24645 const value = field.getValue({ item });
24646 return [].concat(value).every((v2) => validValues.includes(v2));
24647 }
24648
24649 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24650 function getValueFormatted({
24651 item,
24652 field
24653 }) {
24654 return field.getValue({ item });
24655 }
24656 var get_value_formatted_default_default = getValueFormatted;
24657
24658 // packages/dataviews/build-module/field-types/email.mjs
24659 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])?)*$/;
24660 function isValidCustom(item, field) {
24661 const value = field.getValue({ item });
24662 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24663 return (0, import_i18n39.__)("Value must be a valid email address.");
24664 }
24665 return null;
24666 }
24667 var email_default = {
24668 type: "email",
24669 render,
24670 Edit: "email",
24671 sort: sort_text_default,
24672 enableSorting: true,
24673 enableGlobalSearch: false,
24674 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24675 validOperators: [
24676 OPERATOR_IS,
24677 OPERATOR_IS_NOT,
24678 OPERATOR_CONTAINS,
24679 OPERATOR_NOT_CONTAINS,
24680 OPERATOR_STARTS_WITH,
24681 // Multiple selection
24682 OPERATOR_IS_ANY,
24683 OPERATOR_IS_NONE,
24684 OPERATOR_IS_ALL,
24685 OPERATOR_IS_NOT_ALL
24686 ],
24687 format: {},
24688 getValueFormatted: get_value_formatted_default_default,
24689 validate: {
24690 required: isValidRequired,
24691 pattern: isValidPattern,
24692 minLength: isValidMinLength,
24693 maxLength: isValidMaxLength,
24694 elements: isValidElements,
24695 custom: isValidCustom
24696 }
24697 };
24698
24699 // packages/dataviews/build-module/field-types/integer.mjs
24700 var import_i18n40 = __toESM(require_i18n(), 1);
24701
24702 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24703 var sort_number_default = (a2, b2, direction) => {
24704 return direction === "asc" ? a2 - b2 : b2 - a2;
24705 };
24706
24707 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24708 function isValidMin(item, field) {
24709 if (typeof field.isValid.min?.constraint !== "number") {
24710 return false;
24711 }
24712 const value = field.getValue({ item });
24713 if ([void 0, "", null].includes(value)) {
24714 return true;
24715 }
24716 return Number(value) >= field.isValid.min.constraint;
24717 }
24718
24719 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24720 function isValidMax(item, field) {
24721 if (typeof field.isValid.max?.constraint !== "number") {
24722 return false;
24723 }
24724 const value = field.getValue({ item });
24725 if ([void 0, "", null].includes(value)) {
24726 return true;
24727 }
24728 return Number(value) <= field.isValid.max.constraint;
24729 }
24730
24731 // packages/dataviews/build-module/field-types/integer.mjs
24732 var format2 = {
24733 separatorThousand: ","
24734 };
24735 function getValueFormatted2({
24736 item,
24737 field
24738 }) {
24739 let value = field.getValue({ item });
24740 if (value === null || value === void 0) {
24741 return "";
24742 }
24743 value = Number(value);
24744 if (!Number.isFinite(value)) {
24745 return String(value);
24746 }
24747 let formatInteger;
24748 if (field.type !== "integer") {
24749 formatInteger = format2;
24750 } else {
24751 formatInteger = field.format;
24752 }
24753 const { separatorThousand } = formatInteger;
24754 const integerValue = Math.trunc(value);
24755 if (!separatorThousand) {
24756 return String(integerValue);
24757 }
24758 return String(integerValue).replace(
24759 /\B(?=(\d{3})+(?!\d))/g,
24760 separatorThousand
24761 );
24762 }
24763 function isValidCustom2(item, field) {
24764 const value = field.getValue({ item });
24765 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24766 return (0, import_i18n40.__)("Value must be an integer.");
24767 }
24768 return null;
24769 }
24770 var integer_default = {
24771 type: "integer",
24772 render,
24773 Edit: "integer",
24774 sort: sort_number_default,
24775 enableSorting: true,
24776 enableGlobalSearch: false,
24777 defaultOperators: [
24778 OPERATOR_IS,
24779 OPERATOR_IS_NOT,
24780 OPERATOR_LESS_THAN,
24781 OPERATOR_GREATER_THAN,
24782 OPERATOR_LESS_THAN_OR_EQUAL,
24783 OPERATOR_GREATER_THAN_OR_EQUAL,
24784 OPERATOR_BETWEEN
24785 ],
24786 validOperators: [
24787 // Single-selection
24788 OPERATOR_IS,
24789 OPERATOR_IS_NOT,
24790 OPERATOR_LESS_THAN,
24791 OPERATOR_GREATER_THAN,
24792 OPERATOR_LESS_THAN_OR_EQUAL,
24793 OPERATOR_GREATER_THAN_OR_EQUAL,
24794 OPERATOR_BETWEEN,
24795 // Multiple-selection
24796 OPERATOR_IS_ANY,
24797 OPERATOR_IS_NONE,
24798 OPERATOR_IS_ALL,
24799 OPERATOR_IS_NOT_ALL
24800 ],
24801 format: format2,
24802 getValueFormatted: getValueFormatted2,
24803 validate: {
24804 required: isValidRequired,
24805 min: isValidMin,
24806 max: isValidMax,
24807 elements: isValidElements,
24808 custom: isValidCustom2
24809 }
24810 };
24811
24812 // packages/dataviews/build-module/field-types/number.mjs
24813 var import_i18n41 = __toESM(require_i18n(), 1);
24814 var format3 = {
24815 separatorThousand: ",",
24816 separatorDecimal: ".",
24817 decimals: 2
24818 };
24819 function getValueFormatted3({
24820 item,
24821 field
24822 }) {
24823 let value = field.getValue({ item });
24824 if (value === null || value === void 0) {
24825 return "";
24826 }
24827 value = Number(value);
24828 if (!Number.isFinite(value)) {
24829 return String(value);
24830 }
24831 let formatNumber;
24832 if (field.type !== "number") {
24833 formatNumber = format3;
24834 } else {
24835 formatNumber = field.format;
24836 }
24837 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24838 const fixedValue = value.toFixed(decimals);
24839 const [integerPart, decimalPart] = fixedValue.split(".");
24840 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24841 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24842 }
24843 function isEmpty(value) {
24844 return value === "" || value === void 0 || value === null;
24845 }
24846 function isValidCustom3(item, field) {
24847 const value = field.getValue({ item });
24848 if (!isEmpty(value) && !Number.isFinite(value)) {
24849 return (0, import_i18n41.__)("Value must be a number.");
24850 }
24851 return null;
24852 }
24853 var number_default = {
24854 type: "number",
24855 render,
24856 Edit: "number",
24857 sort: sort_number_default,
24858 enableSorting: true,
24859 enableGlobalSearch: false,
24860 defaultOperators: [
24861 OPERATOR_IS,
24862 OPERATOR_IS_NOT,
24863 OPERATOR_LESS_THAN,
24864 OPERATOR_GREATER_THAN,
24865 OPERATOR_LESS_THAN_OR_EQUAL,
24866 OPERATOR_GREATER_THAN_OR_EQUAL,
24867 OPERATOR_BETWEEN
24868 ],
24869 validOperators: [
24870 // Single-selection
24871 OPERATOR_IS,
24872 OPERATOR_IS_NOT,
24873 OPERATOR_LESS_THAN,
24874 OPERATOR_GREATER_THAN,
24875 OPERATOR_LESS_THAN_OR_EQUAL,
24876 OPERATOR_GREATER_THAN_OR_EQUAL,
24877 OPERATOR_BETWEEN,
24878 // Multiple-selection
24879 OPERATOR_IS_ANY,
24880 OPERATOR_IS_NONE,
24881 OPERATOR_IS_ALL,
24882 OPERATOR_IS_NOT_ALL
24883 ],
24884 format: format3,
24885 getValueFormatted: getValueFormatted3,
24886 validate: {
24887 required: isValidRequired,
24888 min: isValidMin,
24889 max: isValidMax,
24890 elements: isValidElements,
24891 custom: isValidCustom3
24892 }
24893 };
24894
24895 // packages/dataviews/build-module/field-types/text.mjs
24896 var text_default = {
24897 type: "text",
24898 render,
24899 Edit: "text",
24900 sort: sort_text_default,
24901 enableSorting: true,
24902 enableGlobalSearch: false,
24903 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24904 validOperators: [
24905 // Single selection
24906 OPERATOR_IS,
24907 OPERATOR_IS_NOT,
24908 OPERATOR_CONTAINS,
24909 OPERATOR_NOT_CONTAINS,
24910 OPERATOR_STARTS_WITH,
24911 // Multiple selection
24912 OPERATOR_IS_ANY,
24913 OPERATOR_IS_NONE,
24914 OPERATOR_IS_ALL,
24915 OPERATOR_IS_NOT_ALL
24916 ],
24917 format: {},
24918 getValueFormatted: get_value_formatted_default_default,
24919 validate: {
24920 required: isValidRequired,
24921 pattern: isValidPattern,
24922 minLength: isValidMinLength,
24923 maxLength: isValidMaxLength,
24924 elements: isValidElements
24925 }
24926 };
24927
24928 // packages/dataviews/build-module/field-types/datetime.mjs
24929 var import_date7 = __toESM(require_date(), 1);
24930
24931 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24932 var import_date6 = __toESM(require_date(), 1);
24933 function parseDateLike(value) {
24934 if (!value) {
24935 return null;
24936 }
24937 if (!isValid(new Date(value))) {
24938 return null;
24939 }
24940 const parsed = (0, import_date6.getDate)(value);
24941 return parsed && isValid(parsed) ? parsed : null;
24942 }
24943 function validateDateLikeBoundary(item, field, boundary) {
24944 const constraint = field.isValid[boundary]?.constraint;
24945 if (typeof constraint !== "string") {
24946 return false;
24947 }
24948 const value = field.getValue({ item });
24949 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24950 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24951 return true;
24952 }
24953 const parsedConstraint = parseDateLike(constraint);
24954 const parsedValue = parseDateLike(String(boundaryValue));
24955 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24956 }
24957 function isValidMinDate(item, field) {
24958 return validateDateLikeBoundary(item, field, "min");
24959 }
24960 function isValidMaxDate(item, field) {
24961 return validateDateLikeBoundary(item, field, "max");
24962 }
24963
24964 // packages/dataviews/build-module/field-types/datetime.mjs
24965 var format4 = {
24966 datetime: (0, import_date7.getSettings)().formats.datetime,
24967 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24968 };
24969 function getValueFormatted4({
24970 item,
24971 field
24972 }) {
24973 const value = field.getValue({ item });
24974 if (["", void 0, null].includes(value)) {
24975 return "";
24976 }
24977 let formatDatetime;
24978 if (field.type !== "datetime") {
24979 formatDatetime = format4;
24980 } else {
24981 formatDatetime = field.format;
24982 }
24983 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
24984 }
24985 var sort = (a2, b2, direction) => {
24986 const timeA = new Date(a2).getTime();
24987 const timeB = new Date(b2).getTime();
24988 return direction === "asc" ? timeA - timeB : timeB - timeA;
24989 };
24990 var datetime_default = {
24991 type: "datetime",
24992 render,
24993 Edit: "datetime",
24994 sort,
24995 enableSorting: true,
24996 enableGlobalSearch: false,
24997 defaultOperators: [
24998 OPERATOR_ON,
24999 OPERATOR_NOT_ON,
25000 OPERATOR_BEFORE,
25001 OPERATOR_AFTER,
25002 OPERATOR_BEFORE_INC,
25003 OPERATOR_AFTER_INC,
25004 OPERATOR_IN_THE_PAST,
25005 OPERATOR_OVER
25006 ],
25007 validOperators: [
25008 OPERATOR_ON,
25009 OPERATOR_NOT_ON,
25010 OPERATOR_BEFORE,
25011 OPERATOR_AFTER,
25012 OPERATOR_BEFORE_INC,
25013 OPERATOR_AFTER_INC,
25014 OPERATOR_IN_THE_PAST,
25015 OPERATOR_OVER
25016 ],
25017 format: format4,
25018 getValueFormatted: getValueFormatted4,
25019 validate: {
25020 required: isValidRequired,
25021 elements: isValidElements,
25022 min: isValidMinDate,
25023 max: isValidMaxDate
25024 }
25025 };
25026
25027 // packages/dataviews/build-module/field-types/date.mjs
25028 var import_date8 = __toESM(require_date(), 1);
25029 var format5 = {
25030 date: (0, import_date8.getSettings)().formats.date,
25031 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25032 };
25033 function getValueFormatted5({
25034 item,
25035 field
25036 }) {
25037 const value = field.getValue({ item });
25038 if (["", void 0, null].includes(value)) {
25039 return "";
25040 }
25041 let formatDate2;
25042 if (field.type !== "date") {
25043 formatDate2 = format5;
25044 } else {
25045 formatDate2 = field.format;
25046 }
25047 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25048 }
25049 var sort2 = (a2, b2, direction) => {
25050 const timeA = new Date(a2).getTime();
25051 const timeB = new Date(b2).getTime();
25052 return direction === "asc" ? timeA - timeB : timeB - timeA;
25053 };
25054 var date_default = {
25055 type: "date",
25056 render,
25057 Edit: "date",
25058 sort: sort2,
25059 enableSorting: true,
25060 enableGlobalSearch: false,
25061 defaultOperators: [
25062 OPERATOR_ON,
25063 OPERATOR_NOT_ON,
25064 OPERATOR_BEFORE,
25065 OPERATOR_AFTER,
25066 OPERATOR_BEFORE_INC,
25067 OPERATOR_AFTER_INC,
25068 OPERATOR_IN_THE_PAST,
25069 OPERATOR_OVER,
25070 OPERATOR_BETWEEN
25071 ],
25072 validOperators: [
25073 OPERATOR_ON,
25074 OPERATOR_NOT_ON,
25075 OPERATOR_BEFORE,
25076 OPERATOR_AFTER,
25077 OPERATOR_BEFORE_INC,
25078 OPERATOR_AFTER_INC,
25079 OPERATOR_IN_THE_PAST,
25080 OPERATOR_OVER,
25081 OPERATOR_BETWEEN
25082 ],
25083 format: format5,
25084 getValueFormatted: getValueFormatted5,
25085 validate: {
25086 required: isValidRequired,
25087 elements: isValidElements,
25088 min: isValidMinDate,
25089 max: isValidMaxDate
25090 }
25091 };
25092
25093 // packages/dataviews/build-module/field-types/boolean.mjs
25094 var import_i18n42 = __toESM(require_i18n(), 1);
25095
25096 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25097 function isValidRequiredForBool(item, field) {
25098 const value = field.getValue({ item });
25099 return value === true;
25100 }
25101
25102 // packages/dataviews/build-module/field-types/boolean.mjs
25103 function getValueFormatted6({
25104 item,
25105 field
25106 }) {
25107 const value = field.getValue({ item });
25108 if (value === true) {
25109 return (0, import_i18n42.__)("True");
25110 }
25111 if (value === false) {
25112 return (0, import_i18n42.__)("False");
25113 }
25114 return "";
25115 }
25116 function isValidCustom4(item, field) {
25117 const value = field.getValue({ item });
25118 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25119 return (0, import_i18n42.__)("Value must be true, false, or undefined");
25120 }
25121 return null;
25122 }
25123 var sort3 = (a2, b2, direction) => {
25124 const boolA = Boolean(a2);
25125 const boolB = Boolean(b2);
25126 if (boolA === boolB) {
25127 return 0;
25128 }
25129 if (direction === "asc") {
25130 return boolA ? 1 : -1;
25131 }
25132 return boolA ? -1 : 1;
25133 };
25134 var boolean_default = {
25135 type: "boolean",
25136 render,
25137 Edit: "checkbox",
25138 sort: sort3,
25139 validate: {
25140 required: isValidRequiredForBool,
25141 elements: isValidElements,
25142 custom: isValidCustom4
25143 },
25144 enableSorting: true,
25145 enableGlobalSearch: false,
25146 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25147 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25148 format: {},
25149 getValueFormatted: getValueFormatted6
25150 };
25151
25152 // packages/dataviews/build-module/field-types/media.mjs
25153 var media_default = {
25154 type: "media",
25155 render: () => null,
25156 Edit: null,
25157 sort: () => 0,
25158 enableSorting: false,
25159 enableGlobalSearch: false,
25160 defaultOperators: [],
25161 validOperators: [],
25162 format: {},
25163 getValueFormatted: get_value_formatted_default_default,
25164 // cannot validate any constraint, so
25165 // the only available validation for the field author
25166 // would be providing a custom validator.
25167 validate: {}
25168 };
25169
25170 // packages/dataviews/build-module/field-types/array.mjs
25171 var import_i18n43 = __toESM(require_i18n(), 1);
25172
25173 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25174 function isValidRequiredForArray(item, field) {
25175 const value = field.getValue({ item });
25176 return Array.isArray(value) && value.length > 0 && value.every(
25177 (element) => ![void 0, "", null].includes(element)
25178 );
25179 }
25180
25181 // packages/dataviews/build-module/field-types/array.mjs
25182 function getValueFormatted7({
25183 item,
25184 field
25185 }) {
25186 const value = field.getValue({ item });
25187 const arr = Array.isArray(value) ? value : [];
25188 return arr.join(", ");
25189 }
25190 function render2({ item, field }) {
25191 return getValueFormatted7({ item, field });
25192 }
25193 function isValidCustom5(item, field) {
25194 const value = field.getValue({ item });
25195 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25196 return (0, import_i18n43.__)("Value must be an array.");
25197 }
25198 if (!value.every((v2) => typeof v2 === "string")) {
25199 return (0, import_i18n43.__)("Every value must be a string.");
25200 }
25201 return null;
25202 }
25203 var sort4 = (a2, b2, direction) => {
25204 const arrA = Array.isArray(a2) ? a2 : [];
25205 const arrB = Array.isArray(b2) ? b2 : [];
25206 if (arrA.length !== arrB.length) {
25207 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25208 }
25209 const joinedA = arrA.join(",");
25210 const joinedB = arrB.join(",");
25211 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25212 };
25213 var array_default = {
25214 type: "array",
25215 render: render2,
25216 Edit: "array",
25217 sort: sort4,
25218 enableSorting: true,
25219 enableGlobalSearch: false,
25220 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25221 validOperators: [
25222 OPERATOR_IS_ANY,
25223 OPERATOR_IS_NONE,
25224 OPERATOR_IS_ALL,
25225 OPERATOR_IS_NOT_ALL
25226 ],
25227 format: {},
25228 getValueFormatted: getValueFormatted7,
25229 validate: {
25230 required: isValidRequiredForArray,
25231 elements: isValidElements,
25232 custom: isValidCustom5
25233 }
25234 };
25235
25236 // packages/dataviews/build-module/field-types/password.mjs
25237 function getValueFormatted8({
25238 item,
25239 field
25240 }) {
25241 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25242 }
25243 var password_default = {
25244 type: "password",
25245 render,
25246 Edit: "password",
25247 sort: () => 0,
25248 // Passwords should not be sortable for security reasons
25249 enableSorting: false,
25250 enableGlobalSearch: false,
25251 defaultOperators: [],
25252 validOperators: [],
25253 format: {},
25254 getValueFormatted: getValueFormatted8,
25255 validate: {
25256 required: isValidRequired,
25257 pattern: isValidPattern,
25258 minLength: isValidMinLength,
25259 maxLength: isValidMaxLength,
25260 elements: isValidElements
25261 }
25262 };
25263
25264 // packages/dataviews/build-module/field-types/telephone.mjs
25265 var telephone_default = {
25266 type: "telephone",
25267 render,
25268 Edit: "telephone",
25269 sort: sort_text_default,
25270 enableSorting: true,
25271 enableGlobalSearch: false,
25272 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25273 validOperators: [
25274 OPERATOR_IS,
25275 OPERATOR_IS_NOT,
25276 OPERATOR_CONTAINS,
25277 OPERATOR_NOT_CONTAINS,
25278 OPERATOR_STARTS_WITH,
25279 // Multiple selection
25280 OPERATOR_IS_ANY,
25281 OPERATOR_IS_NONE,
25282 OPERATOR_IS_ALL,
25283 OPERATOR_IS_NOT_ALL
25284 ],
25285 format: {},
25286 getValueFormatted: get_value_formatted_default_default,
25287 validate: {
25288 required: isValidRequired,
25289 pattern: isValidPattern,
25290 minLength: isValidMinLength,
25291 maxLength: isValidMaxLength,
25292 elements: isValidElements
25293 }
25294 };
25295
25296 // packages/dataviews/build-module/field-types/color.mjs
25297 var import_i18n44 = __toESM(require_i18n(), 1);
25298 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25299 function render3({ item, field }) {
25300 if (field.hasElements) {
25301 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(RenderFromElements, { item, field });
25302 }
25303 const value = get_value_formatted_default_default({ item, field });
25304 if (!value || !w(value).isValid()) {
25305 return value;
25306 }
25307 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25308 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
25309 "div",
25310 {
25311 style: {
25312 width: "16px",
25313 height: "16px",
25314 borderRadius: "50%",
25315 backgroundColor: value,
25316 border: "1px solid #ddd",
25317 flexShrink: 0
25318 }
25319 }
25320 ),
25321 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: value })
25322 ] });
25323 }
25324 function isValidCustom6(item, field) {
25325 const value = field.getValue({ item });
25326 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25327 return (0, import_i18n44.__)("Value must be a valid color.");
25328 }
25329 return null;
25330 }
25331 var sort5 = (a2, b2, direction) => {
25332 const colorA = w(a2);
25333 const colorB = w(b2);
25334 if (!colorA.isValid() && !colorB.isValid()) {
25335 return 0;
25336 }
25337 if (!colorA.isValid()) {
25338 return direction === "asc" ? 1 : -1;
25339 }
25340 if (!colorB.isValid()) {
25341 return direction === "asc" ? -1 : 1;
25342 }
25343 const hslA = colorA.toHsl();
25344 const hslB = colorB.toHsl();
25345 if (hslA.h !== hslB.h) {
25346 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25347 }
25348 if (hslA.s !== hslB.s) {
25349 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25350 }
25351 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25352 };
25353 var color_default = {
25354 type: "color",
25355 render: render3,
25356 Edit: "color",
25357 sort: sort5,
25358 enableSorting: true,
25359 enableGlobalSearch: false,
25360 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25361 validOperators: [
25362 OPERATOR_IS,
25363 OPERATOR_IS_NOT,
25364 OPERATOR_IS_ANY,
25365 OPERATOR_IS_NONE
25366 ],
25367 format: {},
25368 getValueFormatted: get_value_formatted_default_default,
25369 validate: {
25370 required: isValidRequired,
25371 elements: isValidElements,
25372 custom: isValidCustom6
25373 }
25374 };
25375
25376 // packages/dataviews/build-module/field-types/url.mjs
25377 var url_default = {
25378 type: "url",
25379 render,
25380 Edit: "url",
25381 sort: sort_text_default,
25382 enableSorting: true,
25383 enableGlobalSearch: false,
25384 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25385 validOperators: [
25386 OPERATOR_IS,
25387 OPERATOR_IS_NOT,
25388 OPERATOR_CONTAINS,
25389 OPERATOR_NOT_CONTAINS,
25390 OPERATOR_STARTS_WITH,
25391 // Multiple selection
25392 OPERATOR_IS_ANY,
25393 OPERATOR_IS_NONE,
25394 OPERATOR_IS_ALL,
25395 OPERATOR_IS_NOT_ALL
25396 ],
25397 format: {},
25398 getValueFormatted: get_value_formatted_default_default,
25399 validate: {
25400 required: isValidRequired,
25401 pattern: isValidPattern,
25402 minLength: isValidMinLength,
25403 maxLength: isValidMaxLength,
25404 elements: isValidElements
25405 }
25406 };
25407
25408 // packages/dataviews/build-module/field-types/no-type.mjs
25409 var sort6 = (a2, b2, direction) => {
25410 if (typeof a2 === "number" && typeof b2 === "number") {
25411 return sort_number_default(a2, b2, direction);
25412 }
25413 return sort_text_default(a2, b2, direction);
25414 };
25415 var no_type_default = {
25416 // type: no type for this one
25417 render,
25418 Edit: null,
25419 sort: sort6,
25420 enableSorting: true,
25421 enableGlobalSearch: false,
25422 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25423 validOperators: getAllOperatorNames(),
25424 format: {},
25425 getValueFormatted: get_value_formatted_default_default,
25426 validate: {
25427 required: isValidRequired,
25428 elements: isValidElements
25429 }
25430 };
25431
25432 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25433 function supportsNumericRangeConstraint(type) {
25434 return type === "integer" || type === "number";
25435 }
25436 function supportsDateRangeConstraint(type) {
25437 return type === "date" || type === "datetime";
25438 }
25439 function normalizeRangeRule(value, fieldType, key) {
25440 const validator = fieldType.validate[key];
25441 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25442 return { constraint: value, validate: validator };
25443 }
25444 return void 0;
25445 }
25446 function getIsValid(field, fieldType) {
25447 const rules = field.isValid;
25448 let required;
25449 if (rules?.required === true && fieldType.validate.required !== void 0) {
25450 required = {
25451 constraint: true,
25452 validate: fieldType.validate.required
25453 };
25454 }
25455 let elements;
25456 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25457 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25458 elements = {
25459 constraint: true,
25460 validate: fieldType.validate.elements
25461 };
25462 }
25463 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25464 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25465 const minLengthValue = rules?.minLength;
25466 let minLength;
25467 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25468 minLength = {
25469 constraint: minLengthValue,
25470 validate: fieldType.validate.minLength
25471 };
25472 }
25473 const maxLengthValue = rules?.maxLength;
25474 let maxLength;
25475 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25476 maxLength = {
25477 constraint: maxLengthValue,
25478 validate: fieldType.validate.maxLength
25479 };
25480 }
25481 const patternValue = rules?.pattern;
25482 let pattern;
25483 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25484 pattern = {
25485 constraint: patternValue,
25486 validate: fieldType.validate.pattern
25487 };
25488 }
25489 const custom = rules?.custom ?? fieldType.validate.custom;
25490 return {
25491 required,
25492 elements,
25493 min: min2,
25494 max: max2,
25495 minLength,
25496 maxLength,
25497 pattern,
25498 custom
25499 };
25500 }
25501
25502 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25503 function getFilter(fieldType) {
25504 return fieldType.validOperators.reduce((accumulator, operator) => {
25505 const operatorObj = getOperatorByName(operator);
25506 if (operatorObj?.filter) {
25507 accumulator[operator] = operatorObj.filter;
25508 }
25509 return accumulator;
25510 }, {});
25511 }
25512
25513 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25514 function getFormat(field, fieldType) {
25515 return {
25516 ...fieldType.format,
25517 ...field.format
25518 };
25519 }
25520 var get_format_default = getFormat;
25521
25522 // packages/dataviews/build-module/field-types/index.mjs
25523 function getFieldTypeByName(type) {
25524 const found = [
25525 email_default,
25526 integer_default,
25527 number_default,
25528 text_default,
25529 datetime_default,
25530 date_default,
25531 boolean_default,
25532 media_default,
25533 array_default,
25534 password_default,
25535 telephone_default,
25536 color_default,
25537 url_default
25538 ].find((fieldType) => fieldType?.type === type);
25539 if (!!found) {
25540 return found;
25541 }
25542 return no_type_default;
25543 }
25544 function normalizeFields(fields) {
25545 return fields.map((field) => {
25546 const fieldType = getFieldTypeByName(field.type);
25547 const getValue = field.getValue || get_value_from_id_default(field.id);
25548 const sort7 = function(a2, b2, direction) {
25549 const aValue = getValue({ item: a2 });
25550 const bValue = getValue({ item: b2 });
25551 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25552 };
25553 return {
25554 id: field.id,
25555 label: field.label || field.id,
25556 header: field.header || field.label || field.id,
25557 description: field.description,
25558 placeholder: field.placeholder,
25559 getValue,
25560 setValue: field.setValue || set_value_from_id_default(field.id),
25561 elements: field.elements,
25562 getElements: field.getElements,
25563 hasElements: hasElements(field),
25564 isVisible: field.isVisible,
25565 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25566 enableHiding: field.enableHiding ?? true,
25567 readOnly: field.readOnly ?? false,
25568 // The type provides defaults for the following props
25569 type: fieldType.type,
25570 render: field.render ?? fieldType.render,
25571 Edit: getControl(field, fieldType.Edit),
25572 sort: sort7,
25573 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25574 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25575 isValid: getIsValid(field, fieldType),
25576 filterBy: get_filter_by_default(
25577 field,
25578 fieldType.defaultOperators,
25579 fieldType.validOperators
25580 ),
25581 filter: getFilter(fieldType),
25582 format: get_format_default(field, fieldType),
25583 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25584 };
25585 });
25586 }
25587
25588 // packages/dataviews/build-module/hooks/use-data.mjs
25589 var import_element80 = __toESM(require_element(), 1);
25590 function useData({
25591 view,
25592 data: shownData,
25593 getItemId,
25594 isLoading,
25595 paginationInfo,
25596 selection
25597 }) {
25598 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25599 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element80.useState)(
25600 !isLoading
25601 );
25602 (0, import_element80.useEffect)(() => {
25603 if (!isLoading) {
25604 setHasInitiallyLoaded(true);
25605 }
25606 }, [isLoading]);
25607 const previousDataRef = (0, import_element80.useRef)(shownData);
25608 const previousPaginationInfoRef = (0, import_element80.useRef)(paginationInfo);
25609 (0, import_element80.useEffect)(() => {
25610 if (!isLoading) {
25611 previousDataRef.current = shownData;
25612 previousPaginationInfoRef.current = paginationInfo;
25613 }
25614 }, [shownData, isLoading, paginationInfo]);
25615 const [visibleEntries, setVisibleEntries] = (0, import_element80.useState)([]);
25616 const positionMapRef = (0, import_element80.useRef)(/* @__PURE__ */ new Map());
25617 const allLoadedRecordsRef = (0, import_element80.useRef)([]);
25618 const prevViewParamsRef = (0, import_element80.useRef)({
25619 search: void 0,
25620 filters: void 0,
25621 perPage: void 0
25622 });
25623 const scrollDirectionRef = (0, import_element80.useRef)(void 0);
25624 const prevStartPositionRef = (0, import_element80.useRef)(void 0);
25625 const hasInitializedRef = (0, import_element80.useRef)(false);
25626 const allLoadedRecords = (0, import_element80.useMemo)(() => {
25627 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25628 if (view.startPosition < prevStartPositionRef.current) {
25629 scrollDirectionRef.current = "up";
25630 } else if (view.startPosition > prevStartPositionRef.current) {
25631 scrollDirectionRef.current = "down";
25632 }
25633 }
25634 prevStartPositionRef.current = view.startPosition;
25635 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25636 const prevFiltersKey = prevViewParamsRef.current.filters;
25637 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25638 hasInitializedRef.current = true;
25639 prevViewParamsRef.current = {
25640 search: view.search,
25641 filters: currentFiltersKey,
25642 perPage: view.perPage
25643 };
25644 if (shouldReset) {
25645 positionMapRef.current.clear();
25646 scrollDirectionRef.current = void 0;
25647 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25648 const records = shownData.map((record, index2) => {
25649 const position = startPosition + index2;
25650 positionMapRef.current.set(getItemId(record), position);
25651 return {
25652 ...record,
25653 position
25654 };
25655 });
25656 allLoadedRecordsRef.current = records;
25657 return records;
25658 }
25659 const prev = allLoadedRecordsRef.current;
25660 const shownDataIds = new Set(shownData.map(getItemId));
25661 const scrollDirection = scrollDirectionRef.current;
25662 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25663 const newRecords = shownData.map((record, index2) => {
25664 const itemId = getItemId(record);
25665 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25666 if (position !== void 0) {
25667 positionMapRef.current.set(itemId, position);
25668 }
25669 return {
25670 ...record,
25671 position
25672 };
25673 });
25674 if (newRecords.length === 0) {
25675 return prev;
25676 }
25677 const prevWithoutDuplicates = prev.filter(
25678 (record) => !shownDataIds.has(getItemId(record))
25679 );
25680 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25681 allRecords.sort((a2, b2) => {
25682 const posA = a2.position;
25683 const posB = b2.position;
25684 return posA - posB;
25685 });
25686 let result = allRecords;
25687 if (visibleEntries.length > 0) {
25688 const visibleMin = Math.min(...visibleEntries);
25689 const visibleMax = Math.max(...visibleEntries);
25690 const buffer = 20;
25691 const recordPositions = allRecords.map(
25692 (r3) => r3.position
25693 );
25694 const minRecordPos = Math.min(...recordPositions);
25695 const maxRecordPos = Math.max(...recordPositions);
25696 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25697 if (hasOverlap) {
25698 result = allRecords.filter((record) => {
25699 const itemId = getItemId(record);
25700 const isSelected2 = selection?.includes(itemId);
25701 if (isSelected2) {
25702 return true;
25703 }
25704 const itemPosition = record.position;
25705 if (scrollDirection === "up") {
25706 return itemPosition <= visibleMax + buffer;
25707 } else if (scrollDirection === "down") {
25708 return itemPosition >= visibleMin - buffer;
25709 }
25710 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25711 });
25712 }
25713 }
25714 allLoadedRecordsRef.current = result;
25715 return result;
25716 }, [
25717 shownData,
25718 view.search,
25719 view.filters,
25720 view.perPage,
25721 view.startPosition,
25722 view.infiniteScrollEnabled,
25723 visibleEntries,
25724 selection,
25725 getItemId
25726 ]);
25727 if (!isInfiniteScrollEnabled) {
25728 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25729 return {
25730 data: dataToReturn.map((item) => ({
25731 ...item,
25732 position: void 0
25733 })),
25734 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25735 hasInitiallyLoaded,
25736 setVisibleEntries: void 0
25737 };
25738 }
25739 return {
25740 data: allLoadedRecords,
25741 paginationInfo,
25742 hasInitiallyLoaded,
25743 setVisibleEntries
25744 };
25745 }
25746
25747 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25748 var import_element81 = __toESM(require_element(), 1);
25749 var import_compose12 = __toESM(require_compose(), 1);
25750 function captureAnchorElement(container, anchorElementRef, direction) {
25751 const containerRect = container.getBoundingClientRect();
25752 const centerY = containerRect.top + containerRect.height / 2;
25753 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25754 if (items.length === 0) {
25755 return false;
25756 }
25757 const bestAnchor = items.reduce((best, item) => {
25758 const itemRect = item.getBoundingClientRect();
25759 const itemCenterY = itemRect.top + itemRect.height / 2;
25760 const distance = Math.abs(itemCenterY - centerY);
25761 const bestRect = best.getBoundingClientRect();
25762 const bestCenterY = bestRect.top + bestRect.height / 2;
25763 const bestDistance = Math.abs(bestCenterY - centerY);
25764 return distance < bestDistance ? item : best;
25765 });
25766 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25767 const anchorRect = bestAnchor.getBoundingClientRect();
25768 anchorElementRef.current = {
25769 posinset,
25770 viewportOffset: anchorRect.top - containerRect.top,
25771 direction
25772 };
25773 return true;
25774 }
25775 function useInfiniteScroll({
25776 view,
25777 onChangeView,
25778 isLoading,
25779 paginationInfo,
25780 containerRef,
25781 setVisibleEntries
25782 }) {
25783 const anchorElementRef = (0, import_element81.useRef)(null);
25784 const viewRef = (0, import_element81.useRef)(view);
25785 const isLoadingRef = (0, import_element81.useRef)(isLoading);
25786 const onChangeViewRef = (0, import_element81.useRef)(onChangeView);
25787 const totalItemsRef = (0, import_element81.useRef)(paginationInfo.totalItems);
25788 (0, import_element81.useLayoutEffect)(() => {
25789 viewRef.current = view;
25790 isLoadingRef.current = isLoading;
25791 onChangeViewRef.current = onChangeView;
25792 totalItemsRef.current = paginationInfo.totalItems;
25793 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25794 const intersectionObserverCallback = (0, import_element81.useCallback)(
25795 (entries) => {
25796 if (!setVisibleEntries) {
25797 return;
25798 }
25799 setVisibleEntries((prev) => {
25800 const newVisibleEntries = new Set(prev);
25801 let hasChanged = false;
25802 entries.forEach((entry) => {
25803 const posInSet = Number(
25804 entry.target?.attributes?.getNamedItem(
25805 "aria-posinset"
25806 )?.value
25807 );
25808 if (isNaN(posInSet)) {
25809 return;
25810 }
25811 if (entry.isIntersecting) {
25812 if (!newVisibleEntries.has(posInSet)) {
25813 newVisibleEntries.add(posInSet);
25814 hasChanged = true;
25815 }
25816 } else if (newVisibleEntries.has(posInSet)) {
25817 newVisibleEntries.delete(posInSet);
25818 hasChanged = true;
25819 }
25820 });
25821 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25822 });
25823 },
25824 [setVisibleEntries]
25825 );
25826 (0, import_element81.useLayoutEffect)(() => {
25827 const container = containerRef.current;
25828 const anchor = anchorElementRef.current;
25829 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25830 return;
25831 }
25832 const anchorElement = container.querySelector(
25833 `[aria-posinset="${anchor.posinset}"]`
25834 );
25835 if (anchorElement) {
25836 const containerRect = container.getBoundingClientRect();
25837 const anchorRect = anchorElement.getBoundingClientRect();
25838 const currentOffset = anchorRect.top - containerRect.top;
25839 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25840 if (Math.abs(scrollAdjustment) > 1) {
25841 container.scrollTop += scrollAdjustment;
25842 }
25843 }
25844 anchorElementRef.current = null;
25845 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25846 const intersectionObserverRef = (0, import_element81.useRef)(
25847 null
25848 );
25849 (0, import_element81.useEffect)(() => {
25850 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25851 if (intersectionObserverRef.current) {
25852 intersectionObserverRef.current.disconnect();
25853 intersectionObserverRef.current = null;
25854 }
25855 return;
25856 }
25857 intersectionObserverRef.current = new IntersectionObserver(
25858 intersectionObserverCallback,
25859 { root: null, rootMargin: "0px", threshold: 0.1 }
25860 );
25861 return () => {
25862 if (intersectionObserverRef.current) {
25863 intersectionObserverRef.current.disconnect();
25864 intersectionObserverRef.current = null;
25865 }
25866 };
25867 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25868 (0, import_element81.useEffect)(() => {
25869 if (!view.infiniteScrollEnabled || !containerRef.current) {
25870 return;
25871 }
25872 let lastScrollTop = 0;
25873 const BOTTOM_THRESHOLD = 600;
25874 const TOP_THRESHOLD = 800;
25875 const handleScroll = (0, import_compose12.throttle)((event) => {
25876 const currentView = viewRef.current;
25877 const totalItems = totalItemsRef.current;
25878 const target = event.target;
25879 const scrollTop = target.scrollTop;
25880 const scrollHeight = target.scrollHeight;
25881 const clientHeight = target.clientHeight;
25882 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25883 lastScrollTop = scrollTop;
25884 if (isLoadingRef.current) {
25885 return;
25886 }
25887 const currentStartPosition = currentView.startPosition || 1;
25888 const batchSize = currentView.perPage || 10;
25889 const currentEndPosition = Math.min(
25890 currentStartPosition + batchSize,
25891 totalItems
25892 );
25893 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25894 if (currentEndPosition < totalItems) {
25895 const newStartPosition = currentEndPosition;
25896 captureAnchorElement(target, anchorElementRef, "down");
25897 onChangeViewRef.current({
25898 ...currentView,
25899 startPosition: newStartPosition
25900 });
25901 }
25902 }
25903 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25904 if (currentStartPosition > 1) {
25905 const calculatedStartPosition = currentStartPosition - batchSize;
25906 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25907 captureAnchorElement(target, anchorElementRef, "up");
25908 onChangeViewRef.current({
25909 ...currentView,
25910 startPosition: newStartPosition
25911 });
25912 }
25913 }
25914 }, 50);
25915 const container = containerRef.current;
25916 container.addEventListener("scroll", handleScroll);
25917 return () => {
25918 container.removeEventListener("scroll", handleScroll);
25919 handleScroll.cancel();
25920 };
25921 }, [containerRef, view.infiniteScrollEnabled]);
25922 return {
25923 intersectionObserver: intersectionObserverRef.current
25924 };
25925 }
25926
25927 // packages/dataviews/build-module/dataviews/index.mjs
25928 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25929 var defaultGetItemId = (item) => item.id;
25930 var defaultIsItemClickable = () => true;
25931 var EMPTY_ARRAY6 = [];
25932 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25933 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25934 (viewLayout) => !viewLayout.isPicker
25935 );
25936 function DefaultUI({
25937 header,
25938 search = true,
25939 searchLabel = void 0
25940 }) {
25941 const { view } = (0, import_element82.useContext)(dataviews_context_default);
25942 const isInfiniteScroll = view.infiniteScrollEnabled;
25943 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [
25944 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25945 Stack,
25946 {
25947 direction: "row",
25948 align: "top",
25949 justify: "space-between",
25950 className: clsx_default("dataviews__view-actions", {
25951 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25952 }),
25953 gap: "xs",
25954 children: [
25955 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
25956 Stack,
25957 {
25958 direction: "row",
25959 justify: "start",
25960 gap: "sm",
25961 className: "dataviews__search",
25962 children: [
25963 search && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_search_default, { label: searchLabel }),
25964 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(toggle_default, {})
25965 ]
25966 }
25967 ),
25968 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
25969 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_view_config_default, {}),
25970 header
25971 ] })
25972 ]
25973 }
25974 ),
25975 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
25976 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DataViewsLayout, {}),
25977 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DataViewsFooter, {})
25978 ] });
25979 }
25980 function DataViews({
25981 view,
25982 onChangeView,
25983 fields,
25984 search = true,
25985 searchLabel = void 0,
25986 actions = EMPTY_ARRAY6,
25987 data,
25988 getItemId = defaultGetItemId,
25989 getItemLevel,
25990 isLoading = false,
25991 paginationInfo,
25992 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
25993 selection: selectionProperty,
25994 onChangeSelection,
25995 onClickItem,
25996 renderItemLink,
25997 isItemClickable = defaultIsItemClickable,
25998 header,
25999 children,
26000 config = { perPageSizes: [10, 20, 50, 100] },
26001 empty,
26002 onReset
26003 }) {
26004 const [selectionState, setSelectionState] = (0, import_element82.useState)([]);
26005 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26006 const selection = isUncontrolled ? selectionState : selectionProperty;
26007 const {
26008 data: displayData,
26009 paginationInfo: displayPaginationInfo,
26010 hasInitiallyLoaded,
26011 setVisibleEntries
26012 } = useData({
26013 view,
26014 data,
26015 getItemId,
26016 isLoading,
26017 selection,
26018 paginationInfo
26019 });
26020 const containerRef = (0, import_element82.useRef)(null);
26021 const [containerWidth, setContainerWidth] = (0, import_element82.useState)(0);
26022 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
26023 (resizeObserverEntries) => {
26024 setContainerWidth(
26025 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26026 );
26027 },
26028 { box: "border-box" }
26029 );
26030 const [openedFilter, setOpenedFilter] = (0, import_element82.useState)(null);
26031 function setSelectionWithChange(value) {
26032 const newValue = typeof value === "function" ? value(selection) : value;
26033 if (isUncontrolled) {
26034 setSelectionState(newValue);
26035 }
26036 if (onChangeSelection) {
26037 onChangeSelection(newValue);
26038 }
26039 }
26040 const _fields = (0, import_element82.useMemo)(() => normalizeFields(fields), [fields]);
26041 const _selection = (0, import_element82.useMemo)(() => {
26042 if (view.infiniteScrollEnabled) {
26043 return selection;
26044 }
26045 return selection.filter(
26046 (id) => data.some((item) => getItemId(item) === id)
26047 );
26048 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26049 const filters = use_filters_default(_fields, view);
26050 const hasPrimaryOrLockedFilters = (0, import_element82.useMemo)(
26051 () => (filters || []).some(
26052 (filter) => filter.isPrimary || filter.isLocked
26053 ),
26054 [filters]
26055 );
26056 const [isShowingFilter, setIsShowingFilter] = (0, import_element82.useState)(
26057 hasPrimaryOrLockedFilters
26058 );
26059 const { intersectionObserver } = useInfiniteScroll({
26060 view,
26061 onChangeView,
26062 isLoading,
26063 paginationInfo,
26064 containerRef,
26065 setVisibleEntries
26066 });
26067 (0, import_element82.useEffect)(() => {
26068 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26069 setIsShowingFilter(true);
26070 }
26071 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26072 const defaultLayouts = (0, import_element82.useMemo)(
26073 () => Object.fromEntries(
26074 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26075 return dataViewsLayouts.some(
26076 (viewLayout) => viewLayout.type === layoutType
26077 );
26078 }).map(([key, value]) => [
26079 key,
26080 value === true ? {} : value
26081 ])
26082 ),
26083 [defaultLayoutsProperty]
26084 );
26085 if (!defaultLayouts[view.type]) {
26086 return null;
26087 }
26088 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26089 dataviews_context_default.Provider,
26090 {
26091 value: {
26092 view,
26093 onChangeView,
26094 fields: _fields,
26095 actions,
26096 data: displayData,
26097 isLoading,
26098 paginationInfo: displayPaginationInfo,
26099 selection: _selection,
26100 onChangeSelection: setSelectionWithChange,
26101 openedFilter,
26102 setOpenedFilter,
26103 getItemId,
26104 getItemLevel,
26105 isItemClickable,
26106 onClickItem,
26107 renderItemLink,
26108 containerWidth,
26109 containerRef,
26110 resizeObserverRef,
26111 defaultLayouts,
26112 filters,
26113 isShowingFilter,
26114 setIsShowingFilter,
26115 config,
26116 empty,
26117 hasInitiallyLoaded,
26118 onReset,
26119 intersectionObserver
26120 },
26121 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26122 DefaultUI,
26123 {
26124 header,
26125 search,
26126 searchLabel
26127 }
26128 ) })
26129 }
26130 );
26131 }
26132 var DataViewsSubComponents = DataViews;
26133 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26134 DataViewsSubComponents.Filters = filters_default;
26135 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26136 DataViewsSubComponents.FiltersToggle = toggle_default;
26137 DataViewsSubComponents.Layout = DataViewsLayout;
26138 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26139 DataViewsSubComponents.Pagination = DataViewsPagination;
26140 DataViewsSubComponents.Search = dataviews_search_default;
26141 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26142 DataViewsSubComponents.Footer = DataViewsFooter;
26143 var dataviews_default = DataViewsSubComponents;
26144
26145 // widgets/news/components/news-list/news-list.tsx
26146 var import_date10 = __toESM(require_date());
26147 var import_element83 = __toESM(require_element());
26148 var import_html_entities = __toESM(require_html_entities());
26149 var import_i18n45 = __toESM(require_i18n());
26150
26151 // packages/style-runtime/src/index.ts
26152 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26153 function getRuntime14() {
26154 const globalScope = globalThis;
26155 if (globalScope.__wpStyleRuntime) {
26156 return globalScope.__wpStyleRuntime;
26157 }
26158 globalScope.__wpStyleRuntime = {
26159 documents: /* @__PURE__ */ new Map(),
26160 styles: /* @__PURE__ */ new Map(),
26161 injectedStyles: /* @__PURE__ */ new WeakMap()
26162 };
26163 if (typeof document !== "undefined") {
26164 registerDocument14(document);
26165 }
26166 return globalScope.__wpStyleRuntime;
26167 }
26168 function documentContainsStyleHash14(targetDocument, hash) {
26169 if (!targetDocument.head) {
26170 return false;
26171 }
26172 for (const style of targetDocument.head.querySelectorAll(
26173 `style[${STYLE_HASH_ATTRIBUTE14}]`
26174 )) {
26175 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26176 return true;
26177 }
26178 }
26179 return false;
26180 }
26181 function injectStyle14(targetDocument, hash, css) {
26182 if (!targetDocument.head) {
26183 return;
26184 }
26185 const runtime = getRuntime14();
26186 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26187 if (!injectedStyles) {
26188 injectedStyles = /* @__PURE__ */ new Set();
26189 runtime.injectedStyles.set(targetDocument, injectedStyles);
26190 }
26191 if (injectedStyles.has(hash)) {
26192 return;
26193 }
26194 if (documentContainsStyleHash14(targetDocument, hash)) {
26195 injectedStyles.add(hash);
26196 return;
26197 }
26198 const style = targetDocument.createElement("style");
26199 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26200 style.appendChild(targetDocument.createTextNode(css));
26201 targetDocument.head.appendChild(style);
26202 injectedStyles.add(hash);
26203 }
26204 function registerDocument14(targetDocument) {
26205 const runtime = getRuntime14();
26206 runtime.documents.set(
26207 targetDocument,
26208 (runtime.documents.get(targetDocument) ?? 0) + 1
26209 );
26210 for (const [hash, css] of runtime.styles) {
26211 injectStyle14(targetDocument, hash, css);
26212 }
26213 return () => {
26214 const count = runtime.documents.get(targetDocument);
26215 if (count === void 0) {
26216 return;
26217 }
26218 if (count <= 1) {
26219 runtime.documents.delete(targetDocument);
26220 return;
26221 }
26222 runtime.documents.set(targetDocument, count - 1);
26223 };
26224 }
26225 function registerStyle14(hash, css) {
26226 const runtime = getRuntime14();
26227 runtime.styles.set(hash, css);
26228 for (const targetDocument of runtime.documents.keys()) {
26229 injectStyle14(targetDocument, hash, css);
26230 }
26231 }
26232
26233 // widgets/news/components/news-list/news-list.module.css
26234 if (typeof process === "undefined" || true) {
26235 registerStyle14("9549c96cba", ".bdaa5dfae93273b5__root{flex:1;min-height:0;min-width:0;overflow:auto}._2861fc2db3e2384a__feedIcon{align-items:center;background-color:var(--wpds-color-background-track-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-md,4px);color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;height:100%;justify-content:center;width:100%}._0b17b846e53f552a__titleLink{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._33e124d0c35f629a__meta{color:var(--wpds-color-foreground-content-neutral-weak,#707070)}");
26236 }
26237 var news_list_default = { "root": "bdaa5dfae93273b5__root", "feedIcon": "_2861fc2db3e2384a__feedIcon", "titleLink": "_0b17b846e53f552a__titleLink", "meta": "_33e124d0c35f629a__meta" };
26238
26239 // widgets/news/components/news-list/news-list.tsx
26240 var import_jsx_runtime119 = __toESM(require_jsx_runtime());
26241 var NEWS_FEEDS = [
26242 {
26243 key: "news",
26244 label: (0, import_i18n45.__)("WordPress Blog"),
26245 siteUrl: (0, import_i18n45._x)("https://wordpress.org/news/", "News dashboard widget"),
26246 apiUrl: "https://wordpress.org/news/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26247 },
26248 {
26249 key: "planet",
26250 label: (0, import_i18n45.__)("Other WordPress News"),
26251 siteUrl: (0, import_i18n45._x)("https://planet.wordpress.org/", "News dashboard widget"),
26252 apiUrl: "https://planet.wordpress.org/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26253 }
26254 ];
26255 var DEFAULT_LAYOUTS2 = { list: {} };
26256 var INITIAL_VIEW = {
26257 type: "list",
26258 page: 1,
26259 perPage: 4,
26260 search: "",
26261 filters: [],
26262 fields: [],
26263 titleField: "title",
26264 descriptionField: "meta",
26265 mediaField: "feedIcon",
26266 showMedia: true,
26267 layout: { density: "compact" }
26268 };
26269 function FeedIcon({ item }) {
26270 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: news_list_default.feedIcon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Icon, { icon: item.feedKey === "news" ? wordpress_default : globe_default }) });
26271 }
26272 function NewsTitle({ item }) {
26273 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Link, { href: item.url, openInNewTab: true, className: news_list_default.titleLink, children: item.title });
26274 }
26275 function NewsMeta({ item }) {
26276 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(Text, { variant: "body-sm", className: news_list_default.meta, children: [
26277 item.feedLabel,
26278 " \xB7 ",
26279 (0, import_date10.dateI18n)((0, import_i18n45.__)("M j, Y g:i a"), item.date)
26280 ] });
26281 }
26282 var emptyState = /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Stack, { align: "center", justify: "center", style: { margin: "24px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(empty_state_exports.Root, { children: [
26283 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26284 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(empty_state_exports.Title, { children: (0, import_i18n45.__)("Quiet for now \u2014 the next headline is on its way.") })
26285 ] }) });
26286 function combineFeedPosts(newsFeeds) {
26287 return newsFeeds.flatMap(
26288 (feed) => feed.posts.map((post) => ({
26289 id: `${feed.key}-${post.id}`,
26290 feedKey: feed.key,
26291 feedLabel: feed.label,
26292 title: (0, import_html_entities.decodeEntities)(post.title.rendered),
26293 url: post.link,
26294 date: post.date
26295 }))
26296 ).sort(
26297 (a2, b2) => new Date(b2.date).getTime() - new Date(a2.date).getTime()
26298 );
26299 }
26300 function NewsList() {
26301 const [view, setView] = (0, import_element83.useState)(INITIAL_VIEW);
26302 const [newsFeeds, setNewsFeeds] = (0, import_element83.useState)([]);
26303 const [isLoading, setIsLoading] = (0, import_element83.useState)(true);
26304 (0, import_element83.useEffect)(() => {
26305 Promise.all(
26306 NEWS_FEEDS.map(async (feed) => {
26307 try {
26308 const posts = await fetch(feed.apiUrl).then(
26309 (r3) => r3.json()
26310 );
26311 return {
26312 key: feed.key,
26313 label: feed.label,
26314 siteUrl: feed.siteUrl,
26315 posts
26316 };
26317 } catch {
26318 return {
26319 key: feed.key,
26320 label: feed.label,
26321 siteUrl: feed.siteUrl,
26322 posts: []
26323 };
26324 }
26325 })
26326 ).then(setNewsFeeds).finally(() => setIsLoading(false));
26327 }, []);
26328 const items = (0, import_element83.useMemo)(() => combineFeedPosts(newsFeeds), [newsFeeds]);
26329 const fields = (0, import_element83.useMemo)(
26330 () => [
26331 {
26332 id: "title",
26333 label: (0, import_i18n45.__)("Title"),
26334 enableSorting: false,
26335 enableHiding: false,
26336 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsTitle, { item })
26337 },
26338 {
26339 id: "meta",
26340 label: (0, import_i18n45.__)("Source"),
26341 enableSorting: false,
26342 enableHiding: false,
26343 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsMeta, { item })
26344 },
26345 {
26346 id: "feedIcon",
26347 label: (0, import_i18n45.__)("Source"),
26348 enableSorting: false,
26349 enableHiding: false,
26350 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(FeedIcon, { item })
26351 }
26352 ],
26353 []
26354 );
26355 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: news_list_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26356 dataviews_default,
26357 {
26358 data: items,
26359 fields,
26360 view,
26361 onChangeView: setView,
26362 getItemId: (item) => item.id,
26363 isLoading,
26364 paginationInfo: {
26365 totalItems: items.length,
26366 totalPages: 1
26367 },
26368 defaultLayouts: DEFAULT_LAYOUTS2,
26369 empty: emptyState,
26370 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(dataviews_default.Layout, {})
26371 }
26372 ) });
26373 }
26374
26375 // widgets/news/render.module.css
26376 if (typeof process === "undefined" || true) {
26377 registerStyle14("316bb0f754", "._2ab2c8be44ad767d__footer{border-block-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding-block:var(--wpds-dimension-padding-lg,16px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}");
26378 }
26379 var render_default = { "footer": "_2ab2c8be44ad767d__footer" };
26380
26381 // widgets/news/render.tsx
26382 var import_jsx_runtime120 = __toESM(require_jsx_runtime());
26383 function WordPressNews() {
26384 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
26385 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(NewsList, {}),
26386 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: render_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26387 Link,
26388 {
26389 href: (0, import_i18n46._x)(
26390 "https://wordpress.org/news/all-posts/",
26391 "News dashboard widget"
26392 ),
26393 openInNewTab: true,
26394 children: (0, import_i18n46.__)("See all")
26395 }
26396 ) })
26397 ] });
26398 }
26399 export {
26400 WordPressNews as default
26401 };
26402 /*! Bundled license information:
26403
26404 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26405 (**
26406 * @license React
26407 * use-sync-external-store-shim.development.js
26408 *
26409 * Copyright (c) Meta Platforms, Inc. and affiliates.
26410 *
26411 * This source code is licensed under the MIT license found in the
26412 * LICENSE file in the root directory of this source tree.
26413 *)
26414
26415 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26416 (**
26417 * @license React
26418 * use-sync-external-store-shim/with-selector.development.js
26419 *
26420 * Copyright (c) Meta Platforms, Inc. and affiliates.
26421 *
26422 * This source code is licensed under the MIT license found in the
26423 * LICENSE file in the root directory of this source tree.
26424 *)
26425 */
26426