PluginProbe
Gutenberg / 23.6.2
Gutenberg v23.6.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / media-utils / index.js

index.js in Gutenberg 23.6.2, at build/scripts/media-utils/index.js

28,887 lines 1.0 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).mediaUtils = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/element
36 var require_element = __commonJS({
37 "package-external:@wordpress/element"(exports, module) {
38 module.exports = window.wp.element;
39 }
40 });
41
42 // package-external:@wordpress/i18n
43 var require_i18n = __commonJS({
44 "package-external:@wordpress/i18n"(exports, module) {
45 module.exports = window.wp.i18n;
46 }
47 });
48
49 // package-external:@wordpress/data
50 var require_data = __commonJS({
51 "package-external:@wordpress/data"(exports, module) {
52 module.exports = window.wp.data;
53 }
54 });
55
56 // package-external:@wordpress/core-data
57 var require_core_data = __commonJS({
58 "package-external:@wordpress/core-data"(exports, module) {
59 module.exports = window.wp.coreData;
60 }
61 });
62
63 // package-external:@wordpress/blob
64 var require_blob = __commonJS({
65 "package-external:@wordpress/blob"(exports, module) {
66 module.exports = window.wp.blob;
67 }
68 });
69
70 // package-external:@wordpress/api-fetch
71 var require_api_fetch = __commonJS({
72 "package-external:@wordpress/api-fetch"(exports, module) {
73 module.exports = window.wp.apiFetch;
74 }
75 });
76
77 // package-external:@wordpress/components
78 var require_components = __commonJS({
79 "package-external:@wordpress/components"(exports, module) {
80 module.exports = window.wp.components;
81 }
82 });
83
84 // package-external:@wordpress/primitives
85 var require_primitives = __commonJS({
86 "package-external:@wordpress/primitives"(exports, module) {
87 module.exports = window.wp.primitives;
88 }
89 });
90
91 // vendor-external:react/jsx-runtime
92 var require_jsx_runtime = __commonJS({
93 "vendor-external:react/jsx-runtime"(exports, module) {
94 module.exports = window.ReactJSXRuntime;
95 }
96 });
97
98 // package-external:@wordpress/compose
99 var require_compose = __commonJS({
100 "package-external:@wordpress/compose"(exports, module) {
101 module.exports = window.wp.compose;
102 }
103 });
104
105 // vendor-external:react
106 var require_react = __commonJS({
107 "vendor-external:react"(exports, module) {
108 module.exports = window.React;
109 }
110 });
111
112 // vendor-external:react-dom
113 var require_react_dom = __commonJS({
114 "vendor-external:react-dom"(exports, module) {
115 module.exports = window.ReactDOM;
116 }
117 });
118
119 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
120 var require_use_sync_external_store_shim_development = __commonJS({
121 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
122 "use strict";
123 (function() {
124 function is(x2, y2) {
125 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
126 }
127 function useSyncExternalStore$2(subscribe2, getSnapshot) {
128 didWarnOld18Alpha || void 0 === React49.startTransition || (didWarnOld18Alpha = true, console.error(
129 "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."
130 ));
131 var value = getSnapshot();
132 if (!didWarnUncachedGetSnapshot) {
133 var cachedValue = getSnapshot();
134 objectIs(value, cachedValue) || (console.error(
135 "The result of getSnapshot should be cached to avoid an infinite loop"
136 ), didWarnUncachedGetSnapshot = true);
137 }
138 cachedValue = useState43({
139 inst: { value, getSnapshot }
140 });
141 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
142 useLayoutEffect6(
143 function() {
144 inst.value = value;
145 inst.getSnapshot = getSnapshot;
146 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
147 },
148 [subscribe2, value, getSnapshot]
149 );
150 useEffect36(
151 function() {
152 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
153 return subscribe2(function() {
154 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
155 });
156 },
157 [subscribe2]
158 );
159 useDebugValue2(value);
160 return value;
161 }
162 function checkIfSnapshotChanged(inst) {
163 var latestGetSnapshot = inst.getSnapshot;
164 inst = inst.value;
165 try {
166 var nextValue = latestGetSnapshot();
167 return !objectIs(inst, nextValue);
168 } catch (error) {
169 return true;
170 }
171 }
172 function useSyncExternalStore$1(subscribe2, getSnapshot) {
173 return getSnapshot();
174 }
175 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
176 var React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState43 = React49.useState, useEffect36 = React49.useEffect, useLayoutEffect6 = 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;
177 exports.useSyncExternalStore = void 0 !== React49.useSyncExternalStore ? React49.useSyncExternalStore : shim;
178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
179 })();
180 }
181 });
182
183 // node_modules/use-sync-external-store/shim/index.js
184 var require_shim = __commonJS({
185 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
186 "use strict";
187 if (false) {
188 module.exports = null;
189 } else {
190 module.exports = require_use_sync_external_store_shim_development();
191 }
192 }
193 });
194
195 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
196 var require_with_selector_development = __commonJS({
197 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
198 "use strict";
199 (function() {
200 function is(x2, y2) {
201 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
202 }
203 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
204 var React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef51 = React49.useRef, useEffect36 = React49.useEffect, useMemo43 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
205 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
206 var instRef = useRef51(null);
207 if (null === instRef.current) {
208 var inst = { hasValue: false, value: null };
209 instRef.current = inst;
210 } else inst = instRef.current;
211 instRef = useMemo43(
212 function() {
213 function memoizedSelector(nextSnapshot) {
214 if (!hasMemo) {
215 hasMemo = true;
216 memoizedSnapshot = nextSnapshot;
217 nextSnapshot = selector2(nextSnapshot);
218 if (void 0 !== isEqual && inst.hasValue) {
219 var currentSelection = inst.value;
220 if (isEqual(currentSelection, nextSnapshot))
221 return memoizedSelection = currentSelection;
222 }
223 return memoizedSelection = nextSnapshot;
224 }
225 currentSelection = memoizedSelection;
226 if (objectIs(memoizedSnapshot, nextSnapshot))
227 return currentSelection;
228 var nextSelection = selector2(nextSnapshot);
229 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
230 return memoizedSnapshot = nextSnapshot, currentSelection;
231 memoizedSnapshot = nextSnapshot;
232 return memoizedSelection = nextSelection;
233 }
234 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
235 return [
236 function() {
237 return memoizedSelector(getSnapshot());
238 },
239 null === maybeGetServerSnapshot ? void 0 : function() {
240 return memoizedSelector(maybeGetServerSnapshot());
241 }
242 ];
243 },
244 [getSnapshot, getServerSnapshot, selector2, isEqual]
245 );
246 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
247 useEffect36(
248 function() {
249 inst.hasValue = true;
250 inst.value = value;
251 },
252 [value]
253 );
254 useDebugValue2(value);
255 return value;
256 };
257 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
258 })();
259 }
260 });
261
262 // node_modules/use-sync-external-store/shim/with-selector.js
263 var require_with_selector = __commonJS({
264 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
265 "use strict";
266 if (false) {
267 module.exports = null;
268 } else {
269 module.exports = require_with_selector_development();
270 }
271 }
272 });
273
274 // package-external:@wordpress/a11y
275 var require_a11y = __commonJS({
276 "package-external:@wordpress/a11y"(exports, module) {
277 module.exports = window.wp.a11y;
278 }
279 });
280
281 // package-external:@wordpress/theme
282 var require_theme = __commonJS({
283 "package-external:@wordpress/theme"(exports, module) {
284 module.exports = window.wp.theme;
285 }
286 });
287
288 // package-external:@wordpress/private-apis
289 var require_private_apis = __commonJS({
290 "package-external:@wordpress/private-apis"(exports, module) {
291 module.exports = window.wp.privateApis;
292 }
293 });
294
295 // package-external:@wordpress/keycodes
296 var require_keycodes = __commonJS({
297 "package-external:@wordpress/keycodes"(exports, module) {
298 module.exports = window.wp.keycodes;
299 }
300 });
301
302 // node_modules/remove-accents/index.js
303 var require_remove_accents = __commonJS({
304 "node_modules/remove-accents/index.js"(exports, module) {
305 var characterMap = {
306 "\xC0": "A",
307 "\xC1": "A",
308 "\xC2": "A",
309 "\xC3": "A",
310 "\xC4": "A",
311 "\xC5": "A",
312 "\u1EA4": "A",
313 "\u1EAE": "A",
314 "\u1EB2": "A",
315 "\u1EB4": "A",
316 "\u1EB6": "A",
317 "\xC6": "AE",
318 "\u1EA6": "A",
319 "\u1EB0": "A",
320 "\u0202": "A",
321 "\u1EA2": "A",
322 "\u1EA0": "A",
323 "\u1EA8": "A",
324 "\u1EAA": "A",
325 "\u1EAC": "A",
326 "\xC7": "C",
327 "\u1E08": "C",
328 "\xC8": "E",
329 "\xC9": "E",
330 "\xCA": "E",
331 "\xCB": "E",
332 "\u1EBE": "E",
333 "\u1E16": "E",
334 "\u1EC0": "E",
335 "\u1E14": "E",
336 "\u1E1C": "E",
337 "\u0206": "E",
338 "\u1EBA": "E",
339 "\u1EBC": "E",
340 "\u1EB8": "E",
341 "\u1EC2": "E",
342 "\u1EC4": "E",
343 "\u1EC6": "E",
344 "\xCC": "I",
345 "\xCD": "I",
346 "\xCE": "I",
347 "\xCF": "I",
348 "\u1E2E": "I",
349 "\u020A": "I",
350 "\u1EC8": "I",
351 "\u1ECA": "I",
352 "\xD0": "D",
353 "\xD1": "N",
354 "\xD2": "O",
355 "\xD3": "O",
356 "\xD4": "O",
357 "\xD5": "O",
358 "\xD6": "O",
359 "\xD8": "O",
360 "\u1ED0": "O",
361 "\u1E4C": "O",
362 "\u1E52": "O",
363 "\u020E": "O",
364 "\u1ECE": "O",
365 "\u1ECC": "O",
366 "\u1ED4": "O",
367 "\u1ED6": "O",
368 "\u1ED8": "O",
369 "\u1EDC": "O",
370 "\u1EDE": "O",
371 "\u1EE0": "O",
372 "\u1EDA": "O",
373 "\u1EE2": "O",
374 "\xD9": "U",
375 "\xDA": "U",
376 "\xDB": "U",
377 "\xDC": "U",
378 "\u1EE6": "U",
379 "\u1EE4": "U",
380 "\u1EEC": "U",
381 "\u1EEE": "U",
382 "\u1EF0": "U",
383 "\xDD": "Y",
384 "\xE0": "a",
385 "\xE1": "a",
386 "\xE2": "a",
387 "\xE3": "a",
388 "\xE4": "a",
389 "\xE5": "a",
390 "\u1EA5": "a",
391 "\u1EAF": "a",
392 "\u1EB3": "a",
393 "\u1EB5": "a",
394 "\u1EB7": "a",
395 "\xE6": "ae",
396 "\u1EA7": "a",
397 "\u1EB1": "a",
398 "\u0203": "a",
399 "\u1EA3": "a",
400 "\u1EA1": "a",
401 "\u1EA9": "a",
402 "\u1EAB": "a",
403 "\u1EAD": "a",
404 "\xE7": "c",
405 "\u1E09": "c",
406 "\xE8": "e",
407 "\xE9": "e",
408 "\xEA": "e",
409 "\xEB": "e",
410 "\u1EBF": "e",
411 "\u1E17": "e",
412 "\u1EC1": "e",
413 "\u1E15": "e",
414 "\u1E1D": "e",
415 "\u0207": "e",
416 "\u1EBB": "e",
417 "\u1EBD": "e",
418 "\u1EB9": "e",
419 "\u1EC3": "e",
420 "\u1EC5": "e",
421 "\u1EC7": "e",
422 "\xEC": "i",
423 "\xED": "i",
424 "\xEE": "i",
425 "\xEF": "i",
426 "\u1E2F": "i",
427 "\u020B": "i",
428 "\u1EC9": "i",
429 "\u1ECB": "i",
430 "\xF0": "d",
431 "\xF1": "n",
432 "\xF2": "o",
433 "\xF3": "o",
434 "\xF4": "o",
435 "\xF5": "o",
436 "\xF6": "o",
437 "\xF8": "o",
438 "\u1ED1": "o",
439 "\u1E4D": "o",
440 "\u1E53": "o",
441 "\u020F": "o",
442 "\u1ECF": "o",
443 "\u1ECD": "o",
444 "\u1ED5": "o",
445 "\u1ED7": "o",
446 "\u1ED9": "o",
447 "\u1EDD": "o",
448 "\u1EDF": "o",
449 "\u1EE1": "o",
450 "\u1EDB": "o",
451 "\u1EE3": "o",
452 "\xF9": "u",
453 "\xFA": "u",
454 "\xFB": "u",
455 "\xFC": "u",
456 "\u1EE7": "u",
457 "\u1EE5": "u",
458 "\u1EED": "u",
459 "\u1EEF": "u",
460 "\u1EF1": "u",
461 "\xFD": "y",
462 "\xFF": "y",
463 "\u0100": "A",
464 "\u0101": "a",
465 "\u0102": "A",
466 "\u0103": "a",
467 "\u0104": "A",
468 "\u0105": "a",
469 "\u0106": "C",
470 "\u0107": "c",
471 "\u0108": "C",
472 "\u0109": "c",
473 "\u010A": "C",
474 "\u010B": "c",
475 "\u010C": "C",
476 "\u010D": "c",
477 "C\u0306": "C",
478 "c\u0306": "c",
479 "\u010E": "D",
480 "\u010F": "d",
481 "\u0110": "D",
482 "\u0111": "d",
483 "\u0112": "E",
484 "\u0113": "e",
485 "\u0114": "E",
486 "\u0115": "e",
487 "\u0116": "E",
488 "\u0117": "e",
489 "\u0118": "E",
490 "\u0119": "e",
491 "\u011A": "E",
492 "\u011B": "e",
493 "\u011C": "G",
494 "\u01F4": "G",
495 "\u011D": "g",
496 "\u01F5": "g",
497 "\u011E": "G",
498 "\u011F": "g",
499 "\u0120": "G",
500 "\u0121": "g",
501 "\u0122": "G",
502 "\u0123": "g",
503 "\u0124": "H",
504 "\u0125": "h",
505 "\u0126": "H",
506 "\u0127": "h",
507 "\u1E2A": "H",
508 "\u1E2B": "h",
509 "\u0128": "I",
510 "\u0129": "i",
511 "\u012A": "I",
512 "\u012B": "i",
513 "\u012C": "I",
514 "\u012D": "i",
515 "\u012E": "I",
516 "\u012F": "i",
517 "\u0130": "I",
518 "\u0131": "i",
519 "\u0132": "IJ",
520 "\u0133": "ij",
521 "\u0134": "J",
522 "\u0135": "j",
523 "\u0136": "K",
524 "\u0137": "k",
525 "\u1E30": "K",
526 "\u1E31": "k",
527 "K\u0306": "K",
528 "k\u0306": "k",
529 "\u0139": "L",
530 "\u013A": "l",
531 "\u013B": "L",
532 "\u013C": "l",
533 "\u013D": "L",
534 "\u013E": "l",
535 "\u013F": "L",
536 "\u0140": "l",
537 "\u0141": "l",
538 "\u0142": "l",
539 "\u1E3E": "M",
540 "\u1E3F": "m",
541 "M\u0306": "M",
542 "m\u0306": "m",
543 "\u0143": "N",
544 "\u0144": "n",
545 "\u0145": "N",
546 "\u0146": "n",
547 "\u0147": "N",
548 "\u0148": "n",
549 "\u0149": "n",
550 "N\u0306": "N",
551 "n\u0306": "n",
552 "\u014C": "O",
553 "\u014D": "o",
554 "\u014E": "O",
555 "\u014F": "o",
556 "\u0150": "O",
557 "\u0151": "o",
558 "\u0152": "OE",
559 "\u0153": "oe",
560 "P\u0306": "P",
561 "p\u0306": "p",
562 "\u0154": "R",
563 "\u0155": "r",
564 "\u0156": "R",
565 "\u0157": "r",
566 "\u0158": "R",
567 "\u0159": "r",
568 "R\u0306": "R",
569 "r\u0306": "r",
570 "\u0212": "R",
571 "\u0213": "r",
572 "\u015A": "S",
573 "\u015B": "s",
574 "\u015C": "S",
575 "\u015D": "s",
576 "\u015E": "S",
577 "\u0218": "S",
578 "\u0219": "s",
579 "\u015F": "s",
580 "\u0160": "S",
581 "\u0161": "s",
582 "\u0162": "T",
583 "\u0163": "t",
584 "\u021B": "t",
585 "\u021A": "T",
586 "\u0164": "T",
587 "\u0165": "t",
588 "\u0166": "T",
589 "\u0167": "t",
590 "T\u0306": "T",
591 "t\u0306": "t",
592 "\u0168": "U",
593 "\u0169": "u",
594 "\u016A": "U",
595 "\u016B": "u",
596 "\u016C": "U",
597 "\u016D": "u",
598 "\u016E": "U",
599 "\u016F": "u",
600 "\u0170": "U",
601 "\u0171": "u",
602 "\u0172": "U",
603 "\u0173": "u",
604 "\u0216": "U",
605 "\u0217": "u",
606 "V\u0306": "V",
607 "v\u0306": "v",
608 "\u0174": "W",
609 "\u0175": "w",
610 "\u1E82": "W",
611 "\u1E83": "w",
612 "X\u0306": "X",
613 "x\u0306": "x",
614 "\u0176": "Y",
615 "\u0177": "y",
616 "\u0178": "Y",
617 "Y\u0306": "Y",
618 "y\u0306": "y",
619 "\u0179": "Z",
620 "\u017A": "z",
621 "\u017B": "Z",
622 "\u017C": "z",
623 "\u017D": "Z",
624 "\u017E": "z",
625 "\u017F": "s",
626 "\u0192": "f",
627 "\u01A0": "O",
628 "\u01A1": "o",
629 "\u01AF": "U",
630 "\u01B0": "u",
631 "\u01CD": "A",
632 "\u01CE": "a",
633 "\u01CF": "I",
634 "\u01D0": "i",
635 "\u01D1": "O",
636 "\u01D2": "o",
637 "\u01D3": "U",
638 "\u01D4": "u",
639 "\u01D5": "U",
640 "\u01D6": "u",
641 "\u01D7": "U",
642 "\u01D8": "u",
643 "\u01D9": "U",
644 "\u01DA": "u",
645 "\u01DB": "U",
646 "\u01DC": "u",
647 "\u1EE8": "U",
648 "\u1EE9": "u",
649 "\u1E78": "U",
650 "\u1E79": "u",
651 "\u01FA": "A",
652 "\u01FB": "a",
653 "\u01FC": "AE",
654 "\u01FD": "ae",
655 "\u01FE": "O",
656 "\u01FF": "o",
657 "\xDE": "TH",
658 "\xFE": "th",
659 "\u1E54": "P",
660 "\u1E55": "p",
661 "\u1E64": "S",
662 "\u1E65": "s",
663 "X\u0301": "X",
664 "x\u0301": "x",
665 "\u0403": "\u0413",
666 "\u0453": "\u0433",
667 "\u040C": "\u041A",
668 "\u045C": "\u043A",
669 "A\u030B": "A",
670 "a\u030B": "a",
671 "E\u030B": "E",
672 "e\u030B": "e",
673 "I\u030B": "I",
674 "i\u030B": "i",
675 "\u01F8": "N",
676 "\u01F9": "n",
677 "\u1ED2": "O",
678 "\u1ED3": "o",
679 "\u1E50": "O",
680 "\u1E51": "o",
681 "\u1EEA": "U",
682 "\u1EEB": "u",
683 "\u1E80": "W",
684 "\u1E81": "w",
685 "\u1EF2": "Y",
686 "\u1EF3": "y",
687 "\u0200": "A",
688 "\u0201": "a",
689 "\u0204": "E",
690 "\u0205": "e",
691 "\u0208": "I",
692 "\u0209": "i",
693 "\u020C": "O",
694 "\u020D": "o",
695 "\u0210": "R",
696 "\u0211": "r",
697 "\u0214": "U",
698 "\u0215": "u",
699 "B\u030C": "B",
700 "b\u030C": "b",
701 "\u010C\u0323": "C",
702 "\u010D\u0323": "c",
703 "\xCA\u030C": "E",
704 "\xEA\u030C": "e",
705 "F\u030C": "F",
706 "f\u030C": "f",
707 "\u01E6": "G",
708 "\u01E7": "g",
709 "\u021E": "H",
710 "\u021F": "h",
711 "J\u030C": "J",
712 "\u01F0": "j",
713 "\u01E8": "K",
714 "\u01E9": "k",
715 "M\u030C": "M",
716 "m\u030C": "m",
717 "P\u030C": "P",
718 "p\u030C": "p",
719 "Q\u030C": "Q",
720 "q\u030C": "q",
721 "\u0158\u0329": "R",
722 "\u0159\u0329": "r",
723 "\u1E66": "S",
724 "\u1E67": "s",
725 "V\u030C": "V",
726 "v\u030C": "v",
727 "W\u030C": "W",
728 "w\u030C": "w",
729 "X\u030C": "X",
730 "x\u030C": "x",
731 "Y\u030C": "Y",
732 "y\u030C": "y",
733 "A\u0327": "A",
734 "a\u0327": "a",
735 "B\u0327": "B",
736 "b\u0327": "b",
737 "\u1E10": "D",
738 "\u1E11": "d",
739 "\u0228": "E",
740 "\u0229": "e",
741 "\u0190\u0327": "E",
742 "\u025B\u0327": "e",
743 "\u1E28": "H",
744 "\u1E29": "h",
745 "I\u0327": "I",
746 "i\u0327": "i",
747 "\u0197\u0327": "I",
748 "\u0268\u0327": "i",
749 "M\u0327": "M",
750 "m\u0327": "m",
751 "O\u0327": "O",
752 "o\u0327": "o",
753 "Q\u0327": "Q",
754 "q\u0327": "q",
755 "U\u0327": "U",
756 "u\u0327": "u",
757 "X\u0327": "X",
758 "x\u0327": "x",
759 "Z\u0327": "Z",
760 "z\u0327": "z",
761 "\u0439": "\u0438",
762 "\u0419": "\u0418",
763 "\u0451": "\u0435",
764 "\u0401": "\u0415"
765 };
766 var chars = Object.keys(characterMap).join("|");
767 var allAccents = new RegExp(chars, "g");
768 var firstAccent = new RegExp(chars, "");
769 function matcher(match2) {
770 return characterMap[match2];
771 }
772 var removeAccents2 = function(string) {
773 return string.replace(allAccents, matcher);
774 };
775 var hasAccents = function(string) {
776 return !!string.match(firstAccent);
777 };
778 module.exports = removeAccents2;
779 module.exports.has = hasAccents;
780 module.exports.remove = removeAccents2;
781 }
782 });
783
784 // node_modules/fast-deep-equal/es6/index.js
785 var require_es6 = __commonJS({
786 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
787 "use strict";
788 module.exports = function equal(a2, b2) {
789 if (a2 === b2) return true;
790 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
791 if (a2.constructor !== b2.constructor) return false;
792 var length, i2, keys;
793 if (Array.isArray(a2)) {
794 length = a2.length;
795 if (length != b2.length) return false;
796 for (i2 = length; i2-- !== 0; )
797 if (!equal(a2[i2], b2[i2])) return false;
798 return true;
799 }
800 if (a2 instanceof Map && b2 instanceof Map) {
801 if (a2.size !== b2.size) return false;
802 for (i2 of a2.entries())
803 if (!b2.has(i2[0])) return false;
804 for (i2 of a2.entries())
805 if (!equal(i2[1], b2.get(i2[0]))) return false;
806 return true;
807 }
808 if (a2 instanceof Set && b2 instanceof Set) {
809 if (a2.size !== b2.size) return false;
810 for (i2 of a2.entries())
811 if (!b2.has(i2[0])) return false;
812 return true;
813 }
814 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
815 length = a2.length;
816 if (length != b2.length) return false;
817 for (i2 = length; i2-- !== 0; )
818 if (a2[i2] !== b2[i2]) return false;
819 return true;
820 }
821 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
822 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
823 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
824 keys = Object.keys(a2);
825 length = keys.length;
826 if (length !== Object.keys(b2).length) return false;
827 for (i2 = length; i2-- !== 0; )
828 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
829 for (i2 = length; i2-- !== 0; ) {
830 var key = keys[i2];
831 if (!equal(a2[key], b2[key])) return false;
832 }
833 return true;
834 }
835 return a2 !== a2 && b2 !== b2;
836 };
837 }
838 });
839
840 // package-external:@wordpress/date
841 var require_date = __commonJS({
842 "package-external:@wordpress/date"(exports, module) {
843 module.exports = window.wp.date;
844 }
845 });
846
847 // package-external:@wordpress/warning
848 var require_warning = __commonJS({
849 "package-external:@wordpress/warning"(exports, module) {
850 module.exports = window.wp.warning;
851 }
852 });
853
854 // package-external:@wordpress/rich-text
855 var require_rich_text = __commonJS({
856 "package-external:@wordpress/rich-text"(exports, module) {
857 module.exports = window.wp.richText;
858 }
859 });
860
861 // package-external:@wordpress/preferences
862 var require_preferences = __commonJS({
863 "package-external:@wordpress/preferences"(exports, module) {
864 module.exports = window.wp.preferences;
865 }
866 });
867
868 // package-external:@wordpress/url
869 var require_url = __commonJS({
870 "package-external:@wordpress/url"(exports, module) {
871 module.exports = window.wp.url;
872 }
873 });
874
875 // package-external:@wordpress/notices
876 var require_notices = __commonJS({
877 "package-external:@wordpress/notices"(exports, module) {
878 module.exports = window.wp.notices;
879 }
880 });
881
882 // packages/media-utils/build-module/index.mjs
883 var index_exports = {};
884 __export(index_exports, {
885 MediaUpload: () => media_upload_default,
886 privateApis: () => privateApis12,
887 transformAttachment: () => transformAttachment,
888 uploadMedia: () => uploadMedia,
889 validateFileSize: () => validateFileSize,
890 validateMimeType: () => validateMimeType,
891 validateMimeTypeForUser: () => validateMimeTypeForUser
892 });
893
894 // packages/media-utils/build-module/components/media-upload/index.mjs
895 var import_element = __toESM(require_element(), 1);
896 var import_i18n = __toESM(require_i18n(), 1);
897 var import_data = __toESM(require_data(), 1);
898
899 // packages/media-utils/build-module/utils/invalidate-attachment-resolutions.mjs
900 var import_core_data = __toESM(require_core_data(), 1);
901 function invalidateAttachmentResolutions(registry) {
902 const resolvers = registry.select(import_core_data.store).getCachedResolvers();
903 const entityRecordResolutions = resolvers.getEntityRecords;
904 entityRecordResolutions?.forEach((_value, args) => {
905 if (args[0] === "postType" && args[1] === "attachment") {
906 registry.dispatch(import_core_data.store).invalidateResolution("getEntityRecords", args);
907 }
908 });
909 }
910
911 // packages/media-utils/build-module/components/media-upload/index.mjs
912 var DEFAULT_EMPTY_GALLERY = [];
913 var getFeaturedImageMediaFrame = () => {
914 const { wp } = window;
915 return wp.media.view.MediaFrame.Select.extend({
916 /**
917 * Enables the Set Featured Image Button.
918 *
919 * @param {Object} toolbar toolbar for featured image state
920 * @return {void}
921 */
922 featuredImageToolbar(toolbar) {
923 this.createSelectToolbar(toolbar, {
924 text: wp.media.view.l10n.setFeaturedImage,
925 state: this.options.state
926 });
927 },
928 /**
929 * Handle the edit state requirements of selected media item.
930 *
931 * @return {void}
932 */
933 editState() {
934 const selection = this.state("featured-image").get("selection");
935 const view = new wp.media.view.EditImage({
936 model: selection.single(),
937 controller: this
938 }).render();
939 this.content.set(view);
940 view.loadEditor();
941 },
942 /**
943 * Create the default states.
944 *
945 * @return {void}
946 */
947 createStates: function createStates() {
948 this.on(
949 "toolbar:create:featured-image",
950 this.featuredImageToolbar,
951 this
952 );
953 this.on("content:render:edit-image", this.editState, this);
954 this.states.add([
955 new wp.media.controller.FeaturedImage(),
956 new wp.media.controller.EditImage({
957 model: this.options.editImage
958 })
959 ]);
960 }
961 });
962 };
963 var getSingleMediaFrame = () => {
964 const { wp } = window;
965 return wp.media.view.MediaFrame.Select.extend({
966 /**
967 * Create the default states on the frame.
968 */
969 createStates() {
970 const options = this.options;
971 if (this.options.states) {
972 return;
973 }
974 this.states.add([
975 // Main states.
976 new wp.media.controller.Library({
977 library: wp.media.query(options.library),
978 multiple: options.multiple,
979 title: options.title,
980 priority: 20,
981 filterable: "uploaded"
982 // Allow filtering by uploaded images.
983 }),
984 new wp.media.controller.EditImage({
985 model: options.editImage
986 })
987 ]);
988 }
989 });
990 };
991 var getGalleryDetailsMediaFrame = () => {
992 const { wp } = window;
993 return wp.media.view.MediaFrame.Post.extend({
994 /**
995 * Set up gallery toolbar.
996 *
997 * @return {void}
998 */
999 galleryToolbar() {
1000 const editing = this.state().get("editing");
1001 this.toolbar.set(
1002 new wp.media.view.Toolbar({
1003 controller: this,
1004 items: {
1005 insert: {
1006 style: "primary",
1007 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
1008 priority: 80,
1009 requires: { library: true },
1010 /**
1011 * @fires wp.media.controller.State#update
1012 */
1013 click() {
1014 const controller = this.controller, state = controller.state();
1015 controller.close();
1016 state.trigger(
1017 "update",
1018 state.get("library")
1019 );
1020 controller.setState(controller.options.state);
1021 controller.reset();
1022 }
1023 }
1024 }
1025 })
1026 );
1027 },
1028 /**
1029 * Handle the edit state requirements of selected media item.
1030 *
1031 * @return {void}
1032 */
1033 editState() {
1034 const selection = this.state("gallery").get("selection");
1035 const view = new wp.media.view.EditImage({
1036 model: selection.single(),
1037 controller: this
1038 }).render();
1039 this.content.set(view);
1040 view.loadEditor();
1041 },
1042 /**
1043 * Create the default states.
1044 *
1045 * @return {void}
1046 */
1047 createStates: function createStates() {
1048 this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
1049 this.on("content:render:edit-image", this.editState, this);
1050 this.states.add([
1051 new wp.media.controller.Library({
1052 id: "gallery",
1053 title: wp.media.view.l10n.createGalleryTitle,
1054 priority: 40,
1055 toolbar: "main-gallery",
1056 filterable: "uploaded",
1057 multiple: "add",
1058 editable: false,
1059 library: wp.media.query({
1060 type: "image",
1061 ...this.options.library
1062 })
1063 }),
1064 new wp.media.controller.EditImage({
1065 model: this.options.editImage
1066 }),
1067 new wp.media.controller.GalleryEdit({
1068 library: this.options.selection,
1069 editing: this.options.editing,
1070 menu: "gallery",
1071 displaySettings: false,
1072 multiple: true
1073 }),
1074 new wp.media.controller.GalleryAdd()
1075 ]);
1076 }
1077 });
1078 };
1079 var slimImageObject = (img) => {
1080 const attrSet = [
1081 "sizes",
1082 "mime",
1083 "type",
1084 "subtype",
1085 "id",
1086 "url",
1087 "alt",
1088 "link",
1089 "caption"
1090 ];
1091 return attrSet.reduce((result, key) => {
1092 if (img?.hasOwnProperty(key)) {
1093 result[key] = img[key];
1094 }
1095 return result;
1096 }, {});
1097 };
1098 var getAttachmentsCollection = (ids) => {
1099 const { wp } = window;
1100 return wp.media.query({
1101 order: "ASC",
1102 orderby: "post__in",
1103 post__in: ids,
1104 posts_per_page: -1,
1105 query: true,
1106 type: "image"
1107 });
1108 };
1109 var MediaUpload = class extends import_element.Component {
1110 constructor() {
1111 super(...arguments);
1112 this.openModal = this.openModal.bind(this);
1113 this.onOpen = this.onOpen.bind(this);
1114 this.onSelect = this.onSelect.bind(this);
1115 this.onUpdate = this.onUpdate.bind(this);
1116 this.onClose = this.onClose.bind(this);
1117 }
1118 initializeListeners() {
1119 this.frame.on("select", this.onSelect);
1120 this.frame.on("update", this.onUpdate);
1121 this.frame.on("open", this.onOpen);
1122 this.frame.on("close", this.onClose);
1123 }
1124 /**
1125 * Sets the Gallery frame and initializes listeners.
1126 *
1127 * @return {void}
1128 */
1129 buildAndSetGalleryFrame() {
1130 const {
1131 addToGallery = false,
1132 allowedTypes,
1133 multiple = false,
1134 value = DEFAULT_EMPTY_GALLERY
1135 } = this.props;
1136 if (value === this.lastGalleryValue) {
1137 return;
1138 }
1139 const { wp } = window;
1140 this.lastGalleryValue = value;
1141 if (this.frame) {
1142 this.frame.remove();
1143 }
1144 let currentState;
1145 if (addToGallery) {
1146 currentState = "gallery-library";
1147 } else {
1148 currentState = value && value.length ? "gallery-edit" : "gallery";
1149 }
1150 if (!this.GalleryDetailsMediaFrame) {
1151 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1152 }
1153 const attachments = getAttachmentsCollection(value);
1154 const selection = new wp.media.model.Selection(attachments.models, {
1155 props: attachments.props.toJSON(),
1156 multiple
1157 });
1158 this.frame = new this.GalleryDetailsMediaFrame({
1159 mimeType: allowedTypes,
1160 state: currentState,
1161 multiple,
1162 selection,
1163 editing: !!value?.length
1164 });
1165 wp.media.frame = this.frame;
1166 this.initializeListeners();
1167 }
1168 /**
1169 * Initializes the Media Library requirements for the featured image flow.
1170 *
1171 * @return {void}
1172 */
1173 buildAndSetFeatureImageFrame() {
1174 const { wp } = window;
1175 const { value: featuredImageId, multiple, allowedTypes } = this.props;
1176 const featuredImageFrame = getFeaturedImageMediaFrame();
1177 const attachments = getAttachmentsCollection(featuredImageId);
1178 const selection = new wp.media.model.Selection(attachments.models, {
1179 props: attachments.props.toJSON()
1180 });
1181 this.frame = new featuredImageFrame({
1182 mimeType: allowedTypes,
1183 state: "featured-image",
1184 multiple,
1185 selection,
1186 editing: featuredImageId
1187 });
1188 wp.media.frame = this.frame;
1189 wp.media.view.settings.post = {
1190 ...wp.media.view.settings.post,
1191 featuredImageId: featuredImageId || -1
1192 };
1193 }
1194 /**
1195 * Initializes the Media Library requirements for the single image flow.
1196 *
1197 * @return {void}
1198 */
1199 buildAndSetSingleMediaFrame() {
1200 const { wp } = window;
1201 const {
1202 allowedTypes,
1203 multiple = false,
1204 title = (0, import_i18n.__)("Select or Upload Media"),
1205 value
1206 } = this.props;
1207 const frameConfig = {
1208 title,
1209 multiple
1210 };
1211 if (!!allowedTypes) {
1212 frameConfig.library = { type: allowedTypes };
1213 }
1214 if (this.frame) {
1215 this.frame.remove();
1216 }
1217 const singleImageFrame = getSingleMediaFrame();
1218 const attachments = getAttachmentsCollection(value);
1219 const selection = new wp.media.model.Selection(attachments.models, {
1220 props: attachments.props.toJSON()
1221 });
1222 this.frame = new singleImageFrame({
1223 mimeType: allowedTypes,
1224 multiple,
1225 selection,
1226 ...frameConfig
1227 });
1228 wp.media.frame = this.frame;
1229 }
1230 componentWillUnmount() {
1231 this.frame?.remove();
1232 }
1233 onUpdate(selections) {
1234 const { onSelect, multiple = false } = this.props;
1235 const state = this.frame.state();
1236 const selectedImages = selections || state.get("selection");
1237 if (!selectedImages || !selectedImages.models.length) {
1238 return;
1239 }
1240 if (multiple) {
1241 onSelect(
1242 selectedImages.models.map(
1243 (model) => slimImageObject(model.toJSON())
1244 )
1245 );
1246 } else {
1247 onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1248 }
1249 }
1250 onSelect() {
1251 const { onSelect, multiple = false } = this.props;
1252 const attachment = this.frame.state().get("selection").toJSON();
1253 onSelect(multiple ? attachment : attachment[0]);
1254 }
1255 onOpen() {
1256 const { wp } = window;
1257 const { value } = this.props;
1258 this.updateCollection();
1259 if (this.props.mode) {
1260 this.frame.content.mode(this.props.mode);
1261 }
1262 const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1263 if (!hasMedia) {
1264 return;
1265 }
1266 const isGallery = this.props.gallery;
1267 const selection = this.frame.state().get("selection");
1268 const valueArray = Array.isArray(value) ? value : [value];
1269 if (!isGallery) {
1270 valueArray.forEach((id) => {
1271 selection.add(wp.media.attachment(id));
1272 });
1273 }
1274 const attachments = getAttachmentsCollection(valueArray);
1275 attachments.more().done(function() {
1276 if (isGallery && attachments?.models?.length) {
1277 selection.add(attachments.models);
1278 }
1279 });
1280 }
1281 onClose() {
1282 const { onClose } = this.props;
1283 if (onClose) {
1284 onClose();
1285 }
1286 invalidateAttachmentResolutions({ select: import_data.select, dispatch: import_data.dispatch });
1287 this.frame.detach();
1288 }
1289 updateCollection() {
1290 const frameContent = this.frame.content.get();
1291 if (frameContent && frameContent.collection) {
1292 const collection = frameContent.collection;
1293 collection.toArray().forEach((model) => model.trigger("destroy", model));
1294 collection.mirroring._hasMore = true;
1295 collection.more();
1296 }
1297 }
1298 openModal() {
1299 const {
1300 gallery = false,
1301 unstableFeaturedImageFlow = false,
1302 modalClass
1303 } = this.props;
1304 if (gallery) {
1305 this.buildAndSetGalleryFrame();
1306 } else {
1307 this.buildAndSetSingleMediaFrame();
1308 }
1309 if (modalClass) {
1310 this.frame.$el.addClass(modalClass);
1311 }
1312 if (unstableFeaturedImageFlow) {
1313 this.buildAndSetFeatureImageFrame();
1314 }
1315 this.initializeListeners();
1316 this.frame.open();
1317 }
1318 render() {
1319 return this.props.render({ open: this.openModal });
1320 }
1321 };
1322 var media_upload_default = MediaUpload;
1323
1324 // packages/media-utils/build-module/utils/upload-media.mjs
1325 var import_i18n5 = __toESM(require_i18n(), 1);
1326 var import_blob = __toESM(require_blob(), 1);
1327
1328 // packages/media-utils/build-module/utils/upload-to-server.mjs
1329 var import_api_fetch = __toESM(require_api_fetch(), 1);
1330
1331 // packages/media-utils/build-module/utils/flatten-form-data.mjs
1332 function isPlainObject(data) {
1333 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1334 }
1335 function flattenFormData(formData, key, data) {
1336 if (isPlainObject(data)) {
1337 for (const [name, value] of Object.entries(data)) {
1338 flattenFormData(formData, `${key}[${name}]`, value);
1339 }
1340 } else if (data !== void 0) {
1341 formData.append(key, String(data));
1342 }
1343 }
1344
1345 // packages/media-utils/build-module/utils/transform-attachment.mjs
1346 function transformAttachment(attachment) {
1347 const { alt_text, source_url, ...savedMediaProps } = attachment;
1348 return {
1349 ...savedMediaProps,
1350 alt: attachment.alt_text,
1351 caption: attachment.caption?.raw ?? "",
1352 title: attachment.title.raw,
1353 url: attachment.source_url,
1354 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1355 };
1356 }
1357
1358 // packages/media-utils/build-module/utils/upload-to-server.mjs
1359 async function uploadToServer(file, additionalData = {}, signal) {
1360 const data = new FormData();
1361 data.append("file", file, file.name || file.type.replace("/", "."));
1362 for (const [key, value] of Object.entries(additionalData)) {
1363 flattenFormData(
1364 data,
1365 key,
1366 value
1367 );
1368 }
1369 return transformAttachment(
1370 await (0, import_api_fetch.default)({
1371 // This allows the video block to directly get a video's poster image.
1372 path: "/wp/v2/media?_embed=wp:featuredmedia",
1373 body: data,
1374 method: "POST",
1375 signal
1376 })
1377 );
1378 }
1379
1380 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1381 var import_i18n2 = __toESM(require_i18n(), 1);
1382
1383 // packages/media-utils/build-module/utils/upload-error.mjs
1384 var UploadError = class extends Error {
1385 code;
1386 file;
1387 constructor({ code, message: message2, file, cause }) {
1388 super(message2, { cause });
1389 Object.setPrototypeOf(this, new.target.prototype);
1390 this.code = code;
1391 this.file = file;
1392 }
1393 };
1394
1395 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1396 function validateMimeType(file, allowedTypes) {
1397 if (!allowedTypes || allowedTypes.includes("*")) {
1398 return;
1399 }
1400 const isAllowedType = allowedTypes.some((allowedType) => {
1401 if (allowedType.includes("/")) {
1402 return allowedType === file.type;
1403 }
1404 return file.type.startsWith(`${allowedType}/`);
1405 });
1406 if (file.type && !isAllowedType) {
1407 throw new UploadError({
1408 code: "MIME_TYPE_NOT_SUPPORTED",
1409 message: (0, import_i18n2.sprintf)(
1410 // translators: %s: file name.
1411 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1412 file.name
1413 ),
1414 file
1415 });
1416 }
1417 }
1418
1419 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1420 var import_i18n3 = __toESM(require_i18n(), 1);
1421
1422 // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1423 function getMimeTypesArray(wpMimeTypesObject) {
1424 if (!wpMimeTypesObject) {
1425 return null;
1426 }
1427 return Object.entries(wpMimeTypesObject).flatMap(
1428 ([extensionsString, mime]) => {
1429 const [type] = mime.split("/");
1430 const extensions = extensionsString.split("|");
1431 return [
1432 mime,
1433 ...extensions.map(
1434 (extension) => `${type}/${extension}`
1435 )
1436 ];
1437 }
1438 );
1439 }
1440
1441 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1442 function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1443 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1444 if (!allowedMimeTypesForUser) {
1445 return;
1446 }
1447 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1448 file.type
1449 );
1450 if (file.type && !isAllowedMimeTypeForUser) {
1451 throw new UploadError({
1452 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1453 message: (0, import_i18n3.sprintf)(
1454 // translators: %s: file name.
1455 (0, import_i18n3.__)(
1456 "%s: Sorry, you are not allowed to upload this file type."
1457 ),
1458 file.name
1459 ),
1460 file
1461 });
1462 }
1463 }
1464
1465 // packages/media-utils/build-module/utils/validate-file-size.mjs
1466 var import_i18n4 = __toESM(require_i18n(), 1);
1467 function validateFileSize(file, maxUploadFileSize) {
1468 if (file.size <= 0) {
1469 throw new UploadError({
1470 code: "EMPTY_FILE",
1471 message: (0, import_i18n4.sprintf)(
1472 // translators: %s: file name.
1473 (0, import_i18n4.__)("%s: This file is empty."),
1474 file.name
1475 ),
1476 file
1477 });
1478 }
1479 if (maxUploadFileSize && file.size > maxUploadFileSize) {
1480 throw new UploadError({
1481 code: "SIZE_ABOVE_LIMIT",
1482 message: (0, import_i18n4.sprintf)(
1483 // translators: %s: file name.
1484 (0, import_i18n4.__)(
1485 "%s: This file exceeds the maximum upload size for this site."
1486 ),
1487 file.name
1488 ),
1489 file
1490 });
1491 }
1492 }
1493
1494 // packages/media-utils/build-module/utils/upload-media.mjs
1495 function uploadMedia({
1496 wpAllowedMimeTypes,
1497 allowedTypes,
1498 additionalData = {},
1499 filesList,
1500 maxUploadFileSize,
1501 onError,
1502 onFileChange,
1503 signal,
1504 multiple = true
1505 }) {
1506 if (!multiple && filesList.length > 1) {
1507 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1508 return;
1509 }
1510 const validFiles = [];
1511 const filesSet = [];
1512 const setAndUpdateFiles = (index2, value) => {
1513 if (!window.__clientSideMediaProcessing) {
1514 if (filesSet[index2]?.url) {
1515 (0, import_blob.revokeBlobURL)(filesSet[index2].url);
1516 }
1517 }
1518 filesSet[index2] = value;
1519 onFileChange?.(
1520 filesSet.filter((attachment) => attachment !== null)
1521 );
1522 };
1523 for (const mediaFile of filesList) {
1524 try {
1525 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1526 } catch (error) {
1527 onError?.(error);
1528 continue;
1529 }
1530 try {
1531 validateMimeType(mediaFile, allowedTypes);
1532 } catch (error) {
1533 onError?.(error);
1534 continue;
1535 }
1536 try {
1537 validateFileSize(mediaFile, maxUploadFileSize);
1538 } catch (error) {
1539 onError?.(error);
1540 continue;
1541 }
1542 validFiles.push(mediaFile);
1543 if (!window.__clientSideMediaProcessing) {
1544 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1545 onFileChange?.(filesSet);
1546 }
1547 }
1548 validFiles.map(async (file, index2) => {
1549 try {
1550 const attachment = await uploadToServer(
1551 file,
1552 additionalData,
1553 signal
1554 );
1555 setAndUpdateFiles(index2, attachment);
1556 } catch (error) {
1557 setAndUpdateFiles(index2, null);
1558 let message2;
1559 if (typeof error === "object" && error !== null && "message" in error) {
1560 message2 = typeof error.message === "string" ? error.message : String(error.message);
1561 } else {
1562 message2 = (0, import_i18n5.sprintf)(
1563 // translators: %s: file name
1564 (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1565 file.name
1566 );
1567 }
1568 onError?.(
1569 new UploadError({
1570 code: "GENERAL",
1571 message: message2,
1572 file,
1573 cause: error instanceof Error ? error : void 0
1574 })
1575 );
1576 }
1577 });
1578 }
1579
1580 // packages/media-utils/build-module/utils/sideload-media.mjs
1581 var import_i18n6 = __toESM(require_i18n(), 1);
1582
1583 // packages/media-utils/build-module/utils/sideload-to-server.mjs
1584 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1585 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1586 const data = new FormData();
1587 data.append("file", file, file.name || file.type.replace("/", "."));
1588 for (const [key, value] of Object.entries(additionalData)) {
1589 flattenFormData(
1590 data,
1591 key,
1592 value
1593 );
1594 }
1595 return (0, import_api_fetch2.default)({
1596 path: `/wp/v2/media/${attachmentId}/sideload`,
1597 body: data,
1598 method: "POST",
1599 signal
1600 });
1601 }
1602
1603 // packages/media-utils/build-module/utils/sideload-media.mjs
1604 var noop = () => {
1605 };
1606 async function sideloadMedia({
1607 file,
1608 attachmentId,
1609 additionalData = {},
1610 signal,
1611 onSuccess,
1612 onError = noop
1613 }) {
1614 try {
1615 const subSizeData = await sideloadToServer(
1616 file,
1617 attachmentId,
1618 additionalData,
1619 signal
1620 );
1621 onSuccess?.(subSizeData);
1622 } catch (error) {
1623 let message2;
1624 if (error instanceof Error) {
1625 message2 = error.message;
1626 } else {
1627 message2 = (0, import_i18n6.sprintf)(
1628 // translators: %s: file name
1629 (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1630 file.name
1631 );
1632 }
1633 onError(
1634 new UploadError({
1635 code: "GENERAL",
1636 message: message2,
1637 file,
1638 cause: error instanceof Error ? error : void 0
1639 })
1640 );
1641 }
1642 }
1643
1644 // node_modules/clsx/dist/clsx.mjs
1645 function r(e2) {
1646 var t2, f2, n2 = "";
1647 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1648 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1649 var o2 = e2.length;
1650 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1651 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1652 return n2;
1653 }
1654 function clsx() {
1655 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1656 return n2;
1657 }
1658 var clsx_default = clsx;
1659
1660 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1661 var import_element87 = __toESM(require_element(), 1);
1662 var import_i18n68 = __toESM(require_i18n(), 1);
1663 var import_core_data6 = __toESM(require_core_data(), 1);
1664 var import_data14 = __toESM(require_data(), 1);
1665 var import_components54 = __toESM(require_components(), 1);
1666
1667 // packages/icons/build-module/library/arrow-down.mjs
1668 var import_primitives = __toESM(require_primitives(), 1);
1669 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1670 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
1671
1672 // packages/icons/build-module/library/arrow-left.mjs
1673 var import_primitives2 = __toESM(require_primitives(), 1);
1674 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1675 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
1676
1677 // packages/icons/build-module/library/arrow-right.mjs
1678 var import_primitives3 = __toESM(require_primitives(), 1);
1679 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1680 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
1681
1682 // packages/icons/build-module/library/arrow-up.mjs
1683 var import_primitives4 = __toESM(require_primitives(), 1);
1684 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1685 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
1686
1687 // packages/icons/build-module/library/audio.mjs
1688 var import_primitives5 = __toESM(require_primitives(), 1);
1689 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1690 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) });
1691
1692 // packages/icons/build-module/library/block-table.mjs
1693 var import_primitives6 = __toESM(require_primitives(), 1);
1694 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1695 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { 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" }) });
1696
1697 // packages/icons/build-module/library/category.mjs
1698 var import_primitives7 = __toESM(require_primitives(), 1);
1699 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1700 var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { 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" }) });
1701
1702 // packages/icons/build-module/library/check.mjs
1703 var import_primitives8 = __toESM(require_primitives(), 1);
1704 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1705 var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1706
1707 // packages/icons/build-module/library/chevron-down.mjs
1708 var import_primitives9 = __toESM(require_primitives(), 1);
1709 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1710 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
1711
1712 // packages/icons/build-module/library/close-small.mjs
1713 var import_primitives10 = __toESM(require_primitives(), 1);
1714 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1715 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "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" }) });
1716
1717 // packages/icons/build-module/library/cog.mjs
1718 var import_primitives11 = __toESM(require_primitives(), 1);
1719 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1720 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
1721
1722 // packages/icons/build-module/library/comment-author-avatar.mjs
1723 var import_primitives12 = __toESM(require_primitives(), 1);
1724 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1725 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) });
1726
1727 // packages/icons/build-module/library/envelope.mjs
1728 var import_primitives13 = __toESM(require_primitives(), 1);
1729 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1730 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { 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" }) });
1731
1732 // packages/icons/build-module/library/error.mjs
1733 var import_primitives14 = __toESM(require_primitives(), 1);
1734 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1735 var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { 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" }) });
1736
1737 // packages/icons/build-module/library/file.mjs
1738 var import_primitives15 = __toESM(require_primitives(), 1);
1739 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1740 var file_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) });
1741
1742 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1743 var import_primitives16 = __toESM(require_primitives(), 1);
1744 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1745 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "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" }) });
1746
1747 // packages/icons/build-module/library/format-list-bullets.mjs
1748 var import_primitives17 = __toESM(require_primitives(), 1);
1749 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1750 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "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" }) });
1751
1752 // packages/icons/build-module/library/funnel.mjs
1753 var import_primitives18 = __toESM(require_primitives(), 1);
1754 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1755 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1756
1757 // packages/icons/build-module/library/image.mjs
1758 var import_primitives19 = __toESM(require_primitives(), 1);
1759 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1760 var image_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "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.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) });
1761
1762 // packages/icons/build-module/library/link.mjs
1763 var import_primitives20 = __toESM(require_primitives(), 1);
1764 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1765 var link_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { d: "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" }) });
1766
1767 // packages/icons/build-module/library/mobile.mjs
1768 var import_primitives21 = __toESM(require_primitives(), 1);
1769 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1770 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "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" }) });
1771
1772 // packages/icons/build-module/library/more-vertical.mjs
1773 var import_primitives22 = __toESM(require_primitives(), 1);
1774 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1775 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1776
1777 // packages/icons/build-module/library/next.mjs
1778 var import_primitives23 = __toESM(require_primitives(), 1);
1779 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1780 var next_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "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" }) });
1781
1782 // packages/icons/build-module/library/previous.mjs
1783 var import_primitives24 = __toESM(require_primitives(), 1);
1784 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1785 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "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" }) });
1786
1787 // packages/icons/build-module/library/scheduled.mjs
1788 var import_primitives25 = __toESM(require_primitives(), 1);
1789 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1790 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { 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" }) });
1791
1792 // packages/icons/build-module/library/search.mjs
1793 var import_primitives26 = __toESM(require_primitives(), 1);
1794 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1795 var search_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.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" }) });
1796
1797 // packages/icons/build-module/library/seen.mjs
1798 var import_primitives27 = __toESM(require_primitives(), 1);
1799 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1800 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.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" }) });
1801
1802 // packages/icons/build-module/library/unseen.mjs
1803 var import_primitives28 = __toESM(require_primitives(), 1);
1804 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1805 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.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" }) });
1806
1807 // packages/icons/build-module/library/upload.mjs
1808 var import_primitives29 = __toESM(require_primitives(), 1);
1809 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1810 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) });
1811
1812 // packages/icons/build-module/library/video.mjs
1813 var import_primitives30 = __toESM(require_primitives(), 1);
1814 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
1815 var video_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) });
1816
1817 // node_modules/@base-ui/utils/safeReact.mjs
1818 var React = __toESM(require_react(), 1);
1819 var SafeReact = {
1820 ...React
1821 };
1822
1823 // node_modules/@base-ui/utils/useRefWithInit.mjs
1824 var React2 = __toESM(require_react(), 1);
1825 var UNINITIALIZED = {};
1826 function useRefWithInit(init2, initArg) {
1827 const ref = React2.useRef(UNINITIALIZED);
1828 if (ref.current === UNINITIALIZED) {
1829 ref.current = init2(initArg);
1830 }
1831 return ref;
1832 }
1833
1834 // node_modules/@base-ui/utils/useStableCallback.mjs
1835 var useInsertionEffect = SafeReact.useInsertionEffect;
1836 var useSafeInsertionEffect = (
1837 // React 17 doesn't have useInsertionEffect.
1838 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1839 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1840 );
1841 function useStableCallback(callback) {
1842 const stable = useRefWithInit(createStableCallback).current;
1843 stable.next = callback;
1844 useSafeInsertionEffect(stable.effect);
1845 return stable.trampoline;
1846 }
1847 function createStableCallback() {
1848 const stable = {
1849 next: void 0,
1850 callback: assertNotCalled,
1851 trampoline: (...args) => stable.callback?.(...args),
1852 effect: () => {
1853 stable.callback = stable.next;
1854 }
1855 };
1856 return stable;
1857 }
1858 function assertNotCalled() {
1859 if (true) {
1860 throw (
1861 /* minify-error-disabled */
1862 new Error("Base UI: Cannot call an event handler while rendering.")
1863 );
1864 }
1865 }
1866
1867 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1868 var React3 = __toESM(require_react(), 1);
1869 var noop2 = () => {
1870 };
1871 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop2;
1872
1873 // node_modules/@base-ui/utils/warn.mjs
1874 var set;
1875 if (true) {
1876 set = /* @__PURE__ */ new Set();
1877 }
1878 function warn(...messages) {
1879 if (true) {
1880 const messageKey = messages.join(" ");
1881 if (!set.has(messageKey)) {
1882 set.add(messageKey);
1883 console.warn(`Base UI: ${messageKey}`);
1884 }
1885 }
1886 }
1887
1888 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1889 var React4 = __toESM(require_react(), 1);
1890 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1891 if (true) DirectionContext.displayName = "DirectionContext";
1892 function useDirection() {
1893 const context = React4.useContext(DirectionContext);
1894 return context?.direction ?? "ltr";
1895 }
1896
1897 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1898 var React7 = __toESM(require_react(), 1);
1899
1900 // node_modules/@base-ui/utils/useMergedRefs.mjs
1901 function useMergedRefs(a2, b2, c2, d2) {
1902 const forkRef = useRefWithInit(createForkRef).current;
1903 if (didChange(forkRef, a2, b2, c2, d2)) {
1904 update(forkRef, [a2, b2, c2, d2]);
1905 }
1906 return forkRef.callback;
1907 }
1908 function useMergedRefsN(refs) {
1909 const forkRef = useRefWithInit(createForkRef).current;
1910 if (didChangeN(forkRef, refs)) {
1911 update(forkRef, refs);
1912 }
1913 return forkRef.callback;
1914 }
1915 function createForkRef() {
1916 return {
1917 callback: null,
1918 cleanup: null,
1919 refs: []
1920 };
1921 }
1922 function didChange(forkRef, a2, b2, c2, d2) {
1923 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1924 }
1925 function didChangeN(forkRef, newRefs) {
1926 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1927 }
1928 function update(forkRef, refs) {
1929 forkRef.refs = refs;
1930 if (refs.every((ref) => ref == null)) {
1931 forkRef.callback = null;
1932 return;
1933 }
1934 forkRef.callback = (instance) => {
1935 if (forkRef.cleanup) {
1936 forkRef.cleanup();
1937 forkRef.cleanup = null;
1938 }
1939 if (instance != null) {
1940 const cleanupCallbacks = Array(refs.length).fill(null);
1941 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1942 const ref = refs[i2];
1943 if (ref == null) {
1944 continue;
1945 }
1946 switch (typeof ref) {
1947 case "function": {
1948 const refCleanup = ref(instance);
1949 if (typeof refCleanup === "function") {
1950 cleanupCallbacks[i2] = refCleanup;
1951 }
1952 break;
1953 }
1954 case "object": {
1955 ref.current = instance;
1956 break;
1957 }
1958 default:
1959 }
1960 }
1961 forkRef.cleanup = () => {
1962 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1963 const ref = refs[i2];
1964 if (ref == null) {
1965 continue;
1966 }
1967 switch (typeof ref) {
1968 case "function": {
1969 const cleanupCallback = cleanupCallbacks[i2];
1970 if (typeof cleanupCallback === "function") {
1971 cleanupCallback();
1972 } else {
1973 ref(null);
1974 }
1975 break;
1976 }
1977 case "object": {
1978 ref.current = null;
1979 break;
1980 }
1981 default:
1982 }
1983 }
1984 };
1985 }
1986 };
1987 }
1988
1989 // node_modules/@base-ui/utils/getReactElementRef.mjs
1990 var React6 = __toESM(require_react(), 1);
1991
1992 // node_modules/@base-ui/utils/reactVersion.mjs
1993 var React5 = __toESM(require_react(), 1);
1994 var majorVersion = parseInt(React5.version, 10);
1995 function isReactVersionAtLeast(reactVersionToCheck) {
1996 return majorVersion >= reactVersionToCheck;
1997 }
1998
1999 // node_modules/@base-ui/utils/getReactElementRef.mjs
2000 function getReactElementRef(element) {
2001 if (!/* @__PURE__ */ React6.isValidElement(element)) {
2002 return null;
2003 }
2004 const reactElement = element;
2005 const propsWithRef = reactElement.props;
2006 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
2007 }
2008
2009 // node_modules/@base-ui/utils/mergeObjects.mjs
2010 function mergeObjects(a2, b2) {
2011 if (a2 && !b2) {
2012 return a2;
2013 }
2014 if (!a2 && b2) {
2015 return b2;
2016 }
2017 if (a2 || b2) {
2018 return {
2019 ...a2,
2020 ...b2
2021 };
2022 }
2023 return void 0;
2024 }
2025
2026 // node_modules/@base-ui/utils/empty.mjs
2027 function NOOP() {
2028 }
2029 var EMPTY_ARRAY = Object.freeze([]);
2030 var EMPTY_OBJECT = Object.freeze({});
2031
2032 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
2033 function getStateAttributesProps(state, customMapping) {
2034 const props = {};
2035 for (const key in state) {
2036 const value = state[key];
2037 if (customMapping?.hasOwnProperty(key)) {
2038 const customProps = customMapping[key](value);
2039 if (customProps != null) {
2040 Object.assign(props, customProps);
2041 }
2042 continue;
2043 }
2044 if (value === true) {
2045 props[`data-${key.toLowerCase()}`] = "";
2046 } else if (value) {
2047 props[`data-${key.toLowerCase()}`] = value.toString();
2048 }
2049 }
2050 return props;
2051 }
2052
2053 // node_modules/@base-ui/react/utils/resolveClassName.mjs
2054 function resolveClassName(className, state) {
2055 return typeof className === "function" ? className(state) : className;
2056 }
2057
2058 // node_modules/@base-ui/react/utils/resolveStyle.mjs
2059 function resolveStyle(style, state) {
2060 return typeof style === "function" ? style(state) : style;
2061 }
2062
2063 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
2064 var EMPTY_PROPS = {};
2065 function mergeProps(a2, b2, c2, d2, e2) {
2066 if (!c2 && !d2 && !e2 && !a2) {
2067 return createInitialMergedProps(b2);
2068 }
2069 let merged = createInitialMergedProps(a2);
2070 if (b2) {
2071 merged = mergeInto(merged, b2);
2072 }
2073 if (c2) {
2074 merged = mergeInto(merged, c2);
2075 }
2076 if (d2) {
2077 merged = mergeInto(merged, d2);
2078 }
2079 if (e2) {
2080 merged = mergeInto(merged, e2);
2081 }
2082 return merged;
2083 }
2084 function mergePropsN(props) {
2085 if (props.length === 0) {
2086 return EMPTY_PROPS;
2087 }
2088 if (props.length === 1) {
2089 return createInitialMergedProps(props[0]);
2090 }
2091 let merged = createInitialMergedProps(props[0]);
2092 for (let i2 = 1; i2 < props.length; i2 += 1) {
2093 merged = mergeInto(merged, props[i2]);
2094 }
2095 return merged;
2096 }
2097 function createInitialMergedProps(inputProps) {
2098 if (isPropsGetter(inputProps)) {
2099 return {
2100 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
2101 };
2102 }
2103 return copyInitialProps(inputProps);
2104 }
2105 function mergeInto(merged, inputProps) {
2106 if (isPropsGetter(inputProps)) {
2107 return resolvePropsGetter(inputProps, merged);
2108 }
2109 return mutablyMergeInto(merged, inputProps);
2110 }
2111 function copyInitialProps(inputProps) {
2112 const copiedProps = {
2113 ...inputProps
2114 };
2115 for (const propName in copiedProps) {
2116 const propValue = copiedProps[propName];
2117 if (isEventHandler(propName, propValue)) {
2118 copiedProps[propName] = wrapEventHandler(propValue);
2119 }
2120 }
2121 return copiedProps;
2122 }
2123 function mutablyMergeInto(mergedProps, externalProps) {
2124 if (!externalProps) {
2125 return mergedProps;
2126 }
2127 for (const propName in externalProps) {
2128 const externalPropValue = externalProps[propName];
2129 switch (propName) {
2130 case "style": {
2131 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
2132 break;
2133 }
2134 case "className": {
2135 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
2136 break;
2137 }
2138 default: {
2139 if (isEventHandler(propName, externalPropValue)) {
2140 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
2141 } else {
2142 mergedProps[propName] = externalPropValue;
2143 }
2144 }
2145 }
2146 }
2147 return mergedProps;
2148 }
2149 function isEventHandler(key, value) {
2150 const code0 = key.charCodeAt(0);
2151 const code1 = key.charCodeAt(1);
2152 const code2 = key.charCodeAt(2);
2153 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
2154 }
2155 function isPropsGetter(inputProps) {
2156 return typeof inputProps === "function";
2157 }
2158 function resolvePropsGetter(inputProps, previousProps) {
2159 if (isPropsGetter(inputProps)) {
2160 return inputProps(previousProps);
2161 }
2162 return inputProps ?? EMPTY_PROPS;
2163 }
2164 function mergeEventHandlers(ourHandler, theirHandler) {
2165 if (!theirHandler) {
2166 return ourHandler;
2167 }
2168 if (!ourHandler) {
2169 return wrapEventHandler(theirHandler);
2170 }
2171 return (...args) => {
2172 const event = args[0];
2173 if (isSyntheticEvent(event)) {
2174 const baseUIEvent = event;
2175 makeEventPreventable(baseUIEvent);
2176 const result2 = theirHandler(...args);
2177 if (!baseUIEvent.baseUIHandlerPrevented) {
2178 ourHandler?.(...args);
2179 }
2180 return result2;
2181 }
2182 const result = theirHandler(...args);
2183 ourHandler?.(...args);
2184 return result;
2185 };
2186 }
2187 function wrapEventHandler(handler) {
2188 if (!handler) {
2189 return handler;
2190 }
2191 return (...args) => {
2192 const event = args[0];
2193 if (isSyntheticEvent(event)) {
2194 makeEventPreventable(event);
2195 }
2196 return handler(...args);
2197 };
2198 }
2199 function makeEventPreventable(event) {
2200 event.preventBaseUIHandler = () => {
2201 event.baseUIHandlerPrevented = true;
2202 };
2203 return event;
2204 }
2205 function mergeClassNames(ourClassName, theirClassName) {
2206 if (theirClassName) {
2207 if (ourClassName) {
2208 return theirClassName + " " + ourClassName;
2209 }
2210 return theirClassName;
2211 }
2212 return ourClassName;
2213 }
2214 function isSyntheticEvent(event) {
2215 return event != null && typeof event === "object" && "nativeEvent" in event;
2216 }
2217
2218 // node_modules/@base-ui/react/internals/useRenderElement.mjs
2219 var import_react = __toESM(require_react(), 1);
2220 function useRenderElement(element, componentProps, params = {}) {
2221 const renderProp = componentProps.render;
2222 const outProps = useRenderElementProps(componentProps, params);
2223 if (params.enabled === false) {
2224 return null;
2225 }
2226 const state = params.state ?? EMPTY_OBJECT;
2227 return evaluateRenderProp(element, renderProp, outProps, state);
2228 }
2229 function useRenderElementProps(componentProps, params = {}) {
2230 const {
2231 className: classNameProp,
2232 style: styleProp,
2233 render: renderProp
2234 } = componentProps;
2235 const {
2236 state = EMPTY_OBJECT,
2237 ref,
2238 props,
2239 stateAttributesMapping: stateAttributesMapping3,
2240 enabled = true
2241 } = params;
2242 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2243 const style = enabled ? resolveStyle(styleProp, state) : void 0;
2244 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
2245 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
2246 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
2247 if (typeof document !== "undefined") {
2248 if (!enabled) {
2249 useMergedRefs(null, null);
2250 } else if (Array.isArray(ref)) {
2251 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2252 } else {
2253 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2254 }
2255 }
2256 if (!enabled) {
2257 return EMPTY_OBJECT;
2258 }
2259 if (className !== void 0) {
2260 outProps.className = mergeClassNames(outProps.className, className);
2261 }
2262 if (style !== void 0) {
2263 outProps.style = mergeObjects(outProps.style, style);
2264 }
2265 return outProps;
2266 }
2267 function resolveRenderFunctionProps(props) {
2268 if (Array.isArray(props)) {
2269 return mergePropsN(props);
2270 }
2271 return mergeProps(void 0, props);
2272 }
2273 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2274 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
2275 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
2276 function evaluateRenderProp(element, render4, props, state) {
2277 if (render4) {
2278 if (typeof render4 === "function") {
2279 if (true) {
2280 warnIfRenderPropLooksLikeComponent(render4);
2281 }
2282 return render4(props, state);
2283 }
2284 const mergedProps = mergeProps(props, render4.props);
2285 mergedProps.ref = props.ref;
2286 let newElement = render4;
2287 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2288 const children = React7.Children.toArray(render4);
2289 newElement = children[0];
2290 }
2291 if (true) {
2292 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
2293 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"));
2294 }
2295 }
2296 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
2297 }
2298 if (element) {
2299 if (typeof element === "string") {
2300 return renderTag(element, props);
2301 }
2302 }
2303 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2304 }
2305 function warnIfRenderPropLooksLikeComponent(renderFn) {
2306 const functionName = renderFn.name;
2307 if (functionName.length === 0) {
2308 return;
2309 }
2310 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
2311 return;
2312 }
2313 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
2314 return;
2315 }
2316 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");
2317 }
2318 function renderTag(Tag, props) {
2319 if (Tag === "button") {
2320 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2321 type: "button",
2322 ...props,
2323 key: props.key
2324 });
2325 }
2326 if (Tag === "img") {
2327 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2328 alt: "",
2329 ...props,
2330 key: props.key
2331 });
2332 }
2333 return /* @__PURE__ */ React7.createElement(Tag, props);
2334 }
2335
2336 // node_modules/@base-ui/utils/useId.mjs
2337 var React8 = __toESM(require_react(), 1);
2338 var globalId = 0;
2339 function useGlobalId(idOverride, prefix = "mui") {
2340 const [defaultId, setDefaultId] = React8.useState(idOverride);
2341 const id = idOverride || defaultId;
2342 React8.useEffect(() => {
2343 if (defaultId == null) {
2344 globalId += 1;
2345 setDefaultId(`${prefix}-${globalId}`);
2346 }
2347 }, [defaultId, prefix]);
2348 return id;
2349 }
2350 var maybeReactUseId = SafeReact.useId;
2351 function useId(idOverride, prefix) {
2352 if (maybeReactUseId !== void 0) {
2353 const reactId = maybeReactUseId();
2354 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
2355 }
2356 return useGlobalId(idOverride, prefix);
2357 }
2358
2359 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
2360 function useBaseUiId(idOverride) {
2361 return useId(idOverride, "base-ui");
2362 }
2363
2364 // node_modules/@base-ui/react/internals/reason-parts.mjs
2365 var reason_parts_exports = {};
2366 __export(reason_parts_exports, {
2367 cancelOpen: () => cancelOpen,
2368 chipRemovePress: () => chipRemovePress,
2369 clearPress: () => clearPress,
2370 closePress: () => closePress,
2371 closeWatcher: () => closeWatcher,
2372 decrementPress: () => decrementPress,
2373 disabled: () => disabled,
2374 drag: () => drag,
2375 escapeKey: () => escapeKey,
2376 focusOut: () => focusOut,
2377 imperativeAction: () => imperativeAction,
2378 incrementPress: () => incrementPress,
2379 initial: () => initial,
2380 inputBlur: () => inputBlur,
2381 inputChange: () => inputChange,
2382 inputClear: () => inputClear,
2383 inputPaste: () => inputPaste,
2384 inputPress: () => inputPress,
2385 itemPress: () => itemPress,
2386 keyboard: () => keyboard,
2387 linkPress: () => linkPress,
2388 listNavigation: () => listNavigation,
2389 missing: () => missing,
2390 none: () => none,
2391 outsidePress: () => outsidePress,
2392 pointer: () => pointer,
2393 scrub: () => scrub,
2394 siblingOpen: () => siblingOpen,
2395 swipe: () => swipe,
2396 trackPress: () => trackPress,
2397 triggerFocus: () => triggerFocus,
2398 triggerHover: () => triggerHover,
2399 triggerPress: () => triggerPress,
2400 wheel: () => wheel,
2401 windowResize: () => windowResize
2402 });
2403 var none = "none";
2404 var triggerPress = "trigger-press";
2405 var triggerHover = "trigger-hover";
2406 var triggerFocus = "trigger-focus";
2407 var outsidePress = "outside-press";
2408 var itemPress = "item-press";
2409 var closePress = "close-press";
2410 var linkPress = "link-press";
2411 var clearPress = "clear-press";
2412 var chipRemovePress = "chip-remove-press";
2413 var trackPress = "track-press";
2414 var incrementPress = "increment-press";
2415 var decrementPress = "decrement-press";
2416 var inputChange = "input-change";
2417 var inputClear = "input-clear";
2418 var inputBlur = "input-blur";
2419 var inputPaste = "input-paste";
2420 var inputPress = "input-press";
2421 var focusOut = "focus-out";
2422 var escapeKey = "escape-key";
2423 var closeWatcher = "close-watcher";
2424 var listNavigation = "list-navigation";
2425 var keyboard = "keyboard";
2426 var pointer = "pointer";
2427 var drag = "drag";
2428 var wheel = "wheel";
2429 var scrub = "scrub";
2430 var cancelOpen = "cancel-open";
2431 var siblingOpen = "sibling-open";
2432 var disabled = "disabled";
2433 var missing = "missing";
2434 var initial = "initial";
2435 var imperativeAction = "imperative-action";
2436 var swipe = "swipe";
2437 var windowResize = "window-resize";
2438
2439 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
2440 function createChangeEventDetails(reason, event, trigger, customProperties) {
2441 let canceled = false;
2442 let allowPropagation = false;
2443 const custom = customProperties ?? EMPTY_OBJECT;
2444 const details = {
2445 reason,
2446 event: event ?? new Event("base-ui"),
2447 cancel() {
2448 canceled = true;
2449 },
2450 allowPropagation() {
2451 allowPropagation = true;
2452 },
2453 get isCanceled() {
2454 return canceled;
2455 },
2456 get isPropagationAllowed() {
2457 return allowPropagation;
2458 },
2459 trigger,
2460 ...custom
2461 };
2462 return details;
2463 }
2464
2465 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2466 var React10 = __toESM(require_react(), 1);
2467
2468 // node_modules/@base-ui/utils/useOnMount.mjs
2469 var React9 = __toESM(require_react(), 1);
2470 var EMPTY = [];
2471 function useOnMount(fn) {
2472 React9.useEffect(fn, EMPTY);
2473 }
2474
2475 // node_modules/@base-ui/utils/useAnimationFrame.mjs
2476 var EMPTY2 = null;
2477 var LAST_RAF = globalThis.requestAnimationFrame;
2478 var Scheduler = class {
2479 /* This implementation uses an array as a backing data-structure for frame callbacks.
2480 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
2481 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
2482 * be much more efficient if there is a call pattern that alterns as
2483 * "request-cancel-request-cancel-…".
2484 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
2485 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
2486 callbacks = [];
2487 callbacksCount = 0;
2488 nextId = 1;
2489 startId = 1;
2490 isScheduled = false;
2491 tick = (timestamp) => {
2492 this.isScheduled = false;
2493 const currentCallbacks = this.callbacks;
2494 const currentCallbacksCount = this.callbacksCount;
2495 this.callbacks = [];
2496 this.callbacksCount = 0;
2497 this.startId = this.nextId;
2498 if (currentCallbacksCount > 0) {
2499 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
2500 currentCallbacks[i2]?.(timestamp);
2501 }
2502 }
2503 };
2504 request(fn) {
2505 const id = this.nextId;
2506 this.nextId += 1;
2507 this.callbacks.push(fn);
2508 this.callbacksCount += 1;
2509 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
2510 if (!this.isScheduled || didRAFChange) {
2511 requestAnimationFrame(this.tick);
2512 this.isScheduled = true;
2513 }
2514 return id;
2515 }
2516 cancel(id) {
2517 const index2 = id - this.startId;
2518 if (index2 < 0 || index2 >= this.callbacks.length) {
2519 return;
2520 }
2521 this.callbacks[index2] = null;
2522 this.callbacksCount -= 1;
2523 }
2524 };
2525 var scheduler = new Scheduler();
2526 var AnimationFrame = class _AnimationFrame {
2527 static create() {
2528 return new _AnimationFrame();
2529 }
2530 static request(fn) {
2531 return scheduler.request(fn);
2532 }
2533 static cancel(id) {
2534 return scheduler.cancel(id);
2535 }
2536 currentId = EMPTY2;
2537 /**
2538 * Executes `fn` after `delay`, clearing any previously scheduled call.
2539 */
2540 request(fn) {
2541 this.cancel();
2542 this.currentId = scheduler.request(() => {
2543 this.currentId = EMPTY2;
2544 fn();
2545 });
2546 }
2547 cancel = () => {
2548 if (this.currentId !== EMPTY2) {
2549 scheduler.cancel(this.currentId);
2550 this.currentId = EMPTY2;
2551 }
2552 };
2553 disposeEffect = () => {
2554 return this.cancel;
2555 };
2556 };
2557 function useAnimationFrame() {
2558 const timeout = useRefWithInit(AnimationFrame.create).current;
2559 useOnMount(timeout.disposeEffect);
2560 return timeout;
2561 }
2562
2563 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2564 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2565 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
2566 const [mounted, setMounted] = React10.useState(open);
2567 if (open && !mounted) {
2568 setMounted(true);
2569 setTransitionStatus("starting");
2570 }
2571 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2572 setTransitionStatus("ending");
2573 }
2574 if (!open && !mounted && transitionStatus === "ending") {
2575 setTransitionStatus(void 0);
2576 }
2577 useIsoLayoutEffect(() => {
2578 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2579 const frame = AnimationFrame.request(() => {
2580 setTransitionStatus("ending");
2581 });
2582 return () => {
2583 AnimationFrame.cancel(frame);
2584 };
2585 }
2586 return void 0;
2587 }, [open, mounted, transitionStatus, deferEndingState]);
2588 useIsoLayoutEffect(() => {
2589 if (!open || enableIdleState) {
2590 return void 0;
2591 }
2592 const frame = AnimationFrame.request(() => {
2593 setTransitionStatus(void 0);
2594 });
2595 return () => {
2596 AnimationFrame.cancel(frame);
2597 };
2598 }, [enableIdleState, open]);
2599 useIsoLayoutEffect(() => {
2600 if (!open || !enableIdleState) {
2601 return void 0;
2602 }
2603 if (open && mounted && transitionStatus !== "idle") {
2604 setTransitionStatus("starting");
2605 }
2606 const frame = AnimationFrame.request(() => {
2607 setTransitionStatus("idle");
2608 });
2609 return () => {
2610 AnimationFrame.cancel(frame);
2611 };
2612 }, [enableIdleState, open, mounted, transitionStatus]);
2613 return {
2614 mounted,
2615 setMounted,
2616 transitionStatus
2617 };
2618 }
2619
2620 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
2621 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2622 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2623 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2624 return TransitionStatusDataAttributes2;
2625 })({});
2626 var STARTING_HOOK = {
2627 [TransitionStatusDataAttributes.startingStyle]: ""
2628 };
2629 var ENDING_HOOK = {
2630 [TransitionStatusDataAttributes.endingStyle]: ""
2631 };
2632 var transitionStatusMapping = {
2633 transitionStatus(value) {
2634 if (value === "starting") {
2635 return STARTING_HOOK;
2636 }
2637 if (value === "ending") {
2638 return ENDING_HOOK;
2639 }
2640 return null;
2641 }
2642 };
2643
2644 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2645 function hasWindow() {
2646 return typeof window !== "undefined";
2647 }
2648 function getNodeName(node) {
2649 if (isNode(node)) {
2650 return (node.nodeName || "").toLowerCase();
2651 }
2652 return "#document";
2653 }
2654 function getWindow(node) {
2655 var _node$ownerDocument;
2656 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2657 }
2658 function getDocumentElement(node) {
2659 var _ref;
2660 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2661 }
2662 function isNode(value) {
2663 if (!hasWindow()) {
2664 return false;
2665 }
2666 return value instanceof Node || value instanceof getWindow(value).Node;
2667 }
2668 function isElement(value) {
2669 if (!hasWindow()) {
2670 return false;
2671 }
2672 return value instanceof Element || value instanceof getWindow(value).Element;
2673 }
2674 function isHTMLElement(value) {
2675 if (!hasWindow()) {
2676 return false;
2677 }
2678 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2679 }
2680 function isShadowRoot(value) {
2681 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2682 return false;
2683 }
2684 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2685 }
2686 function isOverflowElement(element) {
2687 const {
2688 overflow,
2689 overflowX,
2690 overflowY,
2691 display
2692 } = getComputedStyle2(element);
2693 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2694 }
2695 function isTableElement(element) {
2696 return /^(table|td|th)$/.test(getNodeName(element));
2697 }
2698 function isTopLayer(element) {
2699 try {
2700 if (element.matches(":popover-open")) {
2701 return true;
2702 }
2703 } catch (_e) {
2704 }
2705 try {
2706 return element.matches(":modal");
2707 } catch (_e) {
2708 return false;
2709 }
2710 }
2711 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2712 var containRe = /paint|layout|strict|content/;
2713 var isNotNone = (value) => !!value && value !== "none";
2714 var isWebKitValue;
2715 function isContainingBlock(elementOrCss) {
2716 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2717 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 || "");
2718 }
2719 function getContainingBlock(element) {
2720 let currentNode = getParentNode(element);
2721 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2722 if (isContainingBlock(currentNode)) {
2723 return currentNode;
2724 } else if (isTopLayer(currentNode)) {
2725 return null;
2726 }
2727 currentNode = getParentNode(currentNode);
2728 }
2729 return null;
2730 }
2731 function isWebKit() {
2732 if (isWebKitValue == null) {
2733 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2734 }
2735 return isWebKitValue;
2736 }
2737 function isLastTraversableNode(node) {
2738 return /^(html|body|#document)$/.test(getNodeName(node));
2739 }
2740 function getComputedStyle2(element) {
2741 return getWindow(element).getComputedStyle(element);
2742 }
2743 function getNodeScroll(element) {
2744 if (isElement(element)) {
2745 return {
2746 scrollLeft: element.scrollLeft,
2747 scrollTop: element.scrollTop
2748 };
2749 }
2750 return {
2751 scrollLeft: element.scrollX,
2752 scrollTop: element.scrollY
2753 };
2754 }
2755 function getParentNode(node) {
2756 if (getNodeName(node) === "html") {
2757 return node;
2758 }
2759 const result = (
2760 // Step into the shadow DOM of the parent of a slotted node.
2761 node.assignedSlot || // DOM Element detected.
2762 node.parentNode || // ShadowRoot detected.
2763 isShadowRoot(node) && node.host || // Fallback.
2764 getDocumentElement(node)
2765 );
2766 return isShadowRoot(result) ? result.host : result;
2767 }
2768 function getNearestOverflowAncestor(node) {
2769 const parentNode = getParentNode(node);
2770 if (isLastTraversableNode(parentNode)) {
2771 return node.ownerDocument ? node.ownerDocument.body : node.body;
2772 }
2773 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2774 return parentNode;
2775 }
2776 return getNearestOverflowAncestor(parentNode);
2777 }
2778 function getOverflowAncestors(node, list, traverseIframes) {
2779 var _node$ownerDocument2;
2780 if (list === void 0) {
2781 list = [];
2782 }
2783 if (traverseIframes === void 0) {
2784 traverseIframes = true;
2785 }
2786 const scrollableAncestor = getNearestOverflowAncestor(node);
2787 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2788 const win = getWindow(scrollableAncestor);
2789 if (isBody) {
2790 const frameElement = getFrameElement(win);
2791 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2792 } else {
2793 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2794 }
2795 }
2796 function getFrameElement(win) {
2797 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2798 }
2799
2800 // node_modules/@base-ui/utils/addEventListener.mjs
2801 function addEventListener(target, type, listener, options) {
2802 target.addEventListener(type, listener, options);
2803 return () => {
2804 target.removeEventListener(type, listener, options);
2805 };
2806 }
2807
2808 // node_modules/@base-ui/utils/useValueAsRef.mjs
2809 function useValueAsRef(value) {
2810 const latest = useRefWithInit(createLatestRef, value).current;
2811 latest.next = value;
2812 useIsoLayoutEffect(latest.effect);
2813 return latest;
2814 }
2815 function createLatestRef(value) {
2816 const latest = {
2817 current: value,
2818 next: value,
2819 effect: () => {
2820 latest.current = latest.next;
2821 }
2822 };
2823 return latest;
2824 }
2825
2826 // node_modules/@base-ui/utils/owner.mjs
2827 function ownerDocument(node) {
2828 return node?.ownerDocument || document;
2829 }
2830
2831 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2832 var React11 = __toESM(require_react(), 1);
2833
2834 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2835 var ReactDOM = __toESM(require_react_dom(), 1);
2836
2837 // node_modules/@base-ui/react/utils/resolveRef.mjs
2838 function resolveRef(maybeRef) {
2839 if (maybeRef == null) {
2840 return maybeRef;
2841 }
2842 return "current" in maybeRef ? maybeRef.current : maybeRef;
2843 }
2844
2845 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2846 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2847 const frame = useAnimationFrame();
2848 return useStableCallback((fnToExecute, signal = null) => {
2849 frame.cancel();
2850 const element = resolveRef(elementOrRef);
2851 if (element == null) {
2852 return;
2853 }
2854 const resolvedElement = element;
2855 const done = () => {
2856 ReactDOM.flushSync(fnToExecute);
2857 };
2858 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2859 fnToExecute();
2860 return;
2861 }
2862 function exec() {
2863 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2864 if (!signal?.aborted) {
2865 done();
2866 }
2867 }).catch(() => {
2868 if (treatAbortedAsFinished) {
2869 if (!signal?.aborted) {
2870 done();
2871 }
2872 return;
2873 }
2874 const currentAnimations = resolvedElement.getAnimations();
2875 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2876 exec();
2877 }
2878 });
2879 }
2880 if (waitForStartingStyleRemoved) {
2881 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2882 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2883 frame.request(exec);
2884 return;
2885 }
2886 const attributeObserver = new MutationObserver(() => {
2887 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2888 attributeObserver.disconnect();
2889 exec();
2890 }
2891 });
2892 attributeObserver.observe(resolvedElement, {
2893 attributes: true,
2894 attributeFilter: [startingStyleAttribute]
2895 });
2896 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2897 once: true
2898 });
2899 return;
2900 }
2901 frame.request(exec);
2902 });
2903 }
2904
2905 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2906 function useOpenChangeComplete(parameters) {
2907 const {
2908 enabled = true,
2909 open,
2910 ref,
2911 onComplete: onCompleteParam
2912 } = parameters;
2913 const onComplete = useStableCallback(onCompleteParam);
2914 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2915 React11.useEffect(() => {
2916 if (!enabled) {
2917 return void 0;
2918 }
2919 const abortController = new AbortController();
2920 runOnceAnimationsFinish(onComplete, abortController.signal);
2921 return () => {
2922 abortController.abort();
2923 };
2924 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2925 }
2926
2927 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2928 var React12 = __toESM(require_react(), 1);
2929 function useOnFirstRender(fn) {
2930 const ref = React12.useRef(true);
2931 if (ref.current) {
2932 ref.current = false;
2933 fn();
2934 }
2935 }
2936
2937 // node_modules/@base-ui/utils/platform/parts.mjs
2938 var parts_exports = {};
2939 __export(parts_exports, {
2940 engine: () => engine_exports,
2941 env: () => env_exports,
2942 os: () => os_exports,
2943 screenReader: () => screen_reader_exports
2944 });
2945
2946 // node_modules/@base-ui/utils/platform/os.mjs
2947 var os_exports = {};
2948 __export(os_exports, {
2949 android: () => android,
2950 apple: () => apple,
2951 ios: () => ios,
2952 linux: () => linux,
2953 mac: () => mac,
2954 windows: () => windows
2955 });
2956
2957 // node_modules/@base-ui/utils/platform/shared.mjs
2958 function readRawData() {
2959 if (typeof navigator === "undefined") {
2960 return {
2961 userAgent: "",
2962 platform: "",
2963 maxTouchPoints: 0
2964 };
2965 }
2966 if (true) {
2967 const uaData = navigator.userAgentData;
2968 if (uaData && Array.isArray(uaData.brands)) {
2969 return {
2970 userAgent: uaData.brands.map(({
2971 brand,
2972 version: version2
2973 }) => `${brand}/${version2}`).join(" "),
2974 platform: uaData.platform ?? navigator.platform ?? "",
2975 maxTouchPoints: navigator.maxTouchPoints ?? 0
2976 };
2977 }
2978 }
2979 return {
2980 userAgent: navigator.userAgent,
2981 platform: navigator.platform ?? "",
2982 maxTouchPoints: navigator.maxTouchPoints ?? 0
2983 };
2984 }
2985 var {
2986 userAgent,
2987 platform,
2988 maxTouchPoints
2989 } = readRawData();
2990 var lowerUserAgent = userAgent.toLowerCase();
2991 var lowerPlatform = platform.toLowerCase();
2992
2993 // node_modules/@base-ui/utils/platform/os.mjs
2994 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2995 var ANDROID_STRING = "android";
2996 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2997 var mac = !ios && lowerPlatform.startsWith("mac");
2998 var windows = lowerPlatform.startsWith("win");
2999 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
3000 var apple = mac || ios;
3001
3002 // node_modules/@base-ui/utils/platform/engine.mjs
3003 var engine_exports = {};
3004 __export(engine_exports, {
3005 blink: () => blink,
3006 gecko: () => gecko,
3007 webkit: () => webkit
3008 });
3009 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
3010 var gecko = !webkit && lowerUserAgent.includes("firefox");
3011 var blink = !webkit && lowerUserAgent.includes("chrom");
3012
3013 // node_modules/@base-ui/utils/platform/screen-reader.mjs
3014 var screen_reader_exports = {};
3015 __export(screen_reader_exports, {
3016 voiceOver: () => voiceOver
3017 });
3018 var voiceOver = apple;
3019
3020 // node_modules/@base-ui/utils/platform/env.mjs
3021 var env_exports = {};
3022 __export(env_exports, {
3023 jsdom: () => jsdom
3024 });
3025 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
3026
3027 // node_modules/@base-ui/utils/useTimeout.mjs
3028 var EMPTY3 = 0;
3029 var Timeout = class _Timeout {
3030 static create() {
3031 return new _Timeout();
3032 }
3033 currentId = EMPTY3;
3034 /**
3035 * Executes `fn` after `delay`, clearing any previously scheduled call.
3036 */
3037 start(delay, fn) {
3038 this.clear();
3039 this.currentId = setTimeout(() => {
3040 this.currentId = EMPTY3;
3041 fn();
3042 }, delay);
3043 }
3044 isStarted() {
3045 return this.currentId !== EMPTY3;
3046 }
3047 clear = () => {
3048 if (this.currentId !== EMPTY3) {
3049 clearTimeout(this.currentId);
3050 this.currentId = EMPTY3;
3051 }
3052 };
3053 disposeEffect = () => {
3054 return this.clear;
3055 };
3056 };
3057 function useTimeout() {
3058 const timeout = useRefWithInit(Timeout.create).current;
3059 useOnMount(timeout.disposeEffect);
3060 return timeout;
3061 }
3062
3063 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3064 var React13 = __toESM(require_react(), 1);
3065
3066 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
3067 function isReactEvent(event) {
3068 return "nativeEvent" in event;
3069 }
3070 function isMouseLikePointerType(pointerType, strict) {
3071 const values = ["mouse", "pen"];
3072 if (!strict) {
3073 values.push("", void 0);
3074 }
3075 return values.includes(pointerType);
3076 }
3077 function isClickLikeEvent(event) {
3078 const type = event.type;
3079 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
3080 }
3081
3082 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
3083 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
3084 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
3085
3086 // node_modules/@base-ui/react/internals/shadowDom.mjs
3087 function activeElement(doc) {
3088 let element = doc.activeElement;
3089 while (element?.shadowRoot?.activeElement != null) {
3090 element = element.shadowRoot.activeElement;
3091 }
3092 return element;
3093 }
3094 function contains(parent, child) {
3095 if (!parent || !child) {
3096 return false;
3097 }
3098 const rootNode = child.getRootNode?.();
3099 if (parent.contains(child)) {
3100 return true;
3101 }
3102 if (rootNode && isShadowRoot(rootNode)) {
3103 let next = child;
3104 while (next) {
3105 if (parent === next) {
3106 return true;
3107 }
3108 next = next.parentNode || next.host;
3109 }
3110 }
3111 return false;
3112 }
3113 function getTarget(event) {
3114 if ("composedPath" in event) {
3115 return event.composedPath()[0];
3116 }
3117 return event.target;
3118 }
3119
3120 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
3121 function isTargetInsideEnabledTrigger(target, triggerElements) {
3122 if (!isElement(target)) {
3123 return false;
3124 }
3125 const targetElement = target;
3126 if (triggerElements.hasElement(targetElement)) {
3127 return !targetElement.hasAttribute("data-trigger-disabled");
3128 }
3129 for (const [, trigger] of triggerElements.entries()) {
3130 if (contains(trigger, targetElement)) {
3131 return !trigger.hasAttribute("data-trigger-disabled");
3132 }
3133 }
3134 return false;
3135 }
3136 function isEventTargetWithin(event, node) {
3137 if (node == null) {
3138 return false;
3139 }
3140 if ("composedPath" in event) {
3141 return event.composedPath().includes(node);
3142 }
3143 const eventAgain = event;
3144 return eventAgain.target != null && node.contains(eventAgain.target);
3145 }
3146 function isRootElement(element) {
3147 return element.matches("html,body");
3148 }
3149 function isTypeableElement(element) {
3150 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
3151 }
3152 function isInteractiveElement(element) {
3153 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
3154 }
3155 function matchesFocusVisible(element) {
3156 if (!element || parts_exports.env.jsdom) {
3157 return true;
3158 }
3159 try {
3160 return element.matches(":focus-visible");
3161 } catch (_e) {
3162 return true;
3163 }
3164 }
3165
3166 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
3167 function resolveValue(value, pointerType) {
3168 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3169 return 0;
3170 }
3171 if (typeof value === "function") {
3172 return value();
3173 }
3174 return value;
3175 }
3176 function getDelay(value, prop, pointerType) {
3177 const result = resolveValue(value, pointerType);
3178 if (typeof result === "number") {
3179 return result;
3180 }
3181 return result?.[prop];
3182 }
3183 function getRestMs(value) {
3184 if (typeof value === "function") {
3185 return value();
3186 }
3187 return value;
3188 }
3189 function isClickLikeOpenEvent(openEventType, interactedInside) {
3190 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3191 }
3192 function isHoverOpenEvent(openEventType) {
3193 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3194 }
3195
3196 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3197 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3198 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
3199 hasProvider: false,
3200 timeoutMs: 0,
3201 delayRef: {
3202 current: 0
3203 },
3204 initialDelayRef: {
3205 current: 0
3206 },
3207 timeout: new Timeout(),
3208 currentIdRef: {
3209 current: null
3210 },
3211 currentContextRef: {
3212 current: null
3213 }
3214 });
3215 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3216 function resetDelayRef(delayRef, initialDelayRef) {
3217 delayRef.current = initialDelayRef.current;
3218 }
3219 function FloatingDelayGroup(props) {
3220 const {
3221 children,
3222 delay,
3223 timeoutMs = 0
3224 } = props;
3225 const delayRef = React13.useRef(delay);
3226 const initialDelayRef = React13.useRef(delay);
3227 const currentIdRef = React13.useRef(null);
3228 const currentContextRef = React13.useRef(null);
3229 const timeout = useTimeout();
3230 useIsoLayoutEffect(() => {
3231 initialDelayRef.current = delay;
3232 if (!currentIdRef.current) {
3233 delayRef.current = delay;
3234 return;
3235 }
3236 delayRef.current = {
3237 open: getDelay(delayRef.current, "open"),
3238 close: getDelay(delay, "close")
3239 };
3240 }, [delay, currentIdRef, delayRef, initialDelayRef]);
3241 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FloatingDelayGroupContext.Provider, {
3242 value: React13.useMemo(() => ({
3243 hasProvider: true,
3244 delayRef,
3245 initialDelayRef,
3246 currentIdRef,
3247 timeoutMs,
3248 currentContextRef,
3249 timeout
3250 }), [timeoutMs, timeout]),
3251 children
3252 });
3253 }
3254 function useDelayGroup(context, options = {
3255 open: false
3256 }) {
3257 const {
3258 open
3259 } = options;
3260 const store = "rootStore" in context ? context.rootStore : context;
3261 const floatingId = store.useState("floatingId");
3262 const groupContext = React13.useContext(FloatingDelayGroupContext);
3263 const {
3264 currentIdRef,
3265 delayRef,
3266 timeoutMs,
3267 initialDelayRef,
3268 currentContextRef,
3269 hasProvider,
3270 timeout
3271 } = groupContext;
3272 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
3273 const openRef = React13.useRef(open);
3274 const isUnmountedRef = React13.useRef(false);
3275 useIsoLayoutEffect(() => {
3276 openRef.current = open;
3277 }, [open]);
3278 useIsoLayoutEffect(() => {
3279 return () => {
3280 isUnmountedRef.current = true;
3281 };
3282 }, []);
3283 useIsoLayoutEffect(() => {
3284 function unset() {
3285 if (!isUnmountedRef.current) {
3286 setIsInstantPhase(false);
3287 }
3288 currentContextRef.current?.setIsInstantPhase(false);
3289 currentIdRef.current = null;
3290 currentContextRef.current = null;
3291 delayRef.current = initialDelayRef.current;
3292 timeout.clear();
3293 }
3294 if (!currentIdRef.current) {
3295 return void 0;
3296 }
3297 if (!open && currentIdRef.current === floatingId) {
3298 setIsInstantPhase(false);
3299 if (timeoutMs) {
3300 const closingId = floatingId;
3301 timeout.start(timeoutMs, () => {
3302 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3303 return;
3304 }
3305 unset();
3306 });
3307 return () => {
3308 if (openRef.current || currentIdRef.current !== closingId) {
3309 timeout.clear();
3310 }
3311 };
3312 }
3313 unset();
3314 }
3315 return void 0;
3316 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3317 useIsoLayoutEffect(() => {
3318 if (!open) {
3319 return;
3320 }
3321 const prevContext = currentContextRef.current;
3322 const prevId = currentIdRef.current;
3323 timeout.clear();
3324 currentContextRef.current = {
3325 onOpenChange: store.setOpen,
3326 setIsInstantPhase
3327 };
3328 currentIdRef.current = floatingId;
3329 delayRef.current = {
3330 open: 0,
3331 close: getDelay(initialDelayRef.current, "close")
3332 };
3333 if (prevId !== null && prevId !== floatingId) {
3334 setIsInstantPhase(true);
3335 prevContext?.setIsInstantPhase(true);
3336 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3337 } else {
3338 setIsInstantPhase(false);
3339 prevContext?.setIsInstantPhase(false);
3340 }
3341 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3342 useIsoLayoutEffect(() => {
3343 return () => {
3344 if (currentIdRef.current === floatingId) {
3345 currentContextRef.current = null;
3346 if (!openRef.current) {
3347 return;
3348 }
3349 currentIdRef.current = null;
3350 resetDelayRef(delayRef, initialDelayRef);
3351 timeout.clear();
3352 }
3353 };
3354 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3355 return React13.useMemo(() => ({
3356 hasProvider,
3357 delayRef,
3358 isInstantPhase
3359 }), [hasProvider, delayRef, isInstantPhase]);
3360 }
3361
3362 // node_modules/@base-ui/utils/mergeCleanups.mjs
3363 function mergeCleanups(...cleanups) {
3364 return () => {
3365 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3366 const cleanup = cleanups[i2];
3367 if (cleanup) {
3368 cleanup();
3369 }
3370 }
3371 };
3372 }
3373
3374 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3375 var React14 = __toESM(require_react(), 1);
3376
3377 // node_modules/@base-ui/utils/visuallyHidden.mjs
3378 var visuallyHiddenBase = {
3379 clipPath: "inset(50%)",
3380 overflow: "hidden",
3381 whiteSpace: "nowrap",
3382 border: 0,
3383 padding: 0,
3384 width: 1,
3385 height: 1,
3386 margin: -1
3387 };
3388 var visuallyHidden = {
3389 ...visuallyHiddenBase,
3390 position: "fixed",
3391 top: 0,
3392 left: 0
3393 };
3394 var visuallyHiddenInput = {
3395 ...visuallyHiddenBase,
3396 position: "absolute"
3397 };
3398
3399 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3400 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3401 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
3402 const [role, setRole] = React14.useState();
3403 useIsoLayoutEffect(() => {
3404 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3405 setRole("button");
3406 }
3407 }, []);
3408 const restProps = {
3409 tabIndex: 0,
3410 // Role is only for VoiceOver
3411 role
3412 };
3413 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", {
3414 ...props,
3415 ref,
3416 style: visuallyHidden,
3417 "aria-hidden": role ? void 0 : true,
3418 ...restProps,
3419 "data-base-ui-focus-guard": ""
3420 });
3421 });
3422 if (true) FocusGuard.displayName = "FocusGuard";
3423
3424 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3425 var sides = ["top", "right", "bottom", "left"];
3426 var min = Math.min;
3427 var max = Math.max;
3428 var round = Math.round;
3429 var floor = Math.floor;
3430 var createCoords = (v2) => ({
3431 x: v2,
3432 y: v2
3433 });
3434 var oppositeSideMap = {
3435 left: "right",
3436 right: "left",
3437 bottom: "top",
3438 top: "bottom"
3439 };
3440 function clamp(start, value, end) {
3441 return max(start, min(value, end));
3442 }
3443 function evaluate(value, param) {
3444 return typeof value === "function" ? value(param) : value;
3445 }
3446 function getSide(placement) {
3447 return placement.split("-")[0];
3448 }
3449 function getAlignment(placement) {
3450 return placement.split("-")[1];
3451 }
3452 function getOppositeAxis(axis) {
3453 return axis === "x" ? "y" : "x";
3454 }
3455 function getAxisLength(axis) {
3456 return axis === "y" ? "height" : "width";
3457 }
3458 function getSideAxis(placement) {
3459 const firstChar = placement[0];
3460 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3461 }
3462 function getAlignmentAxis(placement) {
3463 return getOppositeAxis(getSideAxis(placement));
3464 }
3465 function getAlignmentSides(placement, rects, rtl) {
3466 if (rtl === void 0) {
3467 rtl = false;
3468 }
3469 const alignment = getAlignment(placement);
3470 const alignmentAxis = getAlignmentAxis(placement);
3471 const length = getAxisLength(alignmentAxis);
3472 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3473 if (rects.reference[length] > rects.floating[length]) {
3474 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3475 }
3476 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3477 }
3478 function getExpandedPlacements(placement) {
3479 const oppositePlacement = getOppositePlacement(placement);
3480 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3481 }
3482 function getOppositeAlignmentPlacement(placement) {
3483 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3484 }
3485 var lrPlacement = ["left", "right"];
3486 var rlPlacement = ["right", "left"];
3487 var tbPlacement = ["top", "bottom"];
3488 var btPlacement = ["bottom", "top"];
3489 function getSideList(side, isStart, rtl) {
3490 switch (side) {
3491 case "top":
3492 case "bottom":
3493 if (rtl) return isStart ? rlPlacement : lrPlacement;
3494 return isStart ? lrPlacement : rlPlacement;
3495 case "left":
3496 case "right":
3497 return isStart ? tbPlacement : btPlacement;
3498 default:
3499 return [];
3500 }
3501 }
3502 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3503 const alignment = getAlignment(placement);
3504 let list = getSideList(getSide(placement), direction === "start", rtl);
3505 if (alignment) {
3506 list = list.map((side) => side + "-" + alignment);
3507 if (flipAlignment) {
3508 list = list.concat(list.map(getOppositeAlignmentPlacement));
3509 }
3510 }
3511 return list;
3512 }
3513 function getOppositePlacement(placement) {
3514 const side = getSide(placement);
3515 return oppositeSideMap[side] + placement.slice(side.length);
3516 }
3517 function expandPaddingObject(padding) {
3518 return {
3519 top: 0,
3520 right: 0,
3521 bottom: 0,
3522 left: 0,
3523 ...padding
3524 };
3525 }
3526 function getPaddingObject(padding) {
3527 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3528 top: padding,
3529 right: padding,
3530 bottom: padding,
3531 left: padding
3532 };
3533 }
3534 function rectToClientRect(rect) {
3535 const {
3536 x: x2,
3537 y: y2,
3538 width,
3539 height
3540 } = rect;
3541 return {
3542 width,
3543 height,
3544 top: y2,
3545 left: x2,
3546 right: x2 + width,
3547 bottom: y2 + height,
3548 x: x2,
3549 y: y2
3550 };
3551 }
3552
3553 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3554 function isHiddenByStyles(styles) {
3555 return styles.visibility === "hidden" || styles.visibility === "collapse";
3556 }
3557 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3558 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3559 return false;
3560 }
3561 if (typeof element.checkVisibility === "function") {
3562 return element.checkVisibility();
3563 }
3564 return styles.display !== "none" && styles.display !== "contents";
3565 }
3566
3567 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3568 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3569 function getParentElement(element) {
3570 const assignedSlot = element.assignedSlot;
3571 if (assignedSlot) {
3572 return assignedSlot;
3573 }
3574 if (element.parentElement) {
3575 return element.parentElement;
3576 }
3577 const rootNode = element.getRootNode();
3578 return isShadowRoot(rootNode) ? rootNode.host : null;
3579 }
3580 function getDetailsSummary(details) {
3581 for (const child of Array.from(details.children)) {
3582 if (getNodeName(child) === "summary") {
3583 return child;
3584 }
3585 }
3586 return null;
3587 }
3588 function isWithinOpenDetailsSummary(element, details) {
3589 const summary = getDetailsSummary(details);
3590 return !!summary && (element === summary || contains(summary, element));
3591 }
3592 function isFocusableCandidate(element) {
3593 const nodeName = element ? getNodeName(element) : "";
3594 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");
3595 }
3596 function isFocusableElement(element) {
3597 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3598 return false;
3599 }
3600 for (let current = element; current; current = getParentElement(current)) {
3601 const isAncestor = current !== element;
3602 const isSlot = getNodeName(current) === "slot";
3603 if (current.hasAttribute("inert")) {
3604 return false;
3605 }
3606 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3607 return false;
3608 }
3609 }
3610 return true;
3611 }
3612 function isVisibleInTabbableTree(element, isAncestor) {
3613 const styles = getComputedStyle2(element);
3614 if (!isAncestor) {
3615 return isElementVisible(element, styles);
3616 }
3617 return styles.display !== "none";
3618 }
3619 function getTabIndex(element) {
3620 const tabIndex = element.tabIndex;
3621 if (tabIndex < 0) {
3622 const nodeName = getNodeName(element);
3623 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3624 return 0;
3625 }
3626 }
3627 return tabIndex;
3628 }
3629 function getNamedRadioInput(element) {
3630 if (getNodeName(element) !== "input") {
3631 return null;
3632 }
3633 const input = element;
3634 return input.type === "radio" && input.name !== "" ? input : null;
3635 }
3636 function isTabbableRadio(element, candidates) {
3637 const input = getNamedRadioInput(element);
3638 if (!input) {
3639 return true;
3640 }
3641 const checkedRadio = candidates.find((candidate) => {
3642 const radio = getNamedRadioInput(candidate);
3643 return radio?.name === input.name && radio.form === input.form && radio.checked;
3644 });
3645 if (checkedRadio) {
3646 return checkedRadio === input;
3647 }
3648 return candidates.find((candidate) => {
3649 const radio = getNamedRadioInput(candidate);
3650 return radio?.name === input.name && radio.form === input.form;
3651 }) === input;
3652 }
3653 function getComposedChildren(container) {
3654 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3655 const assignedElements = container.assignedElements({
3656 flatten: true
3657 });
3658 if (assignedElements.length > 0) {
3659 return assignedElements;
3660 }
3661 }
3662 if (isHTMLElement(container) && container.shadowRoot) {
3663 return Array.from(container.shadowRoot.children);
3664 }
3665 return Array.from(container.children);
3666 }
3667 function appendCandidates(container, list) {
3668 getComposedChildren(container).forEach((child) => {
3669 if (isFocusableCandidate(child)) {
3670 list.push(child);
3671 }
3672 appendCandidates(child, list);
3673 });
3674 }
3675 function appendMatchingElements(container, selector2, list) {
3676 getComposedChildren(container).forEach((child) => {
3677 if (isHTMLElement(child) && child.matches(selector2)) {
3678 list.push(child);
3679 }
3680 appendMatchingElements(child, selector2, list);
3681 });
3682 }
3683 function focusable(container) {
3684 const candidates = [];
3685 appendCandidates(container, candidates);
3686 return candidates.filter(isFocusableElement);
3687 }
3688 function tabbable(container) {
3689 const candidates = focusable(container);
3690 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3691 }
3692 function getTabbableIn(container, dir) {
3693 const list = tabbable(container);
3694 const len = list.length;
3695 if (len === 0) {
3696 return void 0;
3697 }
3698 const active = activeElement(ownerDocument(container));
3699 const index2 = list.indexOf(active);
3700 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3701 return list[nextIndex];
3702 }
3703 function getNextTabbable(referenceElement) {
3704 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3705 }
3706 function getPreviousTabbable(referenceElement) {
3707 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3708 }
3709 function isOutsideEvent(event, container) {
3710 const containerElement = container || event.currentTarget;
3711 const relatedTarget = event.relatedTarget;
3712 return !relatedTarget || !contains(containerElement, relatedTarget);
3713 }
3714 function disableFocusInside(container) {
3715 const tabbableElements = tabbable(container);
3716 tabbableElements.forEach((element) => {
3717 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3718 element.setAttribute("tabindex", "-1");
3719 });
3720 }
3721 function enableFocusInside(container) {
3722 const elements = [];
3723 appendMatchingElements(container, "[data-tabindex]", elements);
3724 elements.forEach((element) => {
3725 const tabindex = element.dataset.tabindex;
3726 delete element.dataset.tabindex;
3727 if (tabindex) {
3728 element.setAttribute("tabindex", tabindex);
3729 } else {
3730 element.removeAttribute("tabindex");
3731 }
3732 });
3733 }
3734
3735 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3736 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3737 const directChildren = nodes.filter((node) => node.parentId === id);
3738 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3739 }
3740
3741 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3742 function createAttribute(name) {
3743 return `data-base-ui-${name}`;
3744 }
3745
3746 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3747 var React15 = __toESM(require_react(), 1);
3748 var ReactDOM2 = __toESM(require_react_dom(), 1);
3749
3750 // node_modules/@base-ui/react/internals/constants.mjs
3751 var DISABLED_TRANSITIONS_STYLE = {
3752 style: {
3753 transition: "none"
3754 }
3755 };
3756 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3757 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3758 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3759 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3760 var POPUP_COLLISION_AVOIDANCE = {
3761 fallbackAxisSide: "end"
3762 };
3763 var ownerVisuallyHidden = {
3764 clipPath: "inset(50%)",
3765 position: "fixed",
3766 top: 0,
3767 left: 0
3768 };
3769
3770 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3771 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3772 var PortalContext = /* @__PURE__ */ React15.createContext(null);
3773 if (true) PortalContext.displayName = "PortalContext";
3774 var usePortalContext = () => React15.useContext(PortalContext);
3775 var attr = createAttribute("portal");
3776 function useFloatingPortalNode(props = {}) {
3777 const {
3778 ref,
3779 container: containerProp,
3780 componentProps = EMPTY_OBJECT,
3781 elementProps
3782 } = props;
3783 const uniqueId = useId();
3784 const portalContext = usePortalContext();
3785 const parentPortalNode = portalContext?.portalNode;
3786 const [containerElement, setContainerElement] = React15.useState(null);
3787 const [portalNode, setPortalNode] = React15.useState(null);
3788 const setPortalNodeRef = useStableCallback((node) => {
3789 if (node !== null) {
3790 setPortalNode(node);
3791 }
3792 });
3793 const containerRef = React15.useRef(null);
3794 useIsoLayoutEffect(() => {
3795 if (containerProp === null) {
3796 if (containerRef.current) {
3797 containerRef.current = null;
3798 setPortalNode(null);
3799 setContainerElement(null);
3800 }
3801 return;
3802 }
3803 if (uniqueId == null) {
3804 return;
3805 }
3806 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3807 if (resolvedContainer == null) {
3808 if (containerRef.current) {
3809 containerRef.current = null;
3810 setPortalNode(null);
3811 setContainerElement(null);
3812 }
3813 return;
3814 }
3815 if (containerRef.current !== resolvedContainer) {
3816 containerRef.current = resolvedContainer;
3817 setPortalNode(null);
3818 setContainerElement(resolvedContainer);
3819 }
3820 }, [containerProp, parentPortalNode, uniqueId]);
3821 const portalElement = useRenderElement("div", componentProps, {
3822 ref: [ref, setPortalNodeRef],
3823 props: [{
3824 id: uniqueId,
3825 [attr]: ""
3826 }, elementProps]
3827 });
3828 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3829 return {
3830 portalNode,
3831 portalSubtree
3832 };
3833 }
3834 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3835 const {
3836 render: render4,
3837 className,
3838 style,
3839 children,
3840 container,
3841 renderGuards,
3842 ...elementProps
3843 } = componentProps;
3844 const {
3845 portalNode,
3846 portalSubtree
3847 } = useFloatingPortalNode({
3848 container,
3849 ref: forwardedRef,
3850 componentProps,
3851 elementProps
3852 });
3853 const beforeOutsideRef = React15.useRef(null);
3854 const afterOutsideRef = React15.useRef(null);
3855 const beforeInsideRef = React15.useRef(null);
3856 const afterInsideRef = React15.useRef(null);
3857 const [focusManagerState, setFocusManagerState] = React15.useState(null);
3858 const focusInsideDisabledRef = React15.useRef(false);
3859 const modal = focusManagerState?.modal;
3860 const open = focusManagerState?.open;
3861 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3862 React15.useEffect(() => {
3863 if (!portalNode || modal) {
3864 return void 0;
3865 }
3866 function onFocus(event) {
3867 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3868 if (event.type === "focusin") {
3869 if (focusInsideDisabledRef.current) {
3870 enableFocusInside(portalNode);
3871 focusInsideDisabledRef.current = false;
3872 }
3873 } else {
3874 disableFocusInside(portalNode);
3875 focusInsideDisabledRef.current = true;
3876 }
3877 }
3878 }
3879 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3880 }, [portalNode, modal]);
3881 useIsoLayoutEffect(() => {
3882 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3883 return;
3884 }
3885 enableFocusInside(portalNode);
3886 focusInsideDisabledRef.current = false;
3887 }, [open, portalNode]);
3888 const portalContextValue = React15.useMemo(() => ({
3889 beforeOutsideRef,
3890 afterOutsideRef,
3891 beforeInsideRef,
3892 afterInsideRef,
3893 portalNode,
3894 setFocusManagerState
3895 }), [portalNode]);
3896 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(React15.Fragment, {
3897 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(PortalContext.Provider, {
3898 value: portalContextValue,
3899 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3900 "data-type": "outside",
3901 ref: beforeOutsideRef,
3902 onFocus: (event) => {
3903 if (isOutsideEvent(event, portalNode)) {
3904 beforeInsideRef.current?.focus();
3905 } else {
3906 const domReference = focusManagerState ? focusManagerState.domReference : null;
3907 const prevTabbable = getPreviousTabbable(domReference);
3908 prevTabbable?.focus();
3909 }
3910 }
3911 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", {
3912 "aria-owns": portalNode.id,
3913 style: ownerVisuallyHidden
3914 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3915 "data-type": "outside",
3916 ref: afterOutsideRef,
3917 onFocus: (event) => {
3918 if (isOutsideEvent(event, portalNode)) {
3919 afterInsideRef.current?.focus();
3920 } else {
3921 const domReference = focusManagerState ? focusManagerState.domReference : null;
3922 const nextTabbable = getNextTabbable(domReference);
3923 nextTabbable?.focus();
3924 if (focusManagerState?.closeOnFocusOut) {
3925 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3926 }
3927 }
3928 }
3929 })]
3930 })]
3931 });
3932 });
3933 if (true) FloatingPortal.displayName = "FloatingPortal";
3934
3935 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3936 var React16 = __toESM(require_react(), 1);
3937
3938 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3939 function createEventEmitter() {
3940 const map = /* @__PURE__ */ new Map();
3941 return {
3942 emit(event, data) {
3943 map.get(event)?.forEach((listener) => listener(data));
3944 },
3945 on(event, listener) {
3946 if (!map.has(event)) {
3947 map.set(event, /* @__PURE__ */ new Set());
3948 }
3949 map.get(event).add(listener);
3950 },
3951 off(event, listener) {
3952 map.get(event)?.delete(listener);
3953 }
3954 };
3955 }
3956
3957 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3958 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3959 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3960 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3961 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3962 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3963 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3964 var useFloatingTree = (externalTree) => {
3965 const contextTree = React16.useContext(FloatingTreeContext);
3966 return externalTree ?? contextTree;
3967 };
3968
3969 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3970 var React17 = __toESM(require_react(), 1);
3971 function createVirtualElement(domElement, data) {
3972 let offsetX = null;
3973 let offsetY = null;
3974 let isAutoUpdateEvent = false;
3975 return {
3976 contextElement: domElement || void 0,
3977 getBoundingClientRect() {
3978 const domRect = domElement?.getBoundingClientRect() || {
3979 width: 0,
3980 height: 0,
3981 x: 0,
3982 y: 0
3983 };
3984 const isXAxis = data.axis === "x" || data.axis === "both";
3985 const isYAxis = data.axis === "y" || data.axis === "both";
3986 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3987 let width = domRect.width;
3988 let height = domRect.height;
3989 let x2 = domRect.x;
3990 let y2 = domRect.y;
3991 if (offsetX == null && data.x && isXAxis) {
3992 offsetX = domRect.x - data.x;
3993 }
3994 if (offsetY == null && data.y && isYAxis) {
3995 offsetY = domRect.y - data.y;
3996 }
3997 x2 -= offsetX || 0;
3998 y2 -= offsetY || 0;
3999 width = 0;
4000 height = 0;
4001 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4002 width = data.axis === "y" ? domRect.width : 0;
4003 height = data.axis === "x" ? domRect.height : 0;
4004 x2 = isXAxis && data.x != null ? data.x : x2;
4005 y2 = isYAxis && data.y != null ? data.y : y2;
4006 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4007 height = data.axis === "x" ? domRect.height : height;
4008 width = data.axis === "y" ? domRect.width : width;
4009 }
4010 isAutoUpdateEvent = true;
4011 return {
4012 width,
4013 height,
4014 x: x2,
4015 y: y2,
4016 top: y2,
4017 right: x2 + width,
4018 bottom: y2 + height,
4019 left: x2
4020 };
4021 }
4022 };
4023 }
4024 function isMouseBasedEvent(event) {
4025 return event != null && event.clientX != null;
4026 }
4027 function useClientPoint(context, props = {}) {
4028 const {
4029 enabled = true,
4030 axis = "both"
4031 } = props;
4032 const store = "rootStore" in context ? context.rootStore : context;
4033 const open = store.useState("open");
4034 const floating = store.useState("floatingElement");
4035 const domReference = store.useState("domReferenceElement");
4036 const dataRef = store.context.dataRef;
4037 const initialRef = React17.useRef(false);
4038 const cleanupListenerRef = React17.useRef(null);
4039 const [pointerType, setPointerType] = React17.useState();
4040 const [reactive, setReactive] = React17.useState([]);
4041 const resetReference = useStableCallback((reference2) => {
4042 store.set("positionReference", reference2);
4043 });
4044 const setReference = useStableCallback((newX, newY, referenceElement) => {
4045 if (initialRef.current) {
4046 return;
4047 }
4048 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4049 return;
4050 }
4051 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4052 x: newX,
4053 y: newY,
4054 axis,
4055 dataRef,
4056 pointerType
4057 }));
4058 });
4059 const handleReferenceEnterOrMove = useStableCallback((event) => {
4060 if (!open) {
4061 setReference(event.clientX, event.clientY, event.currentTarget);
4062 } else if (!cleanupListenerRef.current) {
4063 setReference(event.clientX, event.clientY, event.currentTarget);
4064 setReactive([]);
4065 }
4066 });
4067 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4068 React17.useEffect(() => {
4069 if (!enabled) {
4070 resetReference(domReference);
4071 return void 0;
4072 }
4073 if (!openCheck) {
4074 return void 0;
4075 }
4076 function cleanupListener() {
4077 cleanupListenerRef.current?.();
4078 cleanupListenerRef.current = null;
4079 }
4080 const win = getWindow(floating);
4081 function handleMouseMove(event) {
4082 const target = getTarget(event);
4083 if (!contains(floating, target)) {
4084 setReference(event.clientX, event.clientY);
4085 } else {
4086 cleanupListener();
4087 }
4088 }
4089 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4090 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4091 } else {
4092 resetReference(domReference);
4093 }
4094 return cleanupListener;
4095 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
4096 React17.useEffect(() => () => {
4097 store.set("positionReference", null);
4098 }, [store]);
4099 React17.useEffect(() => {
4100 if (enabled && !floating) {
4101 initialRef.current = false;
4102 }
4103 }, [enabled, floating]);
4104 React17.useEffect(() => {
4105 if (!enabled && open) {
4106 initialRef.current = true;
4107 }
4108 }, [enabled, open]);
4109 const reference = React17.useMemo(() => {
4110 function setPointerTypeRef(event) {
4111 setPointerType(event.pointerType);
4112 }
4113 return {
4114 onPointerDown: setPointerTypeRef,
4115 onPointerEnter: setPointerTypeRef,
4116 onMouseMove: handleReferenceEnterOrMove,
4117 onMouseEnter: handleReferenceEnterOrMove
4118 };
4119 }, [handleReferenceEnterOrMove]);
4120 return React17.useMemo(() => enabled ? {
4121 reference,
4122 trigger: reference
4123 } : {}, [enabled, reference]);
4124 }
4125
4126 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
4127 var React18 = __toESM(require_react(), 1);
4128 function alwaysFalse() {
4129 return false;
4130 }
4131 function normalizeProp(normalizable) {
4132 return {
4133 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4134 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4135 };
4136 }
4137 function useDismiss(context, props = {}) {
4138 const {
4139 enabled = true,
4140 escapeKey: escapeKey2 = true,
4141 outsidePress: outsidePressProp = true,
4142 outsidePressEvent = "sloppy",
4143 referencePress = alwaysFalse,
4144 bubbles,
4145 externalTree
4146 } = props;
4147 const store = "rootStore" in context ? context.rootStore : context;
4148 const open = store.useState("open");
4149 const floatingElement = store.useState("floatingElement");
4150 const {
4151 dataRef
4152 } = store.context;
4153 const tree = useFloatingTree(externalTree);
4154 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4155 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4156 const outsidePressEnabled = outsidePress2 !== false;
4157 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4158 const {
4159 escapeKey: escapeKeyBubbles,
4160 outsidePress: outsidePressBubbles
4161 } = normalizeProp(bubbles);
4162 const pressStartedInsideRef = React18.useRef(false);
4163 const pressStartPreventedRef = React18.useRef(false);
4164 const suppressNextOutsideClickRef = React18.useRef(false);
4165 const isComposingRef = React18.useRef(false);
4166 const currentPointerTypeRef = React18.useRef("");
4167 const touchStateRef = React18.useRef(null);
4168 const cancelDismissOnEndTimeout = useTimeout();
4169 const clearInsideReactTreeTimeout = useTimeout();
4170 const clearInsideReactTree = useStableCallback(() => {
4171 clearInsideReactTreeTimeout.clear();
4172 dataRef.current.insideReactTree = false;
4173 });
4174 const hasBlockingChild = useStableCallback((bubbleKey) => {
4175 const nodeId = dataRef.current.floatingContext?.nodeId;
4176 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4177 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
4178 });
4179 const isEventWithinOwnElements = useStableCallback((event) => {
4180 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
4181 });
4182 const closeOnReferencePress = useStableCallback((event) => {
4183 if (!referencePress()) {
4184 return;
4185 }
4186 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4187 });
4188 const closeOnEscapeKeyDown = useStableCallback((event) => {
4189 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4190 return;
4191 }
4192 if (isComposingRef.current) {
4193 return;
4194 }
4195 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4196 return;
4197 }
4198 const native = isReactEvent(event) ? event.nativeEvent : event;
4199 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4200 store.setOpen(false, eventDetails);
4201 if (!eventDetails.isCanceled) {
4202 event.preventDefault();
4203 }
4204 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4205 event.stopPropagation();
4206 }
4207 });
4208 const markInsideReactTree = useStableCallback(() => {
4209 dataRef.current.insideReactTree = true;
4210 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4211 });
4212 const markPressStartedInsideReactTree = useStableCallback((event) => {
4213 if (!open || !enabled || event.button !== 0) {
4214 return;
4215 }
4216 const target = getTarget(event.nativeEvent);
4217 if (!contains(store.select("floatingElement"), target)) {
4218 return;
4219 }
4220 if (!pressStartedInsideRef.current) {
4221 pressStartedInsideRef.current = true;
4222 pressStartPreventedRef.current = false;
4223 }
4224 });
4225 const markInsidePressStartPrevented = useStableCallback((event) => {
4226 if (!open || !enabled) {
4227 return;
4228 }
4229 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4230 return;
4231 }
4232 if (pressStartedInsideRef.current) {
4233 pressStartPreventedRef.current = true;
4234 }
4235 });
4236 React18.useEffect(() => {
4237 if (!open || !enabled) {
4238 return void 0;
4239 }
4240 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4241 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4242 const compositionTimeout = new Timeout();
4243 const preventedPressSuppressionTimeout = new Timeout();
4244 function handleCompositionStart() {
4245 compositionTimeout.clear();
4246 isComposingRef.current = true;
4247 }
4248 function handleCompositionEnd() {
4249 compositionTimeout.start(
4250 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4251 // Only apply to WebKit for the test to remain 0ms.
4252 parts_exports.engine.webkit ? 5 : 0,
4253 () => {
4254 isComposingRef.current = false;
4255 }
4256 );
4257 }
4258 function suppressImmediateOutsideClickAfterPreventedStart() {
4259 suppressNextOutsideClickRef.current = true;
4260 preventedPressSuppressionTimeout.start(0, () => {
4261 suppressNextOutsideClickRef.current = false;
4262 });
4263 }
4264 function resetPressStartState() {
4265 pressStartedInsideRef.current = false;
4266 pressStartPreventedRef.current = false;
4267 }
4268 function getOutsidePressEvent() {
4269 const type = currentPointerTypeRef.current;
4270 const computedType = type === "pen" || !type ? "mouse" : type;
4271 const outsidePressEventValue = getOutsidePressEventProp();
4272 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4273 if (typeof resolved === "string") {
4274 return resolved;
4275 }
4276 return resolved[computedType];
4277 }
4278 function shouldIgnoreEvent(event) {
4279 const computedOutsidePressEvent = getOutsidePressEvent();
4280 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4281 }
4282 function isEventWithinFloatingTree(event) {
4283 const nodeId = dataRef.current.floatingContext?.nodeId;
4284 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4285 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4286 }
4287 function closeOnPressOutside(event) {
4288 if (shouldIgnoreEvent(event)) {
4289 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4290 preventedPressSuppressionTimeout.clear();
4291 suppressNextOutsideClickRef.current = false;
4292 }
4293 clearInsideReactTree();
4294 return;
4295 }
4296 if (dataRef.current.insideReactTree) {
4297 clearInsideReactTree();
4298 return;
4299 }
4300 const target = getTarget(event);
4301 const inertSelector = `[${createAttribute("inert")}]`;
4302 const targetRoot = isElement(target) ? target.getRootNode() : null;
4303 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4304 const triggers = store.context.triggerElements;
4305 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4306 return;
4307 }
4308 let targetRootAncestor = isElement(target) ? target : null;
4309 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4310 const nextParent = getParentNode(targetRootAncestor);
4311 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4312 break;
4313 }
4314 targetRootAncestor = nextParent;
4315 }
4316 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4317 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4318 // element was injected after the floating element rendered.
4319 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4320 return;
4321 }
4322 if (isHTMLElement(target) && !("touches" in event)) {
4323 const lastTraversableNode = isLastTraversableNode(target);
4324 const style = getComputedStyle2(target);
4325 const scrollRe = /auto|scroll/;
4326 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4327 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4328 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4329 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4330 const isRTL7 = style.direction === "rtl";
4331 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4332 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4333 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4334 return;
4335 }
4336 }
4337 if (isEventWithinFloatingTree(event)) {
4338 return;
4339 }
4340 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4341 preventedPressSuppressionTimeout.clear();
4342 suppressNextOutsideClickRef.current = false;
4343 return;
4344 }
4345 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4346 return;
4347 }
4348 if (hasBlockingChild("__outsidePressBubbles")) {
4349 return;
4350 }
4351 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4352 clearInsideReactTree();
4353 }
4354 function handlePointerDown(event) {
4355 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4356 return;
4357 }
4358 closeOnPressOutside(event);
4359 }
4360 function handleTouchStart(event) {
4361 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4362 return;
4363 }
4364 const touch = event.touches[0];
4365 if (touch) {
4366 touchStateRef.current = {
4367 startTime: Date.now(),
4368 startX: touch.clientX,
4369 startY: touch.clientY,
4370 dismissOnTouchEnd: false,
4371 dismissOnMouseDown: true
4372 };
4373 cancelDismissOnEndTimeout.start(1e3, () => {
4374 if (touchStateRef.current) {
4375 touchStateRef.current.dismissOnTouchEnd = false;
4376 touchStateRef.current.dismissOnMouseDown = false;
4377 }
4378 });
4379 }
4380 }
4381 function addTargetEventListenerOnce(event, listener) {
4382 const target = getTarget(event);
4383 if (!target) {
4384 return;
4385 }
4386 const unsubscribe2 = addEventListener(target, event.type, () => {
4387 listener(event);
4388 unsubscribe2();
4389 });
4390 }
4391 function handleTouchStartCapture(event) {
4392 currentPointerTypeRef.current = "touch";
4393 addTargetEventListenerOnce(event, handleTouchStart);
4394 }
4395 function closeOnPressOutsideCapture(event) {
4396 cancelDismissOnEndTimeout.clear();
4397 if (event.type === "pointerdown") {
4398 currentPointerTypeRef.current = event.pointerType;
4399 }
4400 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4401 return;
4402 }
4403 addTargetEventListenerOnce(event, (targetEvent) => {
4404 if (targetEvent.type === "pointerdown") {
4405 handlePointerDown(targetEvent);
4406 } else {
4407 closeOnPressOutside(targetEvent);
4408 }
4409 });
4410 }
4411 function handlePressEndCapture(event) {
4412 if (!pressStartedInsideRef.current) {
4413 return;
4414 }
4415 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4416 resetPressStartState();
4417 if (getOutsidePressEvent() !== "intentional") {
4418 return;
4419 }
4420 if (event.type === "pointercancel") {
4421 if (pressStartedInsideDefaultPrevented) {
4422 suppressImmediateOutsideClickAfterPreventedStart();
4423 }
4424 return;
4425 }
4426 if (isEventWithinFloatingTree(event)) {
4427 return;
4428 }
4429 if (pressStartedInsideDefaultPrevented) {
4430 suppressImmediateOutsideClickAfterPreventedStart();
4431 return;
4432 }
4433 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4434 return;
4435 }
4436 preventedPressSuppressionTimeout.clear();
4437 suppressNextOutsideClickRef.current = true;
4438 clearInsideReactTree();
4439 }
4440 function handleTouchMove(event) {
4441 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4442 return;
4443 }
4444 const touch = event.touches[0];
4445 if (!touch) {
4446 return;
4447 }
4448 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4449 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4450 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4451 if (distance > 5) {
4452 touchStateRef.current.dismissOnTouchEnd = true;
4453 }
4454 if (distance > 10) {
4455 closeOnPressOutside(event);
4456 cancelDismissOnEndTimeout.clear();
4457 touchStateRef.current = null;
4458 }
4459 }
4460 function handleTouchMoveCapture(event) {
4461 addTargetEventListenerOnce(event, handleTouchMove);
4462 }
4463 function handleTouchEnd(event) {
4464 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4465 return;
4466 }
4467 if (touchStateRef.current.dismissOnTouchEnd) {
4468 closeOnPressOutside(event);
4469 }
4470 cancelDismissOnEndTimeout.clear();
4471 touchStateRef.current = null;
4472 }
4473 function handleTouchEndCapture(event) {
4474 addTargetEventListenerOnce(event, handleTouchEnd);
4475 }
4476 const doc = ownerDocument(floatingElement);
4477 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)));
4478 return () => {
4479 unsubscribe();
4480 compositionTimeout.clear();
4481 preventedPressSuppressionTimeout.clear();
4482 resetPressStartState();
4483 suppressNextOutsideClickRef.current = false;
4484 };
4485 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4486 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4487 const reference = React18.useMemo(() => ({
4488 onKeyDown: closeOnEscapeKeyDown,
4489 onPointerDown: closeOnReferencePress,
4490 onClick: closeOnReferencePress
4491 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4492 const floating = React18.useMemo(() => ({
4493 onKeyDown: closeOnEscapeKeyDown,
4494 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4495 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4496 // See https://github.com/mui/base-ui/pull/3379
4497 onPointerDown: markInsidePressStartPrevented,
4498 onMouseDown: markInsidePressStartPrevented,
4499 onClickCapture: markInsideReactTree,
4500 onMouseDownCapture(event) {
4501 markInsideReactTree();
4502 markPressStartedInsideReactTree(event);
4503 },
4504 onPointerDownCapture(event) {
4505 markInsideReactTree();
4506 markPressStartedInsideReactTree(event);
4507 },
4508 onMouseUpCapture: markInsideReactTree,
4509 onTouchEndCapture: markInsideReactTree,
4510 onTouchMoveCapture: markInsideReactTree
4511 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4512 return React18.useMemo(() => enabled ? {
4513 reference,
4514 floating,
4515 trigger: reference
4516 } : {}, [enabled, reference, floating]);
4517 }
4518
4519 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4520 var React25 = __toESM(require_react(), 1);
4521
4522 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4523 function computeCoordsFromPlacement(_ref, placement, rtl) {
4524 let {
4525 reference,
4526 floating
4527 } = _ref;
4528 const sideAxis = getSideAxis(placement);
4529 const alignmentAxis = getAlignmentAxis(placement);
4530 const alignLength = getAxisLength(alignmentAxis);
4531 const side = getSide(placement);
4532 const isVertical = sideAxis === "y";
4533 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4534 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4535 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4536 let coords;
4537 switch (side) {
4538 case "top":
4539 coords = {
4540 x: commonX,
4541 y: reference.y - floating.height
4542 };
4543 break;
4544 case "bottom":
4545 coords = {
4546 x: commonX,
4547 y: reference.y + reference.height
4548 };
4549 break;
4550 case "right":
4551 coords = {
4552 x: reference.x + reference.width,
4553 y: commonY
4554 };
4555 break;
4556 case "left":
4557 coords = {
4558 x: reference.x - floating.width,
4559 y: commonY
4560 };
4561 break;
4562 default:
4563 coords = {
4564 x: reference.x,
4565 y: reference.y
4566 };
4567 }
4568 switch (getAlignment(placement)) {
4569 case "start":
4570 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4571 break;
4572 case "end":
4573 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4574 break;
4575 }
4576 return coords;
4577 }
4578 async function detectOverflow(state, options) {
4579 var _await$platform$isEle;
4580 if (options === void 0) {
4581 options = {};
4582 }
4583 const {
4584 x: x2,
4585 y: y2,
4586 platform: platform3,
4587 rects,
4588 elements,
4589 strategy
4590 } = state;
4591 const {
4592 boundary = "clippingAncestors",
4593 rootBoundary = "viewport",
4594 elementContext = "floating",
4595 altBoundary = false,
4596 padding = 0
4597 } = evaluate(options, state);
4598 const paddingObject = getPaddingObject(padding);
4599 const altContext = elementContext === "floating" ? "reference" : "floating";
4600 const element = elements[altBoundary ? altContext : elementContext];
4601 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4602 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)),
4603 boundary,
4604 rootBoundary,
4605 strategy
4606 }));
4607 const rect = elementContext === "floating" ? {
4608 x: x2,
4609 y: y2,
4610 width: rects.floating.width,
4611 height: rects.floating.height
4612 } : rects.reference;
4613 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4614 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4615 x: 1,
4616 y: 1
4617 } : {
4618 x: 1,
4619 y: 1
4620 };
4621 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4622 elements,
4623 rect,
4624 offsetParent,
4625 strategy
4626 }) : rect);
4627 return {
4628 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4629 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4630 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4631 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4632 };
4633 }
4634 var MAX_RESET_COUNT = 50;
4635 var computePosition = async (reference, floating, config) => {
4636 const {
4637 placement = "bottom",
4638 strategy = "absolute",
4639 middleware = [],
4640 platform: platform3
4641 } = config;
4642 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4643 ...platform3,
4644 detectOverflow
4645 };
4646 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4647 let rects = await platform3.getElementRects({
4648 reference,
4649 floating,
4650 strategy
4651 });
4652 let {
4653 x: x2,
4654 y: y2
4655 } = computeCoordsFromPlacement(rects, placement, rtl);
4656 let statefulPlacement = placement;
4657 let resetCount = 0;
4658 const middlewareData = {};
4659 for (let i2 = 0; i2 < middleware.length; i2++) {
4660 const currentMiddleware = middleware[i2];
4661 if (!currentMiddleware) {
4662 continue;
4663 }
4664 const {
4665 name,
4666 fn
4667 } = currentMiddleware;
4668 const {
4669 x: nextX,
4670 y: nextY,
4671 data,
4672 reset
4673 } = await fn({
4674 x: x2,
4675 y: y2,
4676 initialPlacement: placement,
4677 placement: statefulPlacement,
4678 strategy,
4679 middlewareData,
4680 rects,
4681 platform: platformWithDetectOverflow,
4682 elements: {
4683 reference,
4684 floating
4685 }
4686 });
4687 x2 = nextX != null ? nextX : x2;
4688 y2 = nextY != null ? nextY : y2;
4689 middlewareData[name] = {
4690 ...middlewareData[name],
4691 ...data
4692 };
4693 if (reset && resetCount < MAX_RESET_COUNT) {
4694 resetCount++;
4695 if (typeof reset === "object") {
4696 if (reset.placement) {
4697 statefulPlacement = reset.placement;
4698 }
4699 if (reset.rects) {
4700 rects = reset.rects === true ? await platform3.getElementRects({
4701 reference,
4702 floating,
4703 strategy
4704 }) : reset.rects;
4705 }
4706 ({
4707 x: x2,
4708 y: y2
4709 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4710 }
4711 i2 = -1;
4712 }
4713 }
4714 return {
4715 x: x2,
4716 y: y2,
4717 placement: statefulPlacement,
4718 strategy,
4719 middlewareData
4720 };
4721 };
4722 var flip = function(options) {
4723 if (options === void 0) {
4724 options = {};
4725 }
4726 return {
4727 name: "flip",
4728 options,
4729 async fn(state) {
4730 var _middlewareData$arrow, _middlewareData$flip;
4731 const {
4732 placement,
4733 middlewareData,
4734 rects,
4735 initialPlacement,
4736 platform: platform3,
4737 elements
4738 } = state;
4739 const {
4740 mainAxis: checkMainAxis = true,
4741 crossAxis: checkCrossAxis = true,
4742 fallbackPlacements: specifiedFallbackPlacements,
4743 fallbackStrategy = "bestFit",
4744 fallbackAxisSideDirection = "none",
4745 flipAlignment = true,
4746 ...detectOverflowOptions
4747 } = evaluate(options, state);
4748 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4749 return {};
4750 }
4751 const side = getSide(placement);
4752 const initialSideAxis = getSideAxis(initialPlacement);
4753 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4754 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4755 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4756 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4757 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4758 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4759 }
4760 const placements2 = [initialPlacement, ...fallbackPlacements];
4761 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4762 const overflows = [];
4763 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4764 if (checkMainAxis) {
4765 overflows.push(overflow[side]);
4766 }
4767 if (checkCrossAxis) {
4768 const sides2 = getAlignmentSides(placement, rects, rtl);
4769 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4770 }
4771 overflowsData = [...overflowsData, {
4772 placement,
4773 overflows
4774 }];
4775 if (!overflows.every((side2) => side2 <= 0)) {
4776 var _middlewareData$flip2, _overflowsData$filter;
4777 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4778 const nextPlacement = placements2[nextIndex];
4779 if (nextPlacement) {
4780 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4781 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4782 // overflows the main axis.
4783 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4784 return {
4785 data: {
4786 index: nextIndex,
4787 overflows: overflowsData
4788 },
4789 reset: {
4790 placement: nextPlacement
4791 }
4792 };
4793 }
4794 }
4795 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;
4796 if (!resetPlacement) {
4797 switch (fallbackStrategy) {
4798 case "bestFit": {
4799 var _overflowsData$filter2;
4800 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4801 if (hasFallbackAxisSideDirection) {
4802 const currentSideAxis = getSideAxis(d2.placement);
4803 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4804 // reading directions favoring greater width.
4805 currentSideAxis === "y";
4806 }
4807 return true;
4808 }).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];
4809 if (placement2) {
4810 resetPlacement = placement2;
4811 }
4812 break;
4813 }
4814 case "initialPlacement":
4815 resetPlacement = initialPlacement;
4816 break;
4817 }
4818 }
4819 if (placement !== resetPlacement) {
4820 return {
4821 reset: {
4822 placement: resetPlacement
4823 }
4824 };
4825 }
4826 }
4827 return {};
4828 }
4829 };
4830 };
4831 function getSideOffsets(overflow, rect) {
4832 return {
4833 top: overflow.top - rect.height,
4834 right: overflow.right - rect.width,
4835 bottom: overflow.bottom - rect.height,
4836 left: overflow.left - rect.width
4837 };
4838 }
4839 function isAnySideFullyClipped(overflow) {
4840 return sides.some((side) => overflow[side] >= 0);
4841 }
4842 var hide = function(options) {
4843 if (options === void 0) {
4844 options = {};
4845 }
4846 return {
4847 name: "hide",
4848 options,
4849 async fn(state) {
4850 const {
4851 rects,
4852 platform: platform3
4853 } = state;
4854 const {
4855 strategy = "referenceHidden",
4856 ...detectOverflowOptions
4857 } = evaluate(options, state);
4858 switch (strategy) {
4859 case "referenceHidden": {
4860 const overflow = await platform3.detectOverflow(state, {
4861 ...detectOverflowOptions,
4862 elementContext: "reference"
4863 });
4864 const offsets = getSideOffsets(overflow, rects.reference);
4865 return {
4866 data: {
4867 referenceHiddenOffsets: offsets,
4868 referenceHidden: isAnySideFullyClipped(offsets)
4869 }
4870 };
4871 }
4872 case "escaped": {
4873 const overflow = await platform3.detectOverflow(state, {
4874 ...detectOverflowOptions,
4875 altBoundary: true
4876 });
4877 const offsets = getSideOffsets(overflow, rects.floating);
4878 return {
4879 data: {
4880 escapedOffsets: offsets,
4881 escaped: isAnySideFullyClipped(offsets)
4882 }
4883 };
4884 }
4885 default: {
4886 return {};
4887 }
4888 }
4889 }
4890 };
4891 };
4892 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4893 async function convertValueToCoords(state, options) {
4894 const {
4895 placement,
4896 platform: platform3,
4897 elements
4898 } = state;
4899 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4900 const side = getSide(placement);
4901 const alignment = getAlignment(placement);
4902 const isVertical = getSideAxis(placement) === "y";
4903 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4904 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4905 const rawValue = evaluate(options, state);
4906 let {
4907 mainAxis,
4908 crossAxis,
4909 alignmentAxis
4910 } = typeof rawValue === "number" ? {
4911 mainAxis: rawValue,
4912 crossAxis: 0,
4913 alignmentAxis: null
4914 } : {
4915 mainAxis: rawValue.mainAxis || 0,
4916 crossAxis: rawValue.crossAxis || 0,
4917 alignmentAxis: rawValue.alignmentAxis
4918 };
4919 if (alignment && typeof alignmentAxis === "number") {
4920 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4921 }
4922 return isVertical ? {
4923 x: crossAxis * crossAxisMulti,
4924 y: mainAxis * mainAxisMulti
4925 } : {
4926 x: mainAxis * mainAxisMulti,
4927 y: crossAxis * crossAxisMulti
4928 };
4929 }
4930 var offset = function(options) {
4931 if (options === void 0) {
4932 options = 0;
4933 }
4934 return {
4935 name: "offset",
4936 options,
4937 async fn(state) {
4938 var _middlewareData$offse, _middlewareData$arrow;
4939 const {
4940 x: x2,
4941 y: y2,
4942 placement,
4943 middlewareData
4944 } = state;
4945 const diffCoords = await convertValueToCoords(state, options);
4946 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4947 return {};
4948 }
4949 return {
4950 x: x2 + diffCoords.x,
4951 y: y2 + diffCoords.y,
4952 data: {
4953 ...diffCoords,
4954 placement
4955 }
4956 };
4957 }
4958 };
4959 };
4960 var shift = function(options) {
4961 if (options === void 0) {
4962 options = {};
4963 }
4964 return {
4965 name: "shift",
4966 options,
4967 async fn(state) {
4968 const {
4969 x: x2,
4970 y: y2,
4971 placement,
4972 platform: platform3
4973 } = state;
4974 const {
4975 mainAxis: checkMainAxis = true,
4976 crossAxis: checkCrossAxis = false,
4977 limiter = {
4978 fn: (_ref) => {
4979 let {
4980 x: x3,
4981 y: y3
4982 } = _ref;
4983 return {
4984 x: x3,
4985 y: y3
4986 };
4987 }
4988 },
4989 ...detectOverflowOptions
4990 } = evaluate(options, state);
4991 const coords = {
4992 x: x2,
4993 y: y2
4994 };
4995 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4996 const crossAxis = getSideAxis(getSide(placement));
4997 const mainAxis = getOppositeAxis(crossAxis);
4998 let mainAxisCoord = coords[mainAxis];
4999 let crossAxisCoord = coords[crossAxis];
5000 if (checkMainAxis) {
5001 const minSide = mainAxis === "y" ? "top" : "left";
5002 const maxSide = mainAxis === "y" ? "bottom" : "right";
5003 const min2 = mainAxisCoord + overflow[minSide];
5004 const max2 = mainAxisCoord - overflow[maxSide];
5005 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5006 }
5007 if (checkCrossAxis) {
5008 const minSide = crossAxis === "y" ? "top" : "left";
5009 const maxSide = crossAxis === "y" ? "bottom" : "right";
5010 const min2 = crossAxisCoord + overflow[minSide];
5011 const max2 = crossAxisCoord - overflow[maxSide];
5012 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5013 }
5014 const limitedCoords = limiter.fn({
5015 ...state,
5016 [mainAxis]: mainAxisCoord,
5017 [crossAxis]: crossAxisCoord
5018 });
5019 return {
5020 ...limitedCoords,
5021 data: {
5022 x: limitedCoords.x - x2,
5023 y: limitedCoords.y - y2,
5024 enabled: {
5025 [mainAxis]: checkMainAxis,
5026 [crossAxis]: checkCrossAxis
5027 }
5028 }
5029 };
5030 }
5031 };
5032 };
5033 var limitShift = function(options) {
5034 if (options === void 0) {
5035 options = {};
5036 }
5037 return {
5038 options,
5039 fn(state) {
5040 const {
5041 x: x2,
5042 y: y2,
5043 placement,
5044 rects,
5045 middlewareData
5046 } = state;
5047 const {
5048 offset: offset4 = 0,
5049 mainAxis: checkMainAxis = true,
5050 crossAxis: checkCrossAxis = true
5051 } = evaluate(options, state);
5052 const coords = {
5053 x: x2,
5054 y: y2
5055 };
5056 const crossAxis = getSideAxis(placement);
5057 const mainAxis = getOppositeAxis(crossAxis);
5058 let mainAxisCoord = coords[mainAxis];
5059 let crossAxisCoord = coords[crossAxis];
5060 const rawOffset = evaluate(offset4, state);
5061 const computedOffset = typeof rawOffset === "number" ? {
5062 mainAxis: rawOffset,
5063 crossAxis: 0
5064 } : {
5065 mainAxis: 0,
5066 crossAxis: 0,
5067 ...rawOffset
5068 };
5069 if (checkMainAxis) {
5070 const len = mainAxis === "y" ? "height" : "width";
5071 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5072 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5073 if (mainAxisCoord < limitMin) {
5074 mainAxisCoord = limitMin;
5075 } else if (mainAxisCoord > limitMax) {
5076 mainAxisCoord = limitMax;
5077 }
5078 }
5079 if (checkCrossAxis) {
5080 var _middlewareData$offse, _middlewareData$offse2;
5081 const len = mainAxis === "y" ? "width" : "height";
5082 const isOriginSide = originSides.has(getSide(placement));
5083 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);
5084 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);
5085 if (crossAxisCoord < limitMin) {
5086 crossAxisCoord = limitMin;
5087 } else if (crossAxisCoord > limitMax) {
5088 crossAxisCoord = limitMax;
5089 }
5090 }
5091 return {
5092 [mainAxis]: mainAxisCoord,
5093 [crossAxis]: crossAxisCoord
5094 };
5095 }
5096 };
5097 };
5098 var size = function(options) {
5099 if (options === void 0) {
5100 options = {};
5101 }
5102 return {
5103 name: "size",
5104 options,
5105 async fn(state) {
5106 var _state$middlewareData, _state$middlewareData2;
5107 const {
5108 placement,
5109 rects,
5110 platform: platform3,
5111 elements
5112 } = state;
5113 const {
5114 apply = () => {
5115 },
5116 ...detectOverflowOptions
5117 } = evaluate(options, state);
5118 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5119 const side = getSide(placement);
5120 const alignment = getAlignment(placement);
5121 const isYAxis = getSideAxis(placement) === "y";
5122 const {
5123 width,
5124 height
5125 } = rects.floating;
5126 let heightSide;
5127 let widthSide;
5128 if (side === "top" || side === "bottom") {
5129 heightSide = side;
5130 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5131 } else {
5132 widthSide = side;
5133 heightSide = alignment === "end" ? "top" : "bottom";
5134 }
5135 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5136 const maximumClippingWidth = width - overflow.left - overflow.right;
5137 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5138 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5139 const noShift = !state.middlewareData.shift;
5140 let availableHeight = overflowAvailableHeight;
5141 let availableWidth = overflowAvailableWidth;
5142 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5143 availableWidth = maximumClippingWidth;
5144 }
5145 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5146 availableHeight = maximumClippingHeight;
5147 }
5148 if (noShift && !alignment) {
5149 const xMin = max(overflow.left, 0);
5150 const xMax = max(overflow.right, 0);
5151 const yMin = max(overflow.top, 0);
5152 const yMax = max(overflow.bottom, 0);
5153 if (isYAxis) {
5154 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5155 } else {
5156 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5157 }
5158 }
5159 await apply({
5160 ...state,
5161 availableWidth,
5162 availableHeight
5163 });
5164 const nextDimensions = await platform3.getDimensions(elements.floating);
5165 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5166 return {
5167 reset: {
5168 rects: true
5169 }
5170 };
5171 }
5172 return {};
5173 }
5174 };
5175 };
5176
5177 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5178 function getCssDimensions(element) {
5179 const css = getComputedStyle2(element);
5180 let width = parseFloat(css.width) || 0;
5181 let height = parseFloat(css.height) || 0;
5182 const hasOffset = isHTMLElement(element);
5183 const offsetWidth = hasOffset ? element.offsetWidth : width;
5184 const offsetHeight = hasOffset ? element.offsetHeight : height;
5185 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5186 if (shouldFallback) {
5187 width = offsetWidth;
5188 height = offsetHeight;
5189 }
5190 return {
5191 width,
5192 height,
5193 $: shouldFallback
5194 };
5195 }
5196 function unwrapElement(element) {
5197 return !isElement(element) ? element.contextElement : element;
5198 }
5199 function getScale(element) {
5200 const domElement = unwrapElement(element);
5201 if (!isHTMLElement(domElement)) {
5202 return createCoords(1);
5203 }
5204 const rect = domElement.getBoundingClientRect();
5205 const {
5206 width,
5207 height,
5208 $: $2
5209 } = getCssDimensions(domElement);
5210 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5211 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5212 if (!x2 || !Number.isFinite(x2)) {
5213 x2 = 1;
5214 }
5215 if (!y2 || !Number.isFinite(y2)) {
5216 y2 = 1;
5217 }
5218 return {
5219 x: x2,
5220 y: y2
5221 };
5222 }
5223 var noOffsets = /* @__PURE__ */ createCoords(0);
5224 function getVisualOffsets(element) {
5225 const win = getWindow(element);
5226 if (!isWebKit() || !win.visualViewport) {
5227 return noOffsets;
5228 }
5229 return {
5230 x: win.visualViewport.offsetLeft,
5231 y: win.visualViewport.offsetTop
5232 };
5233 }
5234 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5235 if (isFixed === void 0) {
5236 isFixed = false;
5237 }
5238 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5239 return false;
5240 }
5241 return isFixed;
5242 }
5243 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5244 if (includeScale === void 0) {
5245 includeScale = false;
5246 }
5247 if (isFixedStrategy === void 0) {
5248 isFixedStrategy = false;
5249 }
5250 const clientRect = element.getBoundingClientRect();
5251 const domElement = unwrapElement(element);
5252 let scale = createCoords(1);
5253 if (includeScale) {
5254 if (offsetParent) {
5255 if (isElement(offsetParent)) {
5256 scale = getScale(offsetParent);
5257 }
5258 } else {
5259 scale = getScale(element);
5260 }
5261 }
5262 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5263 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5264 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5265 let width = clientRect.width / scale.x;
5266 let height = clientRect.height / scale.y;
5267 if (domElement) {
5268 const win = getWindow(domElement);
5269 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5270 let currentWin = win;
5271 let currentIFrame = getFrameElement(currentWin);
5272 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5273 const iframeScale = getScale(currentIFrame);
5274 const iframeRect = currentIFrame.getBoundingClientRect();
5275 const css = getComputedStyle2(currentIFrame);
5276 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5277 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5278 x2 *= iframeScale.x;
5279 y2 *= iframeScale.y;
5280 width *= iframeScale.x;
5281 height *= iframeScale.y;
5282 x2 += left;
5283 y2 += top;
5284 currentWin = getWindow(currentIFrame);
5285 currentIFrame = getFrameElement(currentWin);
5286 }
5287 }
5288 return rectToClientRect({
5289 width,
5290 height,
5291 x: x2,
5292 y: y2
5293 });
5294 }
5295 function getWindowScrollBarX(element, rect) {
5296 const leftScroll = getNodeScroll(element).scrollLeft;
5297 if (!rect) {
5298 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5299 }
5300 return rect.left + leftScroll;
5301 }
5302 function getHTMLOffset(documentElement, scroll) {
5303 const htmlRect = documentElement.getBoundingClientRect();
5304 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5305 const y2 = htmlRect.top + scroll.scrollTop;
5306 return {
5307 x: x2,
5308 y: y2
5309 };
5310 }
5311 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5312 let {
5313 elements,
5314 rect,
5315 offsetParent,
5316 strategy
5317 } = _ref;
5318 const isFixed = strategy === "fixed";
5319 const documentElement = getDocumentElement(offsetParent);
5320 const topLayer = elements ? isTopLayer(elements.floating) : false;
5321 if (offsetParent === documentElement || topLayer && isFixed) {
5322 return rect;
5323 }
5324 let scroll = {
5325 scrollLeft: 0,
5326 scrollTop: 0
5327 };
5328 let scale = createCoords(1);
5329 const offsets = createCoords(0);
5330 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5331 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5332 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5333 scroll = getNodeScroll(offsetParent);
5334 }
5335 if (isOffsetParentAnElement) {
5336 const offsetRect = getBoundingClientRect(offsetParent);
5337 scale = getScale(offsetParent);
5338 offsets.x = offsetRect.x + offsetParent.clientLeft;
5339 offsets.y = offsetRect.y + offsetParent.clientTop;
5340 }
5341 }
5342 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5343 return {
5344 width: rect.width * scale.x,
5345 height: rect.height * scale.y,
5346 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5347 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5348 };
5349 }
5350 function getClientRects(element) {
5351 return Array.from(element.getClientRects());
5352 }
5353 function getDocumentRect(element) {
5354 const html = getDocumentElement(element);
5355 const scroll = getNodeScroll(element);
5356 const body = element.ownerDocument.body;
5357 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5358 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5359 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5360 const y2 = -scroll.scrollTop;
5361 if (getComputedStyle2(body).direction === "rtl") {
5362 x2 += max(html.clientWidth, body.clientWidth) - width;
5363 }
5364 return {
5365 width,
5366 height,
5367 x: x2,
5368 y: y2
5369 };
5370 }
5371 var SCROLLBAR_MAX = 25;
5372 function getViewportRect(element, strategy) {
5373 const win = getWindow(element);
5374 const html = getDocumentElement(element);
5375 const visualViewport = win.visualViewport;
5376 let width = html.clientWidth;
5377 let height = html.clientHeight;
5378 let x2 = 0;
5379 let y2 = 0;
5380 if (visualViewport) {
5381 width = visualViewport.width;
5382 height = visualViewport.height;
5383 const visualViewportBased = isWebKit();
5384 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5385 x2 = visualViewport.offsetLeft;
5386 y2 = visualViewport.offsetTop;
5387 }
5388 }
5389 const windowScrollbarX = getWindowScrollBarX(html);
5390 if (windowScrollbarX <= 0) {
5391 const doc = html.ownerDocument;
5392 const body = doc.body;
5393 const bodyStyles = getComputedStyle(body);
5394 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5395 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5396 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5397 width -= clippingStableScrollbarWidth;
5398 }
5399 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5400 width += windowScrollbarX;
5401 }
5402 return {
5403 width,
5404 height,
5405 x: x2,
5406 y: y2
5407 };
5408 }
5409 function getInnerBoundingClientRect(element, strategy) {
5410 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5411 const top = clientRect.top + element.clientTop;
5412 const left = clientRect.left + element.clientLeft;
5413 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5414 const width = element.clientWidth * scale.x;
5415 const height = element.clientHeight * scale.y;
5416 const x2 = left * scale.x;
5417 const y2 = top * scale.y;
5418 return {
5419 width,
5420 height,
5421 x: x2,
5422 y: y2
5423 };
5424 }
5425 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5426 let rect;
5427 if (clippingAncestor === "viewport") {
5428 rect = getViewportRect(element, strategy);
5429 } else if (clippingAncestor === "document") {
5430 rect = getDocumentRect(getDocumentElement(element));
5431 } else if (isElement(clippingAncestor)) {
5432 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5433 } else {
5434 const visualOffsets = getVisualOffsets(element);
5435 rect = {
5436 x: clippingAncestor.x - visualOffsets.x,
5437 y: clippingAncestor.y - visualOffsets.y,
5438 width: clippingAncestor.width,
5439 height: clippingAncestor.height
5440 };
5441 }
5442 return rectToClientRect(rect);
5443 }
5444 function hasFixedPositionAncestor(element, stopNode) {
5445 const parentNode = getParentNode(element);
5446 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5447 return false;
5448 }
5449 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5450 }
5451 function getClippingElementAncestors(element, cache) {
5452 const cachedResult = cache.get(element);
5453 if (cachedResult) {
5454 return cachedResult;
5455 }
5456 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5457 let currentContainingBlockComputedStyle = null;
5458 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5459 let currentNode = elementIsFixed ? getParentNode(element) : element;
5460 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5461 const computedStyle = getComputedStyle2(currentNode);
5462 const currentNodeIsContaining = isContainingBlock(currentNode);
5463 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5464 currentContainingBlockComputedStyle = null;
5465 }
5466 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5467 if (shouldDropCurrentNode) {
5468 result = result.filter((ancestor) => ancestor !== currentNode);
5469 } else {
5470 currentContainingBlockComputedStyle = computedStyle;
5471 }
5472 currentNode = getParentNode(currentNode);
5473 }
5474 cache.set(element, result);
5475 return result;
5476 }
5477 function getClippingRect(_ref) {
5478 let {
5479 element,
5480 boundary,
5481 rootBoundary,
5482 strategy
5483 } = _ref;
5484 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5485 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5486 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5487 let top = firstRect.top;
5488 let right = firstRect.right;
5489 let bottom = firstRect.bottom;
5490 let left = firstRect.left;
5491 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5492 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5493 top = max(rect.top, top);
5494 right = min(rect.right, right);
5495 bottom = min(rect.bottom, bottom);
5496 left = max(rect.left, left);
5497 }
5498 return {
5499 width: right - left,
5500 height: bottom - top,
5501 x: left,
5502 y: top
5503 };
5504 }
5505 function getDimensions(element) {
5506 const {
5507 width,
5508 height
5509 } = getCssDimensions(element);
5510 return {
5511 width,
5512 height
5513 };
5514 }
5515 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5516 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5517 const documentElement = getDocumentElement(offsetParent);
5518 const isFixed = strategy === "fixed";
5519 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5520 let scroll = {
5521 scrollLeft: 0,
5522 scrollTop: 0
5523 };
5524 const offsets = createCoords(0);
5525 function setLeftRTLScrollbarOffset() {
5526 offsets.x = getWindowScrollBarX(documentElement);
5527 }
5528 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5529 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5530 scroll = getNodeScroll(offsetParent);
5531 }
5532 if (isOffsetParentAnElement) {
5533 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5534 offsets.x = offsetRect.x + offsetParent.clientLeft;
5535 offsets.y = offsetRect.y + offsetParent.clientTop;
5536 } else if (documentElement) {
5537 setLeftRTLScrollbarOffset();
5538 }
5539 }
5540 if (isFixed && !isOffsetParentAnElement && documentElement) {
5541 setLeftRTLScrollbarOffset();
5542 }
5543 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5544 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5545 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5546 return {
5547 x: x2,
5548 y: y2,
5549 width: rect.width,
5550 height: rect.height
5551 };
5552 }
5553 function isStaticPositioned(element) {
5554 return getComputedStyle2(element).position === "static";
5555 }
5556 function getTrueOffsetParent(element, polyfill) {
5557 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5558 return null;
5559 }
5560 if (polyfill) {
5561 return polyfill(element);
5562 }
5563 let rawOffsetParent = element.offsetParent;
5564 if (getDocumentElement(element) === rawOffsetParent) {
5565 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5566 }
5567 return rawOffsetParent;
5568 }
5569 function getOffsetParent(element, polyfill) {
5570 const win = getWindow(element);
5571 if (isTopLayer(element)) {
5572 return win;
5573 }
5574 if (!isHTMLElement(element)) {
5575 let svgOffsetParent = getParentNode(element);
5576 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5577 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5578 return svgOffsetParent;
5579 }
5580 svgOffsetParent = getParentNode(svgOffsetParent);
5581 }
5582 return win;
5583 }
5584 let offsetParent = getTrueOffsetParent(element, polyfill);
5585 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5586 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5587 }
5588 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5589 return win;
5590 }
5591 return offsetParent || getContainingBlock(element) || win;
5592 }
5593 var getElementRects = async function(data) {
5594 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5595 const getDimensionsFn = this.getDimensions;
5596 const floatingDimensions = await getDimensionsFn(data.floating);
5597 return {
5598 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5599 floating: {
5600 x: 0,
5601 y: 0,
5602 width: floatingDimensions.width,
5603 height: floatingDimensions.height
5604 }
5605 };
5606 };
5607 function isRTL(element) {
5608 return getComputedStyle2(element).direction === "rtl";
5609 }
5610 var platform2 = {
5611 convertOffsetParentRelativeRectToViewportRelativeRect,
5612 getDocumentElement,
5613 getClippingRect,
5614 getOffsetParent,
5615 getElementRects,
5616 getClientRects,
5617 getDimensions,
5618 getScale,
5619 isElement,
5620 isRTL
5621 };
5622 function rectsAreEqual(a2, b2) {
5623 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5624 }
5625 function observeMove(element, onMove) {
5626 let io = null;
5627 let timeoutId;
5628 const root = getDocumentElement(element);
5629 function cleanup() {
5630 var _io;
5631 clearTimeout(timeoutId);
5632 (_io = io) == null || _io.disconnect();
5633 io = null;
5634 }
5635 function refresh(skip, threshold) {
5636 if (skip === void 0) {
5637 skip = false;
5638 }
5639 if (threshold === void 0) {
5640 threshold = 1;
5641 }
5642 cleanup();
5643 const elementRectForRootMargin = element.getBoundingClientRect();
5644 const {
5645 left,
5646 top,
5647 width,
5648 height
5649 } = elementRectForRootMargin;
5650 if (!skip) {
5651 onMove();
5652 }
5653 if (!width || !height) {
5654 return;
5655 }
5656 const insetTop = floor(top);
5657 const insetRight = floor(root.clientWidth - (left + width));
5658 const insetBottom = floor(root.clientHeight - (top + height));
5659 const insetLeft = floor(left);
5660 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5661 const options = {
5662 rootMargin,
5663 threshold: max(0, min(1, threshold)) || 1
5664 };
5665 let isFirstUpdate = true;
5666 function handleObserve(entries) {
5667 const ratio = entries[0].intersectionRatio;
5668 if (ratio !== threshold) {
5669 if (!isFirstUpdate) {
5670 return refresh();
5671 }
5672 if (!ratio) {
5673 timeoutId = setTimeout(() => {
5674 refresh(false, 1e-7);
5675 }, 1e3);
5676 } else {
5677 refresh(false, ratio);
5678 }
5679 }
5680 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5681 refresh();
5682 }
5683 isFirstUpdate = false;
5684 }
5685 try {
5686 io = new IntersectionObserver(handleObserve, {
5687 ...options,
5688 // Handle <iframe>s
5689 root: root.ownerDocument
5690 });
5691 } catch (_e) {
5692 io = new IntersectionObserver(handleObserve, options);
5693 }
5694 io.observe(element);
5695 }
5696 refresh(true);
5697 return cleanup;
5698 }
5699 function autoUpdate(reference, floating, update2, options) {
5700 if (options === void 0) {
5701 options = {};
5702 }
5703 const {
5704 ancestorScroll = true,
5705 ancestorResize = true,
5706 elementResize = typeof ResizeObserver === "function",
5707 layoutShift = typeof IntersectionObserver === "function",
5708 animationFrame = false
5709 } = options;
5710 const referenceEl = unwrapElement(reference);
5711 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5712 ancestors.forEach((ancestor) => {
5713 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5714 passive: true
5715 });
5716 ancestorResize && ancestor.addEventListener("resize", update2);
5717 });
5718 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5719 let reobserveFrame = -1;
5720 let resizeObserver = null;
5721 if (elementResize) {
5722 resizeObserver = new ResizeObserver((_ref) => {
5723 let [firstEntry] = _ref;
5724 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5725 resizeObserver.unobserve(floating);
5726 cancelAnimationFrame(reobserveFrame);
5727 reobserveFrame = requestAnimationFrame(() => {
5728 var _resizeObserver;
5729 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5730 });
5731 }
5732 update2();
5733 });
5734 if (referenceEl && !animationFrame) {
5735 resizeObserver.observe(referenceEl);
5736 }
5737 if (floating) {
5738 resizeObserver.observe(floating);
5739 }
5740 }
5741 let frameId;
5742 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5743 if (animationFrame) {
5744 frameLoop();
5745 }
5746 function frameLoop() {
5747 const nextRefRect = getBoundingClientRect(reference);
5748 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5749 update2();
5750 }
5751 prevRefRect = nextRefRect;
5752 frameId = requestAnimationFrame(frameLoop);
5753 }
5754 update2();
5755 return () => {
5756 var _resizeObserver2;
5757 ancestors.forEach((ancestor) => {
5758 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5759 ancestorResize && ancestor.removeEventListener("resize", update2);
5760 });
5761 cleanupIo == null || cleanupIo();
5762 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5763 resizeObserver = null;
5764 if (animationFrame) {
5765 cancelAnimationFrame(frameId);
5766 }
5767 };
5768 }
5769 var offset2 = offset;
5770 var shift2 = shift;
5771 var flip2 = flip;
5772 var size2 = size;
5773 var hide2 = hide;
5774 var limitShift2 = limitShift;
5775 var computePosition2 = (reference, floating, options) => {
5776 const cache = /* @__PURE__ */ new Map();
5777 const mergedOptions = {
5778 platform: platform2,
5779 ...options
5780 };
5781 const platformWithCache = {
5782 ...mergedOptions.platform,
5783 _c: cache
5784 };
5785 return computePosition(reference, floating, {
5786 ...mergedOptions,
5787 platform: platformWithCache
5788 });
5789 };
5790
5791 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5792 var React19 = __toESM(require_react(), 1);
5793 var import_react2 = __toESM(require_react(), 1);
5794 var ReactDOM3 = __toESM(require_react_dom(), 1);
5795 var isClient = typeof document !== "undefined";
5796 var noop3 = function noop4() {
5797 };
5798 var index = isClient ? import_react2.useLayoutEffect : noop3;
5799 function deepEqual(a2, b2) {
5800 if (a2 === b2) {
5801 return true;
5802 }
5803 if (typeof a2 !== typeof b2) {
5804 return false;
5805 }
5806 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5807 return true;
5808 }
5809 let length;
5810 let i2;
5811 let keys;
5812 if (a2 && b2 && typeof a2 === "object") {
5813 if (Array.isArray(a2)) {
5814 length = a2.length;
5815 if (length !== b2.length) return false;
5816 for (i2 = length; i2-- !== 0; ) {
5817 if (!deepEqual(a2[i2], b2[i2])) {
5818 return false;
5819 }
5820 }
5821 return true;
5822 }
5823 keys = Object.keys(a2);
5824 length = keys.length;
5825 if (length !== Object.keys(b2).length) {
5826 return false;
5827 }
5828 for (i2 = length; i2-- !== 0; ) {
5829 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5830 return false;
5831 }
5832 }
5833 for (i2 = length; i2-- !== 0; ) {
5834 const key = keys[i2];
5835 if (key === "_owner" && a2.$$typeof) {
5836 continue;
5837 }
5838 if (!deepEqual(a2[key], b2[key])) {
5839 return false;
5840 }
5841 }
5842 return true;
5843 }
5844 return a2 !== a2 && b2 !== b2;
5845 }
5846 function getDPR(element) {
5847 if (typeof window === "undefined") {
5848 return 1;
5849 }
5850 const win = element.ownerDocument.defaultView || window;
5851 return win.devicePixelRatio || 1;
5852 }
5853 function roundByDPR(element, value) {
5854 const dpr = getDPR(element);
5855 return Math.round(value * dpr) / dpr;
5856 }
5857 function useLatestRef(value) {
5858 const ref = React19.useRef(value);
5859 index(() => {
5860 ref.current = value;
5861 });
5862 return ref;
5863 }
5864 function useFloating(options) {
5865 if (options === void 0) {
5866 options = {};
5867 }
5868 const {
5869 placement = "bottom",
5870 strategy = "absolute",
5871 middleware = [],
5872 platform: platform3,
5873 elements: {
5874 reference: externalReference,
5875 floating: externalFloating
5876 } = {},
5877 transform = true,
5878 whileElementsMounted,
5879 open
5880 } = options;
5881 const [data, setData] = React19.useState({
5882 x: 0,
5883 y: 0,
5884 strategy,
5885 placement,
5886 middlewareData: {},
5887 isPositioned: false
5888 });
5889 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
5890 if (!deepEqual(latestMiddleware, middleware)) {
5891 setLatestMiddleware(middleware);
5892 }
5893 const [_reference, _setReference] = React19.useState(null);
5894 const [_floating, _setFloating] = React19.useState(null);
5895 const setReference = React19.useCallback((node) => {
5896 if (node !== referenceRef.current) {
5897 referenceRef.current = node;
5898 _setReference(node);
5899 }
5900 }, []);
5901 const setFloating = React19.useCallback((node) => {
5902 if (node !== floatingRef.current) {
5903 floatingRef.current = node;
5904 _setFloating(node);
5905 }
5906 }, []);
5907 const referenceEl = externalReference || _reference;
5908 const floatingEl = externalFloating || _floating;
5909 const referenceRef = React19.useRef(null);
5910 const floatingRef = React19.useRef(null);
5911 const dataRef = React19.useRef(data);
5912 const hasWhileElementsMounted = whileElementsMounted != null;
5913 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5914 const platformRef = useLatestRef(platform3);
5915 const openRef = useLatestRef(open);
5916 const update2 = React19.useCallback(() => {
5917 if (!referenceRef.current || !floatingRef.current) {
5918 return;
5919 }
5920 const config = {
5921 placement,
5922 strategy,
5923 middleware: latestMiddleware
5924 };
5925 if (platformRef.current) {
5926 config.platform = platformRef.current;
5927 }
5928 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5929 const fullData = {
5930 ...data2,
5931 // The floating element's position may be recomputed while it's closed
5932 // but still mounted (such as when transitioning out). To ensure
5933 // `isPositioned` will be `false` initially on the next open, avoid
5934 // setting it to `true` when `open === false` (must be specified).
5935 isPositioned: openRef.current !== false
5936 };
5937 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5938 dataRef.current = fullData;
5939 ReactDOM3.flushSync(() => {
5940 setData(fullData);
5941 });
5942 }
5943 });
5944 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5945 index(() => {
5946 if (open === false && dataRef.current.isPositioned) {
5947 dataRef.current.isPositioned = false;
5948 setData((data2) => ({
5949 ...data2,
5950 isPositioned: false
5951 }));
5952 }
5953 }, [open]);
5954 const isMountedRef = React19.useRef(false);
5955 index(() => {
5956 isMountedRef.current = true;
5957 return () => {
5958 isMountedRef.current = false;
5959 };
5960 }, []);
5961 index(() => {
5962 if (referenceEl) referenceRef.current = referenceEl;
5963 if (floatingEl) floatingRef.current = floatingEl;
5964 if (referenceEl && floatingEl) {
5965 if (whileElementsMountedRef.current) {
5966 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5967 }
5968 update2();
5969 }
5970 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5971 const refs = React19.useMemo(() => ({
5972 reference: referenceRef,
5973 floating: floatingRef,
5974 setReference,
5975 setFloating
5976 }), [setReference, setFloating]);
5977 const elements = React19.useMemo(() => ({
5978 reference: referenceEl,
5979 floating: floatingEl
5980 }), [referenceEl, floatingEl]);
5981 const floatingStyles = React19.useMemo(() => {
5982 const initialStyles = {
5983 position: strategy,
5984 left: 0,
5985 top: 0
5986 };
5987 if (!elements.floating) {
5988 return initialStyles;
5989 }
5990 const x2 = roundByDPR(elements.floating, data.x);
5991 const y2 = roundByDPR(elements.floating, data.y);
5992 if (transform) {
5993 return {
5994 ...initialStyles,
5995 transform: "translate(" + x2 + "px, " + y2 + "px)",
5996 ...getDPR(elements.floating) >= 1.5 && {
5997 willChange: "transform"
5998 }
5999 };
6000 }
6001 return {
6002 position: strategy,
6003 left: x2,
6004 top: y2
6005 };
6006 }, [strategy, transform, elements.floating, data.x, data.y]);
6007 return React19.useMemo(() => ({
6008 ...data,
6009 update: update2,
6010 refs,
6011 elements,
6012 floatingStyles
6013 }), [data, update2, refs, elements, floatingStyles]);
6014 }
6015 var offset3 = (options, deps) => {
6016 const result = offset2(options);
6017 return {
6018 name: result.name,
6019 fn: result.fn,
6020 options: [options, deps]
6021 };
6022 };
6023 var shift3 = (options, deps) => {
6024 const result = shift2(options);
6025 return {
6026 name: result.name,
6027 fn: result.fn,
6028 options: [options, deps]
6029 };
6030 };
6031 var limitShift3 = (options, deps) => {
6032 const result = limitShift2(options);
6033 return {
6034 fn: result.fn,
6035 options: [options, deps]
6036 };
6037 };
6038 var flip3 = (options, deps) => {
6039 const result = flip2(options);
6040 return {
6041 name: result.name,
6042 fn: result.fn,
6043 options: [options, deps]
6044 };
6045 };
6046 var size3 = (options, deps) => {
6047 const result = size2(options);
6048 return {
6049 name: result.name,
6050 fn: result.fn,
6051 options: [options, deps]
6052 };
6053 };
6054 var hide3 = (options, deps) => {
6055 const result = hide2(options);
6056 return {
6057 name: result.name,
6058 fn: result.fn,
6059 options: [options, deps]
6060 };
6061 };
6062
6063 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6064 var React24 = __toESM(require_react(), 1);
6065 var ReactDOM4 = __toESM(require_react_dom(), 1);
6066
6067 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6068 var React23 = __toESM(require_react(), 1);
6069
6070 // node_modules/@base-ui/utils/store/createSelector.mjs
6071 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6072 if (other.length > 0) {
6073 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6074 }
6075 let selector2;
6076 if (a2 && b2 && c2 && d2 && e2 && f2) {
6077 selector2 = (state, a1, a22, a3) => {
6078 const va = a2(state, a1, a22, a3);
6079 const vb = b2(state, a1, a22, a3);
6080 const vc = c2(state, a1, a22, a3);
6081 const vd = d2(state, a1, a22, a3);
6082 const ve = e2(state, a1, a22, a3);
6083 return f2(va, vb, vc, vd, ve, a1, a22, a3);
6084 };
6085 } else if (a2 && b2 && c2 && d2 && e2) {
6086 selector2 = (state, a1, a22, a3) => {
6087 const va = a2(state, a1, a22, a3);
6088 const vb = b2(state, a1, a22, a3);
6089 const vc = c2(state, a1, a22, a3);
6090 const vd = d2(state, a1, a22, a3);
6091 return e2(va, vb, vc, vd, a1, a22, a3);
6092 };
6093 } else if (a2 && b2 && c2 && d2) {
6094 selector2 = (state, a1, a22, a3) => {
6095 const va = a2(state, a1, a22, a3);
6096 const vb = b2(state, a1, a22, a3);
6097 const vc = c2(state, a1, a22, a3);
6098 return d2(va, vb, vc, a1, a22, a3);
6099 };
6100 } else if (a2 && b2 && c2) {
6101 selector2 = (state, a1, a22, a3) => {
6102 const va = a2(state, a1, a22, a3);
6103 const vb = b2(state, a1, a22, a3);
6104 return c2(va, vb, a1, a22, a3);
6105 };
6106 } else if (a2 && b2) {
6107 selector2 = (state, a1, a22, a3) => {
6108 const va = a2(state, a1, a22, a3);
6109 return b2(va, a1, a22, a3);
6110 };
6111 } else if (a2) {
6112 selector2 = a2;
6113 } else {
6114 throw (
6115 /* minify-error-disabled */
6116 new Error("Missing arguments")
6117 );
6118 }
6119 return selector2;
6120 };
6121
6122 // node_modules/@base-ui/utils/store/useStore.mjs
6123 var React21 = __toESM(require_react(), 1);
6124 var import_shim = __toESM(require_shim(), 1);
6125 var import_with_selector = __toESM(require_with_selector(), 1);
6126
6127 // node_modules/@base-ui/utils/fastHooks.mjs
6128 var React20 = __toESM(require_react(), 1);
6129 var hooks = [];
6130 var currentInstance = void 0;
6131 function getInstance() {
6132 return currentInstance;
6133 }
6134 function register(hook) {
6135 hooks.push(hook);
6136 }
6137 function fastComponent(fn) {
6138 const FastComponent = (props, forwardedRef) => {
6139 const instance = useRefWithInit(createInstance).current;
6140 let result;
6141 try {
6142 currentInstance = instance;
6143 for (const hook of hooks) {
6144 hook.before(instance);
6145 }
6146 result = fn(props, forwardedRef);
6147 for (const hook of hooks) {
6148 hook.after(instance);
6149 }
6150 instance.didInitialize = true;
6151 } finally {
6152 currentInstance = void 0;
6153 }
6154 return result;
6155 };
6156 FastComponent.displayName = fn.displayName || fn.name;
6157 return FastComponent;
6158 }
6159 function fastComponentRef(fn) {
6160 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
6161 }
6162 function createInstance() {
6163 return {
6164 didInitialize: false
6165 };
6166 }
6167
6168 // node_modules/@base-ui/utils/store/useStore.mjs
6169 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6170 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6171 function useStore(store, selector2, a1, a2, a3) {
6172 return useStoreImplementation(store, selector2, a1, a2, a3);
6173 }
6174 function useStoreR19(store, selector2, a1, a2, a3) {
6175 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6176 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6177 }
6178 register({
6179 before(instance) {
6180 instance.syncIndex = 0;
6181 if (!instance.didInitialize) {
6182 instance.syncTick = 1;
6183 instance.syncHooks = [];
6184 instance.didChangeStore = true;
6185 instance.getSnapshot = () => {
6186 let didChange2 = false;
6187 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6188 const hook = instance.syncHooks[i2];
6189 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6190 if (!Object.is(hook.value, value)) {
6191 didChange2 = true;
6192 hook.value = value;
6193 }
6194 }
6195 if (didChange2) {
6196 instance.syncTick += 1;
6197 }
6198 return instance.syncTick;
6199 };
6200 }
6201 },
6202 after(instance) {
6203 if (instance.syncHooks.length > 0) {
6204 if (instance.didChangeStore) {
6205 instance.didChangeStore = false;
6206 instance.subscribe = (onStoreChange) => {
6207 const stores = /* @__PURE__ */ new Set();
6208 for (const hook of instance.syncHooks) {
6209 stores.add(hook.store);
6210 }
6211 const unsubscribes = [];
6212 for (const store of stores) {
6213 unsubscribes.push(store.subscribe(onStoreChange));
6214 }
6215 return () => {
6216 for (const unsubscribe of unsubscribes) {
6217 unsubscribe();
6218 }
6219 };
6220 };
6221 }
6222 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6223 }
6224 }
6225 });
6226 function useStoreFast(store, selector2, a1, a2, a3) {
6227 const instance = getInstance();
6228 if (!instance) {
6229 return useStoreR19(store, selector2, a1, a2, a3);
6230 }
6231 const index2 = instance.syncIndex;
6232 instance.syncIndex += 1;
6233 let hook;
6234 if (!instance.didInitialize) {
6235 hook = {
6236 store,
6237 selector: selector2,
6238 a1,
6239 a2,
6240 a3,
6241 value: selector2(store.getSnapshot(), a1, a2, a3)
6242 };
6243 instance.syncHooks.push(hook);
6244 } else {
6245 hook = instance.syncHooks[index2];
6246 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6247 if (hook.store !== store) {
6248 instance.didChangeStore = true;
6249 }
6250 hook.store = store;
6251 hook.selector = selector2;
6252 hook.a1 = a1;
6253 hook.a2 = a2;
6254 hook.a3 = a3;
6255 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
6256 }
6257 }
6258 return hook.value;
6259 }
6260 function useStoreLegacy(store, selector2, a1, a2, a3) {
6261 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6262 }
6263
6264 // node_modules/@base-ui/utils/store/Store.mjs
6265 var Store = class {
6266 /**
6267 * The current state of the store.
6268 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6269 * 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).
6270 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6271 *
6272 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6273 */
6274 // Internal state to handle recursive `setState()` calls
6275 constructor(state) {
6276 this.state = state;
6277 this.listeners = /* @__PURE__ */ new Set();
6278 this.updateTick = 0;
6279 }
6280 /**
6281 * Registers a listener that will be called whenever the store's state changes.
6282 *
6283 * @param fn The listener function to be called on state changes.
6284 * @returns A function to unsubscribe the listener.
6285 */
6286 subscribe = (fn) => {
6287 this.listeners.add(fn);
6288 return () => {
6289 this.listeners.delete(fn);
6290 };
6291 };
6292 /**
6293 * Returns the current state of the store.
6294 */
6295 getSnapshot = () => {
6296 return this.state;
6297 };
6298 /**
6299 * Updates the entire store's state and notifies all registered listeners.
6300 *
6301 * @param newState The new state to set for the store.
6302 */
6303 setState(newState) {
6304 if (this.state === newState) {
6305 return;
6306 }
6307 this.state = newState;
6308 this.updateTick += 1;
6309 const currentTick = this.updateTick;
6310 for (const listener of this.listeners) {
6311 if (currentTick !== this.updateTick) {
6312 return;
6313 }
6314 listener(newState);
6315 }
6316 }
6317 /**
6318 * Merges the provided changes into the current state and notifies listeners if there are changes.
6319 *
6320 * @param changes An object containing the changes to apply to the current state.
6321 */
6322 update(changes) {
6323 for (const key in changes) {
6324 if (!Object.is(this.state[key], changes[key])) {
6325 this.setState({
6326 ...this.state,
6327 ...changes
6328 });
6329 return;
6330 }
6331 }
6332 }
6333 /**
6334 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6335 *
6336 * @param key The key in the store's state to update.
6337 * @param value The new value to set for the specified key.
6338 */
6339 set(key, value) {
6340 if (!Object.is(this.state[key], value)) {
6341 this.setState({
6342 ...this.state,
6343 [key]: value
6344 });
6345 }
6346 }
6347 /**
6348 * Gives the state a new reference and updates all registered listeners.
6349 */
6350 notifyAll() {
6351 const newState = {
6352 ...this.state
6353 };
6354 this.setState(newState);
6355 }
6356 use(selector2, a1, a2, a3) {
6357 return useStore(this, selector2, a1, a2, a3);
6358 }
6359 };
6360
6361 // node_modules/@base-ui/utils/store/ReactStore.mjs
6362 var React22 = __toESM(require_react(), 1);
6363 var ReactStore = class extends Store {
6364 /**
6365 * Creates a new ReactStore instance.
6366 *
6367 * @param state Initial state of the store.
6368 * @param context Non-reactive context values.
6369 * @param selectors Optional selectors for use with `useState`.
6370 */
6371 constructor(state, context = {}, selectors3) {
6372 super(state);
6373 this.context = context;
6374 this.selectors = selectors3;
6375 }
6376 /**
6377 * Non-reactive values such as refs, callbacks, etc.
6378 */
6379 /**
6380 * Synchronizes a single external value into the store.
6381 *
6382 * Note that the while the value in `state` is updated immediately, the value returned
6383 * by `useState` is updated before the next render (similarly to React's `useState`).
6384 */
6385 useSyncedValue(key, value) {
6386 React22.useDebugValue(key);
6387 const store = this;
6388 useIsoLayoutEffect(() => {
6389 if (store.state[key] !== value) {
6390 store.set(key, value);
6391 }
6392 }, [store, key, value]);
6393 }
6394 /**
6395 * Synchronizes a single external value into the store and
6396 * cleans it up (sets to `undefined`) on unmount.
6397 *
6398 * Note that the while the value in `state` is updated immediately, the value returned
6399 * by `useState` is updated before the next render (similarly to React's `useState`).
6400 */
6401 useSyncedValueWithCleanup(key, value) {
6402 const store = this;
6403 useIsoLayoutEffect(() => {
6404 if (store.state[key] !== value) {
6405 store.set(key, value);
6406 }
6407 return () => {
6408 store.set(key, void 0);
6409 };
6410 }, [store, key, value]);
6411 }
6412 /**
6413 * Synchronizes multiple external values into the store.
6414 *
6415 * Note that the while the values in `state` are updated immediately, the values returned
6416 * by `useState` are updated before the next render (similarly to React's `useState`).
6417 */
6418 useSyncedValues(statePart) {
6419 const store = this;
6420 if (true) {
6421 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
6422 const keys = React22.useRef(Object.keys(statePart)).current;
6423 const nextKeys = Object.keys(statePart);
6424 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6425 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6426 }
6427 }
6428 const dependencies = Object.values(statePart);
6429 useIsoLayoutEffect(() => {
6430 store.update(statePart);
6431 }, [store, ...dependencies]);
6432 }
6433 /**
6434 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6435 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6436 */
6437 useControlledProp(key, controlled) {
6438 React22.useDebugValue(key);
6439 const store = this;
6440 const isControlled = controlled !== void 0;
6441 useIsoLayoutEffect(() => {
6442 if (isControlled && !Object.is(store.state[key], controlled)) {
6443 store.setState({
6444 ...store.state,
6445 [key]: controlled
6446 });
6447 }
6448 }, [store, key, controlled, isControlled]);
6449 if (true) {
6450 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6451 if (!cache.has(key)) {
6452 cache.set(key, isControlled);
6453 }
6454 const previouslyControlled = cache.get(key);
6455 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6456 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).`);
6457 }
6458 }
6459 }
6460 /** Gets the current value from the store using a selector with the provided key.
6461 *
6462 * @param key Key of the selector to use.
6463 */
6464 select(key, a1, a2, a3) {
6465 const selector2 = this.selectors[key];
6466 return selector2(this.state, a1, a2, a3);
6467 }
6468 /**
6469 * Returns a value from the store's state using a selector function.
6470 * Used to subscribe to specific parts of the state.
6471 * This methods causes a rerender whenever the selected state changes.
6472 *
6473 * @param key Key of the selector to use.
6474 */
6475 useState(key, a1, a2, a3) {
6476 React22.useDebugValue(key);
6477 return useStore(this, this.selectors[key], a1, a2, a3);
6478 }
6479 /**
6480 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6481 * and assigns it to the context.
6482 *
6483 * @param key Key of the event callback. Must be a function in the context.
6484 * @param fn Function to assign.
6485 */
6486 useContextCallback(key, fn) {
6487 React22.useDebugValue(key);
6488 const stableFunction = useStableCallback(fn ?? NOOP);
6489 this.context[key] = stableFunction;
6490 }
6491 /**
6492 * Returns a stable setter function for a specific key in the store's state.
6493 * It's commonly used to pass as a ref callback to React elements.
6494 *
6495 * @param key Key of the state to set.
6496 */
6497 useStateSetter(key) {
6498 const ref = React22.useRef(void 0);
6499 if (ref.current === void 0) {
6500 ref.current = (value) => {
6501 this.set(key, value);
6502 };
6503 }
6504 return ref.current;
6505 }
6506 /**
6507 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6508 *
6509 * @param key Key of the selector to observe.
6510 * @param listener Listener function called when the selector result changes.
6511 */
6512 observe(selector2, listener) {
6513 let selectFn;
6514 if (typeof selector2 === "function") {
6515 selectFn = selector2;
6516 } else {
6517 selectFn = this.selectors[selector2];
6518 }
6519 let prevValue = selectFn(this.state);
6520 listener(prevValue, prevValue, this);
6521 return this.subscribe((nextState) => {
6522 const nextValue = selectFn(nextState);
6523 if (!Object.is(prevValue, nextValue)) {
6524 const oldValue = prevValue;
6525 prevValue = nextValue;
6526 listener(nextValue, oldValue, this);
6527 }
6528 });
6529 }
6530 };
6531
6532 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6533 var selectors = {
6534 open: createSelector((state) => state.open),
6535 transitionStatus: createSelector((state) => state.transitionStatus),
6536 domReferenceElement: createSelector((state) => state.domReferenceElement),
6537 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6538 floatingElement: createSelector((state) => state.floatingElement),
6539 floatingId: createSelector((state) => state.floatingId)
6540 };
6541 var FloatingRootStore = class extends ReactStore {
6542 constructor(options) {
6543 const {
6544 syncOnly,
6545 nested,
6546 onOpenChange,
6547 triggerElements,
6548 ...initialState
6549 } = options;
6550 super({
6551 ...initialState,
6552 positionReference: initialState.referenceElement,
6553 domReferenceElement: initialState.referenceElement
6554 }, {
6555 onOpenChange,
6556 dataRef: {
6557 current: {}
6558 },
6559 events: createEventEmitter(),
6560 nested,
6561 triggerElements
6562 }, selectors);
6563 this.syncOnly = syncOnly;
6564 }
6565 /**
6566 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6567 */
6568 syncOpenEvent = (newOpen, event) => {
6569 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6570 // click events to upgrade a hover-open.
6571 event != null && isClickLikeEvent(event)) {
6572 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6573 }
6574 };
6575 /**
6576 * Runs the root-owned side effects for an open state change.
6577 */
6578 dispatchOpenChange = (newOpen, eventDetails) => {
6579 this.syncOpenEvent(newOpen, eventDetails.event);
6580 const details = {
6581 open: newOpen,
6582 reason: eventDetails.reason,
6583 nativeEvent: eventDetails.event,
6584 nested: this.context.nested,
6585 triggerElement: eventDetails.trigger
6586 };
6587 this.context.events.emit("openchange", details);
6588 };
6589 /**
6590 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6591 *
6592 * @param newOpen The new open state.
6593 * @param eventDetails Details about the event that triggered the open state change.
6594 */
6595 setOpen = (newOpen, eventDetails) => {
6596 if (this.syncOnly) {
6597 this.context.onOpenChange?.(newOpen, eventDetails);
6598 return;
6599 }
6600 this.dispatchOpenChange(newOpen, eventDetails);
6601 this.context.onOpenChange?.(newOpen, eventDetails);
6602 };
6603 };
6604
6605 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6606 function useSyncedFloatingRootContext(options) {
6607 const {
6608 popupStore,
6609 treatPopupAsFloatingElement = false,
6610 floatingRootContext: floatingRootContextProp,
6611 floatingId,
6612 nested,
6613 onOpenChange
6614 } = options;
6615 const open = popupStore.useState("open");
6616 const referenceElement = popupStore.useState("activeTriggerElement");
6617 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6618 const triggerElements = popupStore.context.triggerElements;
6619 const handleOpenChange = onOpenChange;
6620 const internalStoreRef = React23.useRef(null);
6621 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6622 internalStoreRef.current = new FloatingRootStore({
6623 open,
6624 transitionStatus: void 0,
6625 referenceElement,
6626 floatingElement,
6627 triggerElements,
6628 onOpenChange: handleOpenChange,
6629 floatingId,
6630 syncOnly: true,
6631 nested
6632 });
6633 }
6634 const store = floatingRootContextProp ?? internalStoreRef.current;
6635 popupStore.useSyncedValue("floatingId", floatingId);
6636 useIsoLayoutEffect(() => {
6637 const valuesToSync = {
6638 open,
6639 floatingId,
6640 referenceElement,
6641 floatingElement
6642 };
6643 if (isElement(referenceElement)) {
6644 valuesToSync.domReferenceElement = referenceElement;
6645 }
6646 if (store.state.positionReference === store.state.referenceElement) {
6647 valuesToSync.positionReference = referenceElement;
6648 }
6649 store.update(valuesToSync);
6650 }, [open, floatingId, referenceElement, floatingElement, store]);
6651 store.context.onOpenChange = handleOpenChange;
6652 store.context.nested = nested;
6653 return store;
6654 }
6655
6656 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6657 var FOCUSABLE_POPUP_PROPS = {
6658 tabIndex: -1,
6659 [FOCUSABLE_ATTRIBUTE]: ""
6660 };
6661 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6662 const floatingId = useId();
6663 const nested = useFloatingParentNodeId() != null;
6664 const internalStoreRef = React24.useRef(null);
6665 if (externalStore === void 0 && internalStoreRef.current === null) {
6666 internalStoreRef.current = createStore2(floatingId, nested);
6667 }
6668 const store = externalStore ?? internalStoreRef.current;
6669 useSyncedFloatingRootContext({
6670 popupStore: store,
6671 treatPopupAsFloatingElement,
6672 floatingRootContext: store.state.floatingRootContext,
6673 floatingId,
6674 nested,
6675 onOpenChange: store.setOpen
6676 });
6677 return {
6678 store,
6679 internalStore: internalStoreRef.current
6680 };
6681 }
6682 function useTriggerRegistration(id, store) {
6683 const registeredElementIdRef = React24.useRef(null);
6684 const registeredElementRef = React24.useRef(null);
6685 return React24.useCallback((element) => {
6686 if (id === void 0) {
6687 return;
6688 }
6689 let shouldSyncTriggerCount = false;
6690 if (registeredElementIdRef.current !== null) {
6691 const registeredId = registeredElementIdRef.current;
6692 const registeredElement = registeredElementRef.current;
6693 const currentElement = store.context.triggerElements.getById(registeredId);
6694 if (registeredElement && currentElement === registeredElement) {
6695 store.context.triggerElements.delete(registeredId);
6696 shouldSyncTriggerCount = true;
6697 }
6698 registeredElementIdRef.current = null;
6699 registeredElementRef.current = null;
6700 }
6701 if (element !== null) {
6702 registeredElementIdRef.current = id;
6703 registeredElementRef.current = element;
6704 store.context.triggerElements.add(id, element);
6705 shouldSyncTriggerCount = true;
6706 }
6707 if (shouldSyncTriggerCount) {
6708 const triggerCount = store.context.triggerElements.size;
6709 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6710 store.set("triggerCount", triggerCount);
6711 }
6712 }
6713 }, [store, id]);
6714 }
6715 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6716 if (open) {
6717 state.preventUnmountingOnClose = false;
6718 } else if (preventUnmountOnClose) {
6719 state.preventUnmountingOnClose = true;
6720 }
6721 const triggerId = trigger?.id ?? null;
6722 if (triggerId || open) {
6723 state.activeTriggerId = triggerId;
6724 state.activeTriggerElement = trigger ?? null;
6725 }
6726 }
6727 function attachPreventUnmountOnClose(eventDetails) {
6728 let preventUnmountOnClose = false;
6729 eventDetails.preventUnmountOnClose = () => {
6730 preventUnmountOnClose = true;
6731 };
6732 return () => preventUnmountOnClose;
6733 }
6734 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6735 const reason = eventDetails.reason;
6736 const isHover = reason === reason_parts_exports.triggerHover;
6737 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6738 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6739 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6740 store.context.onOpenChange?.(nextOpen, eventDetails);
6741 if (eventDetails.isCanceled) {
6742 return;
6743 }
6744 options.onBeforeDispatch?.();
6745 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6746 const changeState = () => {
6747 const updatedState = {
6748 ...options.extraState,
6749 open: nextOpen
6750 };
6751 if (isFocusOpen) {
6752 updatedState.instantType = "focus";
6753 } else if (isDismissClose) {
6754 updatedState.instantType = "dismiss";
6755 } else if (isHover) {
6756 updatedState.instantType = void 0;
6757 }
6758 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6759 store.update(updatedState);
6760 };
6761 if (isHover) {
6762 ReactDOM4.flushSync(changeState);
6763 } else {
6764 changeState();
6765 }
6766 }
6767 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6768 useOnFirstRender(() => {
6769 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6770 store.state = {
6771 ...store.state,
6772 open: true,
6773 activeTriggerId: defaultTriggerId,
6774 preventUnmountingOnClose: false
6775 };
6776 }
6777 });
6778 }
6779 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6780 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6781 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6782 const registerTrigger = useStableCallback((element) => {
6783 baseRegisterTrigger(element);
6784 if (!element) {
6785 return;
6786 }
6787 const open = store.select("open");
6788 const activeTriggerId = store.select("activeTriggerId");
6789 if (activeTriggerId === triggerId) {
6790 store.update({
6791 activeTriggerElement: element,
6792 ...open ? stateUpdates : null
6793 });
6794 return;
6795 }
6796 if (activeTriggerId == null && open) {
6797 store.update({
6798 activeTriggerId: triggerId,
6799 activeTriggerElement: element,
6800 ...stateUpdates
6801 });
6802 }
6803 });
6804 useIsoLayoutEffect(() => {
6805 if (isMountedByThisTrigger) {
6806 store.update({
6807 activeTriggerElement: triggerElementRef.current,
6808 ...stateUpdates
6809 });
6810 }
6811 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6812 return {
6813 registerTrigger,
6814 isMountedByThisTrigger
6815 };
6816 }
6817 function useImplicitActiveTrigger(store, options = {}) {
6818 const {
6819 closeOnActiveTriggerUnmount = false
6820 } = options;
6821 const open = store.useState("open");
6822 const reactiveTriggerCount = store.useState("triggerCount");
6823 useIsoLayoutEffect(() => {
6824 if (!open) {
6825 if (store.state.triggerCount !== 0) {
6826 store.set("triggerCount", 0);
6827 }
6828 return;
6829 }
6830 const triggerCount = store.context.triggerElements.size;
6831 const stateUpdates = {};
6832 if (store.state.triggerCount !== triggerCount) {
6833 stateUpdates.triggerCount = triggerCount;
6834 }
6835 const activeTriggerId = store.select("activeTriggerId");
6836 let lostActiveTriggerId = null;
6837 if (activeTriggerId) {
6838 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6839 if (!activeTriggerElement) {
6840 lostActiveTriggerId = activeTriggerId;
6841 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6842 stateUpdates.activeTriggerElement = activeTriggerElement;
6843 }
6844 }
6845 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6846 const iteratorResult = store.context.triggerElements.entries().next();
6847 if (!iteratorResult.done) {
6848 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6849 stateUpdates.activeTriggerId = implicitTriggerId;
6850 stateUpdates.activeTriggerElement = implicitTriggerElement;
6851 }
6852 }
6853 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6854 store.update(stateUpdates);
6855 }
6856 if (lostActiveTriggerId) {
6857 if (closeOnActiveTriggerUnmount) {
6858 queueMicrotask(() => {
6859 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6860 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6861 store.setOpen(false, eventDetails);
6862 if (!eventDetails.isCanceled) {
6863 store.update({
6864 activeTriggerId: null,
6865 activeTriggerElement: null
6866 });
6867 }
6868 }
6869 });
6870 }
6871 }
6872 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6873 }
6874 function useOpenStateTransitions(open, store, onUnmount) {
6875 const {
6876 mounted,
6877 setMounted,
6878 transitionStatus
6879 } = useTransitionStatus(open);
6880 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6881 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6882 store.useSyncedValues({
6883 mounted,
6884 transitionStatus,
6885 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6886 });
6887 const forceUnmount = useStableCallback(() => {
6888 setMounted(false);
6889 store.update({
6890 activeTriggerId: null,
6891 activeTriggerElement: null,
6892 mounted: false,
6893 preventUnmountingOnClose: false
6894 });
6895 onUnmount?.();
6896 store.context.onOpenChangeComplete?.(false);
6897 });
6898 useOpenChangeComplete({
6899 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6900 open,
6901 ref: store.context.popupRef,
6902 onComplete() {
6903 if (!open) {
6904 forceUnmount();
6905 }
6906 }
6907 });
6908 return {
6909 forceUnmount,
6910 transitionStatus
6911 };
6912 }
6913 function usePopupInteractionProps(store, statePart) {
6914 store.useSyncedValues(statePart);
6915 useIsoLayoutEffect(() => () => {
6916 store.update({
6917 activeTriggerProps: EMPTY_OBJECT,
6918 inactiveTriggerProps: EMPTY_OBJECT,
6919 popupProps: EMPTY_OBJECT
6920 });
6921 }, [store]);
6922 }
6923
6924 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6925 var PopupTriggerMap = class {
6926 constructor() {
6927 this.elementsSet = /* @__PURE__ */ new Set();
6928 this.idMap = /* @__PURE__ */ new Map();
6929 }
6930 /**
6931 * Adds a trigger element with the given ID.
6932 *
6933 * Note: The provided element is assumed to not be registered under multiple IDs.
6934 */
6935 add(id, element) {
6936 const existingElement = this.idMap.get(id);
6937 if (existingElement === element) {
6938 return;
6939 }
6940 if (existingElement !== void 0) {
6941 this.elementsSet.delete(existingElement);
6942 }
6943 this.elementsSet.add(element);
6944 this.idMap.set(id, element);
6945 if (true) {
6946 if (this.elementsSet.size !== this.idMap.size) {
6947 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6948 }
6949 }
6950 }
6951 /**
6952 * Removes the trigger element with the given ID.
6953 */
6954 delete(id) {
6955 const element = this.idMap.get(id);
6956 if (element) {
6957 this.elementsSet.delete(element);
6958 this.idMap.delete(id);
6959 }
6960 }
6961 /**
6962 * Whether the given element is registered as a trigger.
6963 */
6964 hasElement(element) {
6965 return this.elementsSet.has(element);
6966 }
6967 /**
6968 * Whether there is a registered trigger element matching the given predicate.
6969 */
6970 hasMatchingElement(predicate) {
6971 for (const element of this.elementsSet) {
6972 if (predicate(element)) {
6973 return true;
6974 }
6975 }
6976 return false;
6977 }
6978 /**
6979 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6980 */
6981 getById(id) {
6982 return this.idMap.get(id);
6983 }
6984 /**
6985 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6986 */
6987 entries() {
6988 return this.idMap.entries();
6989 }
6990 /**
6991 * Returns an iterable of all registered trigger elements.
6992 */
6993 elements() {
6994 return this.elementsSet.values();
6995 }
6996 /**
6997 * Returns the number of registered trigger elements.
6998 */
6999 get size() {
7000 return this.idMap.size;
7001 }
7002 };
7003
7004 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
7005 function getEmptyRootContext() {
7006 return new FloatingRootStore({
7007 open: false,
7008 transitionStatus: void 0,
7009 floatingElement: null,
7010 referenceElement: null,
7011 triggerElements: new PopupTriggerMap(),
7012 floatingId: void 0,
7013 syncOnly: false,
7014 nested: false,
7015 onOpenChange: void 0
7016 });
7017 }
7018
7019 // node_modules/@base-ui/react/utils/popups/store.mjs
7020 function createInitialPopupStoreState() {
7021 return {
7022 open: false,
7023 openProp: void 0,
7024 mounted: false,
7025 transitionStatus: void 0,
7026 floatingRootContext: getEmptyRootContext(),
7027 floatingId: void 0,
7028 triggerCount: 0,
7029 preventUnmountingOnClose: false,
7030 payload: void 0,
7031 activeTriggerId: null,
7032 activeTriggerElement: null,
7033 triggerIdProp: void 0,
7034 popupElement: null,
7035 positionerElement: null,
7036 activeTriggerProps: EMPTY_OBJECT,
7037 inactiveTriggerProps: EMPTY_OBJECT,
7038 popupProps: EMPTY_OBJECT
7039 };
7040 }
7041 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
7042 return new FloatingRootStore({
7043 open: false,
7044 transitionStatus: void 0,
7045 floatingElement: null,
7046 referenceElement: null,
7047 triggerElements,
7048 floatingId,
7049 syncOnly: true,
7050 nested,
7051 onOpenChange: void 0
7052 });
7053 }
7054 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7055 var openSelector = createSelector((state) => state.openProp ?? state.open);
7056 var popupIdSelector = createSelector((state) => {
7057 const popupId = state.popupElement?.id ?? state.floatingId;
7058 return popupId || void 0;
7059 });
7060 function triggerOwnsOpenPopup(state, triggerId) {
7061 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
7062 }
7063 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
7064 if (triggerOwnsOpenPopup(state, triggerId)) {
7065 return true;
7066 }
7067 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
7068 }
7069 var popupStoreSelectors = {
7070 open: openSelector,
7071 mounted: createSelector((state) => state.mounted),
7072 transitionStatus: createSelector((state) => state.transitionStatus),
7073 floatingRootContext: createSelector((state) => state.floatingRootContext),
7074 triggerCount: createSelector((state) => state.triggerCount),
7075 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7076 payload: createSelector((state) => state.payload),
7077 activeTriggerId: activeTriggerIdSelector,
7078 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7079 popupId: popupIdSelector,
7080 /**
7081 * Whether the trigger with the given ID was used to open the popup.
7082 */
7083 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7084 /**
7085 * Whether the popup is open and was activated by a trigger with the given ID.
7086 */
7087 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
7088 /**
7089 * Whether the popup is mounted and was activated by a trigger with the given ID.
7090 */
7091 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7092 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7093 /**
7094 * Popup id for the trigger that currently owns the open popup.
7095 */
7096 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
7097 popupProps: createSelector((state) => state.popupProps),
7098 popupElement: createSelector((state) => state.popupElement),
7099 positionerElement: createSelector((state) => state.positionerElement)
7100 };
7101
7102 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
7103 function useFloatingRootContext(options) {
7104 const {
7105 open = false,
7106 onOpenChange,
7107 elements = {}
7108 } = options;
7109 const floatingId = useId();
7110 const nested = useFloatingParentNodeId() != null;
7111 if (true) {
7112 const optionDomReference = elements.reference;
7113 if (optionDomReference && !isElement(optionDomReference)) {
7114 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7115 }
7116 }
7117 const store = useRefWithInit(() => new FloatingRootStore({
7118 open,
7119 transitionStatus: void 0,
7120 onOpenChange,
7121 referenceElement: elements.reference ?? null,
7122 floatingElement: elements.floating ?? null,
7123 triggerElements: new PopupTriggerMap(),
7124 floatingId,
7125 syncOnly: false,
7126 nested
7127 })).current;
7128 useIsoLayoutEffect(() => {
7129 const valuesToSync = {
7130 open,
7131 floatingId
7132 };
7133 if (elements.reference !== void 0) {
7134 valuesToSync.referenceElement = elements.reference;
7135 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7136 }
7137 if (elements.floating !== void 0) {
7138 valuesToSync.floatingElement = elements.floating;
7139 }
7140 store.update(valuesToSync);
7141 }, [open, floatingId, elements.reference, elements.floating, store]);
7142 store.context.onOpenChange = onOpenChange;
7143 store.context.nested = nested;
7144 return store;
7145 }
7146
7147 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7148 function useFloating2(options = {}) {
7149 const {
7150 nodeId,
7151 externalTree
7152 } = options;
7153 const internalStore = useFloatingRootContext(options);
7154 const store = options.rootContext || internalStore;
7155 const referenceElement = store.useState("referenceElement");
7156 const floatingElement = store.useState("floatingElement");
7157 const domReferenceElement = store.useState("domReferenceElement");
7158 const open = store.useState("open");
7159 const floatingId = store.useState("floatingId");
7160 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
7161 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
7162 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
7163 const domReferenceRef = React25.useRef(null);
7164 const tree = useFloatingTree(externalTree);
7165 const storeElements = React25.useMemo(() => ({
7166 reference: referenceElement,
7167 floating: floatingElement,
7168 domReference: domReferenceElement
7169 }), [referenceElement, floatingElement, domReferenceElement]);
7170 const position = useFloating({
7171 ...options,
7172 elements: {
7173 ...storeElements,
7174 ...positionReference && {
7175 reference: positionReference
7176 }
7177 }
7178 });
7179 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7180 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7181 store.useSyncedValue("referenceElement", localDomReference ?? null);
7182 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7183 store.useSyncedValue("floatingElement", syncedFloatingElement);
7184 const setPositionReference = React25.useCallback((node) => {
7185 const computedPositionReference = isElement(node) ? {
7186 getBoundingClientRect: () => node.getBoundingClientRect(),
7187 getClientRects: () => node.getClientRects(),
7188 contextElement: node
7189 } : node;
7190 setPositionReferenceRaw(computedPositionReference);
7191 position.refs.setReference(computedPositionReference);
7192 }, [position.refs]);
7193 const setReference = React25.useCallback((node) => {
7194 if (isElement(node) || node === null) {
7195 domReferenceRef.current = node;
7196 setLocalDomReference(node);
7197 }
7198 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7199 // `null` to support `positionReference` + an unstable `reference`
7200 // callback ref.
7201 node !== null && !isElement(node)) {
7202 position.refs.setReference(node);
7203 }
7204 }, [position.refs, setLocalDomReference]);
7205 const setFloating = React25.useCallback((node) => {
7206 setLocalFloatingElement(node);
7207 position.refs.setFloating(node);
7208 }, [position.refs]);
7209 const refs = React25.useMemo(() => ({
7210 ...position.refs,
7211 setReference,
7212 setFloating,
7213 setPositionReference,
7214 domReference: domReferenceRef
7215 }), [position.refs, setReference, setFloating, setPositionReference]);
7216 const elements = React25.useMemo(() => ({
7217 ...position.elements,
7218 domReference: domReferenceElement
7219 }), [position.elements, domReferenceElement]);
7220 const context = React25.useMemo(() => ({
7221 ...position,
7222 dataRef: store.context.dataRef,
7223 open,
7224 onOpenChange: store.setOpen,
7225 events: store.context.events,
7226 floatingId,
7227 refs,
7228 elements,
7229 nodeId,
7230 rootStore: store
7231 }), [position, refs, elements, nodeId, store, open, floatingId]);
7232 useIsoLayoutEffect(() => {
7233 if (domReferenceElement) {
7234 domReferenceRef.current = domReferenceElement;
7235 }
7236 }, [domReferenceElement]);
7237 useIsoLayoutEffect(() => {
7238 store.context.dataRef.current.floatingContext = context;
7239 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7240 if (node) {
7241 node.context = context;
7242 }
7243 });
7244 return React25.useMemo(() => ({
7245 ...position,
7246 context,
7247 refs,
7248 elements,
7249 rootStore: store
7250 }), [position, refs, elements, context, store]);
7251 }
7252
7253 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7254 var React26 = __toESM(require_react(), 1);
7255 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7256 function useFocus(context, props = {}) {
7257 const {
7258 enabled = true,
7259 delay
7260 } = props;
7261 const store = "rootStore" in context ? context.rootStore : context;
7262 const {
7263 events,
7264 dataRef
7265 } = store.context;
7266 const blockFocusRef = React26.useRef(false);
7267 const blockedReferenceRef = React26.useRef(null);
7268 const keyboardModalityRef = React26.useRef(true);
7269 const timeout = useTimeout();
7270 React26.useEffect(() => {
7271 const domReference = store.select("domReferenceElement");
7272 if (!enabled) {
7273 return void 0;
7274 }
7275 const win = getWindow(domReference);
7276 function onBlur() {
7277 const currentDomReference = store.select("domReferenceElement");
7278 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7279 blockFocusRef.current = true;
7280 }
7281 }
7282 function onKeyDown() {
7283 keyboardModalityRef.current = true;
7284 }
7285 function onPointerDown() {
7286 keyboardModalityRef.current = false;
7287 }
7288 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7289 }, [store, enabled]);
7290 React26.useEffect(() => {
7291 if (!enabled) {
7292 return void 0;
7293 }
7294 function onOpenChangeLocal(details) {
7295 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7296 const referenceElement = store.select("domReferenceElement");
7297 if (isElement(referenceElement)) {
7298 blockedReferenceRef.current = referenceElement;
7299 blockFocusRef.current = true;
7300 }
7301 }
7302 }
7303 events.on("openchange", onOpenChangeLocal);
7304 return () => {
7305 events.off("openchange", onOpenChangeLocal);
7306 };
7307 }, [events, enabled, store]);
7308 const reference = React26.useMemo(() => {
7309 function resetBlockedFocus() {
7310 blockFocusRef.current = false;
7311 blockedReferenceRef.current = null;
7312 }
7313 return {
7314 onMouseLeave() {
7315 resetBlockedFocus();
7316 },
7317 onFocus(event) {
7318 const focusTarget = event.currentTarget;
7319 if (blockFocusRef.current) {
7320 if (blockedReferenceRef.current === focusTarget) {
7321 return;
7322 }
7323 resetBlockedFocus();
7324 }
7325 const target = getTarget(event.nativeEvent);
7326 if (isElement(target)) {
7327 if (isMacSafari && !event.relatedTarget) {
7328 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7329 return;
7330 }
7331 } else if (!matchesFocusVisible(target)) {
7332 return;
7333 }
7334 }
7335 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7336 const {
7337 nativeEvent,
7338 currentTarget
7339 } = event;
7340 const delayValue = typeof delay === "function" ? delay() : delay;
7341 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7342 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7343 return;
7344 }
7345 timeout.start(delayValue, () => {
7346 if (blockFocusRef.current) {
7347 return;
7348 }
7349 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7350 });
7351 },
7352 onBlur(event) {
7353 resetBlockedFocus();
7354 const relatedTarget = event.relatedTarget;
7355 const nativeEvent = event.nativeEvent;
7356 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7357 timeout.start(0, () => {
7358 const domReference = store.select("domReferenceElement");
7359 const activeEl = activeElement(ownerDocument(domReference));
7360 if (!relatedTarget && activeEl === domReference) {
7361 return;
7362 }
7363 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7364 return;
7365 }
7366 const nextFocusedElement = relatedTarget ?? activeEl;
7367 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7368 return;
7369 }
7370 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7371 });
7372 }
7373 };
7374 }, [dataRef, delay, store, timeout]);
7375 return React26.useMemo(() => enabled ? {
7376 reference,
7377 trigger: reference
7378 } : {}, [enabled, reference]);
7379 }
7380
7381 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7382 var React27 = __toESM(require_react(), 1);
7383
7384 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7385 var HoverInteraction = class _HoverInteraction {
7386 constructor() {
7387 this.pointerType = void 0;
7388 this.interactedInside = false;
7389 this.handler = void 0;
7390 this.blockMouseMove = true;
7391 this.performedPointerEventsMutation = false;
7392 this.pointerEventsScopeElement = null;
7393 this.pointerEventsReferenceElement = null;
7394 this.pointerEventsFloatingElement = null;
7395 this.restTimeoutPending = false;
7396 this.openChangeTimeout = new Timeout();
7397 this.restTimeout = new Timeout();
7398 this.handleCloseOptions = void 0;
7399 }
7400 static create() {
7401 return new _HoverInteraction();
7402 }
7403 dispose = () => {
7404 this.openChangeTimeout.clear();
7405 this.restTimeout.clear();
7406 };
7407 disposeEffect = () => {
7408 return this.dispose;
7409 };
7410 };
7411 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7412 function clearSafePolygonPointerEventsMutation(instance) {
7413 if (!instance.performedPointerEventsMutation) {
7414 return;
7415 }
7416 const scopeElement = instance.pointerEventsScopeElement;
7417 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7418 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7419 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7420 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7421 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7422 }
7423 instance.performedPointerEventsMutation = false;
7424 instance.pointerEventsScopeElement = null;
7425 instance.pointerEventsReferenceElement = null;
7426 instance.pointerEventsFloatingElement = null;
7427 }
7428 function applySafePolygonPointerEventsMutation(instance, options) {
7429 const {
7430 scopeElement,
7431 referenceElement,
7432 floatingElement
7433 } = options;
7434 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7435 if (existingOwner && existingOwner !== instance) {
7436 clearSafePolygonPointerEventsMutation(existingOwner);
7437 }
7438 clearSafePolygonPointerEventsMutation(instance);
7439 instance.performedPointerEventsMutation = true;
7440 instance.pointerEventsScopeElement = scopeElement;
7441 instance.pointerEventsReferenceElement = referenceElement;
7442 instance.pointerEventsFloatingElement = floatingElement;
7443 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7444 scopeElement.style.pointerEvents = "none";
7445 referenceElement.style.pointerEvents = "auto";
7446 floatingElement.style.pointerEvents = "auto";
7447 }
7448 function useHoverInteractionSharedState(store) {
7449 const data = store.context.dataRef.current;
7450 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7451 if (!data.hoverInteractionState) {
7452 data.hoverInteractionState = instance;
7453 }
7454 useOnMount(data.hoverInteractionState.disposeEffect);
7455 return data.hoverInteractionState;
7456 }
7457
7458 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7459 function useHoverFloatingInteraction(context, parameters = {}) {
7460 const {
7461 enabled = true,
7462 closeDelay: closeDelayProp = 0,
7463 nodeId: nodeIdProp
7464 } = parameters;
7465 const store = "rootStore" in context ? context.rootStore : context;
7466 const open = store.useState("open");
7467 const floatingElement = store.useState("floatingElement");
7468 const domReferenceElement = store.useState("domReferenceElement");
7469 const {
7470 dataRef
7471 } = store.context;
7472 const tree = useFloatingTree();
7473 const parentId = useFloatingParentNodeId();
7474 const instance = useHoverInteractionSharedState(store);
7475 const childClosedTimeout = useTimeout();
7476 const isClickLikeOpenEvent2 = useStableCallback(() => {
7477 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7478 });
7479 const isHoverOpen = useStableCallback(() => {
7480 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7481 });
7482 const clearPointerEvents = useStableCallback(() => {
7483 clearSafePolygonPointerEventsMutation(instance);
7484 });
7485 useIsoLayoutEffect(() => {
7486 if (!open) {
7487 instance.pointerType = void 0;
7488 instance.restTimeoutPending = false;
7489 instance.interactedInside = false;
7490 clearPointerEvents();
7491 }
7492 }, [open, instance, clearPointerEvents]);
7493 React27.useEffect(() => {
7494 return clearPointerEvents;
7495 }, [clearPointerEvents]);
7496 useIsoLayoutEffect(() => {
7497 if (!enabled) {
7498 return void 0;
7499 }
7500 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7501 const ref = domReferenceElement;
7502 const floatingEl = floatingElement;
7503 const doc = ownerDocument(floatingElement);
7504 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7505 if (parentFloating) {
7506 parentFloating.style.pointerEvents = "";
7507 }
7508 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7509 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7510 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7511 applySafePolygonPointerEventsMutation(instance, {
7512 scopeElement,
7513 referenceElement: ref,
7514 floatingElement: floatingEl
7515 });
7516 return () => {
7517 clearPointerEvents();
7518 };
7519 }
7520 return void 0;
7521 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7522 React27.useEffect(() => {
7523 if (!enabled) {
7524 return void 0;
7525 }
7526 function hasParentChildren() {
7527 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7528 }
7529 function closeWithDelay(event) {
7530 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7531 const close = () => {
7532 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7533 tree?.events.emit("floating.closed", event);
7534 };
7535 if (closeDelay) {
7536 instance.openChangeTimeout.start(closeDelay, close);
7537 } else {
7538 instance.openChangeTimeout.clear();
7539 close();
7540 }
7541 }
7542 function handleInteractInside(event) {
7543 const target = getTarget(event);
7544 if (!isInteractiveElement(target)) {
7545 instance.interactedInside = false;
7546 return;
7547 }
7548 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7549 }
7550 function onFloatingMouseEnter() {
7551 instance.openChangeTimeout.clear();
7552 childClosedTimeout.clear();
7553 tree?.events.off("floating.closed", onNodeClosed);
7554 clearPointerEvents();
7555 }
7556 function onFloatingMouseLeave(event) {
7557 if (hasParentChildren() && tree) {
7558 tree.events.on("floating.closed", onNodeClosed);
7559 return;
7560 }
7561 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7562 return;
7563 }
7564 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7565 const relatedTarget = event.relatedTarget;
7566 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7567 if (isMovingIntoDescendantFloating) {
7568 return;
7569 }
7570 if (instance.handler) {
7571 instance.handler(event);
7572 return;
7573 }
7574 clearPointerEvents();
7575 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7576 closeWithDelay(event);
7577 }
7578 }
7579 function onNodeClosed(event) {
7580 if (!tree || !parentId || hasParentChildren()) {
7581 return;
7582 }
7583 childClosedTimeout.start(0, () => {
7584 tree.events.off("floating.closed", onNodeClosed);
7585 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7586 tree.events.emit("floating.closed", event);
7587 });
7588 }
7589 const floating = floatingElement;
7590 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7591 tree?.events.off("floating.closed", onNodeClosed);
7592 });
7593 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7594 }
7595
7596 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7597 var React28 = __toESM(require_react(), 1);
7598 var ReactDOM5 = __toESM(require_react_dom(), 1);
7599 var EMPTY_REF = {
7600 current: null
7601 };
7602 function useHoverReferenceInteraction(context, props = {}) {
7603 const {
7604 enabled = true,
7605 delay = 0,
7606 handleClose = null,
7607 mouseOnly = false,
7608 restMs = 0,
7609 move = true,
7610 triggerElementRef = EMPTY_REF,
7611 externalTree,
7612 isActiveTrigger = true,
7613 getHandleCloseContext,
7614 isClosing,
7615 shouldOpen: shouldOpenProp
7616 } = props;
7617 const store = "rootStore" in context ? context.rootStore : context;
7618 const {
7619 dataRef,
7620 events
7621 } = store.context;
7622 const tree = useFloatingTree(externalTree);
7623 const instance = useHoverInteractionSharedState(store);
7624 const isHoverCloseActiveRef = React28.useRef(false);
7625 const handleCloseRef = useValueAsRef(handleClose);
7626 const delayRef = useValueAsRef(delay);
7627 const restMsRef = useValueAsRef(restMs);
7628 const enabledRef = useValueAsRef(enabled);
7629 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7630 const isClosingRef = useValueAsRef(isClosing);
7631 const isClickLikeOpenEvent2 = useStableCallback(() => {
7632 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7633 });
7634 const checkShouldOpen = useStableCallback(() => {
7635 return shouldOpenRef.current?.() !== false;
7636 });
7637 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7638 const allTriggers = store.context.triggerElements;
7639 if (allTriggers.hasElement(currentTarget)) {
7640 return !currentDomReference || !contains(currentDomReference, currentTarget);
7641 }
7642 if (!isElement(target)) {
7643 return false;
7644 }
7645 const targetElement = target;
7646 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7647 });
7648 const cleanupMouseMoveHandler = useStableCallback(() => {
7649 if (!instance.handler) {
7650 return;
7651 }
7652 const doc = ownerDocument(store.select("domReferenceElement"));
7653 doc.removeEventListener("mousemove", instance.handler);
7654 instance.handler = void 0;
7655 });
7656 const clearPointerEvents = useStableCallback(() => {
7657 clearSafePolygonPointerEventsMutation(instance);
7658 });
7659 if (isActiveTrigger) {
7660 instance.handleCloseOptions = handleCloseRef.current?.__options;
7661 }
7662 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7663 React28.useEffect(() => {
7664 if (!enabled) {
7665 return void 0;
7666 }
7667 function onOpenChangeLocal(details) {
7668 if (!details.open) {
7669 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7670 cleanupMouseMoveHandler();
7671 instance.openChangeTimeout.clear();
7672 instance.restTimeout.clear();
7673 instance.blockMouseMove = true;
7674 instance.restTimeoutPending = false;
7675 } else {
7676 isHoverCloseActiveRef.current = false;
7677 }
7678 }
7679 events.on("openchange", onOpenChangeLocal);
7680 return () => {
7681 events.off("openchange", onOpenChangeLocal);
7682 };
7683 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7684 React28.useEffect(() => {
7685 if (!enabled) {
7686 return void 0;
7687 }
7688 function closeWithDelay(event, runElseBranch = true) {
7689 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7690 if (closeDelay) {
7691 instance.openChangeTimeout.start(closeDelay, () => {
7692 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7693 tree?.events.emit("floating.closed", event);
7694 });
7695 } else if (runElseBranch) {
7696 instance.openChangeTimeout.clear();
7697 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7698 tree?.events.emit("floating.closed", event);
7699 }
7700 }
7701 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7702 if (!isElement(trigger)) {
7703 return void 0;
7704 }
7705 function onMouseEnter(event) {
7706 instance.openChangeTimeout.clear();
7707 instance.blockMouseMove = false;
7708 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7709 return;
7710 }
7711 const restMsValue = getRestMs(restMsRef.current);
7712 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7713 const eventTarget = getTarget(event);
7714 const currentTarget = event.currentTarget ?? null;
7715 const currentDomReference = store.select("domReferenceElement");
7716 let triggerNode = currentTarget;
7717 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7718 for (const triggerElement of store.context.triggerElements.elements()) {
7719 if (contains(triggerElement, eventTarget)) {
7720 triggerNode = triggerElement;
7721 break;
7722 }
7723 }
7724 }
7725 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7726 triggerNode = currentDomReference;
7727 }
7728 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7729 const isOpen = store.select("open");
7730 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7731 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7732 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7733 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7734 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7735 const shouldOpen = !isOpen || isOverInactive;
7736 if (shouldOpenImmediately) {
7737 if (checkShouldOpen()) {
7738 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7739 }
7740 return;
7741 }
7742 if (isRestOnlyDelay) {
7743 return;
7744 }
7745 if (openDelay) {
7746 instance.openChangeTimeout.start(openDelay, () => {
7747 if (shouldOpen && checkShouldOpen()) {
7748 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7749 }
7750 });
7751 } else if (shouldOpen) {
7752 if (checkShouldOpen()) {
7753 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7754 }
7755 }
7756 }
7757 function onMouseLeave(event) {
7758 if (isClickLikeOpenEvent2()) {
7759 clearPointerEvents();
7760 return;
7761 }
7762 cleanupMouseMoveHandler();
7763 const domReferenceElement = store.select("domReferenceElement");
7764 const doc = ownerDocument(domReferenceElement);
7765 instance.restTimeout.clear();
7766 instance.restTimeoutPending = false;
7767 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7768 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7769 return;
7770 }
7771 if (handleCloseRef.current && handleCloseContextBase) {
7772 if (!store.select("open")) {
7773 instance.openChangeTimeout.clear();
7774 }
7775 const currentTrigger = triggerElementRef.current;
7776 instance.handler = handleCloseRef.current({
7777 ...handleCloseContextBase,
7778 tree,
7779 x: event.clientX,
7780 y: event.clientY,
7781 onClose() {
7782 clearPointerEvents();
7783 cleanupMouseMoveHandler();
7784 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7785 closeWithDelay(event, true);
7786 }
7787 }
7788 });
7789 doc.addEventListener("mousemove", instance.handler);
7790 instance.handler(event);
7791 return;
7792 }
7793 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7794 if (shouldClose) {
7795 closeWithDelay(event);
7796 }
7797 }
7798 if (move) {
7799 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7800 once: true
7801 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7802 }
7803 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7804 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7805 return React28.useMemo(() => {
7806 if (!enabled) {
7807 return void 0;
7808 }
7809 function setPointerRef(event) {
7810 instance.pointerType = event.pointerType;
7811 }
7812 return {
7813 onPointerDown: setPointerRef,
7814 onPointerEnter: setPointerRef,
7815 onMouseMove(event) {
7816 const {
7817 nativeEvent
7818 } = event;
7819 const trigger = event.currentTarget;
7820 const currentDomReference = store.select("domReferenceElement");
7821 const currentOpen = store.select("open");
7822 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7823 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7824 return;
7825 }
7826 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7827 const floatingElement = store.select("floatingElement");
7828 if (floatingElement) {
7829 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7830 applySafePolygonPointerEventsMutation(instance, {
7831 scopeElement,
7832 referenceElement: trigger,
7833 floatingElement
7834 });
7835 }
7836 }
7837 const restMsValue = getRestMs(restMsRef.current);
7838 if (currentOpen && !isOverInactive || restMsValue === 0) {
7839 return;
7840 }
7841 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7842 return;
7843 }
7844 instance.restTimeout.clear();
7845 function handleMouseMove() {
7846 instance.restTimeoutPending = false;
7847 if (isClickLikeOpenEvent2()) {
7848 return;
7849 }
7850 const latestOpen = store.select("open");
7851 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7852 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7853 }
7854 }
7855 if (instance.pointerType === "touch") {
7856 ReactDOM5.flushSync(() => {
7857 handleMouseMove();
7858 });
7859 } else if (isOverInactive && currentOpen) {
7860 handleMouseMove();
7861 } else {
7862 instance.restTimeoutPending = true;
7863 instance.restTimeout.start(restMsValue, handleMouseMove);
7864 }
7865 }
7866 };
7867 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7868 }
7869
7870 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7871 var CURSOR_SPEED_THRESHOLD = 0.1;
7872 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7873 var POLYGON_BUFFER = 0.5;
7874 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7875 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7876 }
7877 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7878 let isInsideValue = false;
7879 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7880 isInsideValue = !isInsideValue;
7881 }
7882 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7883 isInsideValue = !isInsideValue;
7884 }
7885 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7886 isInsideValue = !isInsideValue;
7887 }
7888 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7889 isInsideValue = !isInsideValue;
7890 }
7891 return isInsideValue;
7892 }
7893 function isInsideRect(pointX, pointY, rect) {
7894 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7895 }
7896 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7897 const minX = Math.min(x1, x2);
7898 const maxX = Math.max(x1, x2);
7899 const minY = Math.min(y1, y2);
7900 const maxY = Math.max(y1, y2);
7901 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7902 }
7903 function safePolygon(options = {}) {
7904 const {
7905 blockPointerEvents = false
7906 } = options;
7907 const timeout = new Timeout();
7908 const fn = ({
7909 x: x2,
7910 y: y2,
7911 placement,
7912 elements,
7913 onClose,
7914 nodeId,
7915 tree
7916 }) => {
7917 const side = placement?.split("-")[0];
7918 let hasLanded = false;
7919 let lastX = null;
7920 let lastY = null;
7921 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7922 function isCursorMovingSlowly(nextX, nextY) {
7923 const currentTime = performance.now();
7924 const elapsedTime = currentTime - lastCursorTime;
7925 if (lastX === null || lastY === null || elapsedTime === 0) {
7926 lastX = nextX;
7927 lastY = nextY;
7928 lastCursorTime = currentTime;
7929 return false;
7930 }
7931 const deltaX = nextX - lastX;
7932 const deltaY = nextY - lastY;
7933 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7934 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7935 lastX = nextX;
7936 lastY = nextY;
7937 lastCursorTime = currentTime;
7938 return distanceSquared < thresholdSquared;
7939 }
7940 function close() {
7941 timeout.clear();
7942 onClose();
7943 }
7944 return function onMouseMove(event) {
7945 timeout.clear();
7946 const domReference = elements.domReference;
7947 const floating = elements.floating;
7948 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7949 return void 0;
7950 }
7951 const {
7952 clientX,
7953 clientY
7954 } = event;
7955 const target = getTarget(event);
7956 const isLeave = event.type === "mouseleave";
7957 const isOverFloatingEl = contains(floating, target);
7958 const isOverReferenceEl = contains(domReference, target);
7959 if (isOverFloatingEl) {
7960 hasLanded = true;
7961 if (!isLeave) {
7962 return void 0;
7963 }
7964 }
7965 if (isOverReferenceEl) {
7966 hasLanded = false;
7967 if (!isLeave) {
7968 hasLanded = true;
7969 return void 0;
7970 }
7971 }
7972 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7973 return void 0;
7974 }
7975 function hasOpenChildNode() {
7976 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7977 }
7978 function closeIfNoOpenChild() {
7979 if (!hasOpenChildNode()) {
7980 close();
7981 }
7982 }
7983 if (hasOpenChildNode()) {
7984 return void 0;
7985 }
7986 const refRect = domReference.getBoundingClientRect();
7987 const rect = floating.getBoundingClientRect();
7988 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7989 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7990 const isFloatingWider = rect.width > refRect.width;
7991 const isFloatingTaller = rect.height > refRect.height;
7992 const left = (isFloatingWider ? refRect : rect).left;
7993 const right = (isFloatingWider ? refRect : rect).right;
7994 const top = (isFloatingTaller ? refRect : rect).top;
7995 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7996 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) {
7997 closeIfNoOpenChild();
7998 return void 0;
7999 }
8000 let isInsideTroughRect = false;
8001 switch (side) {
8002 case "top":
8003 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8004 break;
8005 case "bottom":
8006 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8007 break;
8008 case "left":
8009 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8010 break;
8011 case "right":
8012 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8013 break;
8014 default:
8015 }
8016 if (isInsideTroughRect) {
8017 return void 0;
8018 }
8019 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8020 closeIfNoOpenChild();
8021 return void 0;
8022 }
8023 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8024 closeIfNoOpenChild();
8025 return void 0;
8026 }
8027 let isInsidePolygon = false;
8028 switch (side) {
8029 case "top": {
8030 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8031 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8032 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8033 const cursorPointY = y2 + POLYGON_BUFFER + 1;
8034 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8035 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8036 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8037 break;
8038 }
8039 case "bottom": {
8040 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8041 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8042 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8043 const cursorPointY = y2 - POLYGON_BUFFER;
8044 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8045 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8046 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8047 break;
8048 }
8049 case "left": {
8050 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8051 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8052 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8053 const cursorPointX = x2 + POLYGON_BUFFER + 1;
8054 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8055 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8056 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8057 break;
8058 }
8059 case "right": {
8060 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8061 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8062 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8063 const cursorPointX = x2 - POLYGON_BUFFER;
8064 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8065 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8066 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8067 break;
8068 }
8069 default:
8070 }
8071 if (!isInsidePolygon) {
8072 closeIfNoOpenChild();
8073 } else if (!hasLanded) {
8074 timeout.start(40, closeIfNoOpenChild);
8075 }
8076 return void 0;
8077 };
8078 };
8079 fn.__options = {
8080 ...options,
8081 blockPointerEvents
8082 };
8083 return fn;
8084 }
8085
8086 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
8087 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
8088 CommonPopupDataAttributes2["open"] = "data-open";
8089 CommonPopupDataAttributes2["closed"] = "data-closed";
8090 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
8091 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
8092 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
8093 CommonPopupDataAttributes2["side"] = "data-side";
8094 CommonPopupDataAttributes2["align"] = "data-align";
8095 return CommonPopupDataAttributes2;
8096 })({});
8097 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
8098 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
8099 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
8100 return CommonTriggerDataAttributes2;
8101 })({});
8102 var TRIGGER_HOOK = {
8103 [CommonTriggerDataAttributes.popupOpen]: ""
8104 };
8105 var PRESSABLE_TRIGGER_HOOK = {
8106 [CommonTriggerDataAttributes.popupOpen]: "",
8107 [CommonTriggerDataAttributes.pressed]: ""
8108 };
8109 var POPUP_OPEN_HOOK = {
8110 [CommonPopupDataAttributes.open]: ""
8111 };
8112 var POPUP_CLOSED_HOOK = {
8113 [CommonPopupDataAttributes.closed]: ""
8114 };
8115 var ANCHOR_HIDDEN_HOOK = {
8116 [CommonPopupDataAttributes.anchorHidden]: ""
8117 };
8118 var triggerOpenStateMapping = {
8119 open(value) {
8120 if (value) {
8121 return TRIGGER_HOOK;
8122 }
8123 return null;
8124 }
8125 };
8126 var popupStateMapping = {
8127 open(value) {
8128 if (value) {
8129 return POPUP_OPEN_HOOK;
8130 }
8131 return POPUP_CLOSED_HOOK;
8132 },
8133 anchorHidden(value) {
8134 if (value) {
8135 return ANCHOR_HIDDEN_HOOK;
8136 }
8137 return null;
8138 }
8139 };
8140
8141 // node_modules/@base-ui/utils/inertValue.mjs
8142 function inertValue(value) {
8143 if (isReactVersionAtLeast(19)) {
8144 return value;
8145 }
8146 return value ? "true" : void 0;
8147 }
8148
8149 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8150 var React29 = __toESM(require_react(), 1);
8151
8152 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8153 var baseArrow = (options) => ({
8154 name: "arrow",
8155 options,
8156 async fn(state) {
8157 const {
8158 x: x2,
8159 y: y2,
8160 placement,
8161 rects,
8162 platform: platform3,
8163 elements,
8164 middlewareData
8165 } = state;
8166 const {
8167 element,
8168 padding = 0,
8169 offsetParent = "real"
8170 } = evaluate(options, state) || {};
8171 if (element == null) {
8172 return {};
8173 }
8174 const paddingObject = getPaddingObject(padding);
8175 const coords = {
8176 x: x2,
8177 y: y2
8178 };
8179 const axis = getAlignmentAxis(placement);
8180 const length = getAxisLength(axis);
8181 const arrowDimensions = await platform3.getDimensions(element);
8182 const isYAxis = axis === "y";
8183 const minProp = isYAxis ? "top" : "left";
8184 const maxProp = isYAxis ? "bottom" : "right";
8185 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8186 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8187 const startDiff = coords[axis] - rects.reference[axis];
8188 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8189 let clientSize = elements.floating[clientProp] || rects.floating[length];
8190 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8191 clientSize = elements.floating[clientProp] || rects.floating[length];
8192 }
8193 const centerToReference = endDiff / 2 - startDiff / 2;
8194 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8195 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8196 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8197 const min2 = minPadding;
8198 const max2 = clientSize - arrowDimensions[length] - maxPadding;
8199 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8200 const offset4 = clamp(min2, center, max2);
8201 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8202 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
8203 return {
8204 [axis]: coords[axis] + alignmentOffset,
8205 data: {
8206 [axis]: offset4,
8207 centerOffset: center - offset4 - alignmentOffset,
8208 ...shouldAddOffset && {
8209 alignmentOffset
8210 }
8211 },
8212 reset: shouldAddOffset
8213 };
8214 }
8215 });
8216 var arrow4 = (options, deps) => ({
8217 ...baseArrow(options),
8218 options: [options, deps]
8219 });
8220
8221 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8222 var nativeHideFn = hide3().fn;
8223 var hide4 = {
8224 name: "hide",
8225 async fn(state) {
8226 const {
8227 width,
8228 height,
8229 x: x2,
8230 y: y2
8231 } = state.rects.reference;
8232 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8233 const nativeHideResult = await nativeHideFn(state);
8234 return {
8235 data: {
8236 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8237 }
8238 };
8239 }
8240 };
8241
8242 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
8243 var DEFAULT_SIDES = {
8244 sideX: "left",
8245 sideY: "top"
8246 };
8247 var adaptiveOrigin = {
8248 name: "adaptiveOrigin",
8249 async fn(state) {
8250 const {
8251 x: rawX,
8252 y: rawY,
8253 rects: {
8254 floating: floatRect
8255 },
8256 elements: {
8257 floating
8258 },
8259 platform: platform3,
8260 strategy,
8261 placement
8262 } = state;
8263 const win = getWindow(floating);
8264 const styles = win.getComputedStyle(floating);
8265 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8266 if (!hasTransition) {
8267 return {
8268 x: rawX,
8269 y: rawY,
8270 data: DEFAULT_SIDES
8271 };
8272 }
8273 const offsetParent = await platform3.getOffsetParent?.(floating);
8274 let offsetDimensions = {
8275 width: 0,
8276 height: 0
8277 };
8278 if (strategy === "fixed" && win?.visualViewport) {
8279 offsetDimensions = {
8280 width: win.visualViewport.width,
8281 height: win.visualViewport.height
8282 };
8283 } else if (offsetParent === win) {
8284 const doc = ownerDocument(floating);
8285 offsetDimensions = {
8286 width: doc.documentElement.clientWidth,
8287 height: doc.documentElement.clientHeight
8288 };
8289 } else if (await platform3.isElement?.(offsetParent)) {
8290 offsetDimensions = await platform3.getDimensions(offsetParent);
8291 }
8292 const currentSide = getSide(placement);
8293 let x2 = rawX;
8294 let y2 = rawY;
8295 if (currentSide === "left") {
8296 x2 = offsetDimensions.width - (rawX + floatRect.width);
8297 }
8298 if (currentSide === "top") {
8299 y2 = offsetDimensions.height - (rawY + floatRect.height);
8300 }
8301 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8302 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8303 return {
8304 x: x2,
8305 y: y2,
8306 data: {
8307 sideX,
8308 sideY
8309 }
8310 };
8311 }
8312 };
8313
8314 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8315 function getLogicalSide(sideParam, renderedSide, isRtl) {
8316 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8317 const logicalRight = isRtl ? "inline-start" : "inline-end";
8318 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8319 return {
8320 top: "top",
8321 right: isLogicalSideParam ? logicalRight : "right",
8322 bottom: "bottom",
8323 left: isLogicalSideParam ? logicalLeft : "left"
8324 }[renderedSide];
8325 }
8326 function getOffsetData(state, sideParam, isRtl) {
8327 const {
8328 rects,
8329 placement
8330 } = state;
8331 const data = {
8332 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8333 align: getAlignment(placement) || "center",
8334 anchor: {
8335 width: rects.reference.width,
8336 height: rects.reference.height
8337 },
8338 positioner: {
8339 width: rects.floating.width,
8340 height: rects.floating.height
8341 }
8342 };
8343 return data;
8344 }
8345 function useAnchorPositioning(params) {
8346 const {
8347 // Public parameters
8348 anchor,
8349 positionMethod = "absolute",
8350 side: sideParam = "bottom",
8351 sideOffset = 0,
8352 align = "center",
8353 alignOffset = 0,
8354 collisionBoundary,
8355 collisionPadding: collisionPaddingParam = 5,
8356 sticky = false,
8357 arrowPadding = 5,
8358 disableAnchorTracking = false,
8359 inline: inlineMiddleware,
8360 // Private parameters
8361 keepMounted = false,
8362 floatingRootContext,
8363 mounted,
8364 collisionAvoidance,
8365 shiftCrossAxis = false,
8366 nodeId,
8367 adaptiveOrigin: adaptiveOrigin2,
8368 lazyFlip = false,
8369 externalTree
8370 } = params;
8371 const [mountSide, setMountSide] = React29.useState(null);
8372 if (!mounted && mountSide !== null) {
8373 setMountSide(null);
8374 }
8375 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8376 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8377 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8378 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8379 const anchorFnCallback = useStableCallback(anchorFn);
8380 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8381 const anchorValueRef = useValueAsRef(anchor);
8382 const mountedRef = useValueAsRef(mounted);
8383 const direction = useDirection();
8384 const isRtl = direction === "rtl";
8385 const side = mountSide || {
8386 top: "top",
8387 right: "right",
8388 bottom: "bottom",
8389 left: "left",
8390 "inline-end": isRtl ? "left" : "right",
8391 "inline-start": isRtl ? "right" : "left"
8392 }[sideParam];
8393 const placement = align === "center" ? side : `${side}-${align}`;
8394 let collisionPadding = collisionPaddingParam;
8395 const bias = 1;
8396 const biasTop = sideParam === "bottom" ? bias : 0;
8397 const biasBottom = sideParam === "top" ? bias : 0;
8398 const biasLeft = sideParam === "right" ? bias : 0;
8399 const biasRight = sideParam === "left" ? bias : 0;
8400 if (typeof collisionPadding === "number") {
8401 collisionPadding = {
8402 top: collisionPadding + biasTop,
8403 right: collisionPadding + biasRight,
8404 bottom: collisionPadding + biasBottom,
8405 left: collisionPadding + biasLeft
8406 };
8407 } else if (collisionPadding) {
8408 collisionPadding = {
8409 top: (collisionPadding.top || 0) + biasTop,
8410 right: (collisionPadding.right || 0) + biasRight,
8411 bottom: (collisionPadding.bottom || 0) + biasBottom,
8412 left: (collisionPadding.left || 0) + biasLeft
8413 };
8414 }
8415 const commonCollisionProps = {
8416 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8417 padding: collisionPadding
8418 };
8419 const arrowRef = React29.useRef(null);
8420 const sideOffsetRef = useValueAsRef(sideOffset);
8421 const alignOffsetRef = useValueAsRef(alignOffset);
8422 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8423 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8424 const middleware = [];
8425 if (inlineMiddleware) {
8426 middleware.push(inlineMiddleware);
8427 }
8428 middleware.push(offset3((state) => {
8429 const data = getOffsetData(state, sideParam, isRtl);
8430 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8431 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8432 return {
8433 mainAxis: sideAxis,
8434 crossAxis: alignAxis,
8435 alignmentAxis: alignAxis
8436 };
8437 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8438 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8439 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8440 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8441 ...commonCollisionProps,
8442 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8443 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8444 padding: {
8445 top: collisionPadding.top + bias,
8446 right: collisionPadding.right + bias,
8447 bottom: collisionPadding.bottom + bias,
8448 left: collisionPadding.left + bias
8449 },
8450 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8451 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8452 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8453 });
8454 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8455 const html = ownerDocument(data.elements.floating).documentElement;
8456 return {
8457 ...commonCollisionProps,
8458 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8459 // for context menus.
8460 rootBoundary: shiftCrossAxis ? {
8461 x: 0,
8462 y: 0,
8463 width: html.clientWidth,
8464 height: html.clientHeight
8465 } : void 0,
8466 mainAxis: collisionAvoidanceAlign !== "none",
8467 crossAxis: crossAxisShiftEnabled,
8468 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8469 if (!arrowRef.current) {
8470 return {};
8471 }
8472 const {
8473 width,
8474 height
8475 } = arrowRef.current.getBoundingClientRect();
8476 const sideAxis = getSideAxis(getSide(limitData.placement));
8477 const arrowSize = sideAxis === "y" ? width : height;
8478 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8479 return {
8480 offset: arrowSize / 2 + offsetAmount / 2
8481 };
8482 })
8483 };
8484 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8485 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8486 middleware.push(shiftMiddleware, flipMiddleware);
8487 } else {
8488 middleware.push(flipMiddleware, shiftMiddleware);
8489 }
8490 middleware.push(size3({
8491 ...commonCollisionProps,
8492 apply({
8493 elements: {
8494 floating
8495 },
8496 availableWidth,
8497 availableHeight,
8498 rects
8499 }) {
8500 if (!mountedRef.current) {
8501 return;
8502 }
8503 const floatingStyle = floating.style;
8504 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8505 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8506 const dpr = getWindow(floating).devicePixelRatio || 1;
8507 const {
8508 x: x3,
8509 y: y3,
8510 width,
8511 height
8512 } = rects.reference;
8513 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8514 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8515 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8516 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8517 }
8518 }), arrow4((state) => ({
8519 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8520 // we'll create a fake element.
8521 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8522 padding: arrowPadding,
8523 offsetParent: "floating"
8524 }), [arrowPadding]), {
8525 name: "transformOrigin",
8526 fn(state) {
8527 const {
8528 elements: elements2,
8529 middlewareData: middlewareData2,
8530 placement: renderedPlacement2,
8531 rects,
8532 y: y3
8533 } = state;
8534 const currentRenderedSide = getSide(renderedPlacement2);
8535 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8536 const arrowEl = arrowRef.current;
8537 const arrowX = middlewareData2.arrow?.x || 0;
8538 const arrowY = middlewareData2.arrow?.y || 0;
8539 const arrowWidth = arrowEl?.clientWidth || 0;
8540 const arrowHeight = arrowEl?.clientHeight || 0;
8541 const transformX = arrowX + arrowWidth / 2;
8542 const transformY = arrowY + arrowHeight / 2;
8543 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8544 const halfAnchorHeight = rects.reference.height / 2;
8545 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8546 const isOverlappingAnchor = shiftY > sideOffsetValue;
8547 const adjacentTransformOrigin = {
8548 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8549 bottom: `${transformX}px ${-sideOffsetValue}px`,
8550 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8551 right: `${-sideOffsetValue}px ${transformY}px`
8552 }[currentRenderedSide];
8553 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8554 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8555 return {};
8556 }
8557 }, hide4, adaptiveOrigin2);
8558 useIsoLayoutEffect(() => {
8559 if (!mounted && floatingRootContext) {
8560 floatingRootContext.update({
8561 referenceElement: null,
8562 floatingElement: null,
8563 domReferenceElement: null,
8564 positionReference: null
8565 });
8566 }
8567 }, [mounted, floatingRootContext]);
8568 const autoUpdateOptions = React29.useMemo(() => ({
8569 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8570 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8571 }), [disableAnchorTracking]);
8572 const {
8573 refs,
8574 elements,
8575 x: x2,
8576 y: y2,
8577 middlewareData,
8578 update: update2,
8579 placement: renderedPlacement,
8580 context,
8581 isPositioned,
8582 floatingStyles: originalFloatingStyles
8583 } = useFloating2({
8584 rootContext: floatingRootContext,
8585 open: keepMounted ? mounted : void 0,
8586 placement,
8587 middleware,
8588 strategy: positionMethod,
8589 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8590 nodeId,
8591 externalTree
8592 });
8593 const {
8594 sideX,
8595 sideY
8596 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8597 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8598 const floatingStyles = React29.useMemo(() => {
8599 const base = adaptiveOrigin2 ? {
8600 position: resolvedPosition,
8601 [sideX]: x2,
8602 [sideY]: y2
8603 } : {
8604 position: resolvedPosition,
8605 ...originalFloatingStyles
8606 };
8607 if (!isPositioned) {
8608 base.opacity = 0;
8609 }
8610 return base;
8611 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8612 const registeredPositionReferenceRef = React29.useRef(null);
8613 useIsoLayoutEffect(() => {
8614 if (!mounted) {
8615 return;
8616 }
8617 const anchorValue = anchorValueRef.current;
8618 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8619 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8620 const finalAnchor = unwrappedElement || null;
8621 if (finalAnchor !== registeredPositionReferenceRef.current) {
8622 refs.setPositionReference(finalAnchor);
8623 registeredPositionReferenceRef.current = finalAnchor;
8624 }
8625 }, [mounted, refs, anchorDep, anchorValueRef]);
8626 React29.useEffect(() => {
8627 if (!mounted) {
8628 return;
8629 }
8630 const anchorValue = anchorValueRef.current;
8631 if (typeof anchorValue === "function") {
8632 return;
8633 }
8634 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8635 refs.setPositionReference(anchorValue.current);
8636 registeredPositionReferenceRef.current = anchorValue.current;
8637 }
8638 }, [mounted, refs, anchorDep, anchorValueRef]);
8639 React29.useEffect(() => {
8640 if (keepMounted && mounted && elements.reference && elements.floating) {
8641 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8642 }
8643 return void 0;
8644 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8645 const renderedSide = getSide(renderedPlacement);
8646 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8647 const renderedAlign = getAlignment(renderedPlacement) || "center";
8648 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8649 useIsoLayoutEffect(() => {
8650 if (lazyFlip && mounted && isPositioned) {
8651 setMountSide(renderedSide);
8652 }
8653 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8654 const arrowStyles = React29.useMemo(() => ({
8655 position: "absolute",
8656 top: middlewareData.arrow?.y,
8657 left: middlewareData.arrow?.x
8658 }), [middlewareData.arrow]);
8659 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8660 return React29.useMemo(() => ({
8661 positionerStyles: floatingStyles,
8662 arrowStyles,
8663 arrowRef,
8664 arrowUncentered,
8665 side: logicalRenderedSide,
8666 align: renderedAlign,
8667 physicalSide: renderedSide,
8668 anchorHidden,
8669 refs,
8670 context,
8671 isPositioned,
8672 update: update2
8673 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8674 }
8675 function isRef(param) {
8676 return param != null && "current" in param;
8677 }
8678
8679 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8680 function getDisabledMountTransitionStyles(transitionStatus) {
8681 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8682 }
8683
8684 // node_modules/@base-ui/react/utils/usePositioner.mjs
8685 function usePositioner(componentProps, state, {
8686 styles,
8687 transitionStatus,
8688 props,
8689 refs,
8690 hidden,
8691 inert = false
8692 }) {
8693 const style = {
8694 ...styles
8695 };
8696 if (inert) {
8697 style.pointerEvents = "none";
8698 }
8699 return useRenderElement("div", componentProps, {
8700 state,
8701 ref: refs,
8702 props: [{
8703 role: "presentation",
8704 hidden,
8705 style
8706 }, getDisabledMountTransitionStyles(transitionStatus), props],
8707 stateAttributesMapping: popupStateMapping
8708 });
8709 }
8710
8711 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8712 var React32 = __toESM(require_react(), 1);
8713 var ReactDOM6 = __toESM(require_react_dom(), 1);
8714
8715 // node_modules/@base-ui/utils/usePreviousValue.mjs
8716 var React30 = __toESM(require_react(), 1);
8717 function usePreviousValue(value) {
8718 const [state, setState] = React30.useState({
8719 current: value,
8720 previous: null
8721 });
8722 if (value !== state.current) {
8723 setState({
8724 current: value,
8725 previous: state.current
8726 });
8727 }
8728 return state.previous;
8729 }
8730
8731 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8732 var React31 = __toESM(require_react(), 1);
8733
8734 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8735 function getCssDimensions2(element) {
8736 const css = getComputedStyle2(element);
8737 let width = parseFloat(css.width) || 0;
8738 let height = parseFloat(css.height) || 0;
8739 const hasOffset = isHTMLElement(element);
8740 const offsetWidth = hasOffset ? element.offsetWidth : width;
8741 const offsetHeight = hasOffset ? element.offsetHeight : height;
8742 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8743 if (shouldFallback) {
8744 width = offsetWidth;
8745 height = offsetHeight;
8746 }
8747 return {
8748 width,
8749 height
8750 };
8751 }
8752
8753 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8754 function usePopupAutoResize(parameters) {
8755 const {
8756 popupElement,
8757 positionerElement,
8758 content,
8759 mounted,
8760 onMeasureLayout: onMeasureLayoutParam,
8761 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8762 side,
8763 direction
8764 } = parameters;
8765 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8766 const animationFrame = useAnimationFrame();
8767 const committedDimensionsRef = React31.useRef(null);
8768 const isInitialRenderRef = React31.useRef(true);
8769 const restoreAnchoringStylesRef = React31.useRef(NOOP);
8770 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8771 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8772 const anchoringStyles = React31.useMemo(() => {
8773 let isOriginSide = side === "top";
8774 let isPhysicalLeft = side === "left";
8775 if (direction === "rtl") {
8776 isOriginSide = isOriginSide || side === "inline-end";
8777 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8778 } else {
8779 isOriginSide = isOriginSide || side === "inline-start";
8780 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8781 }
8782 return isOriginSide ? {
8783 position: "absolute",
8784 [side === "top" ? "bottom" : "top"]: "0",
8785 [isPhysicalLeft ? "right" : "left"]: "0"
8786 } : EMPTY_OBJECT;
8787 }, [side, direction]);
8788 useIsoLayoutEffect(() => {
8789 if (!mounted) {
8790 restoreAnchoringStylesRef.current = NOOP;
8791 isInitialRenderRef.current = true;
8792 committedDimensionsRef.current = null;
8793 return void 0;
8794 }
8795 if (!popupElement || !positionerElement) {
8796 return void 0;
8797 }
8798 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8799 setPopupCssSize(popupElement, "auto");
8800 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8801 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8802 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8803 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8804 "--available-width": "max-content",
8805 "--available-height": "max-content"
8806 });
8807 function restoreMeasurementOverrides() {
8808 restorePopupPosition();
8809 restorePopupTransform();
8810 restorePositionerAvailableSize();
8811 }
8812 function restoreMeasurementOverridesIncludingScale() {
8813 restoreMeasurementOverrides();
8814 restorePopupScale();
8815 }
8816 onMeasureLayout?.();
8817 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8818 setPositionerCssSize(positionerElement, "max-content");
8819 const dimensions = getCssDimensions2(popupElement);
8820 committedDimensionsRef.current = dimensions;
8821 setPositionerCssSize(positionerElement, dimensions);
8822 restoreMeasurementOverridesIncludingScale();
8823 onMeasureLayoutComplete?.(null, dimensions);
8824 isInitialRenderRef.current = false;
8825 return () => {
8826 restoreAnchoringStylesRef.current();
8827 restoreAnchoringStylesRef.current = NOOP;
8828 };
8829 }
8830 setPositionerCssSize(positionerElement, "max-content");
8831 const previousDimensions = committedDimensionsRef.current;
8832 const newDimensions = getCssDimensions2(popupElement);
8833 committedDimensionsRef.current = newDimensions;
8834 setPopupCssSize(popupElement, previousDimensions);
8835 restoreMeasurementOverridesIncludingScale();
8836 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8837 setPositionerCssSize(positionerElement, newDimensions);
8838 const abortController = new AbortController();
8839 animationFrame.request(() => {
8840 setPopupCssSize(popupElement, newDimensions);
8841 runOnceAnimationsFinish(() => {
8842 popupElement.style.setProperty("--popup-width", "auto");
8843 popupElement.style.setProperty("--popup-height", "auto");
8844 }, abortController.signal);
8845 });
8846 return () => {
8847 abortController.abort();
8848 animationFrame.cancel();
8849 restoreAnchoringStylesRef.current();
8850 restoreAnchoringStylesRef.current = NOOP;
8851 };
8852 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8853 }
8854 function overrideElementStyle(element, property, value) {
8855 const originalValue = element.style.getPropertyValue(property);
8856 element.style.setProperty(property, value);
8857 return () => {
8858 element.style.setProperty(property, originalValue);
8859 };
8860 }
8861 function applyElementStyles(element, styles) {
8862 const restorers = [];
8863 for (const [key, value] of Object.entries(styles)) {
8864 restorers.push(overrideElementStyle(element, key, value));
8865 }
8866 return restorers.length ? () => {
8867 restorers.forEach((restore) => restore());
8868 } : NOOP;
8869 }
8870 function setPopupCssSize(popupElement, size4) {
8871 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8872 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8873 popupElement.style.setProperty("--popup-width", width);
8874 popupElement.style.setProperty("--popup-height", height);
8875 }
8876 function setPositionerCssSize(positionerElement, size4) {
8877 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8878 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8879 positionerElement.style.setProperty("--positioner-width", width);
8880 positionerElement.style.setProperty("--positioner-height", height);
8881 }
8882
8883 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8884 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8885 function usePopupViewport(parameters) {
8886 const {
8887 store,
8888 side,
8889 cssVars,
8890 children
8891 } = parameters;
8892 const direction = useDirection();
8893 const activeTrigger = store.useState("activeTriggerElement");
8894 const activeTriggerId = store.useState("activeTriggerId");
8895 const open = store.useState("open");
8896 const payload = store.useState("payload");
8897 const mounted = store.useState("mounted");
8898 const popupElement = store.useState("popupElement");
8899 const positionerElement = store.useState("positionerElement");
8900 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8901 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8902 const capturedNodeRef = React32.useRef(null);
8903 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
8904 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
8905 const currentContainerRef = React32.useRef(null);
8906 const previousContainerRef = React32.useRef(null);
8907 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8908 const cleanupFrame = useAnimationFrame();
8909 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
8910 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
8911 useIsoLayoutEffect(() => {
8912 store.set("hasViewport", true);
8913 return () => {
8914 store.set("hasViewport", false);
8915 };
8916 }, [store]);
8917 const handleMeasureLayout = useStableCallback(() => {
8918 currentContainerRef.current?.style.setProperty("animation", "none");
8919 currentContainerRef.current?.style.setProperty("transition", "none");
8920 previousContainerRef.current?.style.setProperty("display", "none");
8921 });
8922 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8923 currentContainerRef.current?.style.removeProperty("animation");
8924 currentContainerRef.current?.style.removeProperty("transition");
8925 previousContainerRef.current?.style.removeProperty("display");
8926 if (previousDimensions) {
8927 setPreviousContentDimensions(previousDimensions);
8928 }
8929 });
8930 const lastHandledTriggerRef = React32.useRef(null);
8931 useIsoLayoutEffect(() => {
8932 if (!open || !mounted) {
8933 lastHandledTriggerRef.current = null;
8934 }
8935 }, [open, mounted]);
8936 useIsoLayoutEffect(() => {
8937 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8938 setPreviousContentNode(capturedNodeRef.current);
8939 setShowStartingStyleAttribute(true);
8940 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8941 setNewTriggerOffset(offset4);
8942 cleanupFrame.request(() => {
8943 ReactDOM6.flushSync(() => {
8944 setShowStartingStyleAttribute(false);
8945 });
8946 onAnimationsFinished(() => {
8947 setPreviousContentNode(null);
8948 setPreviousContentDimensions(null);
8949 capturedNodeRef.current = null;
8950 });
8951 });
8952 lastHandledTriggerRef.current = activeTrigger;
8953 }
8954 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8955 useIsoLayoutEffect(() => {
8956 const source = currentContainerRef.current;
8957 if (!source) {
8958 return;
8959 }
8960 const wrapper = ownerDocument(source).createElement("div");
8961 for (const child of Array.from(source.childNodes)) {
8962 wrapper.appendChild(child.cloneNode(true));
8963 }
8964 capturedNodeRef.current = wrapper;
8965 });
8966 const isTransitioning = previousContentNode != null;
8967 let childrenToRender;
8968 if (!isTransitioning) {
8969 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8970 "data-current": true,
8971 ref: currentContainerRef,
8972 children
8973 }, currentContentKey);
8974 } else {
8975 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(React32.Fragment, {
8976 children: [/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8977 "data-previous": true,
8978 inert: inertValue(true),
8979 ref: previousContainerRef,
8980 style: {
8981 ...previousContentDimensions ? {
8982 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8983 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8984 } : null,
8985 position: "absolute"
8986 },
8987 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8988 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8989 "data-current": true,
8990 ref: currentContainerRef,
8991 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8992 children
8993 }, currentContentKey)]
8994 });
8995 }
8996 useIsoLayoutEffect(() => {
8997 const container = previousContainerRef.current;
8998 if (!container || !previousContentNode) {
8999 return;
9000 }
9001 container.replaceChildren(...Array.from(previousContentNode.childNodes));
9002 }, [previousContentNode]);
9003 usePopupAutoResize({
9004 popupElement,
9005 positionerElement,
9006 mounted,
9007 content: payload,
9008 onMeasureLayout: handleMeasureLayout,
9009 onMeasureLayoutComplete: handleMeasureLayoutComplete,
9010 side,
9011 direction
9012 });
9013 const state = {
9014 activationDirection: getActivationDirection(newTriggerOffset),
9015 transitioning: isTransitioning
9016 };
9017 return {
9018 children: childrenToRender,
9019 state
9020 };
9021 }
9022 function getActivationDirection(offset4) {
9023 if (!offset4) {
9024 return void 0;
9025 }
9026 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9027 }
9028 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9029 if (value > tolerance) {
9030 return positiveLabel;
9031 }
9032 if (value < -tolerance) {
9033 return negativeLabel;
9034 }
9035 return "";
9036 }
9037 function calculateRelativePosition(from, to) {
9038 const fromRect = from.getBoundingClientRect();
9039 const toRect = to.getBoundingClientRect();
9040 const fromCenter = {
9041 x: fromRect.left + fromRect.width / 2,
9042 y: fromRect.top + fromRect.height / 2
9043 };
9044 const toCenter = {
9045 x: toRect.left + toRect.width / 2,
9046 y: toRect.top + toRect.height / 2
9047 };
9048 return {
9049 horizontal: toCenter.x - fromCenter.x,
9050 vertical: toCenter.y - fromCenter.y
9051 };
9052 }
9053 function usePopupContentKey(activeTriggerId, payload) {
9054 const [contentKey, setContentKey] = React32.useState(0);
9055 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
9056 const previousPayloadRef = React32.useRef(payload);
9057 const pendingPayloadUpdateRef = React32.useRef(false);
9058 useIsoLayoutEffect(() => {
9059 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9060 const previousPayload = previousPayloadRef.current;
9061 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9062 const payloadChanged = payload !== previousPayload;
9063 if (triggerIdChanged) {
9064 setContentKey((value) => value + 1);
9065 pendingPayloadUpdateRef.current = !payloadChanged;
9066 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9067 setContentKey((value) => value + 1);
9068 pendingPayloadUpdateRef.current = false;
9069 }
9070 previousActiveTriggerIdRef.current = activeTriggerId;
9071 previousPayloadRef.current = payload;
9072 }, [activeTriggerId, payload]);
9073 return `${activeTriggerId ?? "current"}-${contentKey}`;
9074 }
9075
9076 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
9077 var React33 = __toESM(require_react(), 1);
9078 var ReactDOM7 = __toESM(require_react_dom(), 1);
9079 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9080 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9081 const {
9082 children,
9083 container,
9084 className,
9085 render: render4,
9086 style,
9087 ...elementProps
9088 } = componentProps;
9089 const {
9090 portalNode,
9091 portalSubtree
9092 } = useFloatingPortalNode({
9093 container,
9094 ref: forwardedRef,
9095 componentProps,
9096 elementProps
9097 });
9098 if (!portalSubtree && !portalNode) {
9099 return null;
9100 }
9101 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(React33.Fragment, {
9102 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
9103 });
9104 });
9105 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9106
9107 // node_modules/@base-ui/react/tooltip/index.parts.mjs
9108 var index_parts_exports = {};
9109 __export(index_parts_exports, {
9110 Arrow: () => TooltipArrow,
9111 Handle: () => TooltipHandle,
9112 Popup: () => TooltipPopup,
9113 Portal: () => TooltipPortal,
9114 Positioner: () => TooltipPositioner,
9115 Provider: () => TooltipProvider,
9116 Root: () => TooltipRoot,
9117 Trigger: () => TooltipTrigger,
9118 Viewport: () => TooltipViewport,
9119 createHandle: () => createTooltipHandle
9120 });
9121
9122 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9123 var React36 = __toESM(require_react(), 1);
9124
9125 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
9126 var React34 = __toESM(require_react(), 1);
9127 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
9128 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9129 function useTooltipRootContext(optional) {
9130 const context = React34.useContext(TooltipRootContext);
9131 if (context === void 0 && !optional) {
9132 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9133 }
9134 return context;
9135 }
9136
9137 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
9138 var React35 = __toESM(require_react(), 1);
9139 var selectors2 = {
9140 ...popupStoreSelectors,
9141 disabled: createSelector((state) => state.disabled),
9142 instantType: createSelector((state) => state.instantType),
9143 isInstantPhase: createSelector((state) => state.isInstantPhase),
9144 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9145 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9146 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9147 closeOnClick: createSelector((state) => state.closeOnClick),
9148 closeDelay: createSelector((state) => state.closeDelay),
9149 hasViewport: createSelector((state) => state.hasViewport)
9150 };
9151 var TooltipStore = class _TooltipStore extends ReactStore {
9152 constructor(initialState, floatingId, nested = false) {
9153 const triggerElements = new PopupTriggerMap();
9154 const state = {
9155 ...createInitialState(),
9156 ...initialState
9157 };
9158 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9159 super(state, {
9160 popupRef: /* @__PURE__ */ React35.createRef(),
9161 onOpenChange: void 0,
9162 onOpenChangeComplete: void 0,
9163 triggerElements
9164 }, selectors2);
9165 }
9166 setOpen = (nextOpen, eventDetails) => {
9167 applyPopupOpenChange(this, nextOpen, eventDetails, {
9168 extraState: {
9169 openChangeReason: eventDetails.reason
9170 }
9171 });
9172 };
9173 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9174 cancelPendingOpen(event) {
9175 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9176 }
9177 static useStore(externalStore, initialState) {
9178 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9179 return store;
9180 }
9181 };
9182 function createInitialState() {
9183 return {
9184 ...createInitialPopupStoreState(),
9185 disabled: false,
9186 instantType: void 0,
9187 isInstantPhase: false,
9188 trackCursorAxis: "none",
9189 disableHoverablePopup: false,
9190 openChangeReason: null,
9191 closeOnClick: true,
9192 closeDelay: 0,
9193 hasViewport: false
9194 };
9195 }
9196
9197 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9198 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9199 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9200 const {
9201 disabled: disabled2 = false,
9202 defaultOpen = false,
9203 open: openProp,
9204 disableHoverablePopup = false,
9205 trackCursorAxis = "none",
9206 actionsRef,
9207 onOpenChange,
9208 onOpenChangeComplete,
9209 handle,
9210 triggerId: triggerIdProp,
9211 defaultTriggerId: defaultTriggerIdProp = null,
9212 children
9213 } = props;
9214 const store = TooltipStore.useStore(handle?.store, {
9215 open: defaultOpen,
9216 openProp,
9217 activeTriggerId: defaultTriggerIdProp,
9218 triggerIdProp
9219 });
9220 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
9221 store.useControlledProp("openProp", openProp);
9222 store.useControlledProp("triggerIdProp", triggerIdProp);
9223 store.useContextCallback("onOpenChange", onOpenChange);
9224 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9225 const openState = store.useState("open");
9226 const open = !disabled2 && openState;
9227 const activeTriggerId = store.useState("activeTriggerId");
9228 const mounted = store.useState("mounted");
9229 const payload = store.useState("payload");
9230 store.useSyncedValues({
9231 trackCursorAxis,
9232 disableHoverablePopup
9233 });
9234 store.useSyncedValue("disabled", disabled2);
9235 useImplicitActiveTrigger(store, {
9236 closeOnActiveTriggerUnmount: true
9237 });
9238 const {
9239 forceUnmount,
9240 transitionStatus
9241 } = useOpenStateTransitions(open, store);
9242 const isInstantPhase = store.useState("isInstantPhase");
9243 const instantType = store.useState("instantType");
9244 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9245 const previousInstantTypeRef = React36.useRef(null);
9246 useIsoLayoutEffect(() => {
9247 if (openState && disabled2) {
9248 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9249 }
9250 }, [openState, disabled2, store]);
9251 useIsoLayoutEffect(() => {
9252 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9253 if (instantType !== "delay") {
9254 previousInstantTypeRef.current = instantType;
9255 }
9256 store.set("instantType", "delay");
9257 } else if (previousInstantTypeRef.current !== null) {
9258 store.set("instantType", previousInstantTypeRef.current);
9259 previousInstantTypeRef.current = null;
9260 }
9261 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9262 useIsoLayoutEffect(() => {
9263 if (open) {
9264 if (activeTriggerId == null) {
9265 store.set("payload", void 0);
9266 }
9267 }
9268 }, [store, activeTriggerId, open]);
9269 const handleImperativeClose = React36.useCallback(() => {
9270 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9271 }, [store]);
9272 React36.useImperativeHandle(actionsRef, () => ({
9273 unmount: forceUnmount,
9274 close: handleImperativeClose
9275 }), [forceUnmount, handleImperativeClose]);
9276 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9277 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(TooltipRootContext.Provider, {
9278 value: store,
9279 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipInteractions, {
9280 store,
9281 disabled: disabled2,
9282 trackCursorAxis
9283 }), typeof children === "function" ? children({
9284 payload
9285 }) : children]
9286 });
9287 });
9288 if (true) TooltipRoot.displayName = "TooltipRoot";
9289 function TooltipInteractions({
9290 store,
9291 disabled: disabled2,
9292 trackCursorAxis
9293 }) {
9294 const floatingRootContext = store.useState("floatingRootContext");
9295 const dismiss = useDismiss(floatingRootContext, {
9296 enabled: !disabled2,
9297 referencePress: () => store.select("closeOnClick")
9298 });
9299 const clientPoint = useClientPoint(floatingRootContext, {
9300 enabled: !disabled2 && trackCursorAxis !== "none",
9301 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9302 });
9303 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9304 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9305 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9306 usePopupInteractionProps(store, {
9307 activeTriggerProps,
9308 inactiveTriggerProps,
9309 popupProps
9310 });
9311 return null;
9312 }
9313
9314 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9315 var React38 = __toESM(require_react(), 1);
9316
9317 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
9318 var React37 = __toESM(require_react(), 1);
9319 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
9320 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9321 function useTooltipProviderContext() {
9322 return React37.useContext(TooltipProviderContext);
9323 }
9324
9325 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
9326 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9327 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9328 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9329 return TooltipTriggerDataAttributes2;
9330 })({});
9331
9332 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
9333 var OPEN_DELAY = 600;
9334
9335 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9336 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9337 function getTargetElement(event) {
9338 if ("composedPath" in event) {
9339 const path = event.composedPath();
9340 for (let i2 = 0; i2 < path.length; i2 += 1) {
9341 const element = path[i2];
9342 if (isElement(element)) {
9343 return element;
9344 }
9345 }
9346 }
9347 const target = event.target;
9348 if (isElement(target)) {
9349 return target;
9350 }
9351 return null;
9352 }
9353 function closestEnabledTooltipTrigger(element) {
9354 let current = element;
9355 while (current) {
9356 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9357 return current;
9358 }
9359 const parentElement = current.parentElement;
9360 if (parentElement) {
9361 current = parentElement;
9362 continue;
9363 }
9364 const root = current.getRootNode();
9365 current = "host" in root && isElement(root.host) ? root.host : null;
9366 }
9367 return null;
9368 }
9369 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9370 const {
9371 render: render4,
9372 className,
9373 style,
9374 handle,
9375 payload,
9376 disabled: disabledProp,
9377 delay,
9378 closeOnClick = true,
9379 closeDelay,
9380 id: idProp,
9381 ...elementProps
9382 } = componentProps;
9383 const rootContext = useTooltipRootContext(true);
9384 const store = handle?.store ?? rootContext;
9385 if (!store) {
9386 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));
9387 }
9388 const thisTriggerId = useBaseUiId(idProp);
9389 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9390 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9391 const floatingRootContext = store.useState("floatingRootContext");
9392 const triggerElementRef = React38.useRef(null);
9393 const delayWithDefault = delay ?? OPEN_DELAY;
9394 const closeDelayWithDefault = closeDelay ?? 0;
9395 const {
9396 registerTrigger,
9397 isMountedByThisTrigger
9398 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9399 payload,
9400 closeOnClick,
9401 closeDelay: closeDelayWithDefault
9402 });
9403 const providerContext = useTooltipProviderContext();
9404 const {
9405 delayRef,
9406 isInstantPhase,
9407 hasProvider
9408 } = useDelayGroup(floatingRootContext, {
9409 open: isOpenedByThisTrigger
9410 });
9411 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9412 store.useSyncedValue("isInstantPhase", isInstantPhase);
9413 const rootDisabled = store.useState("disabled");
9414 const disabled2 = disabledProp ?? rootDisabled;
9415 const disabledRef = useValueAsRef(disabled2);
9416 const trackCursorAxis = store.useState("trackCursorAxis");
9417 const disableHoverablePopup = store.useState("disableHoverablePopup");
9418 const isNestedTriggerHoveredRef = React38.useRef(false);
9419 const nestedTriggerOpenTimeout = useTimeout();
9420 const pointerTypeRef = React38.useRef(void 0);
9421 function getOpenDelay() {
9422 const providerDelay = providerContext?.delay;
9423 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9424 let computedOpenDelay = delayWithDefault;
9425 if (hasProvider) {
9426 if (groupOpenValue !== 0) {
9427 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9428 } else {
9429 computedOpenDelay = 0;
9430 }
9431 }
9432 return computedOpenDelay;
9433 }
9434 function isEnabledNestedTriggerTarget(target) {
9435 const triggerEl = triggerElementRef.current;
9436 if (!triggerEl || !target) {
9437 return false;
9438 }
9439 const nearestTrigger = closestEnabledTooltipTrigger(target);
9440 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9441 }
9442 function detectNestedTriggerHover(target) {
9443 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9444 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9445 if (nestedTriggerHovered) {
9446 hoverInteraction.openChangeTimeout.clear();
9447 hoverInteraction.restTimeout.clear();
9448 hoverInteraction.restTimeoutPending = false;
9449 nestedTriggerOpenTimeout.clear();
9450 }
9451 return nestedTriggerHovered;
9452 }
9453 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9454 enabled: !disabled2,
9455 mouseOnly: true,
9456 move: false,
9457 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9458 restMs: getOpenDelay,
9459 delay() {
9460 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9461 let computedCloseDelay = closeDelayWithDefault;
9462 if (closeDelay == null && hasProvider) {
9463 computedCloseDelay = closeValue;
9464 }
9465 return {
9466 close: computedCloseDelay
9467 };
9468 },
9469 triggerElementRef,
9470 isActiveTrigger: isTriggerActive,
9471 isClosing: () => store.select("transitionStatus") === "ending",
9472 shouldOpen() {
9473 return !isNestedTriggerHoveredRef.current;
9474 }
9475 });
9476 const focusProps = useFocus(floatingRootContext, {
9477 enabled: !disabled2
9478 }).reference;
9479 const handleNestedTriggerHover = (event) => {
9480 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9481 const target = getTargetElement(event);
9482 const nestedTriggerHovered = detectNestedTriggerHover(target);
9483 const triggerEl = triggerElementRef.current;
9484 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9485 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9486 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9487 return;
9488 }
9489 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9490 isMouseLikePointerType(pointerTypeRef.current)) {
9491 const open = () => {
9492 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9493 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9494 }
9495 };
9496 const openDelay = getOpenDelay();
9497 if (openDelay === 0) {
9498 nestedTriggerOpenTimeout.clear();
9499 open();
9500 } else {
9501 nestedTriggerOpenTimeout.start(openDelay, open);
9502 }
9503 }
9504 };
9505 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9506 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9507 const state = {
9508 open: isOpenedByThisTrigger
9509 };
9510 const element = useRenderElement("button", componentProps, {
9511 state,
9512 ref: [forwardedRef, registerTrigger, triggerElementRef],
9513 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9514 onMouseOver(event) {
9515 handleNestedTriggerHover(event.nativeEvent);
9516 },
9517 onFocus(event) {
9518 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9519 event.preventBaseUIHandler();
9520 }
9521 },
9522 onMouseLeave() {
9523 isNestedTriggerHoveredRef.current = false;
9524 nestedTriggerOpenTimeout.clear();
9525 pointerTypeRef.current = void 0;
9526 },
9527 onPointerEnter(event) {
9528 pointerTypeRef.current = event.pointerType;
9529 },
9530 onPointerDown(event) {
9531 pointerTypeRef.current = event.pointerType;
9532 store.set("closeOnClick", closeOnClick);
9533 if (closeOnClick && !store.select("open")) {
9534 store.cancelPendingOpen(event.nativeEvent);
9535 }
9536 },
9537 onClick(event) {
9538 if (closeOnClick && !store.select("open")) {
9539 store.cancelPendingOpen(event.nativeEvent);
9540 }
9541 },
9542 id: thisTriggerId,
9543 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9544 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9545 }, elementProps],
9546 stateAttributesMapping: triggerOpenStateMapping
9547 });
9548 return element;
9549 });
9550 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9551
9552 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9553 var React40 = __toESM(require_react(), 1);
9554
9555 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
9556 var React39 = __toESM(require_react(), 1);
9557 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
9558 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9559 function useTooltipPortalContext() {
9560 const value = React39.useContext(TooltipPortalContext);
9561 if (value === void 0) {
9562 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9563 }
9564 return value;
9565 }
9566
9567 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9568 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9569 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
9570 const {
9571 keepMounted = false,
9572 ...portalProps
9573 } = props;
9574 const store = useTooltipRootContext();
9575 const mounted = store.useState("mounted");
9576 const shouldRender = mounted || keepMounted;
9577 if (!shouldRender) {
9578 return null;
9579 }
9580 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TooltipPortalContext.Provider, {
9581 value: keepMounted,
9582 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FloatingPortalLite, {
9583 ref: forwardedRef,
9584 ...portalProps
9585 })
9586 });
9587 });
9588 if (true) TooltipPortal.displayName = "TooltipPortal";
9589
9590 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9591 var React42 = __toESM(require_react(), 1);
9592
9593 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
9594 var React41 = __toESM(require_react(), 1);
9595 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
9596 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9597 function useTooltipPositionerContext() {
9598 const context = React41.useContext(TooltipPositionerContext);
9599 if (context === void 0) {
9600 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9601 }
9602 return context;
9603 }
9604
9605 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9606 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9607 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9608 const {
9609 render: render4,
9610 className,
9611 anchor,
9612 positionMethod = "absolute",
9613 side = "top",
9614 align = "center",
9615 sideOffset = 0,
9616 alignOffset = 0,
9617 collisionBoundary = "clipping-ancestors",
9618 collisionPadding = 5,
9619 arrowPadding = 5,
9620 sticky = false,
9621 disableAnchorTracking = false,
9622 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9623 style,
9624 ...elementProps
9625 } = componentProps;
9626 const store = useTooltipRootContext();
9627 const keepMounted = useTooltipPortalContext();
9628 const open = store.useState("open");
9629 const mounted = store.useState("mounted");
9630 const trackCursorAxis = store.useState("trackCursorAxis");
9631 const disableHoverablePopup = store.useState("disableHoverablePopup");
9632 const floatingRootContext = store.useState("floatingRootContext");
9633 const instantType = store.useState("instantType");
9634 const transitionStatus = store.useState("transitionStatus");
9635 const hasViewport = store.useState("hasViewport");
9636 const positioning = useAnchorPositioning({
9637 anchor,
9638 positionMethod,
9639 floatingRootContext,
9640 mounted,
9641 side,
9642 sideOffset,
9643 align,
9644 alignOffset,
9645 collisionBoundary,
9646 collisionPadding,
9647 sticky,
9648 arrowPadding,
9649 disableAnchorTracking,
9650 keepMounted,
9651 collisionAvoidance,
9652 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9653 });
9654 const state = React42.useMemo(() => ({
9655 open,
9656 side: positioning.side,
9657 align: positioning.align,
9658 anchorHidden: positioning.anchorHidden,
9659 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9660 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9661 const element = usePositioner(componentProps, state, {
9662 styles: positioning.positionerStyles,
9663 transitionStatus,
9664 props: elementProps,
9665 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9666 hidden: !mounted,
9667 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9668 });
9669 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipPositionerContext.Provider, {
9670 value: positioning,
9671 children: element
9672 });
9673 });
9674 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9675
9676 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9677 var React43 = __toESM(require_react(), 1);
9678 var stateAttributesMapping = {
9679 ...popupStateMapping,
9680 ...transitionStatusMapping
9681 };
9682 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9683 const {
9684 render: render4,
9685 className,
9686 style,
9687 ...elementProps
9688 } = componentProps;
9689 const store = useTooltipRootContext();
9690 const {
9691 side,
9692 align
9693 } = useTooltipPositionerContext();
9694 const open = store.useState("open");
9695 const instantType = store.useState("instantType");
9696 const transitionStatus = store.useState("transitionStatus");
9697 const popupProps = store.useState("popupProps");
9698 const floatingContext = store.useState("floatingRootContext");
9699 const disabled2 = store.useState("disabled");
9700 const closeDelay = store.useState("closeDelay");
9701 useOpenChangeComplete({
9702 open,
9703 ref: store.context.popupRef,
9704 onComplete() {
9705 if (open) {
9706 store.context.onOpenChangeComplete?.(true);
9707 }
9708 }
9709 });
9710 useHoverFloatingInteraction(floatingContext, {
9711 enabled: !disabled2,
9712 closeDelay
9713 });
9714 const setPopupElement = store.useStateSetter("popupElement");
9715 const state = {
9716 open,
9717 side,
9718 align,
9719 instant: instantType,
9720 transitionStatus
9721 };
9722 const element = useRenderElement("div", componentProps, {
9723 state,
9724 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9725 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9726 stateAttributesMapping
9727 });
9728 return element;
9729 });
9730 if (true) TooltipPopup.displayName = "TooltipPopup";
9731
9732 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9733 var React44 = __toESM(require_react(), 1);
9734 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9735 const {
9736 render: render4,
9737 className,
9738 style,
9739 ...elementProps
9740 } = componentProps;
9741 const store = useTooltipRootContext();
9742 const {
9743 arrowRef,
9744 side,
9745 align,
9746 arrowUncentered,
9747 arrowStyles
9748 } = useTooltipPositionerContext();
9749 const open = store.useState("open");
9750 const instantType = store.useState("instantType");
9751 const state = {
9752 open,
9753 side,
9754 align,
9755 uncentered: arrowUncentered,
9756 instant: instantType
9757 };
9758 const element = useRenderElement("div", componentProps, {
9759 state,
9760 ref: [forwardedRef, arrowRef],
9761 props: [{
9762 style: arrowStyles,
9763 "aria-hidden": true
9764 }, elementProps],
9765 stateAttributesMapping: popupStateMapping
9766 });
9767 return element;
9768 });
9769 if (true) TooltipArrow.displayName = "TooltipArrow";
9770
9771 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9772 var React45 = __toESM(require_react(), 1);
9773 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9774 var TooltipProvider = function TooltipProvider2(props) {
9775 const {
9776 delay,
9777 closeDelay,
9778 timeout = 400
9779 } = props;
9780 const contextValue = React45.useMemo(() => ({
9781 delay,
9782 closeDelay
9783 }), [delay, closeDelay]);
9784 const delayValue = React45.useMemo(() => ({
9785 open: delay,
9786 close: closeDelay
9787 }), [delay, closeDelay]);
9788 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TooltipProviderContext.Provider, {
9789 value: contextValue,
9790 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FloatingDelayGroup, {
9791 delay: delayValue,
9792 timeoutMs: timeout,
9793 children: props.children
9794 })
9795 });
9796 };
9797 if (true) TooltipProvider.displayName = "TooltipProvider";
9798
9799 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9800 var React46 = __toESM(require_react(), 1);
9801
9802 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9803 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9804 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9805 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9806 return TooltipViewportCssVars2;
9807 })({});
9808
9809 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9810 var stateAttributesMapping2 = {
9811 activationDirection: (value) => value ? {
9812 "data-activation-direction": value
9813 } : null
9814 };
9815 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9816 const {
9817 render: render4,
9818 className,
9819 style,
9820 children,
9821 ...elementProps
9822 } = componentProps;
9823 const store = useTooltipRootContext();
9824 const positioner = useTooltipPositionerContext();
9825 const instantType = store.useState("instantType");
9826 const {
9827 children: childrenToRender,
9828 state: viewportState
9829 } = usePopupViewport({
9830 store,
9831 side: positioner.side,
9832 cssVars: TooltipViewportCssVars,
9833 children
9834 });
9835 const state = {
9836 activationDirection: viewportState.activationDirection,
9837 transitioning: viewportState.transitioning,
9838 instant: instantType
9839 };
9840 return useRenderElement("div", componentProps, {
9841 state,
9842 ref: forwardedRef,
9843 props: [elementProps, {
9844 children: childrenToRender
9845 }],
9846 stateAttributesMapping: stateAttributesMapping2
9847 });
9848 });
9849 if (true) TooltipViewport.displayName = "TooltipViewport";
9850
9851 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9852 var TooltipHandle = class {
9853 /**
9854 * Internal store holding the tooltip state.
9855 * @internal
9856 */
9857 constructor() {
9858 this.store = new TooltipStore();
9859 }
9860 /**
9861 * Opens the tooltip and associates it with the trigger with the given ID.
9862 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9863 *
9864 * This method should only be called in an event handler or an effect (not during rendering).
9865 *
9866 * @param triggerId ID of the trigger to associate with the tooltip.
9867 */
9868 open(triggerId) {
9869 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9870 if (triggerId && !triggerElement) {
9871 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9872 }
9873 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9874 }
9875 /**
9876 * Closes the tooltip.
9877 */
9878 close() {
9879 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9880 }
9881 /**
9882 * Indicates whether the tooltip is currently open.
9883 */
9884 get isOpen() {
9885 return this.store.select("open");
9886 }
9887 };
9888 function createTooltipHandle() {
9889 return new TooltipHandle();
9890 }
9891
9892 // node_modules/@base-ui/react/use-render/useRender.mjs
9893 function useRender(params) {
9894 return useRenderElement(params.defaultTagName ?? "div", params, params);
9895 }
9896
9897 // packages/ui/build-module/utils/render-slot-with-children.mjs
9898 var import_element11 = __toESM(require_element(), 1);
9899 function renderSlotWithChildren(slot, defaultSlot, children) {
9900 return (0, import_element11.cloneElement)(slot ?? defaultSlot, { children });
9901 }
9902
9903 // packages/ui/build-module/utils/theme-provider.mjs
9904 var theme = __toESM(require_theme(), 1);
9905
9906 // packages/ui/build-module/lock-unlock.mjs
9907 var import_private_apis = __toESM(require_private_apis(), 1);
9908 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9909 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9910 "@wordpress/ui"
9911 );
9912
9913 // packages/ui/build-module/utils/theme-provider.mjs
9914 function getThemeProvider() {
9915 const themePackage = theme;
9916 if (themePackage.ThemeProvider) {
9917 return themePackage.ThemeProvider;
9918 }
9919 if (!themePackage.privateApis) {
9920 throw new Error(
9921 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9922 );
9923 }
9924 return unlock(
9925 themePackage.privateApis
9926 ).ThemeProvider;
9927 }
9928 var ThemeProvider = getThemeProvider();
9929
9930 // packages/ui/build-module/stack/stack.mjs
9931 var import_element12 = __toESM(require_element(), 1);
9932 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9933 function getRuntime() {
9934 const globalScope = globalThis;
9935 if (globalScope.__wpStyleRuntime) {
9936 return globalScope.__wpStyleRuntime;
9937 }
9938 globalScope.__wpStyleRuntime = {
9939 documents: /* @__PURE__ */ new Map(),
9940 styles: /* @__PURE__ */ new Map(),
9941 injectedStyles: /* @__PURE__ */ new WeakMap()
9942 };
9943 if (typeof document !== "undefined") {
9944 registerDocument(document);
9945 }
9946 return globalScope.__wpStyleRuntime;
9947 }
9948 function documentContainsStyleHash(targetDocument, hash) {
9949 if (!targetDocument.head) {
9950 return false;
9951 }
9952 for (const style of targetDocument.head.querySelectorAll(
9953 `style[${STYLE_HASH_ATTRIBUTE}]`
9954 )) {
9955 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9956 return true;
9957 }
9958 }
9959 return false;
9960 }
9961 function injectStyle(targetDocument, hash, css) {
9962 if (!targetDocument.head) {
9963 return;
9964 }
9965 const runtime = getRuntime();
9966 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9967 if (!injectedStyles) {
9968 injectedStyles = /* @__PURE__ */ new Set();
9969 runtime.injectedStyles.set(targetDocument, injectedStyles);
9970 }
9971 if (injectedStyles.has(hash)) {
9972 return;
9973 }
9974 if (documentContainsStyleHash(targetDocument, hash)) {
9975 injectedStyles.add(hash);
9976 return;
9977 }
9978 const style = targetDocument.createElement("style");
9979 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9980 style.appendChild(targetDocument.createTextNode(css));
9981 targetDocument.head.appendChild(style);
9982 injectedStyles.add(hash);
9983 }
9984 function registerDocument(targetDocument) {
9985 const runtime = getRuntime();
9986 runtime.documents.set(
9987 targetDocument,
9988 (runtime.documents.get(targetDocument) ?? 0) + 1
9989 );
9990 for (const [hash, css] of runtime.styles) {
9991 injectStyle(targetDocument, hash, css);
9992 }
9993 return () => {
9994 const count = runtime.documents.get(targetDocument);
9995 if (count === void 0) {
9996 return;
9997 }
9998 if (count <= 1) {
9999 runtime.documents.delete(targetDocument);
10000 return;
10001 }
10002 runtime.documents.set(targetDocument, count - 1);
10003 };
10004 }
10005 function registerStyle(hash, css) {
10006 const runtime = getRuntime();
10007 runtime.styles.set(hash, css);
10008 for (const targetDocument of runtime.documents.keys()) {
10009 injectStyle(targetDocument, hash, css);
10010 }
10011 }
10012 if (typeof process === "undefined" || true) {
10013 registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
10014 }
10015 var style_default = { "stack": "_19ce0419607e1896__stack" };
10016 var gapTokens = {
10017 xs: "var(--wpds-dimension-gap-xs, 4px)",
10018 sm: "var(--wpds-dimension-gap-sm, 8px)",
10019 md: "var(--wpds-dimension-gap-md, 12px)",
10020 lg: "var(--wpds-dimension-gap-lg, 16px)",
10021 xl: "var(--wpds-dimension-gap-xl, 24px)",
10022 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
10023 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
10024 };
10025 var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
10026 const style = {
10027 gap: gap && gapTokens[gap],
10028 alignItems: align,
10029 justifyContent: justify,
10030 flexDirection: direction,
10031 flexWrap: wrap
10032 };
10033 const element = useRender({
10034 render: render4,
10035 ref,
10036 props: mergeProps(props, { style, className: style_default.stack })
10037 });
10038 return element;
10039 });
10040
10041 // packages/ui/build-module/tooltip/index.mjs
10042 var tooltip_exports = {};
10043 __export(tooltip_exports, {
10044 Popup: () => Popup,
10045 Portal: () => Portal,
10046 Positioner: () => Positioner,
10047 Provider: () => Provider,
10048 Root: () => Root,
10049 Trigger: () => Trigger
10050 });
10051
10052 // packages/ui/build-module/tooltip/popup.mjs
10053 var import_element15 = __toESM(require_element(), 1);
10054
10055 // packages/ui/build-module/tooltip/portal.mjs
10056 var import_element13 = __toESM(require_element(), 1);
10057
10058 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
10059 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10060 function getRuntime2() {
10061 const globalScope = globalThis;
10062 if (globalScope.__wpStyleRuntime) {
10063 return globalScope.__wpStyleRuntime;
10064 }
10065 globalScope.__wpStyleRuntime = {
10066 documents: /* @__PURE__ */ new Map(),
10067 styles: /* @__PURE__ */ new Map(),
10068 injectedStyles: /* @__PURE__ */ new WeakMap()
10069 };
10070 if (typeof document !== "undefined") {
10071 registerDocument2(document);
10072 }
10073 return globalScope.__wpStyleRuntime;
10074 }
10075 function documentContainsStyleHash2(targetDocument, hash) {
10076 if (!targetDocument.head) {
10077 return false;
10078 }
10079 for (const style of targetDocument.head.querySelectorAll(
10080 `style[${STYLE_HASH_ATTRIBUTE2}]`
10081 )) {
10082 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10083 return true;
10084 }
10085 }
10086 return false;
10087 }
10088 function injectStyle2(targetDocument, hash, css) {
10089 if (!targetDocument.head) {
10090 return;
10091 }
10092 const runtime = getRuntime2();
10093 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10094 if (!injectedStyles) {
10095 injectedStyles = /* @__PURE__ */ new Set();
10096 runtime.injectedStyles.set(targetDocument, injectedStyles);
10097 }
10098 if (injectedStyles.has(hash)) {
10099 return;
10100 }
10101 if (documentContainsStyleHash2(targetDocument, hash)) {
10102 injectedStyles.add(hash);
10103 return;
10104 }
10105 const style = targetDocument.createElement("style");
10106 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10107 style.appendChild(targetDocument.createTextNode(css));
10108 targetDocument.head.appendChild(style);
10109 injectedStyles.add(hash);
10110 }
10111 function registerDocument2(targetDocument) {
10112 const runtime = getRuntime2();
10113 runtime.documents.set(
10114 targetDocument,
10115 (runtime.documents.get(targetDocument) ?? 0) + 1
10116 );
10117 for (const [hash, css] of runtime.styles) {
10118 injectStyle2(targetDocument, hash, css);
10119 }
10120 return () => {
10121 const count = runtime.documents.get(targetDocument);
10122 if (count === void 0) {
10123 return;
10124 }
10125 if (count <= 1) {
10126 runtime.documents.delete(targetDocument);
10127 return;
10128 }
10129 runtime.documents.set(targetDocument, count - 1);
10130 };
10131 }
10132 function registerStyle2(hash, css) {
10133 const runtime = getRuntime2();
10134 runtime.styles.set(hash, css);
10135 for (const targetDocument of runtime.documents.keys()) {
10136 injectStyle2(targetDocument, hash, css);
10137 }
10138 }
10139 if (typeof process === "undefined" || true) {
10140 registerStyle2("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}}}");
10141 }
10142 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
10143 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
10144 function resolveOwnerDocument() {
10145 return typeof document === "undefined" ? null : document;
10146 }
10147 function isInWordPressEnvironment() {
10148 let topWp;
10149 try {
10150 topWp = window.top?.wp;
10151 } catch {
10152 }
10153 const wp = topWp ?? window.wp;
10154 return typeof wp?.components === "object" && wp.components !== null;
10155 }
10156 var cachedSlot = null;
10157 function ensureSlotIsAccessible(element) {
10158 element.setAttribute("aria-hidden", "false");
10159 return element;
10160 }
10161 function createSlot(ownerDocument2) {
10162 const element = ownerDocument2.createElement("div");
10163 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
10164 if (wp_compat_overlay_slot_default.slot) {
10165 element.classList.add(wp_compat_overlay_slot_default.slot);
10166 }
10167 ownerDocument2.body.appendChild(element);
10168 return element;
10169 }
10170 function getWpCompatOverlaySlot() {
10171 if (typeof window === "undefined") {
10172 return void 0;
10173 }
10174 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
10175 return void 0;
10176 }
10177 const ownerDocument2 = resolveOwnerDocument();
10178 if (!ownerDocument2 || !ownerDocument2.body) {
10179 return void 0;
10180 }
10181 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
10182 return ensureSlotIsAccessible(cachedSlot);
10183 }
10184 const existing = ownerDocument2.querySelector(
10185 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
10186 );
10187 if (existing instanceof HTMLDivElement) {
10188 cachedSlot = ensureSlotIsAccessible(existing);
10189 return cachedSlot;
10190 }
10191 if (cachedSlot?.isConnected) {
10192 cachedSlot.remove();
10193 }
10194 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
10195 return cachedSlot;
10196 }
10197
10198 // packages/ui/build-module/tooltip/portal.mjs
10199 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10200 var Portal = (0, import_element13.forwardRef)(
10201 function TooltipPortal3({ container, ...restProps }, ref) {
10202 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10203 index_parts_exports.Portal,
10204 {
10205 container: container ?? getWpCompatOverlaySlot(),
10206 ...restProps,
10207 ref
10208 }
10209 );
10210 }
10211 );
10212
10213 // packages/ui/build-module/tooltip/positioner.mjs
10214 var import_element14 = __toESM(require_element(), 1);
10215 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10216 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10217 function getRuntime3() {
10218 const globalScope = globalThis;
10219 if (globalScope.__wpStyleRuntime) {
10220 return globalScope.__wpStyleRuntime;
10221 }
10222 globalScope.__wpStyleRuntime = {
10223 documents: /* @__PURE__ */ new Map(),
10224 styles: /* @__PURE__ */ new Map(),
10225 injectedStyles: /* @__PURE__ */ new WeakMap()
10226 };
10227 if (typeof document !== "undefined") {
10228 registerDocument3(document);
10229 }
10230 return globalScope.__wpStyleRuntime;
10231 }
10232 function documentContainsStyleHash3(targetDocument, hash) {
10233 if (!targetDocument.head) {
10234 return false;
10235 }
10236 for (const style of targetDocument.head.querySelectorAll(
10237 `style[${STYLE_HASH_ATTRIBUTE3}]`
10238 )) {
10239 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10240 return true;
10241 }
10242 }
10243 return false;
10244 }
10245 function injectStyle3(targetDocument, hash, css) {
10246 if (!targetDocument.head) {
10247 return;
10248 }
10249 const runtime = getRuntime3();
10250 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10251 if (!injectedStyles) {
10252 injectedStyles = /* @__PURE__ */ new Set();
10253 runtime.injectedStyles.set(targetDocument, injectedStyles);
10254 }
10255 if (injectedStyles.has(hash)) {
10256 return;
10257 }
10258 if (documentContainsStyleHash3(targetDocument, hash)) {
10259 injectedStyles.add(hash);
10260 return;
10261 }
10262 const style = targetDocument.createElement("style");
10263 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10264 style.appendChild(targetDocument.createTextNode(css));
10265 targetDocument.head.appendChild(style);
10266 injectedStyles.add(hash);
10267 }
10268 function registerDocument3(targetDocument) {
10269 const runtime = getRuntime3();
10270 runtime.documents.set(
10271 targetDocument,
10272 (runtime.documents.get(targetDocument) ?? 0) + 1
10273 );
10274 for (const [hash, css] of runtime.styles) {
10275 injectStyle3(targetDocument, hash, css);
10276 }
10277 return () => {
10278 const count = runtime.documents.get(targetDocument);
10279 if (count === void 0) {
10280 return;
10281 }
10282 if (count <= 1) {
10283 runtime.documents.delete(targetDocument);
10284 return;
10285 }
10286 runtime.documents.set(targetDocument, count - 1);
10287 };
10288 }
10289 function registerStyle3(hash, css) {
10290 const runtime = getRuntime3();
10291 runtime.styles.set(hash, css);
10292 for (const targetDocument of runtime.documents.keys()) {
10293 injectStyle3(targetDocument, hash, css);
10294 }
10295 }
10296 if (typeof process === "undefined" || true) {
10297 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10298 }
10299 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10300 if (typeof process === "undefined" || true) {
10301 registerStyle3("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
10302 }
10303 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10304 var Positioner = (0, import_element14.forwardRef)(
10305 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
10306 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10307 index_parts_exports.Positioner,
10308 {
10309 ref,
10310 align,
10311 side,
10312 sideOffset,
10313 ...props,
10314 className: clsx_default(
10315 resets_default["box-sizing"],
10316 style_default2.positioner,
10317 className
10318 )
10319 }
10320 );
10321 }
10322 );
10323
10324 // packages/ui/build-module/tooltip/popup.mjs
10325 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10326 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10327 function getRuntime4() {
10328 const globalScope = globalThis;
10329 if (globalScope.__wpStyleRuntime) {
10330 return globalScope.__wpStyleRuntime;
10331 }
10332 globalScope.__wpStyleRuntime = {
10333 documents: /* @__PURE__ */ new Map(),
10334 styles: /* @__PURE__ */ new Map(),
10335 injectedStyles: /* @__PURE__ */ new WeakMap()
10336 };
10337 if (typeof document !== "undefined") {
10338 registerDocument4(document);
10339 }
10340 return globalScope.__wpStyleRuntime;
10341 }
10342 function documentContainsStyleHash4(targetDocument, hash) {
10343 if (!targetDocument.head) {
10344 return false;
10345 }
10346 for (const style of targetDocument.head.querySelectorAll(
10347 `style[${STYLE_HASH_ATTRIBUTE4}]`
10348 )) {
10349 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10350 return true;
10351 }
10352 }
10353 return false;
10354 }
10355 function injectStyle4(targetDocument, hash, css) {
10356 if (!targetDocument.head) {
10357 return;
10358 }
10359 const runtime = getRuntime4();
10360 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10361 if (!injectedStyles) {
10362 injectedStyles = /* @__PURE__ */ new Set();
10363 runtime.injectedStyles.set(targetDocument, injectedStyles);
10364 }
10365 if (injectedStyles.has(hash)) {
10366 return;
10367 }
10368 if (documentContainsStyleHash4(targetDocument, hash)) {
10369 injectedStyles.add(hash);
10370 return;
10371 }
10372 const style = targetDocument.createElement("style");
10373 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10374 style.appendChild(targetDocument.createTextNode(css));
10375 targetDocument.head.appendChild(style);
10376 injectedStyles.add(hash);
10377 }
10378 function registerDocument4(targetDocument) {
10379 const runtime = getRuntime4();
10380 runtime.documents.set(
10381 targetDocument,
10382 (runtime.documents.get(targetDocument) ?? 0) + 1
10383 );
10384 for (const [hash, css] of runtime.styles) {
10385 injectStyle4(targetDocument, hash, css);
10386 }
10387 return () => {
10388 const count = runtime.documents.get(targetDocument);
10389 if (count === void 0) {
10390 return;
10391 }
10392 if (count <= 1) {
10393 runtime.documents.delete(targetDocument);
10394 return;
10395 }
10396 runtime.documents.set(targetDocument, count - 1);
10397 };
10398 }
10399 function registerStyle4(hash, css) {
10400 const runtime = getRuntime4();
10401 runtime.styles.set(hash, css);
10402 for (const targetDocument of runtime.documents.keys()) {
10403 injectStyle4(targetDocument, hash, css);
10404 }
10405 }
10406 if (typeof process === "undefined" || true) {
10407 registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
10408 }
10409 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10410 var POPUP_COLOR = { background: "#1e1e1e" };
10411 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10412 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10413 index_parts_exports.Popup,
10414 {
10415 ref,
10416 className: clsx_default(style_default3.popup, className),
10417 ...props,
10418 children
10419 }
10420 ) });
10421 const positionedPopup = renderSlotWithChildren(
10422 positioner,
10423 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Positioner, {}),
10424 popupContent
10425 );
10426 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Portal, {}), positionedPopup);
10427 });
10428
10429 // packages/ui/build-module/tooltip/trigger.mjs
10430 var import_element16 = __toESM(require_element(), 1);
10431 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10432 var Trigger = (0, import_element16.forwardRef)(
10433 function TooltipTrigger3(props, ref) {
10434 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(index_parts_exports.Trigger, { ref, ...props });
10435 }
10436 );
10437
10438 // packages/ui/build-module/tooltip/root.mjs
10439 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10440 function Root(props) {
10441 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(index_parts_exports.Root, { ...props });
10442 }
10443
10444 // packages/ui/build-module/tooltip/provider.mjs
10445 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10446 function Provider({ ...props }) {
10447 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports.Provider, { ...props });
10448 }
10449
10450 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10451 var import_element17 = __toESM(require_element(), 1);
10452 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10453 function getRuntime5() {
10454 const globalScope = globalThis;
10455 if (globalScope.__wpStyleRuntime) {
10456 return globalScope.__wpStyleRuntime;
10457 }
10458 globalScope.__wpStyleRuntime = {
10459 documents: /* @__PURE__ */ new Map(),
10460 styles: /* @__PURE__ */ new Map(),
10461 injectedStyles: /* @__PURE__ */ new WeakMap()
10462 };
10463 if (typeof document !== "undefined") {
10464 registerDocument5(document);
10465 }
10466 return globalScope.__wpStyleRuntime;
10467 }
10468 function documentContainsStyleHash5(targetDocument, hash) {
10469 if (!targetDocument.head) {
10470 return false;
10471 }
10472 for (const style of targetDocument.head.querySelectorAll(
10473 `style[${STYLE_HASH_ATTRIBUTE5}]`
10474 )) {
10475 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10476 return true;
10477 }
10478 }
10479 return false;
10480 }
10481 function injectStyle5(targetDocument, hash, css) {
10482 if (!targetDocument.head) {
10483 return;
10484 }
10485 const runtime = getRuntime5();
10486 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10487 if (!injectedStyles) {
10488 injectedStyles = /* @__PURE__ */ new Set();
10489 runtime.injectedStyles.set(targetDocument, injectedStyles);
10490 }
10491 if (injectedStyles.has(hash)) {
10492 return;
10493 }
10494 if (documentContainsStyleHash5(targetDocument, hash)) {
10495 injectedStyles.add(hash);
10496 return;
10497 }
10498 const style = targetDocument.createElement("style");
10499 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10500 style.appendChild(targetDocument.createTextNode(css));
10501 targetDocument.head.appendChild(style);
10502 injectedStyles.add(hash);
10503 }
10504 function registerDocument5(targetDocument) {
10505 const runtime = getRuntime5();
10506 runtime.documents.set(
10507 targetDocument,
10508 (runtime.documents.get(targetDocument) ?? 0) + 1
10509 );
10510 for (const [hash, css] of runtime.styles) {
10511 injectStyle5(targetDocument, hash, css);
10512 }
10513 return () => {
10514 const count = runtime.documents.get(targetDocument);
10515 if (count === void 0) {
10516 return;
10517 }
10518 if (count <= 1) {
10519 runtime.documents.delete(targetDocument);
10520 return;
10521 }
10522 runtime.documents.set(targetDocument, count - 1);
10523 };
10524 }
10525 function registerStyle5(hash, css) {
10526 const runtime = getRuntime5();
10527 runtime.styles.set(hash, css);
10528 for (const targetDocument of runtime.documents.keys()) {
10529 injectStyle5(targetDocument, hash, css);
10530 }
10531 }
10532 if (typeof process === "undefined" || true) {
10533 registerStyle5("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}}}");
10534 }
10535 var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10536 var VisuallyHidden = (0, import_element17.forwardRef)(
10537 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10538 const element = useRender({
10539 render: render4,
10540 ref,
10541 props: mergeProps(
10542 { className: style_default4["visually-hidden"] },
10543 restProps,
10544 {
10545 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10546 "data-visually-hidden": ""
10547 }
10548 )
10549 });
10550 return element;
10551 }
10552 );
10553
10554 // packages/ui/build-module/link/link.mjs
10555 var import_element18 = __toESM(require_element(), 1);
10556 var import_i18n7 = __toESM(require_i18n(), 1);
10557 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10558 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10559 function getRuntime6() {
10560 const globalScope = globalThis;
10561 if (globalScope.__wpStyleRuntime) {
10562 return globalScope.__wpStyleRuntime;
10563 }
10564 globalScope.__wpStyleRuntime = {
10565 documents: /* @__PURE__ */ new Map(),
10566 styles: /* @__PURE__ */ new Map(),
10567 injectedStyles: /* @__PURE__ */ new WeakMap()
10568 };
10569 if (typeof document !== "undefined") {
10570 registerDocument6(document);
10571 }
10572 return globalScope.__wpStyleRuntime;
10573 }
10574 function documentContainsStyleHash6(targetDocument, hash) {
10575 if (!targetDocument.head) {
10576 return false;
10577 }
10578 for (const style of targetDocument.head.querySelectorAll(
10579 `style[${STYLE_HASH_ATTRIBUTE6}]`
10580 )) {
10581 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10582 return true;
10583 }
10584 }
10585 return false;
10586 }
10587 function injectStyle6(targetDocument, hash, css) {
10588 if (!targetDocument.head) {
10589 return;
10590 }
10591 const runtime = getRuntime6();
10592 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10593 if (!injectedStyles) {
10594 injectedStyles = /* @__PURE__ */ new Set();
10595 runtime.injectedStyles.set(targetDocument, injectedStyles);
10596 }
10597 if (injectedStyles.has(hash)) {
10598 return;
10599 }
10600 if (documentContainsStyleHash6(targetDocument, hash)) {
10601 injectedStyles.add(hash);
10602 return;
10603 }
10604 const style = targetDocument.createElement("style");
10605 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10606 style.appendChild(targetDocument.createTextNode(css));
10607 targetDocument.head.appendChild(style);
10608 injectedStyles.add(hash);
10609 }
10610 function registerDocument6(targetDocument) {
10611 const runtime = getRuntime6();
10612 runtime.documents.set(
10613 targetDocument,
10614 (runtime.documents.get(targetDocument) ?? 0) + 1
10615 );
10616 for (const [hash, css] of runtime.styles) {
10617 injectStyle6(targetDocument, hash, css);
10618 }
10619 return () => {
10620 const count = runtime.documents.get(targetDocument);
10621 if (count === void 0) {
10622 return;
10623 }
10624 if (count <= 1) {
10625 runtime.documents.delete(targetDocument);
10626 return;
10627 }
10628 runtime.documents.set(targetDocument, count - 1);
10629 };
10630 }
10631 function registerStyle6(hash, css) {
10632 const runtime = getRuntime6();
10633 runtime.styles.set(hash, css);
10634 for (const targetDocument of runtime.documents.keys()) {
10635 injectStyle6(targetDocument, hash, css);
10636 }
10637 }
10638 if (typeof process === "undefined" || true) {
10639 registerStyle6("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10640 }
10641 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10642 if (typeof process === "undefined" || true) {
10643 registerStyle6("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))}}}");
10644 }
10645 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" };
10646 if (typeof process === "undefined" || true) {
10647 registerStyle6("e8e6a9be37", '@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-default,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"}}}');
10648 }
10649 var style_default5 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10650 if (typeof process === "undefined" || true) {
10651 registerStyle6("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10652 }
10653 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" };
10654 var Link = (0, import_element18.forwardRef)(function Link2({
10655 children,
10656 variant = "default",
10657 tone = "brand",
10658 openInNewTab = false,
10659 render: render4,
10660 className,
10661 ...props
10662 }, ref) {
10663 const element = useRender({
10664 render: render4,
10665 defaultTagName: "a",
10666 ref,
10667 props: mergeProps(props, {
10668 className: clsx_default(
10669 global_css_defense_default.a,
10670 resets_default2["box-sizing"],
10671 focus_default["outset-ring--focus-except-active"],
10672 variant !== "unstyled" && style_default5.link,
10673 variant !== "unstyled" && style_default5[`is-${tone}`],
10674 variant === "unstyled" && style_default5["is-unstyled"],
10675 className
10676 ),
10677 target: openInNewTab ? "_blank" : void 0,
10678 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10679 children,
10680 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10681 "span",
10682 {
10683 className: style_default5["link-icon"],
10684 role: "img",
10685 "aria-label": (
10686 /* translators: accessibility text appended to link text */
10687 (0, import_i18n7.__)("(opens in a new tab)")
10688 )
10689 }
10690 )
10691 ] })
10692 })
10693 });
10694 return element;
10695 });
10696
10697 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10698 var import_element19 = __toESM(require_element(), 1);
10699
10700 // packages/dataviews/build-module/constants.mjs
10701 var import_i18n8 = __toESM(require_i18n(), 1);
10702 var OPERATOR_IS_ANY = "isAny";
10703 var OPERATOR_IS_NONE = "isNone";
10704 var OPERATOR_IS_ALL = "isAll";
10705 var OPERATOR_IS_NOT_ALL = "isNotAll";
10706 var OPERATOR_BETWEEN = "between";
10707 var OPERATOR_IN_THE_PAST = "inThePast";
10708 var OPERATOR_OVER = "over";
10709 var OPERATOR_IS = "is";
10710 var OPERATOR_IS_NOT = "isNot";
10711 var OPERATOR_LESS_THAN = "lessThan";
10712 var OPERATOR_GREATER_THAN = "greaterThan";
10713 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10714 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10715 var OPERATOR_BEFORE = "before";
10716 var OPERATOR_AFTER = "after";
10717 var OPERATOR_BEFORE_INC = "beforeInc";
10718 var OPERATOR_AFTER_INC = "afterInc";
10719 var OPERATOR_CONTAINS = "contains";
10720 var OPERATOR_NOT_CONTAINS = "notContains";
10721 var OPERATOR_STARTS_WITH = "startsWith";
10722 var OPERATOR_ON = "on";
10723 var OPERATOR_NOT_ON = "notOn";
10724 var SORTING_DIRECTIONS = ["asc", "desc"];
10725 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10726 var sortValues = { asc: "ascending", desc: "descending" };
10727 var sortLabels = {
10728 asc: (0, import_i18n8.__)("Sort ascending"),
10729 desc: (0, import_i18n8.__)("Sort descending")
10730 };
10731 var sortIcons = {
10732 asc: arrow_up_default,
10733 desc: arrow_down_default
10734 };
10735 var LAYOUT_TABLE = "table";
10736 var LAYOUT_GRID = "grid";
10737 var LAYOUT_LIST = "list";
10738 var LAYOUT_ACTIVITY = "activity";
10739 var LAYOUT_PICKER_GRID = "pickerGrid";
10740 var LAYOUT_PICKER_TABLE = "pickerTable";
10741 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10742
10743 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10744 var DataViewsContext = (0, import_element19.createContext)({
10745 view: { type: LAYOUT_TABLE },
10746 onChangeView: () => {
10747 },
10748 fields: [],
10749 data: [],
10750 paginationInfo: {
10751 totalItems: 0,
10752 totalPages: 0
10753 },
10754 selection: [],
10755 onChangeSelection: () => {
10756 },
10757 setOpenedFilter: () => {
10758 },
10759 openedFilter: null,
10760 getItemId: (item) => item.id,
10761 isItemClickable: () => true,
10762 renderItemLink: void 0,
10763 containerWidth: 0,
10764 containerRef: (0, import_element19.createRef)(),
10765 resizeObserverRef: () => {
10766 },
10767 defaultLayouts: { list: {}, grid: {}, table: {} },
10768 filters: [],
10769 isShowingFilter: false,
10770 setIsShowingFilter: () => {
10771 },
10772 hasInitiallyLoaded: false,
10773 config: {
10774 perPageSizes: []
10775 },
10776 intersectionObserver: null
10777 });
10778 DataViewsContext.displayName = "DataViewsContext";
10779 var dataviews_context_default = DataViewsContext;
10780
10781 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10782 var import_i18n29 = __toESM(require_i18n(), 1);
10783
10784 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10785 var import_i18n16 = __toESM(require_i18n(), 1);
10786 var import_components6 = __toESM(require_components(), 1);
10787 var import_element28 = __toESM(require_element(), 1);
10788 var import_keycodes2 = __toESM(require_keycodes(), 1);
10789
10790 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10791 var import_components = __toESM(require_components(), 1);
10792 var import_i18n9 = __toESM(require_i18n(), 1);
10793 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10794 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10795 function DataViewsSelectionCheckbox({
10796 selection,
10797 onChangeSelection,
10798 item,
10799 getItemId,
10800 titleField,
10801 disabled: disabled2,
10802 ...extraProps
10803 }) {
10804 const id = getItemId(item);
10805 const isInSelectionArray = selection.includes(id);
10806 const checked = !disabled2 && isInSelectionArray;
10807 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n9.__)("(no title)");
10808 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10809 import_components.CheckboxControl,
10810 {
10811 className: SELECTION_CHECKBOX_CLASS,
10812 "aria-label": selectionLabel,
10813 "aria-disabled": disabled2,
10814 checked,
10815 onChange: () => {
10816 if (disabled2) {
10817 return;
10818 }
10819 onChangeSelection(
10820 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10821 );
10822 },
10823 ...extraProps
10824 }
10825 );
10826 }
10827
10828 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10829 var import_components2 = __toESM(require_components(), 1);
10830 var import_i18n10 = __toESM(require_i18n(), 1);
10831 var import_element20 = __toESM(require_element(), 1);
10832 var import_data2 = __toESM(require_data(), 1);
10833 var import_compose = __toESM(require_compose(), 1);
10834
10835 // packages/dataviews/build-module/lock-unlock.mjs
10836 var import_private_apis2 = __toESM(require_private_apis(), 1);
10837 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10838 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10839 "@wordpress/dataviews"
10840 );
10841
10842 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10843 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10844 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10845 function ButtonTrigger({
10846 action,
10847 onClick,
10848 items,
10849 variant
10850 }) {
10851 const label = typeof action.label === "string" ? action.label : action.label(items);
10852 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10853 import_components2.Button,
10854 {
10855 disabled: !!action.disabled,
10856 accessibleWhenDisabled: true,
10857 size: "compact",
10858 variant,
10859 onClick,
10860 children: label
10861 }
10862 );
10863 }
10864 function MenuItemTrigger({
10865 action,
10866 onClick,
10867 items
10868 }) {
10869 const label = typeof action.label === "string" ? action.label : action.label(items);
10870 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10871 }
10872 function ActionModal({
10873 action,
10874 items,
10875 closeModal
10876 }) {
10877 const label = typeof action.label === "string" ? action.label : action.label(items);
10878 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10879 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10880 import_components2.Modal,
10881 {
10882 title: modalHeader || label,
10883 __experimentalHideHeader: !!action.hideModalHeader,
10884 onRequestClose: closeModal,
10885 focusOnMount: action.modalFocusOnMount ?? true,
10886 size: action.modalSize || "medium",
10887 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10888 action.id
10889 )}`,
10890 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10891 }
10892 );
10893 }
10894 function ActionsMenuGroup({
10895 actions,
10896 item,
10897 registry,
10898 setActiveModalAction
10899 }) {
10900 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10901 return actions.reduce(
10902 (acc, action) => {
10903 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10904 return acc;
10905 },
10906 {
10907 primaryActions: [],
10908 regularActions: []
10909 }
10910 );
10911 }, [actions]);
10912 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10913 MenuItemTrigger,
10914 {
10915 action,
10916 onClick: () => {
10917 if ("RenderModal" in action) {
10918 setActiveModalAction(action);
10919 return;
10920 }
10921 action.callback([item], { registry });
10922 },
10923 items: [item]
10924 },
10925 action.id
10926 ));
10927 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10928 renderActionGroup(primaryActions),
10929 renderActionGroup(regularActions)
10930 ] });
10931 }
10932 function ItemActions({
10933 item,
10934 actions,
10935 isCompact
10936 }) {
10937 const registry = (0, import_data2.useRegistry)();
10938 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10939 const _eligibleActions = actions.filter(
10940 (action) => !action.isEligible || action.isEligible(item)
10941 );
10942 const _primaryActions = _eligibleActions.filter(
10943 (action) => action.isPrimary
10944 );
10945 return {
10946 primaryActions: _primaryActions,
10947 eligibleActions: _eligibleActions
10948 };
10949 }, [actions, item]);
10950 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10951 if (isCompact) {
10952 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10953 CompactItemActions,
10954 {
10955 item,
10956 actions: eligibleActions,
10957 isSmall: true,
10958 registry
10959 }
10960 );
10961 }
10962 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10963 Stack,
10964 {
10965 direction: "row",
10966 justify: "flex-end",
10967 className: "dataviews-item-actions",
10968 style: {
10969 flexShrink: 0,
10970 width: "auto"
10971 },
10972 children: [
10973 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10974 PrimaryActions,
10975 {
10976 item,
10977 actions: primaryActions,
10978 registry
10979 }
10980 ),
10981 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10982 // there if there are any actions at all.
10983 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10984 CompactItemActions,
10985 {
10986 item,
10987 actions: eligibleActions,
10988 registry
10989 }
10990 )
10991 ]
10992 }
10993 );
10994 }
10995 function CompactItemActions({
10996 item,
10997 actions,
10998 isSmall,
10999 registry
11000 }) {
11001 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
11002 null
11003 );
11004 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11005 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
11006 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11007 Menu.TriggerButton,
11008 {
11009 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11010 import_components2.Button,
11011 {
11012 size: isSmall ? "small" : "compact",
11013 icon: more_vertical_default,
11014 label: (0, import_i18n10.__)("Actions"),
11015 accessibleWhenDisabled: true,
11016 disabled: !actions.length,
11017 className: "dataviews-all-actions-button"
11018 }
11019 )
11020 }
11021 ),
11022 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11023 ActionsMenuGroup,
11024 {
11025 actions,
11026 item,
11027 registry,
11028 setActiveModalAction
11029 }
11030 ) })
11031 ] }),
11032 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11033 ActionModal,
11034 {
11035 action: activeModalAction,
11036 items: [item],
11037 closeModal: () => setActiveModalAction(null)
11038 }
11039 )
11040 ] });
11041 }
11042 function PrimaryActions({
11043 item,
11044 actions,
11045 registry,
11046 buttonVariant
11047 }) {
11048 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
11049 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
11050 if (isMobileViewport) {
11051 return null;
11052 }
11053 if (!Array.isArray(actions) || actions.length === 0) {
11054 return null;
11055 }
11056 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11057 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11058 ButtonTrigger,
11059 {
11060 action,
11061 onClick: () => {
11062 if ("RenderModal" in action) {
11063 setActiveModalAction(action);
11064 return;
11065 }
11066 action.callback([item], { registry });
11067 },
11068 items: [item],
11069 variant: buttonVariant
11070 },
11071 action.id
11072 )),
11073 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11074 ActionModal,
11075 {
11076 action: activeModalAction,
11077 items: [item],
11078 closeModal: () => setActiveModalAction(null)
11079 }
11080 )
11081 ] });
11082 }
11083
11084 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11085 var import_components3 = __toESM(require_components(), 1);
11086 var import_i18n12 = __toESM(require_i18n(), 1);
11087 var import_element21 = __toESM(require_element(), 1);
11088 var import_data3 = __toESM(require_data(), 1);
11089 var import_compose2 = __toESM(require_compose(), 1);
11090
11091 // packages/dataviews/build-module/utils/get-footer-message.mjs
11092 var import_i18n11 = __toESM(require_i18n(), 1);
11093 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
11094 if (selectionCount > 0) {
11095 return (0, import_i18n11.sprintf)(
11096 /* translators: %d: number of items. */
11097 (0, import_i18n11._n)("%d Item selected", "%d Items selected", selectionCount),
11098 selectionCount
11099 );
11100 }
11101 if (onlyTotalCount || totalItems <= itemsCount) {
11102 return (0, import_i18n11.sprintf)(
11103 /* translators: %d: number of items. */
11104 (0, import_i18n11._n)("%d Item", "%d Items", totalItems),
11105 totalItems
11106 );
11107 }
11108 return (0, import_i18n11.sprintf)(
11109 /* translators: %1$d: number of items. %2$d: total number of items. */
11110 (0, import_i18n11._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
11111 itemsCount,
11112 totalItems
11113 );
11114 }
11115
11116 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11117 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11118 function hasAPossibleBulkAction(actions, item) {
11119 return actions.some(
11120 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11121 );
11122 }
11123 function useHasAPossibleBulkAction(actions, item) {
11124 return (0, import_element21.useMemo)(
11125 () => hasAPossibleBulkAction(actions, item),
11126 [actions, item]
11127 );
11128 }
11129 function useSomeItemHasAPossibleBulkAction(actions, data) {
11130 return (0, import_element21.useMemo)(
11131 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
11132 [actions, data]
11133 );
11134 }
11135 function BulkSelectionCheckbox({
11136 selection,
11137 onChangeSelection,
11138 data,
11139 actions,
11140 getItemId,
11141 disableSelectAll = false
11142 }) {
11143 const selectableItems = (0, import_element21.useMemo)(() => {
11144 return data.filter((item) => {
11145 return actions.some(
11146 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11147 );
11148 });
11149 }, [data, actions]);
11150 const selectedItems = data.filter(
11151 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11152 );
11153 const hasSelection = selection.length > 0;
11154 const areAllSelected = selectedItems.length === selectableItems.length;
11155 if (disableSelectAll) {
11156 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11157 import_components3.CheckboxControl,
11158 {
11159 className: "dataviews-view-table-selection-checkbox",
11160 checked: hasSelection,
11161 disabled: !hasSelection,
11162 onChange: () => {
11163 onChangeSelection([]);
11164 },
11165 "aria-label": (0, import_i18n12.__)("Deselect all")
11166 }
11167 );
11168 }
11169 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11170 import_components3.CheckboxControl,
11171 {
11172 className: "dataviews-view-table-selection-checkbox",
11173 checked: areAllSelected,
11174 indeterminate: !areAllSelected && !!selectedItems.length,
11175 onChange: () => {
11176 if (areAllSelected) {
11177 onChangeSelection([]);
11178 } else {
11179 onChangeSelection(
11180 selectableItems.map((item) => getItemId(item))
11181 );
11182 }
11183 },
11184 "aria-label": areAllSelected ? (0, import_i18n12.__)("Deselect all") : (0, import_i18n12.__)("Select all")
11185 }
11186 );
11187 }
11188
11189 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11190 var import_i18n13 = __toESM(require_i18n(), 1);
11191 var import_components4 = __toESM(require_components(), 1);
11192 var import_element22 = __toESM(require_element(), 1);
11193
11194 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11195 function getHideableFields(view, fields) {
11196 const togglableFields = [
11197 view?.titleField,
11198 view?.mediaField,
11199 view?.descriptionField
11200 ].filter(Boolean);
11201 return fields.filter(
11202 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11203 );
11204 }
11205
11206 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11207 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11208 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11209 function WithMenuSeparators({ children }) {
11210 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element22.Fragment, { children: [
11211 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11212 child
11213 ] }, i2));
11214 }
11215 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
11216 fieldId,
11217 view,
11218 fields,
11219 onChangeView,
11220 onHide,
11221 setOpenedFilter,
11222 canMove = true,
11223 canInsertLeft = true,
11224 canInsertRight = true
11225 }, ref) {
11226 const visibleFieldIds = view.fields ?? [];
11227 const index2 = visibleFieldIds?.indexOf(fieldId);
11228 const isSorted = view.sort?.field === fieldId;
11229 let isHidable = false;
11230 let isSortable = false;
11231 let canAddFilter = false;
11232 let operators = [];
11233 const field = fields.find((f2) => f2.id === fieldId);
11234 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
11235 if (!field) {
11236 return null;
11237 }
11238 isHidable = field.enableHiding !== false;
11239 isSortable = field.enableSorting !== false;
11240 const header = field.header;
11241 operators = !!field.filterBy && field.filterBy?.operators || [];
11242 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11243 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11244 return header;
11245 }
11246 const hiddenFields = getHideableFields(view, fields).filter(
11247 (f2) => !visibleFieldIds.includes(f2.id)
11248 );
11249 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11250 const isRtl = (0, import_i18n13.isRTL)();
11251 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11252 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11253 Menu2.TriggerButton,
11254 {
11255 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11256 import_components4.Button,
11257 {
11258 size: "compact",
11259 className: "dataviews-view-table-header-button",
11260 ref,
11261 variant: "tertiary"
11262 }
11263 ),
11264 children: [
11265 header,
11266 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11267 ]
11268 }
11269 ),
11270 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11271 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11272 (direction) => {
11273 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11274 const value = `${fieldId}-${direction}`;
11275 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11276 Menu2.RadioItem,
11277 {
11278 name: "view-table-sorting",
11279 value,
11280 checked: isChecked,
11281 onChange: () => {
11282 onChangeView({
11283 ...view,
11284 sort: {
11285 field: fieldId,
11286 direction
11287 },
11288 showLevels: false
11289 });
11290 },
11291 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11292 },
11293 value
11294 );
11295 }
11296 ) }),
11297 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11298 Menu2.Item,
11299 {
11300 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11301 onClick: () => {
11302 setOpenedFilter(fieldId);
11303 setIsShowingFilter(true);
11304 onChangeView({
11305 ...view,
11306 page: 1,
11307 filters: [
11308 ...view.filters || [],
11309 {
11310 field: fieldId,
11311 value: void 0,
11312 operator: operators[0]
11313 }
11314 ]
11315 });
11316 },
11317 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Add filter") })
11318 }
11319 ) }),
11320 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11321 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11322 Menu2.Item,
11323 {
11324 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11325 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11326 onClick: () => {
11327 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11328 const newFields = [
11329 ...visibleFieldIds
11330 ];
11331 newFields.splice(index2, 1);
11332 newFields.splice(
11333 targetIndex,
11334 0,
11335 fieldId
11336 );
11337 onChangeView({
11338 ...view,
11339 fields: newFields
11340 });
11341 },
11342 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move left") })
11343 }
11344 ),
11345 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11346 Menu2.Item,
11347 {
11348 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11349 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11350 onClick: () => {
11351 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11352 const newFields = [
11353 ...visibleFieldIds
11354 ];
11355 newFields.splice(index2, 1);
11356 newFields.splice(
11357 targetIndex,
11358 0,
11359 fieldId
11360 );
11361 onChangeView({
11362 ...view,
11363 fields: newFields
11364 });
11365 },
11366 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move right") })
11367 }
11368 ),
11369 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11370 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert left") }) }),
11371 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11372 const insertIndex = isRtl ? index2 + 1 : index2;
11373 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11374 Menu2.Item,
11375 {
11376 onClick: () => {
11377 onChangeView({
11378 ...view,
11379 fields: [
11380 ...visibleFieldIds.slice(
11381 0,
11382 insertIndex
11383 ),
11384 hiddenField.id,
11385 ...visibleFieldIds.slice(
11386 insertIndex
11387 )
11388 ]
11389 });
11390 },
11391 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11392 },
11393 hiddenField.id
11394 );
11395 }) })
11396 ] }),
11397 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11398 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert right") }) }),
11399 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11400 const insertIndex = isRtl ? index2 : index2 + 1;
11401 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11402 Menu2.Item,
11403 {
11404 onClick: () => {
11405 onChangeView({
11406 ...view,
11407 fields: [
11408 ...visibleFieldIds.slice(
11409 0,
11410 insertIndex
11411 ),
11412 hiddenField.id,
11413 ...visibleFieldIds.slice(
11414 insertIndex
11415 )
11416 ]
11417 });
11418 },
11419 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11420 },
11421 hiddenField.id
11422 );
11423 }) })
11424 ] }),
11425 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11426 Menu2.Item,
11427 {
11428 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11429 onClick: () => {
11430 onHide(field);
11431 onChangeView({
11432 ...view,
11433 fields: visibleFieldIds.filter(
11434 (id) => id !== fieldId
11435 )
11436 });
11437 },
11438 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Hide column") })
11439 }
11440 )
11441 ] })
11442 ] }) })
11443 ] });
11444 });
11445 var ColumnHeaderMenu = _HeaderMenu;
11446 var column_header_menu_default = ColumnHeaderMenu;
11447
11448 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11449 var import_element23 = __toESM(require_element(), 1);
11450 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11451 function getClickableItemProps({
11452 item,
11453 isItemClickable: isItemClickable2,
11454 onClickItem,
11455 className
11456 }) {
11457 if (!isItemClickable2(item) || !onClickItem) {
11458 return { className };
11459 }
11460 return {
11461 className: className ? `${className} ${className}--clickable` : void 0,
11462 role: "button",
11463 tabIndex: 0,
11464 onClick: (event) => {
11465 event.stopPropagation();
11466 onClickItem(item);
11467 },
11468 onKeyDown: (event) => {
11469 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11470 event.stopPropagation();
11471 onClickItem(item);
11472 }
11473 }
11474 };
11475 }
11476 function ItemClickWrapper({
11477 item,
11478 isItemClickable: isItemClickable2,
11479 onClickItem,
11480 renderItemLink,
11481 className,
11482 children,
11483 ...extraProps
11484 }) {
11485 if (!isItemClickable2(item)) {
11486 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11487 }
11488 if (renderItemLink) {
11489 const renderedElement = renderItemLink({
11490 item,
11491 className: `${className} ${className}--clickable`,
11492 ...extraProps,
11493 children
11494 });
11495 return (0, import_element23.cloneElement)(renderedElement, {
11496 onClick: (event) => {
11497 event.stopPropagation();
11498 if (renderedElement.props.onClick) {
11499 renderedElement.props.onClick(event);
11500 }
11501 },
11502 onKeyDown: (event) => {
11503 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11504 event.stopPropagation();
11505 if (renderedElement.props.onKeyDown) {
11506 renderedElement.props.onKeyDown(event);
11507 }
11508 }
11509 }
11510 });
11511 }
11512 const clickProps = getClickableItemProps({
11513 item,
11514 isItemClickable: isItemClickable2,
11515 onClickItem,
11516 className
11517 });
11518 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11519 }
11520
11521 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11522 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11523 function ColumnPrimary({
11524 item,
11525 level,
11526 titleField,
11527 mediaField,
11528 descriptionField: descriptionField2,
11529 onClickItem,
11530 renderItemLink,
11531 isItemClickable: isItemClickable2
11532 }) {
11533 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11534 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11535 ItemClickWrapper,
11536 {
11537 item,
11538 isItemClickable: isItemClickable2,
11539 onClickItem,
11540 renderItemLink,
11541 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11542 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11543 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11544 mediaField.render,
11545 {
11546 item,
11547 field: mediaField,
11548 config: { sizes: "32px" }
11549 }
11550 )
11551 }
11552 ),
11553 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11554 Stack,
11555 {
11556 direction: "column",
11557 align: "flex-start",
11558 className: "dataviews-view-table__primary-column-content",
11559 children: [
11560 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11561 ItemClickWrapper,
11562 {
11563 item,
11564 isItemClickable: isItemClickable2,
11565 onClickItem,
11566 renderItemLink,
11567 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11568 children: [
11569 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11570 Array(level).fill("\u2014").join(" "),
11571 "\xA0"
11572 ] }),
11573 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11574 ]
11575 }
11576 ),
11577 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11578 descriptionField2.render,
11579 {
11580 item,
11581 field: descriptionField2
11582 }
11583 )
11584 ]
11585 }
11586 )
11587 ] });
11588 }
11589 var column_primary_default = ColumnPrimary;
11590
11591 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11592 var import_element24 = __toESM(require_element(), 1);
11593 var import_i18n14 = __toESM(require_i18n(), 1);
11594 var isScrolledToEnd = (element) => {
11595 if ((0, import_i18n14.isRTL)()) {
11596 const scrollLeft = Math.abs(element.scrollLeft);
11597 return scrollLeft <= 1;
11598 }
11599 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11600 };
11601 function useScrollState({
11602 scrollContainerRef,
11603 enabledHorizontal = false
11604 }) {
11605 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11606 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11607 const handleScroll = (0, import_element24.useCallback)(() => {
11608 const scrollContainer = scrollContainerRef.current;
11609 if (!scrollContainer) {
11610 return;
11611 }
11612 if (enabledHorizontal) {
11613 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11614 }
11615 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11616 }, [scrollContainerRef, enabledHorizontal]);
11617 (0, import_element24.useEffect)(() => {
11618 if (typeof window === "undefined" || !scrollContainerRef.current) {
11619 return () => {
11620 };
11621 }
11622 const scrollContainer = scrollContainerRef.current;
11623 handleScroll();
11624 scrollContainer.addEventListener("scroll", handleScroll);
11625 window.addEventListener("resize", handleScroll);
11626 return () => {
11627 scrollContainer.removeEventListener("scroll", handleScroll);
11628 window.removeEventListener("resize", handleScroll);
11629 };
11630 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11631 return { isHorizontalScrollEnd, isVerticallyScrolled };
11632 }
11633
11634 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11635 function getDataByGroup(data, groupByField) {
11636 return data.reduce((groups, item) => {
11637 const groupName = groupByField.getValue({ item });
11638 if (!groups.has(groupName)) {
11639 groups.set(groupName, []);
11640 }
11641 groups.get(groupName)?.push(item);
11642 return groups;
11643 }, /* @__PURE__ */ new Map());
11644 }
11645
11646 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11647 var import_element25 = __toESM(require_element(), 1);
11648 var import_keycodes = __toESM(require_keycodes(), 1);
11649 function getRange(orderedIds, fromIndex, toIndex) {
11650 return orderedIds.slice(
11651 Math.min(fromIndex, toIndex),
11652 Math.max(fromIndex, toIndex) + 1
11653 );
11654 }
11655 function getRangeSelection({
11656 anchorId,
11657 targetId,
11658 lastTargetId,
11659 orderedIds,
11660 selection
11661 }) {
11662 const targetIndex = orderedIds.indexOf(targetId);
11663 if (targetIndex === -1) {
11664 return selection;
11665 }
11666 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11667 const hasAnchor = anchorIndex !== -1;
11668 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11669 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11670 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11671 const base = selection.filter((id) => !lastRange.includes(id));
11672 return [
11673 .../* @__PURE__ */ new Set([
11674 ...base,
11675 ...getRange(orderedIds, rangeStart, targetIndex)
11676 ])
11677 ];
11678 }
11679 function getClosestSelectedId({
11680 targetId,
11681 orderedIds,
11682 selection
11683 }) {
11684 const targetIndex = orderedIds.indexOf(targetId);
11685 if (targetIndex === -1) {
11686 return null;
11687 }
11688 const selectedIds = new Set(selection);
11689 let closestId = null;
11690 let closestDistance = Infinity;
11691 orderedIds.forEach((id, index2) => {
11692 if (!selectedIds.has(id)) {
11693 return;
11694 }
11695 const distance = Math.abs(index2 - targetIndex);
11696 if (distance < closestDistance) {
11697 closestDistance = distance;
11698 closestId = id;
11699 }
11700 });
11701 return closestId;
11702 }
11703 function useSelectionProps({
11704 data,
11705 actions,
11706 getItemId,
11707 selection,
11708 onChangeSelection
11709 }) {
11710 const gestureRef = (0, import_element25.useRef)(null);
11711 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11712 (0, import_element25.useEffect)(() => {
11713 const markTouchDevice = () => {
11714 isTouchDeviceRef.current = true;
11715 };
11716 document.addEventListener("touchstart", markTouchDevice, {
11717 once: true
11718 });
11719 return () => document.removeEventListener("touchstart", markTouchDevice);
11720 }, []);
11721 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
11722 const selectableIdSet = new Set(selectableIds);
11723 const hasSelectableItems = selectableIds.length > 0;
11724 const getSelectionProps = (id) => {
11725 const isSelectable = selectableIdSet.has(id);
11726 return {
11727 onMouseDown: (event) => {
11728 if (event.button === 0 && event.shiftKey && hasSelectableItems) {
11729 event.preventDefault();
11730 }
11731 },
11732 onClickCapture: (event) => {
11733 if (!hasSelectableItems) {
11734 return;
11735 }
11736 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11737 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
11738 if (!isModifierKeyPressed && !event.shiftKey) {
11739 if (isSelectable && isSelectionCheckboxClick) {
11740 gestureRef.current = {
11741 anchorId: id,
11742 lastTargetId: null
11743 };
11744 }
11745 return;
11746 }
11747 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11748 return;
11749 }
11750 event.stopPropagation();
11751 if (!isSelectionCheckboxClick) {
11752 event.preventDefault();
11753 }
11754 if (!isSelectable) {
11755 return;
11756 }
11757 if (event.shiftKey) {
11758 let gesture = gestureRef.current;
11759 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11760 gesture = {
11761 anchorId: getClosestSelectedId({
11762 targetId: id,
11763 orderedIds: selectableIds,
11764 selection
11765 }) ?? id,
11766 lastTargetId: null
11767 };
11768 }
11769 onChangeSelection(
11770 getRangeSelection({
11771 anchorId: gesture.anchorId,
11772 targetId: id,
11773 lastTargetId: gesture.lastTargetId,
11774 orderedIds: selectableIds,
11775 selection
11776 })
11777 );
11778 gestureRef.current = {
11779 anchorId: gesture.anchorId,
11780 lastTargetId: id
11781 };
11782 } else {
11783 onChangeSelection(
11784 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11785 );
11786 gestureRef.current = { anchorId: id, lastTargetId: null };
11787 }
11788 }
11789 };
11790 };
11791 return { getSelectionProps };
11792 }
11793
11794 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11795 var import_components5 = __toESM(require_components(), 1);
11796 var import_i18n15 = __toESM(require_i18n(), 1);
11797 var import_element26 = __toESM(require_element(), 1);
11798 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11799 function FieldItem({
11800 field,
11801 isVisible: isVisible2,
11802 onToggleVisibility
11803 }) {
11804 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: [
11805 /* @__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 }) }),
11806 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11807 ] }) });
11808 }
11809 function isDefined(item) {
11810 return !!item;
11811 }
11812 function PropertiesSection({
11813 showLabel = true
11814 }) {
11815 const { view, fields, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
11816 const regularFields = getHideableFields(view, fields);
11817 if (!regularFields?.length) {
11818 return null;
11819 }
11820 const titleField = fields.find((f2) => f2.id === view.titleField);
11821 const previewField = fields.find((f2) => f2.id === view.mediaField);
11822 const descriptionField2 = fields.find(
11823 (f2) => f2.id === view.descriptionField
11824 );
11825 const lockedFields = [
11826 {
11827 field: titleField,
11828 isVisibleFlag: "showTitle"
11829 },
11830 {
11831 field: previewField,
11832 isVisibleFlag: "showMedia"
11833 },
11834 {
11835 field: descriptionField2,
11836 isVisibleFlag: "showDescription"
11837 }
11838 ].filter(({ field }) => isDefined(field));
11839 const visibleFieldIds = view.fields ?? [];
11840 const visibleRegularFieldsCount = regularFields.filter(
11841 (f2) => visibleFieldIds.includes(f2.id)
11842 ).length;
11843 const visibleLockedFields = lockedFields.filter(
11844 ({ isVisibleFlag }) => (
11845 // @ts-expect-error
11846 view[isVisibleFlag] ?? true
11847 )
11848 );
11849 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11850 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11851 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11852 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n15.__)("Properties") }),
11853 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11854 Stack,
11855 {
11856 direction: "column",
11857 className: "dataviews-view-config__properties",
11858 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11859 lockedFields.map(({ field, isVisibleFlag }) => {
11860 const isVisible2 = view[isVisibleFlag] ?? true;
11861 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11862 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11863 FieldItem,
11864 {
11865 field: fieldToRender,
11866 isVisible: isVisible2,
11867 onToggleVisibility: () => {
11868 onChangeView({
11869 ...view,
11870 [isVisibleFlag]: !isVisible2
11871 });
11872 }
11873 },
11874 field.id
11875 );
11876 }),
11877 regularFields.map((field) => {
11878 const isVisible2 = visibleFieldIds.includes(field.id);
11879 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11880 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11881 FieldItem,
11882 {
11883 field: fieldToRender,
11884 isVisible: isVisible2,
11885 onToggleVisibility: () => {
11886 onChangeView({
11887 ...view,
11888 fields: isVisible2 ? visibleFieldIds.filter(
11889 (fieldId) => fieldId !== field.id
11890 ) : [...visibleFieldIds, field.id]
11891 });
11892 }
11893 },
11894 field.id
11895 );
11896 })
11897 ] })
11898 }
11899 )
11900 ] });
11901 }
11902
11903 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11904 var import_element27 = __toESM(require_element(), 1);
11905 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11906 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
11907 (0, import_element27.useEffect)(() => {
11908 if (!isLoading) {
11909 return;
11910 }
11911 const timeout = setTimeout(() => {
11912 setShowLoader(true);
11913 }, options.delay);
11914 return () => {
11915 clearTimeout(timeout);
11916 setShowLoader(false);
11917 };
11918 }, [isLoading, options.delay]);
11919 return showLoader;
11920 }
11921
11922 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11923 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11924 function getEffectiveAlign(explicitAlign, fieldType) {
11925 if (explicitAlign) {
11926 return explicitAlign;
11927 }
11928 if (fieldType === "integer" || fieldType === "number") {
11929 return "end";
11930 }
11931 return void 0;
11932 }
11933 function TableColumnField({
11934 item,
11935 fields,
11936 column,
11937 align
11938 }) {
11939 const field = fields.find((f2) => f2.id === column);
11940 if (!field) {
11941 return null;
11942 }
11943 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11944 "dataviews-view-table__cell-align-end": align === "end",
11945 "dataviews-view-table__cell-align-center": align === "center"
11946 });
11947 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11948 }
11949 function TableRow({
11950 hasBulkActions,
11951 item,
11952 level,
11953 actions,
11954 fields,
11955 id,
11956 view,
11957 titleField,
11958 mediaField,
11959 descriptionField: descriptionField2,
11960 selection,
11961 getItemId,
11962 isItemClickable: isItemClickable2,
11963 onClickItem,
11964 renderItemLink,
11965 onChangeSelection,
11966 onMouseDown,
11967 onClickCapture,
11968 isActionsColumnSticky,
11969 posinset
11970 }) {
11971 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
11972 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11973 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11974 const {
11975 showTitle = true,
11976 showMedia = true,
11977 showDescription = true,
11978 infiniteScrollEnabled
11979 } = view;
11980 const columns = view.fields ?? [];
11981 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
11982 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11983 "tr",
11984 {
11985 className: clsx_default("dataviews-view-table__row", {
11986 "is-selected": hasPossibleBulkAction && isSelected2,
11987 "has-bulk-actions": hasPossibleBulkAction
11988 }),
11989 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11990 "aria-posinset": posinset,
11991 role: infiniteScrollEnabled ? "article" : void 0,
11992 onClickCapture,
11993 onMouseDown: (event) => {
11994 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
11995 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11996 event.preventDefault();
11997 }
11998 onMouseDown(event);
11999 },
12000 children: [
12001 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)(
12002 DataViewsSelectionCheckbox,
12003 {
12004 item,
12005 selection,
12006 onChangeSelection,
12007 getItemId,
12008 titleField,
12009 disabled: !hasPossibleBulkAction
12010 }
12011 ) }) }),
12012 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12013 column_primary_default,
12014 {
12015 item,
12016 level,
12017 titleField: showTitle ? titleField : void 0,
12018 mediaField: showMedia ? mediaField : void 0,
12019 descriptionField: showDescription ? descriptionField2 : void 0,
12020 isItemClickable: isItemClickable2,
12021 onClickItem,
12022 renderItemLink
12023 }
12024 ) }),
12025 columns.map((column) => {
12026 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12027 const field = fields.find((f2) => f2.id === column);
12028 const effectiveAlign = getEffectiveAlign(align, field?.type);
12029 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12030 "td",
12031 {
12032 style: {
12033 width,
12034 maxWidth,
12035 minWidth
12036 },
12037 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12038 TableColumnField,
12039 {
12040 fields,
12041 item,
12042 column,
12043 align: effectiveAlign
12044 }
12045 )
12046 },
12047 column
12048 );
12049 }),
12050 !!actions?.length && // Disable reason: we are not making the element interactive,
12051 // but preventing any click events from bubbling up to the
12052 // table row. This allows us to add a click handler to the row
12053 // itself (to toggle row selection) without erroneously
12054 // intercepting click events from ItemActions.
12055 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12056 "td",
12057 {
12058 className: clsx_default("dataviews-view-table__actions-column", {
12059 "dataviews-view-table__actions-column--sticky": true,
12060 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12061 }),
12062 onClick: (e2) => e2.stopPropagation(),
12063 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
12064 }
12065 )
12066 ]
12067 }
12068 );
12069 }
12070 function ViewTable({
12071 actions,
12072 data,
12073 fields,
12074 getItemId,
12075 getItemLevel,
12076 isLoading = false,
12077 onChangeView,
12078 onChangeSelection,
12079 selection,
12080 setOpenedFilter,
12081 onClickItem,
12082 isItemClickable: isItemClickable2,
12083 renderItemLink,
12084 view,
12085 className,
12086 empty
12087 }) {
12088 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
12089 const isDelayedLoading = useDelayedLoading(isLoading);
12090 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12091 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12092 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12093 const { getSelectionProps } = useSelectionProps({
12094 data: orderedData,
12095 actions,
12096 getItemId,
12097 selection,
12098 onChangeSelection
12099 });
12100 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
12101 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
12102 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
12103 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
12104 (0, import_element28.useEffect)(() => {
12105 if (headerMenuToFocusRef.current) {
12106 headerMenuToFocusRef.current.focus();
12107 headerMenuToFocusRef.current = void 0;
12108 }
12109 });
12110 const tableNoticeId = (0, import_element28.useId)();
12111 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12112 scrollContainerRef: containerRef,
12113 enabledHorizontal: !!actions?.length
12114 });
12115 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12116 if (nextHeaderMenuToFocus) {
12117 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12118 setNextHeaderMenuToFocus(void 0);
12119 return;
12120 }
12121 const onHide = (field) => {
12122 const hidden = headerMenuRefs.current.get(field.id);
12123 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12124 setNextHeaderMenuToFocus(fallback?.node);
12125 };
12126 const handleHeaderContextMenu = (event) => {
12127 event.preventDefault();
12128 event.stopPropagation();
12129 const virtualAnchor = {
12130 getBoundingClientRect: () => ({
12131 x: event.clientX,
12132 y: event.clientY,
12133 top: event.clientY,
12134 left: event.clientX,
12135 right: event.clientX,
12136 bottom: event.clientY,
12137 width: 0,
12138 height: 0,
12139 toJSON: () => ({})
12140 })
12141 };
12142 window.requestAnimationFrame(() => {
12143 setContextMenuAnchor(virtualAnchor);
12144 });
12145 };
12146 const hasData = !!data?.length;
12147 const titleField = fields.find((field) => field.id === view.titleField);
12148 const mediaField = fields.find((field) => field.id === view.mediaField);
12149 const descriptionField2 = fields.find(
12150 (field) => field.id === view.descriptionField
12151 );
12152 const { showTitle = true, showMedia = true, showDescription = true } = view;
12153 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
12154 const columns = view.fields ?? [];
12155 const headerMenuRef = (column, index2) => (node) => {
12156 if (node) {
12157 headerMenuRefs.current.set(column, {
12158 node,
12159 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12160 });
12161 } else {
12162 headerMenuRefs.current.delete(column);
12163 }
12164 };
12165 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12166 const isRtl = (0, import_i18n16.isRTL)();
12167 if (!hasData) {
12168 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12169 "div",
12170 {
12171 className: clsx_default("dataviews-no-results", {
12172 "is-refreshing": isDelayedLoading
12173 }),
12174 id: tableNoticeId,
12175 children: empty
12176 }
12177 );
12178 }
12179 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12180 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12181 "table",
12182 {
12183 className: clsx_default("dataviews-view-table", className, {
12184 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12185 view.layout.density
12186 ),
12187 "has-bulk-actions": hasBulkActions,
12188 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12189 }),
12190 "aria-busy": isLoading,
12191 "aria-describedby": tableNoticeId,
12192 role: isInfiniteScroll ? "feed" : void 0,
12193 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12194 children: [
12195 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12196 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12197 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12198 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12199 "col",
12200 {
12201 className: clsx_default(
12202 `dataviews-view-table__col-${column}`,
12203 {
12204 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12205 }
12206 )
12207 },
12208 `col-${column}`
12209 )),
12210 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12211 ] }),
12212 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12213 import_components6.Popover,
12214 {
12215 anchor: contextMenuAnchor,
12216 onClose: () => setContextMenuAnchor(null),
12217 placement: "bottom-start",
12218 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12219 }
12220 ),
12221 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12222 "thead",
12223 {
12224 className: clsx_default({
12225 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12226 }),
12227 onContextMenu: handleHeaderContextMenu,
12228 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12229 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12230 "th",
12231 {
12232 className: "dataviews-view-table__checkbox-column",
12233 scope: "col",
12234 onContextMenu: handleHeaderContextMenu,
12235 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12236 BulkSelectionCheckbox,
12237 {
12238 selection,
12239 onChangeSelection,
12240 data,
12241 actions,
12242 getItemId
12243 }
12244 )
12245 }
12246 ),
12247 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12248 column_header_menu_default,
12249 {
12250 ref: headerMenuRef(
12251 titleField.id,
12252 0
12253 ),
12254 fieldId: titleField.id,
12255 view,
12256 fields,
12257 onChangeView,
12258 onHide,
12259 setOpenedFilter,
12260 canMove: false,
12261 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12262 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12263 }
12264 ) }),
12265 columns.map((column, index2) => {
12266 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12267 const field = fields.find(
12268 (f2) => f2.id === column
12269 );
12270 const effectiveAlign = getEffectiveAlign(
12271 align,
12272 field?.type
12273 );
12274 const canInsertOrMove = view.layout?.enableMoving ?? true;
12275 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12276 "th",
12277 {
12278 style: {
12279 width,
12280 maxWidth,
12281 minWidth,
12282 textAlign: effectiveAlign
12283 },
12284 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12285 scope: "col",
12286 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12287 column_header_menu_default,
12288 {
12289 ref: headerMenuRef(column, index2),
12290 fieldId: column,
12291 view,
12292 fields,
12293 onChangeView,
12294 onHide,
12295 setOpenedFilter,
12296 canMove: canInsertOrMove,
12297 canInsertLeft: canInsertOrMove,
12298 canInsertRight: canInsertOrMove
12299 }
12300 )
12301 },
12302 column
12303 );
12304 }),
12305 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12306 "th",
12307 {
12308 className: clsx_default(
12309 "dataviews-view-table__actions-column",
12310 {
12311 "dataviews-view-table__actions-column--sticky": true,
12312 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12313 }
12314 ),
12315 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n16.__)("Actions") })
12316 }
12317 )
12318 ] })
12319 }
12320 ),
12321 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12322 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12323 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12324 "td",
12325 {
12326 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12327 className: "dataviews-view-table__group-header-cell",
12328 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n16.sprintf)(
12329 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12330 (0, import_i18n16.__)("%1$s: %2$s"),
12331 groupField.label,
12332 groupName
12333 )
12334 }
12335 ) }),
12336 groupItems.map((item, index2) => {
12337 const id = getItemId(item) || index2.toString();
12338 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12339 TableRow,
12340 {
12341 item,
12342 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12343 hasBulkActions,
12344 actions,
12345 fields,
12346 id,
12347 view,
12348 titleField,
12349 mediaField,
12350 descriptionField: descriptionField2,
12351 selection,
12352 getItemId,
12353 onChangeSelection,
12354 ...getSelectionProps(id),
12355 onClickItem,
12356 renderItemLink,
12357 isItemClickable: isItemClickable2,
12358 isActionsColumnSticky: !isHorizontalScrollEnd
12359 },
12360 getItemId(item)
12361 );
12362 })
12363 ] }, `group-${groupName}`)
12364 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12365 const id = getItemId(item) || index2.toString();
12366 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12367 TableRow,
12368 {
12369 item,
12370 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12371 hasBulkActions,
12372 actions,
12373 fields,
12374 id,
12375 view,
12376 titleField,
12377 mediaField,
12378 descriptionField: descriptionField2,
12379 selection,
12380 getItemId,
12381 onChangeSelection,
12382 ...getSelectionProps(id),
12383 onClickItem,
12384 renderItemLink,
12385 isItemClickable: isItemClickable2,
12386 isActionsColumnSticky: !isHorizontalScrollEnd,
12387 posinset: isInfiniteScroll ? index2 + 1 : void 0
12388 },
12389 getItemId(item)
12390 );
12391 }) })
12392 ]
12393 }
12394 ),
12395 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, {}) }) })
12396 ] });
12397 }
12398 var table_default = ViewTable;
12399
12400 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12401 var import_components9 = __toESM(require_components(), 1);
12402 var import_i18n19 = __toESM(require_i18n(), 1);
12403
12404 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12405 var import_components8 = __toESM(require_components(), 1);
12406 var import_i18n18 = __toESM(require_i18n(), 1);
12407 var import_compose3 = __toESM(require_compose(), 1);
12408 var import_element32 = __toESM(require_element(), 1);
12409
12410 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12411 var import_components7 = __toESM(require_components(), 1);
12412 var import_i18n17 = __toESM(require_i18n(), 1);
12413 var import_element29 = __toESM(require_element(), 1);
12414 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12415 var imageSizes = [
12416 {
12417 value: 120,
12418 breakpoint: 1
12419 },
12420 {
12421 value: 170,
12422 breakpoint: 1
12423 },
12424 {
12425 value: 230,
12426 breakpoint: 1
12427 },
12428 {
12429 value: 290,
12430 breakpoint: 1112
12431 // at minimum image width, 4 images display at this container size
12432 },
12433 {
12434 value: 350,
12435 breakpoint: 1636
12436 // at minimum image width, 6 images display at this container size
12437 },
12438 {
12439 value: 430,
12440 breakpoint: 588
12441 // at minimum image width, 2 images display at this container size
12442 }
12443 ];
12444 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12445 function useGridColumns() {
12446 const context = (0, import_element29.useContext)(dataviews_context_default);
12447 const view = context.view;
12448 return (0, import_element29.useMemo)(() => {
12449 const containerWidth = context.containerWidth;
12450 const gap = 32;
12451 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12452 const columns = Math.floor(
12453 (containerWidth + gap) / (previewSize + gap)
12454 );
12455 return Math.max(1, columns);
12456 }, [context.containerWidth, view.layout?.previewSize]);
12457 }
12458
12459 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12460 var import_element30 = __toESM(require_element(), 1);
12461 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12462 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
12463 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12464 "div",
12465 {
12466 ref,
12467 className: clsx_default("dataviews-view-grid-items", className),
12468 style: {
12469 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12470 },
12471 ...props
12472 }
12473 );
12474 });
12475
12476 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12477 var import_element31 = __toESM(require_element(), 1);
12478 function useIntersectionObserver(elementRef, posinset) {
12479 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
12480 (0, import_element31.useEffect)(() => {
12481 const element = elementRef.current;
12482 if (!element || posinset === void 0 || !intersectionObserver) {
12483 return;
12484 }
12485 intersectionObserver.observe(element);
12486 return () => {
12487 intersectionObserver.unobserve(element);
12488 };
12489 }, [elementRef, intersectionObserver, posinset]);
12490 }
12491 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12492 const hasData = !!data?.length;
12493 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12494 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12495 }
12496
12497 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12498 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12499 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12500 function chunk(array, size4) {
12501 const chunks = [];
12502 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12503 chunks.push(array.slice(i2, i2 + size4));
12504 }
12505 return chunks;
12506 }
12507 var GridItem = (0, import_element32.forwardRef)(
12508 function GridItem2({
12509 view,
12510 selection,
12511 onChangeSelection,
12512 onClickItem,
12513 isItemClickable: isItemClickable2,
12514 renderItemLink,
12515 getItemId,
12516 item,
12517 actions,
12518 mediaField,
12519 titleField,
12520 descriptionField: descriptionField2,
12521 regularFields,
12522 badgeFields,
12523 hasBulkActions,
12524 config,
12525 posinset,
12526 setsize,
12527 ...props
12528 }, forwardedRef) {
12529 const {
12530 showTitle = true,
12531 showMedia = true,
12532 showDescription = true
12533 } = view;
12534 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12535 const id = getItemId(item);
12536 const elementRef = (0, import_element32.useRef)(null);
12537 const setRefs = (0, import_element32.useCallback)(
12538 (node) => {
12539 elementRef.current = node;
12540 if (typeof forwardedRef === "function") {
12541 forwardedRef(node);
12542 } else if (forwardedRef) {
12543 forwardedRef.current = node;
12544 }
12545 },
12546 [forwardedRef]
12547 );
12548 useIntersectionObserver(elementRef, posinset);
12549 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12550 const isSelected2 = selection.includes(id);
12551 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12552 const rendersMediaField = showMedia && mediaField?.render;
12553 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12554 mediaField.render,
12555 {
12556 item,
12557 field: mediaField,
12558 config
12559 }
12560 ) : mediaPlaceholder;
12561 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12562 let mediaA11yProps;
12563 let titleA11yProps;
12564 if (isItemClickable2(item) && onClickItem) {
12565 if (renderedTitleField) {
12566 mediaA11yProps = {
12567 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12568 };
12569 titleA11yProps = {
12570 id: `dataviews-view-grid__title-field-${instanceId}`
12571 };
12572 } else {
12573 mediaA11yProps = {
12574 "aria-label": (0, import_i18n18.__)("Navigate to item")
12575 };
12576 }
12577 }
12578 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12579 Stack,
12580 {
12581 direction: "column",
12582 ...props,
12583 ref: setRefs,
12584 "aria-setsize": setsize,
12585 "aria-posinset": posinset,
12586 className: clsx_default(
12587 props.className,
12588 "dataviews-view-grid__row__gridcell",
12589 "dataviews-view-grid__card",
12590 {
12591 "is-selected": hasBulkAction && isSelected2
12592 }
12593 ),
12594 children: [
12595 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12596 ItemClickWrapper,
12597 {
12598 item,
12599 isItemClickable: isItemClickable2,
12600 onClickItem,
12601 renderItemLink,
12602 className: clsx_default("dataviews-view-grid__media", {
12603 "dataviews-view-grid__media--placeholder": !rendersMediaField
12604 }),
12605 ...mediaA11yProps,
12606 children: renderedMediaField
12607 }
12608 ),
12609 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12610 DataViewsSelectionCheckbox,
12611 {
12612 item,
12613 selection,
12614 onChangeSelection,
12615 getItemId,
12616 titleField,
12617 disabled: !hasBulkAction
12618 }
12619 ),
12620 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12621 ItemActions,
12622 {
12623 item,
12624 actions,
12625 isCompact: true
12626 }
12627 ) }),
12628 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12629 ItemClickWrapper,
12630 {
12631 item,
12632 isItemClickable: isItemClickable2,
12633 onClickItem,
12634 renderItemLink,
12635 className: "dataviews-view-grid__title-field dataviews-title-field",
12636 ...titleA11yProps,
12637 title: titleField?.getValueFormatted({
12638 item,
12639 field: titleField
12640 }) || void 0,
12641 children: renderedTitleField
12642 }
12643 ) }),
12644 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12645 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12646 descriptionField2.render,
12647 {
12648 item,
12649 field: descriptionField2
12650 }
12651 ),
12652 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12653 Stack,
12654 {
12655 direction: "row",
12656 className: "dataviews-view-grid__badge-fields",
12657 gap: "sm",
12658 wrap: "wrap",
12659 align: "top",
12660 justify: "flex-start",
12661 children: badgeFields.map((field) => {
12662 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12663 WCBadge,
12664 {
12665 className: "dataviews-view-grid__field-value",
12666 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12667 field.render,
12668 {
12669 item,
12670 field
12671 }
12672 )
12673 },
12674 field.id
12675 );
12676 })
12677 }
12678 ),
12679 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12680 Stack,
12681 {
12682 direction: "column",
12683 className: "dataviews-view-grid__fields",
12684 gap: "xs",
12685 children: regularFields.map((field) => {
12686 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12687 import_components8.Flex,
12688 {
12689 className: "dataviews-view-grid__field",
12690 gap: 1,
12691 justify: "flex-start",
12692 expanded: true,
12693 style: { height: "auto" },
12694 direction: "row",
12695 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12696 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12697 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12698 tooltip_exports.Trigger,
12699 {
12700 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12701 }
12702 ),
12703 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12704 ] }),
12705 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12706 import_components8.FlexItem,
12707 {
12708 className: "dataviews-view-grid__field-value",
12709 style: { maxHeight: "none" },
12710 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12711 field.render,
12712 {
12713 item,
12714 field
12715 }
12716 )
12717 }
12718 )
12719 ] })
12720 },
12721 field.id
12722 );
12723 })
12724 }
12725 )
12726 ] })
12727 ]
12728 }
12729 );
12730 }
12731 );
12732 function CompositeGrid({
12733 data,
12734 isInfiniteScroll,
12735 className,
12736 inert,
12737 isLoading,
12738 view,
12739 fields,
12740 selection,
12741 onChangeSelection,
12742 onClickItem,
12743 isItemClickable: isItemClickable2,
12744 renderItemLink,
12745 getItemId,
12746 actions,
12747 getSelectionProps
12748 }) {
12749 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
12750 const gridColumns = useGridColumns();
12751 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12752 const titleField = fields.find(
12753 (field) => field.id === view?.titleField
12754 );
12755 const mediaField = fields.find(
12756 (field) => field.id === view?.mediaField
12757 );
12758 const descriptionField2 = fields.find(
12759 (field) => field.id === view?.descriptionField
12760 );
12761 const otherFields = view.fields ?? [];
12762 const { regularFields, badgeFields } = otherFields.reduce(
12763 (accumulator, fieldId) => {
12764 const field = fields.find((f2) => f2.id === fieldId);
12765 if (!field) {
12766 return accumulator;
12767 }
12768 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12769 accumulator[key].push(field);
12770 return accumulator;
12771 },
12772 { regularFields: [], badgeFields: [] }
12773 );
12774 const size4 = "900px";
12775 const totalRows = Math.ceil(data.length / gridColumns);
12776 const placeholdersNeeded = usePlaceholdersNeeded(
12777 data,
12778 isInfiniteScroll,
12779 gridColumns
12780 );
12781 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12782 // Render infinite scroll layout (no rows, feed semantics)
12783 children: [
12784 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12785 import_components8.Composite,
12786 {
12787 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12788 GridItems,
12789 {
12790 className: clsx_default(
12791 "dataviews-view-grid-infinite-scroll",
12792 className,
12793 {
12794 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12795 "compact",
12796 "comfortable"
12797 ].includes(view.layout.density)
12798 }
12799 ),
12800 previewSize: view.layout?.previewSize,
12801 "aria-busy": isLoading,
12802 ref: resizeObserverRef
12803 }
12804 ),
12805 role: "feed",
12806 focusWrap: true,
12807 inert,
12808 children: [
12809 Array.from({ length: placeholdersNeeded }).map(
12810 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12811 import_components8.Composite.Item,
12812 {
12813 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12814 Stack,
12815 {
12816 ...props,
12817 direction: "column",
12818 role: "article",
12819 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12820 }
12821 ),
12822 "aria-hidden": true,
12823 tabIndex: -1
12824 },
12825 `placeholder-${index2}`
12826 )
12827 ),
12828 data.map((item) => {
12829 const itemId = getItemId(item);
12830 const selectionProps = getSelectionProps(itemId);
12831 const stablePosition = item.position;
12832 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12833 import_components8.Composite.Item,
12834 {
12835 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12836 GridItem,
12837 {
12838 ...props,
12839 id: itemId,
12840 role: "article",
12841 view,
12842 selection,
12843 onChangeSelection,
12844 onClickItem,
12845 isItemClickable: isItemClickable2,
12846 renderItemLink,
12847 getItemId,
12848 item,
12849 actions,
12850 onMouseDown: (event) => {
12851 props.onMouseDown?.(event);
12852 selectionProps.onMouseDown(
12853 event
12854 );
12855 },
12856 onClickCapture: (event) => {
12857 props.onClickCapture?.(event);
12858 selectionProps.onClickCapture(
12859 event
12860 );
12861 },
12862 mediaField,
12863 titleField,
12864 descriptionField: descriptionField2,
12865 regularFields,
12866 badgeFields,
12867 hasBulkActions,
12868 posinset: stablePosition,
12869 setsize: paginationInfo.totalItems,
12870 config: {
12871 sizes: size4
12872 }
12873 }
12874 )
12875 },
12876 itemId
12877 );
12878 })
12879 ]
12880 }
12881 ),
12882 // Render standard grid layout (with rows, grid semantics)
12883 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12884 import_components8.Composite,
12885 {
12886 role: "grid",
12887 className: clsx_default("dataviews-view-grid", className, {
12888 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12889 view.layout.density
12890 )
12891 }),
12892 focusWrap: true,
12893 "aria-busy": isLoading,
12894 "aria-rowcount": totalRows,
12895 ref: resizeObserverRef,
12896 inert,
12897 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12898 import_components8.Composite.Row,
12899 {
12900 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12901 "div",
12902 {
12903 role: "row",
12904 "aria-rowindex": i2 + 1,
12905 "aria-label": (0, import_i18n18.sprintf)(
12906 /* translators: %d: The row number in the grid */
12907 (0, import_i18n18.__)("Row %d"),
12908 i2 + 1
12909 ),
12910 className: "dataviews-view-grid__row",
12911 style: {
12912 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12913 }
12914 }
12915 ),
12916 children: row.map((item) => {
12917 const itemId = getItemId(item);
12918 const selectionProps = getSelectionProps(itemId);
12919 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12920 import_components8.Composite.Item,
12921 {
12922 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12923 GridItem,
12924 {
12925 ...props,
12926 id: itemId,
12927 role: "gridcell",
12928 view,
12929 selection,
12930 onChangeSelection,
12931 onClickItem,
12932 isItemClickable: isItemClickable2,
12933 renderItemLink,
12934 getItemId,
12935 item,
12936 actions,
12937 onMouseDown: (event) => {
12938 props.onMouseDown?.(
12939 event
12940 );
12941 selectionProps.onMouseDown(
12942 event
12943 );
12944 },
12945 onClickCapture: (event) => {
12946 props.onClickCapture?.(
12947 event
12948 );
12949 selectionProps.onClickCapture(
12950 event
12951 );
12952 },
12953 mediaField,
12954 titleField,
12955 descriptionField: descriptionField2,
12956 regularFields,
12957 badgeFields,
12958 hasBulkActions,
12959 config: {
12960 sizes: size4
12961 }
12962 }
12963 )
12964 },
12965 itemId
12966 );
12967 })
12968 },
12969 i2
12970 ))
12971 }
12972 )
12973 ]
12974 });
12975 }
12976
12977 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12978 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12979 function ViewGrid({
12980 actions,
12981 data,
12982 fields,
12983 getItemId,
12984 isLoading,
12985 onChangeSelection,
12986 onClickItem,
12987 isItemClickable: isItemClickable2,
12988 renderItemLink,
12989 selection,
12990 view,
12991 className,
12992 empty
12993 }) {
12994 const isDelayedLoading = useDelayedLoading(!!isLoading);
12995 const hasData = !!data?.length;
12996 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12997 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12998 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12999 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
13000 const { getSelectionProps } = useSelectionProps({
13001 data: orderedData,
13002 actions,
13003 getItemId,
13004 selection,
13005 onChangeSelection
13006 });
13007 if (!hasData) {
13008 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13009 "div",
13010 {
13011 className: clsx_default("dataviews-no-results", {
13012 "is-refreshing": isDelayedLoading
13013 }),
13014 children: empty
13015 }
13016 );
13017 }
13018 const gridProps = {
13019 className: clsx_default(className, {
13020 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13021 }),
13022 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13023 isLoading,
13024 view,
13025 fields,
13026 selection,
13027 onChangeSelection,
13028 onClickItem,
13029 isItemClickable: isItemClickable2,
13030 renderItemLink,
13031 getItemId,
13032 actions,
13033 getSelectionProps
13034 };
13035 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
13036 // Render multiple groups.
13037 children: [
13038 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
13039 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13040 Stack,
13041 {
13042 direction: "column",
13043 gap: "sm",
13044 children: [
13045 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
13046 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13047 (0, import_i18n19.__)("%1$s: %2$s"),
13048 groupField.label,
13049 groupName
13050 ) }),
13051 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13052 CompositeGrid,
13053 {
13054 ...gridProps,
13055 data: groupItems,
13056 isInfiniteScroll: false
13057 }
13058 )
13059 ]
13060 },
13061 groupName
13062 )
13063 ) }),
13064 // Render a single grid with all data.
13065 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13066 CompositeGrid,
13067 {
13068 ...gridProps,
13069 data,
13070 isInfiniteScroll: !!isInfiniteScroll
13071 }
13072 ),
13073 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
13074 ]
13075 });
13076 }
13077 var grid_default = ViewGrid;
13078
13079 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
13080 var import_compose4 = __toESM(require_compose(), 1);
13081 var import_components10 = __toESM(require_components(), 1);
13082 var import_element33 = __toESM(require_element(), 1);
13083 var import_i18n20 = __toESM(require_i18n(), 1);
13084 var import_data4 = __toESM(require_data(), 1);
13085 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13086 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
13087 function generateItemWrapperCompositeId(idPrefix) {
13088 return `${idPrefix}-item-wrapper`;
13089 }
13090 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
13091 return `${idPrefix}-primary-action-${primaryActionId}`;
13092 }
13093 function generateDropdownTriggerCompositeId(idPrefix) {
13094 return `${idPrefix}-dropdown`;
13095 }
13096 function PrimaryActionGridCell({
13097 idPrefix,
13098 primaryAction,
13099 item
13100 }) {
13101 const registry = (0, import_data4.useRegistry)();
13102 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
13103 const compositeItemId = generatePrimaryActionCompositeId(
13104 idPrefix,
13105 primaryAction.id
13106 );
13107 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13108 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13109 import_components10.Composite.Item,
13110 {
13111 id: compositeItemId,
13112 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13113 import_components10.Button,
13114 {
13115 disabled: !!primaryAction.disabled,
13116 accessibleWhenDisabled: true,
13117 text: label,
13118 size: "small",
13119 onClick: () => setIsModalOpen(true)
13120 }
13121 ),
13122 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13123 ActionModal,
13124 {
13125 action: primaryAction,
13126 items: [item],
13127 closeModal: () => setIsModalOpen(false)
13128 }
13129 )
13130 }
13131 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13132 import_components10.Composite.Item,
13133 {
13134 id: compositeItemId,
13135 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13136 import_components10.Button,
13137 {
13138 disabled: !!primaryAction.disabled,
13139 accessibleWhenDisabled: true,
13140 size: "small",
13141 onClick: () => {
13142 primaryAction.callback([item], { registry });
13143 },
13144 children: label
13145 }
13146 )
13147 }
13148 ) }, primaryAction.id);
13149 }
13150 function ListItem({
13151 view,
13152 actions,
13153 idPrefix,
13154 isSelected: isSelected2,
13155 item,
13156 titleField,
13157 mediaField,
13158 descriptionField: descriptionField2,
13159 onSelect,
13160 otherFields,
13161 onDropdownTriggerKeyDown,
13162 posinset
13163 }) {
13164 const {
13165 showTitle = true,
13166 showMedia = true,
13167 showDescription = true,
13168 infiniteScrollEnabled
13169 } = view;
13170 const itemRef = (0, import_element33.useRef)(null);
13171 const labelId = `${idPrefix}-label`;
13172 const descriptionId = `${idPrefix}-description`;
13173 const registry = (0, import_data4.useRegistry)();
13174 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
13175 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
13176 null
13177 );
13178 const handleHover = ({ type }) => {
13179 const isHover = type === "mouseenter";
13180 setIsHovered(isHover);
13181 };
13182 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13183 (0, import_element33.useEffect)(() => {
13184 if (isSelected2) {
13185 itemRef.current?.scrollIntoView({
13186 behavior: "auto",
13187 block: "nearest",
13188 inline: "nearest"
13189 });
13190 }
13191 }, [isSelected2]);
13192 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
13193 const _eligibleActions = actions.filter(
13194 (action) => !action.isEligible || action.isEligible(item)
13195 );
13196 const _primaryActions = _eligibleActions.filter(
13197 (action) => action.isPrimary
13198 );
13199 return {
13200 primaryAction: _primaryActions[0],
13201 eligibleActions: _eligibleActions
13202 };
13203 }, [actions, item]);
13204 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13205 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)(
13206 mediaField.render,
13207 {
13208 item,
13209 field: mediaField,
13210 config: { sizes: "52px" }
13211 }
13212 ) }) : null;
13213 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13214 const renderDescription = showDescription && descriptionField2?.render;
13215 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13216 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13217 Stack,
13218 {
13219 direction: "row",
13220 gap: "md",
13221 className: "dataviews-view-list__item-actions",
13222 children: [
13223 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13224 PrimaryActionGridCell,
13225 {
13226 idPrefix,
13227 primaryAction,
13228 item
13229 }
13230 ),
13231 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13232 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13233 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13234 Menu3.TriggerButton,
13235 {
13236 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13237 import_components10.Composite.Item,
13238 {
13239 id: generateDropdownTriggerCompositeId(
13240 idPrefix
13241 ),
13242 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13243 import_components10.Button,
13244 {
13245 size: "small",
13246 icon: more_vertical_default,
13247 label: (0, import_i18n20.__)("Actions"),
13248 accessibleWhenDisabled: true,
13249 disabled: !actions.length,
13250 onKeyDown: onDropdownTriggerKeyDown
13251 }
13252 )
13253 }
13254 )
13255 }
13256 ),
13257 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13258 ActionsMenuGroup,
13259 {
13260 actions: eligibleActions,
13261 item,
13262 registry,
13263 setActiveModalAction
13264 }
13265 ) })
13266 ] }),
13267 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13268 ActionModal,
13269 {
13270 action: activeModalAction,
13271 items: [item],
13272 closeModal: () => setActiveModalAction(null)
13273 }
13274 )
13275 ] })
13276 ]
13277 }
13278 );
13279 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13280 import_components10.Composite.Row,
13281 {
13282 ref: itemRef,
13283 render: (
13284 /* aria-posinset breaks Composite.Row if passed to it directly. */
13285 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13286 "div",
13287 {
13288 "aria-posinset": posinset,
13289 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13290 }
13291 )
13292 ),
13293 role: infiniteScrollEnabled ? "article" : "row",
13294 className: clsx_default({
13295 "is-selected": isSelected2,
13296 "is-hovered": isHovered
13297 }),
13298 onMouseEnter: handleHover,
13299 onMouseLeave: handleHover,
13300 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13301 Stack,
13302 {
13303 direction: "row",
13304 className: "dataviews-view-list__item-wrapper",
13305 children: [
13306 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13307 import_components10.Composite.Item,
13308 {
13309 id: generateItemWrapperCompositeId(idPrefix),
13310 "aria-pressed": isSelected2,
13311 "aria-labelledby": labelId,
13312 "aria-describedby": descriptionId,
13313 className: "dataviews-view-list__item",
13314 onClick: () => onSelect(item)
13315 }
13316 ) }),
13317 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13318 Stack,
13319 {
13320 direction: "row",
13321 gap: "md",
13322 justify: "start",
13323 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13324 style: { flex: 1, minWidth: 0 },
13325 children: [
13326 renderedMediaField,
13327 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13328 Stack,
13329 {
13330 direction: "column",
13331 gap: "xs",
13332 className: "dataviews-view-list__field-wrapper",
13333 children: [
13334 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13335 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13336 "div",
13337 {
13338 className: "dataviews-title-field dataviews-view-list__title-field",
13339 id: labelId,
13340 children: renderedTitleField
13341 }
13342 ),
13343 usedActions
13344 ] }),
13345 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13346 descriptionField2.render,
13347 {
13348 item,
13349 field: descriptionField2
13350 }
13351 ) }),
13352 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13353 "div",
13354 {
13355 className: "dataviews-view-list__fields",
13356 id: descriptionId,
13357 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13358 "div",
13359 {
13360 className: "dataviews-view-list__field",
13361 children: [
13362 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13363 VisuallyHidden,
13364 {
13365 className: "dataviews-view-list__field-label",
13366 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13367 children: field.label
13368 }
13369 ),
13370 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13371 field.render,
13372 {
13373 item,
13374 field
13375 }
13376 ) })
13377 ]
13378 },
13379 field.id
13380 ))
13381 }
13382 )
13383 ]
13384 }
13385 )
13386 ]
13387 }
13388 )
13389 ]
13390 }
13391 )
13392 }
13393 );
13394 }
13395 function isDefined2(item) {
13396 return !!item;
13397 }
13398 function ViewList(props) {
13399 const {
13400 actions,
13401 data,
13402 fields,
13403 getItemId,
13404 isLoading,
13405 onChangeSelection,
13406 selection,
13407 view,
13408 className,
13409 empty
13410 } = props;
13411 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13412 const isDelayedLoading = useDelayedLoading(!!isLoading);
13413 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13414 const selectedItem = data?.findLast(
13415 (item) => selection.includes(getItemId(item))
13416 );
13417 const titleField = fields.find((field) => field.id === view.titleField);
13418 const mediaField = fields.find((field) => field.id === view.mediaField);
13419 const descriptionField2 = fields.find(
13420 (field) => field.id === view.descriptionField
13421 );
13422 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13423 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13424 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
13425 (item) => `${baseId}-${getItemId(item)}`,
13426 [baseId, getItemId]
13427 );
13428 const isActiveCompositeItem = (0, import_element33.useCallback)(
13429 (item, idToCheck) => {
13430 return idToCheck.startsWith(
13431 generateCompositeItemIdPrefix(item)
13432 );
13433 },
13434 [generateCompositeItemIdPrefix]
13435 );
13436 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
13437 const compositeRef = (0, import_element33.useRef)(null);
13438 (0, import_element33.useEffect)(() => {
13439 if (selectedItem) {
13440 setActiveCompositeId(
13441 generateItemWrapperCompositeId(
13442 generateCompositeItemIdPrefix(selectedItem)
13443 )
13444 );
13445 }
13446 }, [selectedItem, generateCompositeItemIdPrefix]);
13447 const activeItemIndex = data.findIndex(
13448 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13449 );
13450 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13451 const isActiveIdInList = activeItemIndex !== -1;
13452 const selectCompositeItem = (0, import_element33.useCallback)(
13453 (targetIndex, generateCompositeId) => {
13454 const clampedIndex = Math.min(
13455 data.length - 1,
13456 Math.max(0, targetIndex)
13457 );
13458 if (!data[clampedIndex]) {
13459 return;
13460 }
13461 const itemIdPrefix = generateCompositeItemIdPrefix(
13462 data[clampedIndex]
13463 );
13464 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13465 setActiveCompositeId(targetCompositeItemId);
13466 if (compositeRef.current?.contains(
13467 compositeRef.current.ownerDocument.activeElement
13468 )) {
13469 document.getElementById(targetCompositeItemId)?.focus();
13470 }
13471 },
13472 [data, generateCompositeItemIdPrefix]
13473 );
13474 (0, import_element33.useEffect)(() => {
13475 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13476 if (!isActiveIdInList && wasActiveIdInList) {
13477 selectCompositeItem(
13478 previousActiveItemIndex,
13479 generateItemWrapperCompositeId
13480 );
13481 }
13482 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13483 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
13484 (event) => {
13485 if (event.key === "ArrowDown") {
13486 event.preventDefault();
13487 selectCompositeItem(
13488 activeItemIndex + 1,
13489 generateDropdownTriggerCompositeId
13490 );
13491 }
13492 if (event.key === "ArrowUp") {
13493 event.preventDefault();
13494 selectCompositeItem(
13495 activeItemIndex - 1,
13496 generateDropdownTriggerCompositeId
13497 );
13498 }
13499 },
13500 [selectCompositeItem, activeItemIndex]
13501 );
13502 const hasData = !!data?.length;
13503 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13504 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13505 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13506 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13507 const listClassName = clsx_default("dataviews-view-list", className, {
13508 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13509 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13510 });
13511 const compositeProps = {
13512 ref: compositeRef,
13513 id: baseId,
13514 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13515 activeId: activeCompositeId,
13516 setActiveId: setActiveCompositeId,
13517 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13518 };
13519 if (!hasData) {
13520 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13521 "div",
13522 {
13523 className: clsx_default("dataviews-no-results", {
13524 "is-refreshing": isDelayedLoading
13525 }),
13526 children: empty
13527 }
13528 );
13529 }
13530 if (hasData && groupField && dataByGroup) {
13531 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13532 import_components10.Composite,
13533 {
13534 ...compositeProps,
13535 className: "dataviews-view-list__group",
13536 role: "grid",
13537 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13538 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "column", children: [
13539 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
13540 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13541 (0, import_i18n20.__)("%1$s: %2$s"),
13542 groupField.label,
13543 groupName
13544 ) }),
13545 groupItems.map((item) => {
13546 const id = generateCompositeItemIdPrefix(item);
13547 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13548 ListItem,
13549 {
13550 view,
13551 idPrefix: id,
13552 actions,
13553 item,
13554 isSelected: item === selectedItem,
13555 onSelect,
13556 mediaField,
13557 titleField,
13558 descriptionField: descriptionField2,
13559 otherFields,
13560 onDropdownTriggerKeyDown
13561 },
13562 id
13563 );
13564 })
13565 ] }, groupName)
13566 ) })
13567 }
13568 );
13569 }
13570 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13571 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13572 import_components10.Composite,
13573 {
13574 ...compositeProps,
13575 className: listClassName,
13576 role: view.infiniteScrollEnabled ? "feed" : "grid",
13577 children: data.map((item, index2) => {
13578 const id = generateCompositeItemIdPrefix(item);
13579 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13580 ListItem,
13581 {
13582 view,
13583 idPrefix: id,
13584 actions,
13585 item,
13586 isSelected: item === selectedItem,
13587 onSelect,
13588 mediaField,
13589 titleField,
13590 descriptionField: descriptionField2,
13591 otherFields,
13592 onDropdownTriggerKeyDown,
13593 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13594 },
13595 id
13596 );
13597 })
13598 }
13599 ),
13600 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13601 // scroll position doesn't bounce. Hidden, and silent to a11y,
13602 // while idle.
13603 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13604 "p",
13605 {
13606 className: "dataviews-loading-more",
13607 "aria-hidden": !isLoading,
13608 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {})
13609 }
13610 )
13611 ] });
13612 }
13613
13614 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13615 var import_components11 = __toESM(require_components(), 1);
13616
13617 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13618 var import_i18n21 = __toESM(require_i18n(), 1);
13619 var import_element34 = __toESM(require_element(), 1);
13620 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13621 function ActivityGroup({
13622 groupName,
13623 groupData,
13624 groupField,
13625 showLabel = true,
13626 children
13627 }) {
13628 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
13629 // translators: %s: The label of the field e.g. "Status".
13630 (0, import_i18n21.sprintf)((0, import_i18n21.__)("%s: <groupName />"), groupField.label).trim(),
13631 {
13632 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13633 groupField.render,
13634 {
13635 item: groupData[0],
13636 field: groupField
13637 }
13638 )
13639 }
13640 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13641 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13642 Stack,
13643 {
13644 direction: "column",
13645 className: "dataviews-view-activity__group",
13646 children: [
13647 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13648 children
13649 ]
13650 },
13651 groupName
13652 );
13653 }
13654
13655 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13656 var import_element35 = __toESM(require_element(), 1);
13657 var import_data5 = __toESM(require_data(), 1);
13658 var import_compose5 = __toESM(require_compose(), 1);
13659 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13660 function ActivityItem(props) {
13661 const {
13662 view,
13663 actions,
13664 item,
13665 titleField,
13666 mediaField,
13667 descriptionField: descriptionField2,
13668 otherFields,
13669 posinset,
13670 onClickItem,
13671 renderItemLink,
13672 isItemClickable: isItemClickable2
13673 } = props;
13674 const {
13675 showTitle = true,
13676 showMedia = true,
13677 showDescription = true,
13678 infiniteScrollEnabled
13679 } = view;
13680 const itemRef = (0, import_element35.useRef)(null);
13681 const registry = (0, import_data5.useRegistry)();
13682 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
13683 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
13684 const _eligibleActions = actions.filter(
13685 (action) => !action.isEligible || action.isEligible(item)
13686 );
13687 const _primaryActions = _eligibleActions.filter(
13688 (action) => action.isPrimary
13689 );
13690 return {
13691 primaryActions: _primaryActions,
13692 eligibleActions: _eligibleActions
13693 };
13694 }, [actions, item]);
13695 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13696 const density = view.layout?.density ?? "balanced";
13697 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13698 mediaField.render,
13699 {
13700 item,
13701 field: mediaField,
13702 config: {
13703 sizes: density === "comfortable" ? "32px" : "24px"
13704 }
13705 }
13706 ) : null;
13707 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13708 "span",
13709 {
13710 className: "dataviews-view-activity__item-bullet",
13711 "aria-hidden": "true"
13712 }
13713 ) });
13714 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13715 const verticalGap = (0, import_element35.useMemo)(() => {
13716 switch (density) {
13717 case "comfortable":
13718 return "md";
13719 default:
13720 return "sm";
13721 }
13722 }, [density]);
13723 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13724 "div",
13725 {
13726 ref: itemRef,
13727 role: infiniteScrollEnabled ? "article" : void 0,
13728 "aria-posinset": posinset,
13729 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13730 className: clsx_default(
13731 "dataviews-view-activity__item",
13732 density === "compact" && "is-compact",
13733 density === "balanced" && "is-balanced",
13734 density === "comfortable" && "is-comfortable"
13735 ),
13736 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13737 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13738 Stack,
13739 {
13740 direction: "column",
13741 gap: "xs",
13742 align: "center",
13743 className: "dataviews-view-activity__item-type",
13744 children: renderedMediaField
13745 }
13746 ),
13747 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13748 Stack,
13749 {
13750 direction: "column",
13751 gap: verticalGap,
13752 align: "flex-start",
13753 className: "dataviews-view-activity__item-content",
13754 children: [
13755 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13756 ItemClickWrapper,
13757 {
13758 item,
13759 isItemClickable: isItemClickable2,
13760 onClickItem,
13761 renderItemLink,
13762 className: "dataviews-view-activity__item-title",
13763 children: renderedTitleField
13764 }
13765 ),
13766 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13767 descriptionField2.render,
13768 {
13769 item,
13770 field: descriptionField2
13771 }
13772 ) }),
13773 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13774 "div",
13775 {
13776 className: "dataviews-view-activity__item-field",
13777 children: [
13778 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13779 VisuallyHidden,
13780 {
13781 className: "dataviews-view-activity__item-field-label",
13782 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13783 children: field.label
13784 }
13785 ),
13786 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13787 field.render,
13788 {
13789 item,
13790 field
13791 }
13792 ) })
13793 ]
13794 },
13795 field.id
13796 )) }),
13797 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13798 PrimaryActions,
13799 {
13800 item,
13801 actions: primaryActions,
13802 registry,
13803 buttonVariant: "secondary"
13804 }
13805 )
13806 ]
13807 }
13808 ),
13809 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13810 // there if there are any actions at all.
13811 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13812 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13813 ItemActions,
13814 {
13815 item,
13816 actions: eligibleActions,
13817 isCompact: true
13818 }
13819 ) })
13820 ] })
13821 }
13822 );
13823 }
13824 var activity_item_default = ActivityItem;
13825
13826 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13827 var import_react6 = __toESM(require_react(), 1);
13828 function isDefined3(item) {
13829 return !!item;
13830 }
13831 function ActivityItems(props) {
13832 const { data, fields, getItemId, view } = props;
13833 const titleField = fields.find((field) => field.id === view.titleField);
13834 const mediaField = fields.find((field) => field.id === view.mediaField);
13835 const descriptionField2 = fields.find(
13836 (field) => field.id === view.descriptionField
13837 );
13838 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13839 return data.map((item, index2) => {
13840 return /* @__PURE__ */ (0, import_react6.createElement)(
13841 activity_item_default,
13842 {
13843 ...props,
13844 key: getItemId(item),
13845 item,
13846 mediaField,
13847 titleField,
13848 descriptionField: descriptionField2,
13849 otherFields,
13850 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13851 }
13852 );
13853 });
13854 }
13855
13856 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13857 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13858 function ViewActivity(props) {
13859 const { empty, data, fields, isLoading, view, className } = props;
13860 const isDelayedLoading = useDelayedLoading(!!isLoading);
13861 const hasData = !!data?.length;
13862 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13863 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13864 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13865 if (!hasData) {
13866 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13867 "div",
13868 {
13869 className: clsx_default("dataviews-no-results", {
13870 "is-refreshing": isDelayedLoading
13871 }),
13872 children: empty
13873 }
13874 );
13875 }
13876 const isInert = !isInfiniteScroll && !!isLoading;
13877 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13878 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13879 });
13880 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13881 if (hasData && groupField && dataByGroup) {
13882 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13883 Stack,
13884 {
13885 direction: "column",
13886 gap: "sm",
13887 className: wrapperClassName,
13888 inert: isInert ? "true" : void 0,
13889 children: groupedEntries.map(
13890 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13891 ActivityGroup,
13892 {
13893 groupName,
13894 groupData,
13895 groupField,
13896 showLabel: view.groupBy?.showLabel !== false,
13897 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13898 ActivityItems,
13899 {
13900 ...props,
13901 data: groupData
13902 }
13903 )
13904 },
13905 groupName
13906 )
13907 )
13908 }
13909 );
13910 }
13911 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13912 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13913 "div",
13914 {
13915 className: wrapperClassName,
13916 role: view.infiniteScrollEnabled ? "feed" : void 0,
13917 inert: isInert ? "true" : void 0,
13918 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13919 }
13920 ),
13921 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13922 ] });
13923 }
13924
13925 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13926 var import_components14 = __toESM(require_components(), 1);
13927 var import_i18n24 = __toESM(require_i18n(), 1);
13928 var import_compose6 = __toESM(require_compose(), 1);
13929 var import_element38 = __toESM(require_element(), 1);
13930
13931 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13932 var import_components13 = __toESM(require_components(), 1);
13933 var import_data6 = __toESM(require_data(), 1);
13934 var import_element37 = __toESM(require_element(), 1);
13935 var import_i18n23 = __toESM(require_i18n(), 1);
13936
13937 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13938 var import_components12 = __toESM(require_components(), 1);
13939 var import_element36 = __toESM(require_element(), 1);
13940 var import_i18n22 = __toESM(require_i18n(), 1);
13941 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13942 function hasPaginationControls(view, paginationInfo) {
13943 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
13944 }
13945 function DataViewsPagination() {
13946 const { view, onChangeView, paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13947 if (!hasPaginationControls(view, paginationInfo)) {
13948 return null;
13949 }
13950 const { totalPages } = paginationInfo;
13951 const currentPage = view.page ?? 1;
13952 const pageSelectOptions = Array.from(Array(totalPages)).map(
13953 (_, i2) => {
13954 const page = i2 + 1;
13955 return {
13956 value: page.toString(),
13957 label: page.toString(),
13958 "aria-label": currentPage === page ? (0, import_i18n22.sprintf)(
13959 // translators: 1: current page number. 2: total number of pages.
13960 (0, import_i18n22.__)("Page %1$d of %2$d"),
13961 currentPage,
13962 totalPages
13963 ) : page.toString()
13964 };
13965 }
13966 );
13967 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13968 Stack,
13969 {
13970 direction: "row",
13971 className: "dataviews-pagination",
13972 justify: "end",
13973 align: "center",
13974 gap: "xl",
13975 children: [
13976 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13977 Stack,
13978 {
13979 direction: "row",
13980 justify: "flex-start",
13981 align: "center",
13982 gap: "xs",
13983 className: "dataviews-pagination__page-select",
13984 children: (0, import_element36.createInterpolateElement)(
13985 (0, import_i18n22.sprintf)(
13986 // translators: 1: Current page number, 2: Total number of pages.
13987 (0, import_i18n22._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
13988 "<CurrentPage />",
13989 totalPages
13990 ),
13991 {
13992 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13993 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13994 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13995 import_components12.SelectControl,
13996 {
13997 "aria-label": (0, import_i18n22.__)("Current page"),
13998 value: currentPage.toString(),
13999 options: pageSelectOptions,
14000 onChange: (newValue) => {
14001 onChangeView({
14002 ...view,
14003 page: +newValue
14004 });
14005 },
14006 size: "small",
14007 variant: "minimal"
14008 }
14009 )
14010 }
14011 )
14012 }
14013 ),
14014 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
14015 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14016 import_components12.Button,
14017 {
14018 onClick: () => onChangeView({
14019 ...view,
14020 page: currentPage - 1
14021 }),
14022 disabled: currentPage === 1,
14023 accessibleWhenDisabled: true,
14024 label: (0, import_i18n22.__)("Previous page"),
14025 icon: (0, import_i18n22.isRTL)() ? next_default : previous_default,
14026 showTooltip: true,
14027 size: "compact",
14028 tooltipPosition: "top"
14029 }
14030 ),
14031 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14032 import_components12.Button,
14033 {
14034 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
14035 disabled: currentPage >= totalPages,
14036 accessibleWhenDisabled: true,
14037 label: (0, import_i18n22.__)("Next page"),
14038 icon: (0, import_i18n22.isRTL)() ? previous_default : next_default,
14039 showTooltip: true,
14040 size: "compact",
14041 tooltipPosition: "top"
14042 }
14043 )
14044 ] })
14045 ]
14046 }
14047 );
14048 }
14049 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
14050
14051 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
14052 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14053 var EMPTY_ARRAY2 = [];
14054 function useIsMultiselectPicker(actions) {
14055 return (0, import_element37.useMemo)(() => {
14056 return !!actions?.length && actions?.every((action) => action.supportsBulk);
14057 }, [actions]);
14058 }
14059 function BulkSelectionCheckbox2({
14060 selection,
14061 selectedItems,
14062 onChangeSelection,
14063 data,
14064 getItemId,
14065 disableSelectAll = false
14066 }) {
14067 const hasSelection = selection.length > 0;
14068 const areAllSelected = selectedItems.length === data.length;
14069 if (disableSelectAll) {
14070 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14071 import_components13.CheckboxControl,
14072 {
14073 className: "dataviews-view-table-selection-checkbox",
14074 checked: hasSelection,
14075 disabled: !hasSelection,
14076 onChange: () => {
14077 onChangeSelection([]);
14078 },
14079 "aria-label": (0, import_i18n23.__)("Deselect all")
14080 }
14081 );
14082 }
14083 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14084 import_components13.CheckboxControl,
14085 {
14086 className: "dataviews-view-table-selection-checkbox",
14087 checked: areAllSelected,
14088 indeterminate: !areAllSelected && !!selectedItems.length,
14089 onChange: () => {
14090 if (areAllSelected) {
14091 onChangeSelection(
14092 selection.filter(
14093 (id) => !data.some(
14094 (item) => id === getItemId(item)
14095 )
14096 )
14097 );
14098 } else {
14099 const selectionSet = /* @__PURE__ */ new Set([
14100 ...selection,
14101 ...data.map((item) => getItemId(item))
14102 ]);
14103 onChangeSelection(Array.from(selectionSet));
14104 }
14105 },
14106 "aria-label": areAllSelected ? (0, import_i18n23.__)("Deselect all") : (0, import_i18n23.__)("Select all")
14107 }
14108 );
14109 }
14110 function ActionButtons({
14111 actions,
14112 items,
14113 selection
14114 }) {
14115 const registry = (0, import_data6.useRegistry)();
14116 const [actionInProgress, setActionInProgress] = (0, import_element37.useState)(
14117 null
14118 );
14119 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
14120 if (!("callback" in action)) {
14121 return null;
14122 }
14123 const { id, label, icon, isPrimary, callback } = action;
14124 const _label = typeof label === "string" ? label : label(items);
14125 const variant = isPrimary ? "primary" : "tertiary";
14126 const isInProgress = id === actionInProgress;
14127 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14128 import_components13.Button,
14129 {
14130 accessibleWhenDisabled: true,
14131 icon,
14132 disabled: isInProgress || !selection?.length,
14133 isBusy: isInProgress,
14134 onClick: async () => {
14135 setActionInProgress(id);
14136 await callback(items, {
14137 registry
14138 });
14139 setActionInProgress(null);
14140 },
14141 size: "compact",
14142 variant,
14143 children: _label
14144 },
14145 id
14146 );
14147 }) });
14148 }
14149 function PickerBulkSelectionInfo() {
14150 const {
14151 data,
14152 selection,
14153 onChangeSelection,
14154 getItemId,
14155 actions = EMPTY_ARRAY2,
14156 paginationInfo,
14157 view
14158 } = (0, import_element37.useContext)(dataviews_context_default);
14159 const isMultiselect = useIsMultiselectPicker(actions);
14160 const selectedItems = (0, import_element37.useMemo)(
14161 () => data.filter((item) => selection.includes(getItemId(item))),
14162 [selection, getItemId, data]
14163 );
14164 if (!actions.length) {
14165 return null;
14166 }
14167 const message2 = getFooterMessage(
14168 selection.length,
14169 data.length,
14170 paginationInfo.totalItems,
14171 !!view.infiniteScrollEnabled
14172 );
14173 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14174 Stack,
14175 {
14176 direction: "row",
14177 className: "dataviews-picker-footer__bulk-selection",
14178 gap: "md",
14179 align: "center",
14180 children: [
14181 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14182 BulkSelectionCheckbox2,
14183 {
14184 selection,
14185 selectedItems,
14186 onChangeSelection,
14187 data,
14188 getItemId,
14189 disableSelectAll: !!view.infiniteScrollEnabled
14190 }
14191 ),
14192 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
14193 ]
14194 }
14195 );
14196 }
14197 function PickerActions() {
14198 const {
14199 data,
14200 selection,
14201 getItemId,
14202 actions = EMPTY_ARRAY2
14203 } = (0, import_element37.useContext)(dataviews_context_default);
14204 const selectedItems = (0, import_element37.useMemo)(
14205 () => data.filter((item) => selection.includes(getItemId(item))),
14206 [selection, getItemId, data]
14207 );
14208 if (!actions.length) {
14209 return null;
14210 }
14211 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14212 ActionButtons,
14213 {
14214 actions,
14215 items: selectedItems,
14216 selection
14217 }
14218 ) });
14219 }
14220 function DataViewsPickerBulkActionToolbar() {
14221 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "row", gap: "md", align: "center", children: [
14222 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14223 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14224 ] });
14225 }
14226 function DataViewsPickerFooter() {
14227 const {
14228 actions = EMPTY_ARRAY2,
14229 paginationInfo,
14230 view
14231 } = (0, import_element37.useContext)(dataviews_context_default);
14232 const hasPagination = !view.infiniteScrollEnabled && !!paginationInfo.totalItems && paginationInfo.totalPages > 1;
14233 if (!actions.length && !hasPagination) {
14234 return null;
14235 }
14236 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14237 Stack,
14238 {
14239 direction: "row",
14240 justify: "space-between",
14241 align: "center",
14242 className: "dataviews-footer",
14243 gap: "sm",
14244 children: [
14245 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14246 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(dataviews_pagination_default, {}),
14247 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14248 ]
14249 }
14250 );
14251 }
14252
14253 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
14254 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14255 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
14256 function GridItem3({
14257 view,
14258 multiselect,
14259 selection,
14260 onChangeSelection,
14261 getItemId,
14262 item,
14263 mediaField,
14264 titleField,
14265 descriptionField: descriptionField2,
14266 regularFields,
14267 badgeFields,
14268 config,
14269 posinset,
14270 setsize
14271 }) {
14272 const { showTitle = true, showMedia = true, showDescription = true } = view;
14273 const id = getItemId(item);
14274 const elementRef = (0, import_element38.useRef)(null);
14275 const isSelected2 = selection.includes(id);
14276 useIntersectionObserver(elementRef, posinset);
14277 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14278 mediaField.render,
14279 {
14280 item,
14281 field: mediaField,
14282 config
14283 }
14284 ) : null;
14285 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
14286 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14287 import_components14.Composite.Item,
14288 {
14289 ref: elementRef,
14290 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n24.__)("(no title)") : void 0,
14291 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
14292 role: "option",
14293 "aria-posinset": posinset,
14294 "aria-setsize": setsize,
14295 className: clsx_default("dataviews-view-picker-grid__card", {
14296 "is-selected": isSelected2
14297 }),
14298 "aria-selected": isSelected2,
14299 onClick: () => {
14300 if (isSelected2) {
14301 onChangeSelection(
14302 selection.filter((itemId) => id !== itemId)
14303 );
14304 } else {
14305 const newSelection = multiselect ? [...selection, id] : [id];
14306 onChangeSelection(newSelection);
14307 }
14308 },
14309 children: [
14310 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14311 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14312 DataViewsSelectionCheckbox,
14313 {
14314 item,
14315 selection,
14316 onChangeSelection,
14317 getItemId,
14318 titleField,
14319 disabled: false,
14320 "aria-hidden": true,
14321 tabIndex: -1
14322 }
14323 ),
14324 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14325 Stack,
14326 {
14327 direction: "row",
14328 justify: "space-between",
14329 className: "dataviews-view-picker-grid__title-actions",
14330 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14331 }
14332 ),
14333 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14334 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14335 descriptionField2.render,
14336 {
14337 item,
14338 field: descriptionField2
14339 }
14340 ),
14341 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14342 Stack,
14343 {
14344 direction: "row",
14345 className: "dataviews-view-picker-grid__badge-fields",
14346 gap: "sm",
14347 wrap: "wrap",
14348 align: "top",
14349 justify: "flex-start",
14350 children: badgeFields.map((field) => {
14351 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14352 WCBadge2,
14353 {
14354 className: "dataviews-view-picker-grid__field-value",
14355 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14356 field.render,
14357 {
14358 item,
14359 field
14360 }
14361 )
14362 },
14363 field.id
14364 );
14365 })
14366 }
14367 ),
14368 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14369 Stack,
14370 {
14371 direction: "column",
14372 className: "dataviews-view-picker-grid__fields",
14373 gap: "xs",
14374 children: regularFields.map((field) => {
14375 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14376 import_components14.Flex,
14377 {
14378 className: "dataviews-view-picker-grid__field",
14379 gap: 1,
14380 justify: "flex-start",
14381 expanded: true,
14382 style: { height: "auto" },
14383 direction: "row",
14384 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14385 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14386 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14387 import_components14.FlexItem,
14388 {
14389 className: "dataviews-view-picker-grid__field-value",
14390 style: { maxHeight: "none" },
14391 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14392 field.render,
14393 {
14394 item,
14395 field
14396 }
14397 )
14398 }
14399 )
14400 ] })
14401 },
14402 field.id
14403 );
14404 })
14405 }
14406 )
14407 ] })
14408 ]
14409 },
14410 id
14411 );
14412 }
14413 function GridGroup({
14414 groupName,
14415 groupField,
14416 showLabel = true,
14417 children
14418 }) {
14419 const headerId = (0, import_compose6.useInstanceId)(
14420 GridGroup,
14421 "dataviews-view-picker-grid-group__header"
14422 );
14423 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14424 Stack,
14425 {
14426 direction: "column",
14427 gap: "sm",
14428 role: "group",
14429 "aria-labelledby": headerId,
14430 children: [
14431 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14432 "h3",
14433 {
14434 className: "dataviews-view-picker-grid-group__header",
14435 id: headerId,
14436 children: showLabel ? (0, import_i18n24.sprintf)(
14437 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14438 (0, import_i18n24.__)("%1$s: %2$s"),
14439 groupField.label,
14440 groupName
14441 ) : groupName
14442 }
14443 ),
14444 children
14445 ]
14446 },
14447 groupName
14448 );
14449 }
14450 function ViewPickerGrid({
14451 actions,
14452 data,
14453 fields,
14454 getItemId,
14455 isLoading,
14456 onChangeSelection,
14457 selection,
14458 view,
14459 className,
14460 empty
14461 }) {
14462 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
14463 const titleField = fields.find(
14464 (field) => field.id === view?.titleField
14465 );
14466 const mediaField = fields.find(
14467 (field) => field.id === view?.mediaField
14468 );
14469 const descriptionField2 = fields.find(
14470 (field) => field.id === view?.descriptionField
14471 );
14472 const otherFields = view.fields ?? [];
14473 const { regularFields, badgeFields } = otherFields.reduce(
14474 (accumulator, fieldId) => {
14475 const field = fields.find((f2) => f2.id === fieldId);
14476 if (!field) {
14477 return accumulator;
14478 }
14479 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14480 accumulator[key].push(field);
14481 return accumulator;
14482 },
14483 { regularFields: [], badgeFields: [] }
14484 );
14485 const hasData = !!data?.length;
14486 const usedPreviewSize = view.layout?.previewSize;
14487 const isMultiselect = useIsMultiselectPicker(actions);
14488 const size4 = "900px";
14489 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14490 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14491 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14492 const currentPage = view?.page ?? 1;
14493 const perPage = view?.perPage ?? 0;
14494 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14495 const gridColumns = useGridColumns();
14496 const placeholdersNeeded = usePlaceholdersNeeded(
14497 data,
14498 isInfiniteScroll,
14499 gridColumns
14500 );
14501 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14502 // Render multiple groups.
14503 children: [
14504 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14505 import_components14.Composite,
14506 {
14507 virtualFocus: true,
14508 orientation: "horizontal",
14509 role: "listbox",
14510 "aria-multiselectable": isMultiselect,
14511 className: clsx_default(
14512 "dataviews-view-picker-grid",
14513 className,
14514 {
14515 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14516 view.layout.density
14517 )
14518 }
14519 ),
14520 "aria-label": itemListLabel,
14521 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14522 Stack,
14523 {
14524 direction: "column",
14525 gap: "lg",
14526 children,
14527 ...props
14528 }
14529 ),
14530 children: Array.from(dataByGroup.entries()).map(
14531 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14532 GridGroup,
14533 {
14534 groupName,
14535 groupField,
14536 showLabel: view.groupBy?.showLabel !== false,
14537 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14538 GridItems,
14539 {
14540 previewSize: usedPreviewSize,
14541 style: {
14542 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14543 },
14544 "aria-busy": isLoading,
14545 ref: resizeObserverRef,
14546 children: groupItems.map((item) => {
14547 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14548 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14549 GridItem3,
14550 {
14551 view,
14552 multiselect: isMultiselect,
14553 selection,
14554 onChangeSelection,
14555 getItemId,
14556 item,
14557 mediaField,
14558 titleField,
14559 descriptionField: descriptionField2,
14560 regularFields,
14561 badgeFields,
14562 config: {
14563 sizes: size4
14564 },
14565 posinset: posInSet,
14566 setsize: setSize
14567 },
14568 getItemId(item)
14569 );
14570 })
14571 }
14572 )
14573 },
14574 groupName
14575 )
14576 )
14577 }
14578 ),
14579 // Render a single grid with all data.
14580 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14581 import_components14.Composite,
14582 {
14583 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14584 GridItems,
14585 {
14586 className: clsx_default(
14587 "dataviews-view-picker-grid",
14588 className,
14589 {
14590 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14591 "compact",
14592 "comfortable"
14593 ].includes(view.layout.density)
14594 }
14595 ),
14596 previewSize: usedPreviewSize,
14597 "aria-busy": isLoading,
14598 ref: resizeObserverRef
14599 }
14600 ),
14601 virtualFocus: true,
14602 orientation: "horizontal",
14603 role: "listbox",
14604 "aria-multiselectable": isMultiselect,
14605 "aria-label": itemListLabel,
14606 children: [
14607 Array.from({ length: placeholdersNeeded }).map(
14608 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14609 import_components14.Composite.Item,
14610 {
14611 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14612 Stack,
14613 {
14614 direction: "column",
14615 children,
14616 ...props
14617 }
14618 ),
14619 role: "option",
14620 "aria-hidden": true,
14621 tabIndex: -1,
14622 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14623 },
14624 `placeholder-${index2}`
14625 )
14626 ),
14627 data.map((item) => {
14628 const posinset = item.position;
14629 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14630 GridItem3,
14631 {
14632 view,
14633 multiselect: isMultiselect,
14634 selection,
14635 onChangeSelection,
14636 getItemId,
14637 item,
14638 mediaField,
14639 titleField,
14640 descriptionField: descriptionField2,
14641 regularFields,
14642 badgeFields,
14643 config: {
14644 sizes: size4
14645 },
14646 posinset,
14647 setsize: setSize
14648 },
14649 getItemId(item)
14650 );
14651 })
14652 ]
14653 }
14654 ),
14655 // Render empty state.
14656 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14657 "div",
14658 {
14659 className: clsx_default({
14660 "dataviews-loading": isLoading,
14661 "dataviews-no-results": !isLoading
14662 }),
14663 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14664 }
14665 ),
14666 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14667 ]
14668 });
14669 }
14670 var picker_grid_default = ViewPickerGrid;
14671
14672 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14673 var import_i18n25 = __toESM(require_i18n(), 1);
14674 var import_components15 = __toESM(require_components(), 1);
14675 var import_element39 = __toESM(require_element(), 1);
14676 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14677 function TableColumnField2({
14678 item,
14679 fields,
14680 column,
14681 align
14682 }) {
14683 const field = fields.find((f2) => f2.id === column);
14684 if (!field) {
14685 return null;
14686 }
14687 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14688 "dataviews-view-table__cell-align-end": align === "end",
14689 "dataviews-view-table__cell-align-center": align === "center"
14690 });
14691 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14692 }
14693 function TableRow2({
14694 item,
14695 fields,
14696 id,
14697 view,
14698 titleField,
14699 mediaField,
14700 descriptionField: descriptionField2,
14701 selection,
14702 getItemId,
14703 onChangeSelection,
14704 multiselect,
14705 posinset
14706 }) {
14707 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14708 const isSelected2 = selection.includes(id);
14709 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
14710 const elementRef = (0, import_element39.useRef)(null);
14711 useIntersectionObserver(elementRef, posinset);
14712 const {
14713 showTitle = true,
14714 showMedia = true,
14715 showDescription = true,
14716 infiniteScrollEnabled
14717 } = view;
14718 const handleMouseEnter = () => {
14719 setIsHovered(true);
14720 };
14721 const handleMouseLeave = () => {
14722 setIsHovered(false);
14723 };
14724 const columns = view.fields ?? [];
14725 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14726 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14727 import_components15.Composite.Item,
14728 {
14729 ref: elementRef,
14730 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14731 "tr",
14732 {
14733 className: clsx_default("dataviews-view-table__row", {
14734 "is-selected": isSelected2,
14735 "is-hovered": isHovered
14736 }),
14737 onMouseEnter: handleMouseEnter,
14738 onMouseLeave: handleMouseLeave,
14739 children,
14740 ...props
14741 }
14742 ),
14743 "aria-selected": isSelected2,
14744 "aria-setsize": paginationInfo.totalItems || void 0,
14745 "aria-posinset": posinset,
14746 role: infiniteScrollEnabled ? "article" : "option",
14747 onMouseDown: (event) => {
14748 if (event.button !== 0) {
14749 return;
14750 }
14751 event.currentTarget.parentElement?.focus({
14752 preventScroll: true
14753 });
14754 },
14755 onClick: () => {
14756 if (isSelected2) {
14757 onChangeSelection(
14758 selection.filter((itemId) => id !== itemId)
14759 );
14760 } else {
14761 const newSelection = multiselect ? [...selection, id] : [id];
14762 onChangeSelection(newSelection);
14763 }
14764 },
14765 children: [
14766 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14767 "td",
14768 {
14769 className: "dataviews-view-table__checkbox-column",
14770 role: "presentation",
14771 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14772 DataViewsSelectionCheckbox,
14773 {
14774 item,
14775 selection,
14776 onChangeSelection,
14777 getItemId,
14778 titleField,
14779 disabled: false,
14780 "aria-hidden": true,
14781 tabIndex: -1
14782 }
14783 ) })
14784 }
14785 ),
14786 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14787 "td",
14788 {
14789 role: "presentation",
14790 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14791 column_primary_default,
14792 {
14793 item,
14794 titleField: showTitle ? titleField : void 0,
14795 mediaField: showMedia ? mediaField : void 0,
14796 descriptionField: showDescription ? descriptionField2 : void 0,
14797 isItemClickable: () => false
14798 }
14799 )
14800 }
14801 ),
14802 columns.map((column) => {
14803 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14804 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14805 "td",
14806 {
14807 style: {
14808 width,
14809 maxWidth,
14810 minWidth
14811 },
14812 role: "presentation",
14813 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14814 TableColumnField2,
14815 {
14816 fields,
14817 item,
14818 column,
14819 align
14820 }
14821 )
14822 },
14823 column
14824 );
14825 })
14826 ]
14827 },
14828 id
14829 );
14830 }
14831 function ViewPickerTable({
14832 actions,
14833 data,
14834 fields,
14835 getItemId,
14836 isLoading = false,
14837 onChangeView,
14838 onChangeSelection,
14839 selection,
14840 setOpenedFilter,
14841 view,
14842 className,
14843 empty
14844 }) {
14845 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
14846 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
14847 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
14848 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14849 (0, import_element39.useEffect)(() => {
14850 if (headerMenuToFocusRef.current) {
14851 headerMenuToFocusRef.current.focus();
14852 headerMenuToFocusRef.current = void 0;
14853 }
14854 });
14855 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14856 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14857 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14858 const tableNoticeId = (0, import_element39.useId)();
14859 if (nextHeaderMenuToFocus) {
14860 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14861 setNextHeaderMenuToFocus(void 0);
14862 return;
14863 }
14864 const onHide = (field) => {
14865 const hidden = headerMenuRefs.current.get(field.id);
14866 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14867 setNextHeaderMenuToFocus(fallback?.node);
14868 };
14869 const hasData = !!data?.length;
14870 const titleField = fields.find((field) => field.id === view.titleField);
14871 const mediaField = fields.find((field) => field.id === view.mediaField);
14872 const descriptionField2 = fields.find(
14873 (field) => field.id === view.descriptionField
14874 );
14875 const { showTitle = true, showMedia = true, showDescription = true } = view;
14876 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14877 const columns = view.fields ?? [];
14878 const headerMenuRef = (column, index2) => (node) => {
14879 if (node) {
14880 headerMenuRefs.current.set(column, {
14881 node,
14882 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14883 });
14884 } else {
14885 headerMenuRefs.current.delete(column);
14886 }
14887 };
14888 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14889 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14890 "table",
14891 {
14892 className: clsx_default(
14893 "dataviews-view-table",
14894 "dataviews-view-picker-table",
14895 className,
14896 {
14897 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14898 view.layout.density
14899 )
14900 }
14901 ),
14902 "aria-busy": isLoading,
14903 "aria-describedby": tableNoticeId,
14904 role: isInfiniteScroll ? "feed" : "listbox",
14905 children: [
14906 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14907 "tr",
14908 {
14909 className: "dataviews-view-table__row",
14910 role: "presentation",
14911 children: [
14912 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14913 BulkSelectionCheckbox,
14914 {
14915 selection,
14916 onChangeSelection,
14917 data,
14918 actions,
14919 getItemId,
14920 disableSelectAll: isInfiniteScroll
14921 }
14922 ) }),
14923 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14924 column_header_menu_default,
14925 {
14926 ref: headerMenuRef(
14927 titleField.id,
14928 0
14929 ),
14930 fieldId: titleField.id,
14931 view,
14932 fields,
14933 onChangeView,
14934 onHide,
14935 setOpenedFilter,
14936 canMove: false
14937 }
14938 ) }),
14939 columns.map((column, index2) => {
14940 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14941 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14942 "th",
14943 {
14944 style: {
14945 width,
14946 maxWidth,
14947 minWidth,
14948 textAlign: align
14949 },
14950 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14951 scope: "col",
14952 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14953 column_header_menu_default,
14954 {
14955 ref: headerMenuRef(column, index2),
14956 fieldId: column,
14957 view,
14958 fields,
14959 onChangeView,
14960 onHide,
14961 setOpenedFilter,
14962 canMove: view.layout?.enableMoving ?? true
14963 }
14964 )
14965 },
14966 column
14967 );
14968 })
14969 ]
14970 }
14971 ) }),
14972 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14973 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14974 import_components15.Composite,
14975 {
14976 virtualFocus: true,
14977 orientation: "vertical",
14978 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14979 children: [
14980 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14981 "tr",
14982 {
14983 className: "dataviews-view-table__group-header-row",
14984 role: "presentation",
14985 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14986 "td",
14987 {
14988 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14989 className: "dataviews-view-table__group-header-cell",
14990 role: "presentation",
14991 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n25.sprintf)(
14992 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14993 (0, import_i18n25.__)("%1$s: %2$s"),
14994 groupField.label,
14995 groupName
14996 )
14997 }
14998 )
14999 }
15000 ),
15001 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15002 TableRow2,
15003 {
15004 item,
15005 fields,
15006 id: getItemId(item) || index2.toString(),
15007 view,
15008 titleField,
15009 mediaField,
15010 descriptionField: descriptionField2,
15011 selection,
15012 getItemId,
15013 onChangeSelection,
15014 multiselect: isMultiselect
15015 },
15016 getItemId(item)
15017 ))
15018 ]
15019 },
15020 `group-${groupName}`
15021 )
15022 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15023 import_components15.Composite,
15024 {
15025 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
15026 virtualFocus: true,
15027 orientation: "vertical",
15028 children: hasData && data.map((item, index2) => {
15029 const itemId = getItemId(item);
15030 const posinset = item.position;
15031 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15032 TableRow2,
15033 {
15034 item,
15035 fields,
15036 id: itemId || index2.toString(),
15037 view,
15038 titleField,
15039 mediaField,
15040 descriptionField: descriptionField2,
15041 selection,
15042 getItemId,
15043 onChangeSelection,
15044 multiselect: isMultiselect,
15045 posinset
15046 },
15047 itemId
15048 );
15049 })
15050 }
15051 )
15052 ]
15053 }
15054 ),
15055 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
15056 "div",
15057 {
15058 className: clsx_default({
15059 "dataviews-loading": isLoading,
15060 "dataviews-no-results": !hasData && !isLoading
15061 }),
15062 id: tableNoticeId,
15063 children: [
15064 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
15065 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
15066 ]
15067 }
15068 )
15069 ] });
15070 }
15071 var picker_table_default = ViewPickerTable;
15072
15073 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
15074 var import_components16 = __toESM(require_components(), 1);
15075 var import_element40 = __toESM(require_element(), 1);
15076 var import_compose7 = __toESM(require_compose(), 1);
15077 var import_i18n26 = __toESM(require_i18n(), 1);
15078 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15079 function isDefined4(item) {
15080 return !!item;
15081 }
15082 function PickerActivityItem({
15083 view,
15084 multiselect,
15085 selection,
15086 onChangeSelection,
15087 getItemId,
15088 item,
15089 titleField,
15090 mediaField,
15091 descriptionField: descriptionField2,
15092 otherFields,
15093 posinset,
15094 setsize
15095 }) {
15096 const elementRef = (0, import_element40.useRef)(null);
15097 useIntersectionObserver(elementRef, posinset);
15098 const { showTitle = true, showMedia = true, showDescription = true } = view;
15099 const id = getItemId(item);
15100 const isSelected2 = selection.includes(id);
15101 const density = view.layout?.density ?? "balanced";
15102 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15103 mediaField.render,
15104 {
15105 item,
15106 field: mediaField,
15107 config: {
15108 sizes: density === "comfortable" ? "32px" : "24px"
15109 }
15110 }
15111 ) : null;
15112 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)(
15113 "span",
15114 {
15115 className: "dataviews-view-picker-activity__item-bullet",
15116 "aria-hidden": "true"
15117 }
15118 ) });
15119 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
15120 const renderedDescriptionField = showDescription && descriptionField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField2.render, { item, field: descriptionField2 }) : null;
15121 const verticalGap = (0, import_element40.useMemo)(() => {
15122 switch (density) {
15123 case "comfortable":
15124 return "md";
15125 default:
15126 return "sm";
15127 }
15128 }, [density]);
15129 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15130 import_components16.Composite.Item,
15131 {
15132 ref: elementRef,
15133 role: "option",
15134 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
15135 "aria-posinset": posinset,
15136 "aria-setsize": setsize,
15137 "aria-selected": isSelected2,
15138 className: clsx_default(
15139 "dataviews-view-picker-activity__item",
15140 density === "compact" && "is-compact",
15141 density === "balanced" && "is-balanced",
15142 density === "comfortable" && "is-comfortable",
15143 isSelected2 && "is-selected"
15144 ),
15145 onClick: () => {
15146 if (isSelected2) {
15147 onChangeSelection(
15148 selection.filter((itemId) => id !== itemId)
15149 );
15150 } else {
15151 const newSelection = multiselect ? [...selection, id] : [id];
15152 onChangeSelection(newSelection);
15153 }
15154 },
15155 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
15156 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15157 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15158 Stack,
15159 {
15160 direction: "column",
15161 gap: "xs",
15162 align: "center",
15163 className: "dataviews-view-picker-activity__item-type",
15164 children: renderedMediaField
15165 }
15166 ),
15167 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15168 Stack,
15169 {
15170 direction: "column",
15171 gap: verticalGap,
15172 align: "flex-start",
15173 className: "dataviews-view-picker-activity__item-content",
15174 children: [
15175 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
15176 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
15177 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15178 "div",
15179 {
15180 className: "dataviews-view-picker-activity__item-field",
15181 children: [
15182 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15183 VisuallyHidden,
15184 {
15185 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
15186 className: "dataviews-view-picker-activity__item-field-label",
15187 children: field.label
15188 }
15189 ),
15190 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15191 field.render,
15192 {
15193 item,
15194 field
15195 }
15196 ) })
15197 ]
15198 },
15199 field.id
15200 )) })
15201 ]
15202 }
15203 )
15204 ] })
15205 }
15206 );
15207 }
15208 function PickerActivityGroup({
15209 groupName,
15210 groupField,
15211 showLabel = true,
15212 children
15213 }) {
15214 const headerId = (0, import_compose7.useInstanceId)(
15215 PickerActivityGroup,
15216 "dataviews-view-picker-activity-group__header"
15217 );
15218 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15219 Stack,
15220 {
15221 direction: "column",
15222 role: "group",
15223 "aria-labelledby": headerId,
15224 className: "dataviews-view-picker-activity-group",
15225 children: [
15226 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15227 "h3",
15228 {
15229 className: "dataviews-view-picker-activity-group__header",
15230 id: headerId,
15231 children: showLabel ? (0, import_i18n26.sprintf)(
15232 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15233 (0, import_i18n26.__)("%1$s: %2$s"),
15234 groupField.label,
15235 groupName
15236 ) : groupName
15237 }
15238 ),
15239 children
15240 ]
15241 }
15242 );
15243 }
15244 function ViewPickerActivity({
15245 data,
15246 fields,
15247 getItemId,
15248 isLoading,
15249 onChangeSelection,
15250 selection,
15251 view,
15252 actions,
15253 className,
15254 empty
15255 }) {
15256 const { itemListLabel, paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
15257 const isMultiselect = useIsMultiselectPicker(actions);
15258 const titleField = fields.find(
15259 (field) => field.id === view?.titleField
15260 );
15261 const mediaField = fields.find(
15262 (field) => field.id === view?.mediaField
15263 );
15264 const descriptionField2 = fields.find(
15265 (field) => field.id === view?.descriptionField
15266 );
15267 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
15268 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15269 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15270 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15271 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15272 const hasData = !!data?.length;
15273 const isGrouped = !!(groupField && dataByGroup);
15274 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15275 PickerActivityItem,
15276 {
15277 view,
15278 multiselect: isMultiselect,
15279 selection,
15280 onChangeSelection,
15281 getItemId,
15282 item,
15283 titleField,
15284 mediaField,
15285 descriptionField: descriptionField2,
15286 otherFields,
15287 posinset: item.position,
15288 setsize
15289 },
15290 getItemId(item)
15291 );
15292 if (!hasData) {
15293 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15294 "div",
15295 {
15296 className: clsx_default({
15297 "dataviews-loading": isLoading,
15298 "dataviews-no-results": !isLoading
15299 }),
15300 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
15301 }
15302 );
15303 }
15304 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
15305 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15306 import_components16.Composite,
15307 {
15308 virtualFocus: true,
15309 orientation: "vertical",
15310 role: "listbox",
15311 "aria-multiselectable": isMultiselect,
15312 "aria-label": itemListLabel,
15313 "aria-busy": isLoading,
15314 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15315 className: clsx_default(
15316 "dataviews-view-picker-activity",
15317 className
15318 ),
15319 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15320 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15321 PickerActivityGroup,
15322 {
15323 groupName,
15324 groupField,
15325 showLabel: view.groupBy?.showLabel !== false,
15326 children: groupItems.map(renderItem)
15327 },
15328 groupName
15329 )
15330 ) : data.map(renderItem)
15331 }
15332 ),
15333 isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15334 ] });
15335 }
15336
15337 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15338 var import_components17 = __toESM(require_components(), 1);
15339 var import_i18n27 = __toESM(require_i18n(), 1);
15340 var import_element41 = __toESM(require_element(), 1);
15341 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15342 function DensityPicker() {
15343 const context = (0, import_element41.useContext)(dataviews_context_default);
15344 const view = context.view;
15345 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15346 import_components17.__experimentalToggleGroupControl,
15347 {
15348 label: (0, import_i18n27.__)("Density"),
15349 value: view.layout?.density || "balanced",
15350 onChange: (value) => {
15351 context.onChangeView({
15352 ...view,
15353 layout: {
15354 ...view.layout,
15355 density: value
15356 }
15357 });
15358 },
15359 isBlock: true,
15360 children: [
15361 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15362 import_components17.__experimentalToggleGroupControlOption,
15363 {
15364 value: "comfortable",
15365 label: (0, import_i18n27._x)(
15366 "Comfortable",
15367 "Density option for DataView layout"
15368 )
15369 },
15370 "comfortable"
15371 ),
15372 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15373 import_components17.__experimentalToggleGroupControlOption,
15374 {
15375 value: "balanced",
15376 label: (0, import_i18n27._x)("Balanced", "Density option for DataView layout")
15377 },
15378 "balanced"
15379 ),
15380 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15381 import_components17.__experimentalToggleGroupControlOption,
15382 {
15383 value: "compact",
15384 label: (0, import_i18n27._x)("Compact", "Density option for DataView layout")
15385 },
15386 "compact"
15387 )
15388 ]
15389 }
15390 );
15391 }
15392
15393 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15394 var import_components18 = __toESM(require_components(), 1);
15395 var import_i18n28 = __toESM(require_i18n(), 1);
15396 var import_element42 = __toESM(require_element(), 1);
15397 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15398 var imageSizes2 = [
15399 {
15400 value: 120,
15401 breakpoint: 1
15402 },
15403 {
15404 value: 170,
15405 breakpoint: 1
15406 },
15407 {
15408 value: 230,
15409 breakpoint: 1
15410 },
15411 {
15412 value: 290,
15413 breakpoint: 1112
15414 // at minimum image width, 4 images display at this container size
15415 },
15416 {
15417 value: 350,
15418 breakpoint: 1636
15419 // at minimum image width, 6 images display at this container size
15420 },
15421 {
15422 value: 430,
15423 breakpoint: 588
15424 // at minimum image width, 2 images display at this container size
15425 }
15426 ];
15427 function PreviewSizePicker() {
15428 const context = (0, import_element42.useContext)(dataviews_context_default);
15429 const view = context.view;
15430 const breakValues = imageSizes2.filter((size4) => {
15431 return context.containerWidth >= size4.breakpoint;
15432 });
15433 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15434 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15435 const marks = breakValues.map((size4, index2) => {
15436 return {
15437 value: index2
15438 };
15439 });
15440 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15441 import_components18.RangeControl,
15442 {
15443 showTooltip: false,
15444 label: (0, import_i18n28.__)("Preview size"),
15445 value: previewSizeToUse,
15446 min: 0,
15447 max: breakValues.length - 1,
15448 withInputField: false,
15449 onChange: (value = 0) => {
15450 context.onChangeView({
15451 ...view,
15452 layout: {
15453 ...view.layout,
15454 previewSize: breakValues[value].value
15455 }
15456 });
15457 },
15458 step: 1,
15459 marks
15460 }
15461 );
15462 }
15463
15464 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15465 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15466 function GridConfigOptions() {
15467 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15468 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15469 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15470 ] });
15471 }
15472
15473 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15474 var VIEW_LAYOUTS = [
15475 {
15476 type: LAYOUT_TABLE,
15477 label: (0, import_i18n29.__)("Table"),
15478 component: table_default,
15479 icon: block_table_default,
15480 viewConfigOptions: DensityPicker
15481 },
15482 {
15483 type: LAYOUT_GRID,
15484 label: (0, import_i18n29.__)("Grid"),
15485 component: grid_default,
15486 icon: category_default,
15487 viewConfigOptions: GridConfigOptions
15488 },
15489 {
15490 type: LAYOUT_LIST,
15491 label: (0, import_i18n29.__)("List"),
15492 component: ViewList,
15493 icon: (0, import_i18n29.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15494 viewConfigOptions: DensityPicker
15495 },
15496 {
15497 type: LAYOUT_ACTIVITY,
15498 label: (0, import_i18n29.__)("Activity"),
15499 component: ViewActivity,
15500 icon: scheduled_default,
15501 viewConfigOptions: DensityPicker
15502 },
15503 {
15504 type: LAYOUT_PICKER_GRID,
15505 label: (0, import_i18n29.__)("Grid"),
15506 component: picker_grid_default,
15507 icon: category_default,
15508 viewConfigOptions: GridConfigOptions,
15509 isPicker: true
15510 },
15511 {
15512 type: LAYOUT_PICKER_TABLE,
15513 label: (0, import_i18n29.__)("Table"),
15514 component: picker_table_default,
15515 icon: block_table_default,
15516 viewConfigOptions: DensityPicker,
15517 isPicker: true
15518 },
15519 {
15520 type: LAYOUT_PICKER_ACTIVITY,
15521 label: (0, import_i18n29.__)("Activity"),
15522 component: ViewPickerActivity,
15523 icon: scheduled_default,
15524 viewConfigOptions: DensityPicker,
15525 isPicker: true
15526 }
15527 ];
15528
15529 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15530 var import_element50 = __toESM(require_element(), 1);
15531
15532 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15533 var import_components21 = __toESM(require_components(), 1);
15534 var import_i18n32 = __toESM(require_i18n(), 1);
15535 var import_element47 = __toESM(require_element(), 1);
15536
15537 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15538 var import_react7 = __toESM(require_react(), 1);
15539 var FocusableContext = (0, import_react7.createContext)(true);
15540
15541 // node_modules/@ariakit/utils/dist/index.js
15542 function toArray(arg) {
15543 if (Array.isArray(arg)) return arg;
15544 return typeof arg !== "undefined" ? [arg] : [];
15545 }
15546 function flatten2DArray(array) {
15547 const flattened = [];
15548 for (const row of array) flattened.push(...row);
15549 return flattened;
15550 }
15551 function reverseArray(array) {
15552 return array.slice().reverse();
15553 }
15554 function noop5(..._) {
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 afterPaint(cb = noop5) {
15582 let raf = requestAnimationFrame(() => {
15583 raf = requestAnimationFrame(cb);
15584 });
15585 return () => cancelAnimationFrame(raf);
15586 }
15587 function invariant(condition, message2) {
15588 if (condition) return;
15589 if (typeof message2 !== "string") throw new Error("Invariant failed");
15590 throw new Error(message2);
15591 }
15592 function getKeys(obj) {
15593 return Object.keys(obj);
15594 }
15595 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15596 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15597 if (result == null) return false;
15598 return !result;
15599 }
15600 function disabledFromProps(props) {
15601 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15602 }
15603 function removeUndefinedValues(obj) {
15604 const result = {};
15605 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15606 return result;
15607 }
15608 function defaultValue(...values) {
15609 for (const value of values) if (value !== void 0) return value;
15610 }
15611 var canUseDOM = checkIsBrowser();
15612 function checkIsBrowser() {
15613 return typeof window !== "undefined" && !!window.document?.createElement;
15614 }
15615 function getDocument(node) {
15616 if (!node) return document;
15617 if ("self" in node) return node.document;
15618 return node.ownerDocument || document;
15619 }
15620 function getActiveElement(node, activeDescendant = false) {
15621 const { activeElement: activeElement2 } = getDocument(node);
15622 if (!activeElement2?.nodeName) return null;
15623 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15624 if (activeDescendant) {
15625 const id = activeElement2.getAttribute("aria-activedescendant");
15626 if (id) {
15627 const element = getDocument(activeElement2).getElementById(id);
15628 if (element) return element;
15629 }
15630 }
15631 return activeElement2;
15632 }
15633 function contains2(parent, child) {
15634 return parent === child || parent.contains(child);
15635 }
15636 function isElement2(target) {
15637 return target?.nodeType === 1;
15638 }
15639 function isNode2(target) {
15640 return typeof target?.nodeType === "number";
15641 }
15642 function isFrame(element) {
15643 return element.tagName === "IFRAME";
15644 }
15645 function isButton(element) {
15646 const tagName = element.tagName.toLowerCase();
15647 if (tagName === "button") return true;
15648 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15649 return false;
15650 }
15651 var buttonInputTypes = [
15652 "button",
15653 "color",
15654 "file",
15655 "image",
15656 "reset",
15657 "submit"
15658 ];
15659 function isVisible(element) {
15660 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15661 const htmlElement = element;
15662 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15663 }
15664 function isTextField(element) {
15665 try {
15666 if (element.tagName === "TEXTAREA") return true;
15667 if (element.tagName !== "INPUT") return false;
15668 return element.selectionStart !== null;
15669 } catch (_error) {
15670 return false;
15671 }
15672 }
15673 function isTextbox(element) {
15674 return element.isContentEditable || isTextField(element);
15675 }
15676 function getTextboxValue(element) {
15677 if (isTextField(element)) return element.value;
15678 if (element.isContentEditable) {
15679 const range = getDocument(element).createRange();
15680 range.selectNodeContents(element);
15681 return range.toString();
15682 }
15683 return "";
15684 }
15685 function getTextboxSelection(element) {
15686 let start = 0;
15687 let end = 0;
15688 if (isTextField(element)) {
15689 start = element.selectionStart || 0;
15690 end = element.selectionEnd || 0;
15691 } else if (element.isContentEditable) {
15692 const selection = getDocument(element).getSelection();
15693 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15694 const range = selection.getRangeAt(0);
15695 const nextRange = range.cloneRange();
15696 nextRange.selectNodeContents(element);
15697 nextRange.setEnd(range.startContainer, range.startOffset);
15698 start = nextRange.toString().length;
15699 nextRange.setEnd(range.endContainer, range.endOffset);
15700 end = nextRange.toString().length;
15701 }
15702 }
15703 return {
15704 start,
15705 end
15706 };
15707 }
15708 var allowedPopupRoles = [
15709 "dialog",
15710 "menu",
15711 "listbox",
15712 "tree",
15713 "grid"
15714 ];
15715 var itemRoleByPopupRole = {
15716 menu: "menuitem",
15717 listbox: "option",
15718 tree: "treeitem"
15719 };
15720 function getPopupRole(element, fallback) {
15721 const role = element?.getAttribute("role");
15722 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15723 return fallback;
15724 }
15725 function getItemRoleByPopupRole(popupRole) {
15726 if (popupRole == null) return;
15727 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15728 return itemRoleByPopupRole[popupRole];
15729 }
15730 function getScrollingElement(element) {
15731 if (!element) return null;
15732 const isScrollableOverflow = (overflow) => {
15733 if (overflow === "auto") return true;
15734 if (overflow === "scroll") return true;
15735 return false;
15736 };
15737 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15738 const { overflowY } = getComputedStyle(element);
15739 if (isScrollableOverflow(overflowY)) return element;
15740 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15741 const { overflowX } = getComputedStyle(element);
15742 if (isScrollableOverflow(overflowX)) return element;
15743 }
15744 const doc = getDocument(element);
15745 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15746 }
15747 function setSelectionRange(element, ...args) {
15748 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15749 }
15750 function sortBasedOnDOMPosition(items, getElement) {
15751 const pairs = items.map((item, index2) => [index2, item]);
15752 let isOrderDifferent = false;
15753 pairs.sort(([indexA, a2], [indexB, b2]) => {
15754 const elementA = getElement(a2);
15755 const elementB = getElement(b2);
15756 if (elementA === elementB) return 0;
15757 if (!elementA || !elementB) return 0;
15758 if (isElementPreceding(elementA, elementB)) {
15759 if (indexA > indexB) isOrderDifferent = true;
15760 return -1;
15761 }
15762 if (indexA < indexB) isOrderDifferent = true;
15763 return 1;
15764 });
15765 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15766 return items;
15767 }
15768 function isElementPreceding(a2, b2) {
15769 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15770 }
15771 function isTouchDevice() {
15772 return canUseDOM && !!navigator.maxTouchPoints;
15773 }
15774 function isApple() {
15775 if (!canUseDOM) return false;
15776 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15777 }
15778 function isSafari() {
15779 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15780 }
15781 function isFirefox() {
15782 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15783 }
15784 function isPortalEvent(event) {
15785 const { currentTarget, target } = event;
15786 if (!currentTarget) return false;
15787 if (!isNode2(target)) return true;
15788 return !contains2(currentTarget, target);
15789 }
15790 function isSelfTarget(event) {
15791 return event.target === event.currentTarget;
15792 }
15793 function isActivatableNavigationTarget(element) {
15794 if (!isElement2(element)) return false;
15795 const target = element;
15796 const tagName = target.tagName.toLowerCase();
15797 if (tagName === "a") return true;
15798 if (tagName === "button" && target.type === "submit") return true;
15799 if (tagName === "input" && target.type === "submit") return true;
15800 return false;
15801 }
15802 function isOpeningInNewTab(event) {
15803 const isAppleDevice = isApple();
15804 if (isAppleDevice && !event.metaKey) return false;
15805 if (!isAppleDevice && !event.ctrlKey) return false;
15806 return isActivatableNavigationTarget(event.currentTarget);
15807 }
15808 function isDownloading(event) {
15809 if (!event.altKey) return false;
15810 return isActivatableNavigationTarget(event.currentTarget);
15811 }
15812 function fireBlurEvent(element, eventInit) {
15813 const event = new FocusEvent("blur", eventInit);
15814 const defaultAllowed = element.dispatchEvent(event);
15815 const bubbleInit = {
15816 ...eventInit,
15817 bubbles: true
15818 };
15819 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15820 return defaultAllowed;
15821 }
15822 function fireKeyboardEvent(element, type, eventInit) {
15823 const event = new KeyboardEvent(type, eventInit);
15824 return element.dispatchEvent(event);
15825 }
15826 function fireClickEvent(element, eventInit) {
15827 const event = new MouseEvent("click", eventInit);
15828 return element.dispatchEvent(event);
15829 }
15830 function isFocusEventOutside(event, container) {
15831 const containerElement = container || event.currentTarget;
15832 const relatedTarget = event.relatedTarget;
15833 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15834 }
15835 function isInputEvent(event) {
15836 return event.type === "input";
15837 }
15838 function queueBeforeEvent(element, type, callback, timeout) {
15839 const createTimer = (callback2) => {
15840 if (timeout) {
15841 const timerId2 = setTimeout(callback2, timeout);
15842 return () => clearTimeout(timerId2);
15843 }
15844 const timerId = requestAnimationFrame(callback2);
15845 return () => cancelAnimationFrame(timerId);
15846 };
15847 const cancelTimer = createTimer(() => {
15848 element.removeEventListener(type, callSync, true);
15849 callback();
15850 });
15851 const callSync = () => {
15852 cancelTimer();
15853 callback();
15854 };
15855 element.addEventListener(type, callSync, {
15856 once: true,
15857 capture: true
15858 });
15859 return () => {
15860 cancelTimer();
15861 element.removeEventListener(type, callSync, true);
15862 };
15863 }
15864 function addGlobalEventListener(type, listener, options, scope = window) {
15865 const children = [];
15866 try {
15867 scope.document.addEventListener(type, listener, options);
15868 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15869 } catch {
15870 }
15871 const removeEventListener = () => {
15872 try {
15873 scope.document.removeEventListener(type, listener, options);
15874 } catch {
15875 }
15876 for (const remove of children) remove();
15877 };
15878 return removeEventListener;
15879 }
15880 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'])";
15881 function isFocusable(element) {
15882 if (!element.matches(selector)) return false;
15883 if (!isVisible(element)) return false;
15884 if (element.closest("[inert]")) return false;
15885 return true;
15886 }
15887 function hasFocus(element) {
15888 const activeElement2 = getActiveElement(element);
15889 if (!activeElement2) return false;
15890 if (activeElement2 === element) return true;
15891 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15892 if (!activeDescendant) return false;
15893 return activeDescendant === element.id;
15894 }
15895 function hasFocusWithin(element) {
15896 const activeElement2 = getActiveElement(element);
15897 if (!activeElement2) return false;
15898 if (contains2(element, activeElement2)) return true;
15899 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15900 if (!activeDescendant) return false;
15901 if (!("id" in element)) return false;
15902 if (activeDescendant === element.id) return true;
15903 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15904 }
15905 function focusIntoView(element, options) {
15906 if (!("scrollIntoView" in element)) element.focus();
15907 else {
15908 element.focus({ preventScroll: true });
15909 element.scrollIntoView({
15910 block: "nearest",
15911 inline: "nearest",
15912 ...options
15913 });
15914 }
15915 }
15916 function createUndoCallback(callback) {
15917 return async () => {
15918 const redo = await callback?.();
15919 return createUndoCallback(async () => {
15920 await redo?.();
15921 return callback;
15922 });
15923 };
15924 }
15925 var UndoManager = createUndoManager();
15926 function createUndoManager({ limit = 100 } = {}) {
15927 const undoStack = [];
15928 let redoStack = [];
15929 let currentGroup = null;
15930 const canUndo = () => undoStack.length > 0;
15931 const canRedo = () => redoStack.length > 0;
15932 const undo = async () => {
15933 if (!canUndo()) return;
15934 currentGroup = null;
15935 redoStack.push(await undoStack.pop()?.());
15936 };
15937 const redo = async () => {
15938 if (!canRedo()) return;
15939 currentGroup = null;
15940 undoStack.push(await redoStack.pop()?.());
15941 };
15942 const execute = async (callback, group) => {
15943 if (!callback) return;
15944 const sameGroup = group === currentGroup;
15945 currentGroup = group ?? null;
15946 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15947 const undoCallback = await callback();
15948 if (!undoCallback) return;
15949 redoStack = [];
15950 const currentUndo = undoStack[nextIndex];
15951 undoStack[nextIndex] = createUndoCallback(async () => {
15952 await undoCallback?.();
15953 const currentRedo = await currentUndo?.();
15954 return async () => {
15955 await currentRedo?.();
15956 await callback?.();
15957 };
15958 });
15959 while (undoStack.length > limit) undoStack.shift();
15960 };
15961 return {
15962 canUndo,
15963 canRedo,
15964 undo,
15965 redo,
15966 execute
15967 };
15968 }
15969
15970 // node_modules/@ariakit/react-utils/dist/index.js
15971 var React47 = __toESM(require_react(), 1);
15972 var import_react8 = __toESM(require_react(), 1);
15973 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15974 function setRef(ref, value) {
15975 if (typeof ref === "function") {
15976 const cleanup = ref(value);
15977 if (typeof cleanup === "function") return cleanup;
15978 } else if (ref) ref.current = value;
15979 }
15980 function isValidElementWithRef(element) {
15981 if (!element) return false;
15982 if (!(0, import_react8.isValidElement)(element)) return false;
15983 if ("ref" in element.props) return true;
15984 if ("ref" in element) return true;
15985 return false;
15986 }
15987 function getRefProperty(element) {
15988 if (!isValidElementWithRef(element)) return null;
15989 return { ...element.props }.ref || element.ref;
15990 }
15991 function mergeProps2(base, overrides) {
15992 const props = { ...base };
15993 for (const key in overrides) {
15994 if (!hasOwnProperty(overrides, key)) continue;
15995 if (key === "className") {
15996 const prop = "className";
15997 const baseClass = base[prop];
15998 const overrideClass = overrides[prop];
15999 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
16000 else props[prop] = overrideClass || baseClass;
16001 continue;
16002 }
16003 if (key === "style") {
16004 const prop = "style";
16005 props[prop] = base[prop] ? {
16006 ...base[prop],
16007 ...overrides[prop]
16008 } : overrides[prop];
16009 continue;
16010 }
16011 const overrideValue = overrides[key];
16012 if (key.startsWith("on")) {
16013 if (typeof overrideValue !== "function") continue;
16014 const baseValue = base[key];
16015 if (typeof baseValue === "function") {
16016 props[key] = (...args) => {
16017 overrideValue(...args);
16018 baseValue(...args);
16019 };
16020 continue;
16021 }
16022 }
16023 props[key] = overrideValue;
16024 }
16025 return props;
16026 }
16027 var _React = { ...React47 };
16028 var useReactId = _React.useId;
16029 var useReactDeferredValue = _React.useDeferredValue;
16030 var useReactInsertionEffect = _React.useInsertionEffect;
16031 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
16032 function useInitialValue(value) {
16033 const [initialValue] = (0, import_react8.useState)(value);
16034 return initialValue;
16035 }
16036 function useLiveRef(value) {
16037 const ref = (0, import_react8.useRef)(value);
16038 useSafeLayoutEffect(() => {
16039 ref.current = value;
16040 });
16041 return ref;
16042 }
16043 function useEvent(callback) {
16044 const ref = (0, import_react8.useRef)(() => {
16045 throw new Error("Cannot call an event handler while rendering.");
16046 });
16047 if (useReactInsertionEffect) useReactInsertionEffect(() => {
16048 ref.current = callback;
16049 });
16050 else ref.current = callback;
16051 return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
16052 }
16053 function useTransactionState(callback) {
16054 const [state, setState] = (0, import_react8.useState)(null);
16055 useSafeLayoutEffect(() => {
16056 if (state == null) return;
16057 if (!callback) return;
16058 let prevState = null;
16059 callback((prev) => {
16060 prevState = prev;
16061 return state;
16062 });
16063 return () => {
16064 callback(prevState);
16065 };
16066 }, [state, callback]);
16067 return [state, setState];
16068 }
16069 function useMergeRefs(...refs) {
16070 return (0, import_react8.useMemo)(() => {
16071 if (!refs.some(Boolean)) return;
16072 return (value) => {
16073 const refEffects = [];
16074 for (const ref of refs) {
16075 if (!ref) continue;
16076 const cleanup = setRef(ref, value);
16077 refEffects.push({
16078 ref,
16079 cleanup: typeof cleanup === "function" ? cleanup : void 0
16080 });
16081 }
16082 if (!refEffects.some((effect) => effect.cleanup)) return;
16083 return () => {
16084 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
16085 else setRef(ref, null);
16086 };
16087 };
16088 }, refs);
16089 }
16090 function useId4(defaultId) {
16091 if (useReactId) {
16092 const reactId = useReactId();
16093 if (defaultId) return defaultId;
16094 return reactId;
16095 }
16096 const [id, setId] = (0, import_react8.useState)(defaultId);
16097 useSafeLayoutEffect(() => {
16098 if (defaultId || id) return;
16099 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
16100 }, [defaultId, id]);
16101 return defaultId || id;
16102 }
16103 function useTagName(refOrElement, type) {
16104 const stringOrUndefined = (type2) => {
16105 if (typeof type2 !== "string") return;
16106 return type2;
16107 };
16108 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
16109 useSafeLayoutEffect(() => {
16110 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
16111 }, [refOrElement, type]);
16112 return tagName;
16113 }
16114 function useAttribute(refOrElement, attributeName, defaultValue2) {
16115 const initialValue = useInitialValue(defaultValue2);
16116 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
16117 (0, import_react8.useEffect)(() => {
16118 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
16119 if (!element) return;
16120 const callback = () => {
16121 const value = element.getAttribute(attributeName);
16122 setAttribute(value == null ? initialValue : value);
16123 };
16124 const observer = new MutationObserver(callback);
16125 observer.observe(element, { attributeFilter: [attributeName] });
16126 callback();
16127 return () => observer.disconnect();
16128 }, [
16129 refOrElement,
16130 attributeName,
16131 initialValue
16132 ]);
16133 return attribute;
16134 }
16135 function useUpdateEffect(effect, deps) {
16136 const mounted = (0, import_react8.useRef)(false);
16137 (0, import_react8.useEffect)(() => {
16138 if (mounted.current) return effect();
16139 mounted.current = true;
16140 }, deps);
16141 (0, import_react8.useEffect)(() => () => {
16142 mounted.current = false;
16143 }, []);
16144 }
16145 function useUpdateLayoutEffect(effect, deps) {
16146 const mounted = (0, import_react8.useRef)(false);
16147 useSafeLayoutEffect(() => {
16148 if (mounted.current) return effect();
16149 mounted.current = true;
16150 }, deps);
16151 useSafeLayoutEffect(() => () => {
16152 mounted.current = false;
16153 }, []);
16154 }
16155 function useForceUpdate() {
16156 return (0, import_react8.useReducer)(() => [], []);
16157 }
16158 function useBooleanEvent(booleanOrCallback) {
16159 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
16160 }
16161 function useWrapElement(props, callback, deps = []) {
16162 const wrapElement = (0, import_react8.useCallback)((element) => {
16163 if (props.wrapElement) element = props.wrapElement(element);
16164 return callback(element);
16165 }, [...deps, props.wrapElement]);
16166 return {
16167 ...props,
16168 wrapElement
16169 };
16170 }
16171 function useMetadataProps(props, key, value) {
16172 const parent = props.onLoadedMetadataCapture;
16173 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
16174 return Object.assign(() => {
16175 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
16176 }, [
16177 parent,
16178 key,
16179 value
16180 ]);
16181 return [parent?.[key], { onLoadedMetadataCapture }];
16182 }
16183 var hasInstalledGlobalEventListeners = false;
16184 function useIsMouseMoving() {
16185 (0, import_react8.useEffect)(() => {
16186 if (hasInstalledGlobalEventListeners) return;
16187 addGlobalEventListener("mousemove", setMouseMoving, true);
16188 addGlobalEventListener("mousedown", resetMouseMoving, true);
16189 addGlobalEventListener("mouseup", resetMouseMoving, true);
16190 addGlobalEventListener("keydown", resetMouseMoving, true);
16191 addGlobalEventListener("scroll", resetMouseMoving, true);
16192 hasInstalledGlobalEventListeners = true;
16193 }, []);
16194 return useEvent(() => mouseMoving);
16195 }
16196 var mouseMoving = false;
16197 var previousScreenX = 0;
16198 var previousScreenY = 0;
16199 function hasMouseMovement(event) {
16200 const movementX = event.movementX || event.screenX - previousScreenX;
16201 const movementY = event.movementY || event.screenY - previousScreenY;
16202 previousScreenX = event.screenX;
16203 previousScreenY = event.screenY;
16204 return movementX || movementY || false;
16205 }
16206 function setMouseMoving(event) {
16207 if (!hasMouseMovement(event)) return;
16208 mouseMoving = true;
16209 }
16210 function resetMouseMoving() {
16211 mouseMoving = false;
16212 }
16213 function forwardRef21(render4) {
16214 const Role = React47.forwardRef((props, ref) => render4({
16215 ...props,
16216 ref
16217 }));
16218 Role.displayName = render4.displayName || render4.name;
16219 return Role;
16220 }
16221 function memo3(Component2, propsAreEqual) {
16222 return React47.memo(Component2, propsAreEqual);
16223 }
16224 function createElement3(Type, props) {
16225 const { wrapElement, render: render4, ...rest } = props;
16226 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
16227 let element;
16228 if (React47.isValidElement(render4)) {
16229 const renderProps = {
16230 ...render4.props,
16231 ref: mergedRef
16232 };
16233 element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
16234 } else if (render4) element = render4(rest);
16235 else element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
16236 if (wrapElement) return wrapElement(element);
16237 return element;
16238 }
16239 function createHook(useProps) {
16240 const useRole = (props = {}) => {
16241 return useProps(props);
16242 };
16243 useRole.displayName = useProps.name;
16244 return useRole;
16245 }
16246 function createStoreContext(providers = [], scopedProviders = []) {
16247 const context = React47.createContext(void 0);
16248 const scopedContext = React47.createContext(void 0);
16249 const useContext37 = () => React47.useContext(context);
16250 const useScopedContext = (onlyScoped = false) => {
16251 const scoped = React47.useContext(scopedContext);
16252 const store = useContext37();
16253 if (onlyScoped) return scoped;
16254 return scoped || store;
16255 };
16256 const useProviderContext = () => {
16257 const scoped = React47.useContext(scopedContext);
16258 const store = useContext37();
16259 if (scoped && scoped === store) return;
16260 return store;
16261 };
16262 const ContextProvider = (props) => {
16263 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16264 ...props,
16265 children
16266 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props }));
16267 };
16268 const ScopedContextProvider = (props) => {
16269 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, {
16270 ...props,
16271 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16272 ...props,
16273 children
16274 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props }))
16275 });
16276 };
16277 return {
16278 context,
16279 scopedContext,
16280 useContext: useContext37,
16281 useScopedContext,
16282 useProviderContext,
16283 ContextProvider,
16284 ScopedContextProvider
16285 };
16286 }
16287
16288 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
16289 var import_react9 = __toESM(require_react(), 1);
16290 var TagName = "div";
16291 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
16292 var isSafariBrowser = isSafari();
16293 var alwaysFocusVisibleInputTypes = [
16294 "text",
16295 "search",
16296 "url",
16297 "tel",
16298 "email",
16299 "password",
16300 "number",
16301 "date",
16302 "month",
16303 "week",
16304 "time",
16305 "datetime",
16306 "datetime-local"
16307 ];
16308 function isAlwaysFocusVisible(element) {
16309 const { tagName, readOnly, type } = element;
16310 if (tagName === "TEXTAREA" && !readOnly) return true;
16311 if (tagName === "SELECT" && !readOnly) return true;
16312 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
16313 if (element.isContentEditable) return true;
16314 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
16315 return false;
16316 }
16317 function isNativeTabbable(tagName) {
16318 if (!tagName) return true;
16319 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16320 }
16321 function supportsDisabledAttribute(tagName) {
16322 if (!tagName) return true;
16323 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16324 }
16325 function isNativeSubmitControl(element) {
16326 if (element.tagName === "BUTTON") {
16327 const { type } = element;
16328 return type === "submit";
16329 }
16330 if (element.tagName === "INPUT") {
16331 const { type } = element;
16332 return type === "submit" || type === "image";
16333 }
16334 return false;
16335 }
16336 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16337 if (!focusable2) return tabIndexProp;
16338 if (trulyDisabled) {
16339 if (nativeTabbable && !supportsDisabled) return -1;
16340 return;
16341 }
16342 if (nativeTabbable) {
16343 if (safariTabIndex && tabIndexProp == null) return 0;
16344 return tabIndexProp;
16345 }
16346 return tabIndexProp ?? 0;
16347 }
16348 function useDisableEvent(onEvent, disabled2) {
16349 return useEvent((event) => {
16350 onEvent?.(event);
16351 if (event.defaultPrevented) return;
16352 if (disabled2) {
16353 event.stopPropagation();
16354 event.preventDefault();
16355 }
16356 });
16357 }
16358 var hasInstalledGlobalEventListeners2 = false;
16359 var isKeyboardModality = true;
16360 function onGlobalMouseDown(event) {
16361 const target = event.target;
16362 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16363 }
16364 function onGlobalKeyDown(event) {
16365 if (event.metaKey) return;
16366 if (event.ctrlKey) return;
16367 if (event.altKey) return;
16368 isKeyboardModality = true;
16369 }
16370 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16371 const ref = (0, import_react9.useRef)(null);
16372 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16373 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16374 (0, import_react9.useEffect)(() => {
16375 if (!focusable2) return;
16376 if (hasInstalledGlobalEventListeners2) return;
16377 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16378 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16379 hasInstalledGlobalEventListeners2 = true;
16380 }, [focusable2]);
16381 const disabled2 = focusable2 && disabledFromProps(props);
16382 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16383 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
16384 const focusVisibleRef = (0, import_react9.useRef)(false);
16385 const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
16386 const cleanupFocusVisible = useEvent((element) => {
16387 nativeSubmitObserverCleanupRef.current?.();
16388 nativeSubmitObserverCleanupRef.current = null;
16389 focusVisibleRef.current = false;
16390 element?.removeAttribute("data-focus-visible");
16391 });
16392 (0, import_react9.useEffect)(() => {
16393 if (!focusable2) return;
16394 if (!trulyDisabled) return;
16395 cleanupFocusVisible(ref.current);
16396 if (focusVisible) setFocusVisible(false);
16397 }, [
16398 focusable2,
16399 trulyDisabled,
16400 focusVisible,
16401 cleanupFocusVisible
16402 ]);
16403 (0, import_react9.useEffect)(() => {
16404 if (!focusable2) return;
16405 if (!focusVisible) return;
16406 const element = ref.current;
16407 if (!element) return;
16408 if (typeof IntersectionObserver === "undefined") return;
16409 const observer = new IntersectionObserver(() => {
16410 if (!isFocusable(element)) {
16411 focusVisibleRef.current = false;
16412 setFocusVisible(false);
16413 }
16414 });
16415 observer.observe(element);
16416 return () => observer.disconnect();
16417 }, [focusable2, focusVisible]);
16418 (0, import_react9.useEffect)(() => {
16419 return () => nativeSubmitObserverCleanupRef.current?.();
16420 }, []);
16421 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16422 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16423 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16424 const handleFocusVisible = (event, currentTarget) => {
16425 if (currentTarget) event.currentTarget = currentTarget;
16426 if (!focusable2) return;
16427 const element = event.currentTarget;
16428 if (!element) return;
16429 if (!hasFocus(element)) return;
16430 onFocusVisible?.(event);
16431 if (event.defaultPrevented) return;
16432 element.dataset.focusVisible = "true";
16433 focusVisibleRef.current = true;
16434 if (isNativeSubmitControl(element)) {
16435 nativeSubmitObserverCleanupRef.current?.();
16436 nativeSubmitObserverCleanupRef.current = null;
16437 if (typeof IntersectionObserver !== "undefined") {
16438 const observer = new IntersectionObserver(() => {
16439 if (isFocusable(element)) return;
16440 cleanupFocusVisible(element);
16441 });
16442 observer.observe(element);
16443 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16444 }
16445 return;
16446 }
16447 setFocusVisible(true);
16448 };
16449 const onKeyDownCaptureProp = props.onKeyDownCapture;
16450 const onKeyDownCapture = useEvent((event) => {
16451 onKeyDownCaptureProp?.(event);
16452 if (event.defaultPrevented) return;
16453 if (!focusable2) return;
16454 if (focusVisible) return;
16455 if (focusVisibleRef.current) return;
16456 if (event.metaKey) return;
16457 if (event.altKey) return;
16458 if (event.ctrlKey) return;
16459 if (!isSelfTarget(event)) return;
16460 const element = event.currentTarget;
16461 const applyFocusVisible = () => handleFocusVisible(event, element);
16462 queueBeforeEvent(element, "focusout", applyFocusVisible);
16463 });
16464 const onFocusCaptureProp = props.onFocusCapture;
16465 const onFocusCapture = useEvent((event) => {
16466 onFocusCaptureProp?.(event);
16467 if (event.defaultPrevented) return;
16468 if (!focusable2) return;
16469 if (!isSelfTarget(event)) {
16470 setFocusVisible(false);
16471 return;
16472 }
16473 const element = event.currentTarget;
16474 const applyFocusVisible = () => handleFocusVisible(event, element);
16475 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16476 else setFocusVisible(false);
16477 });
16478 const onBlurProp = props.onBlur;
16479 const onBlur = useEvent((event) => {
16480 onBlurProp?.(event);
16481 if (!focusable2) return;
16482 if (!isFocusEventOutside(event)) return;
16483 cleanupFocusVisible(event.currentTarget);
16484 setFocusVisible(false);
16485 });
16486 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
16487 const autoFocusRef = useEvent((element) => {
16488 if (!focusable2) return;
16489 if (!autoFocus) return;
16490 if (!element) return;
16491 if (!autoFocusOnShow) return;
16492 queueMicrotask(() => {
16493 if (hasFocus(element)) return;
16494 if (!isFocusable(element)) return;
16495 element.focus();
16496 });
16497 });
16498 const tagName = useTagName(ref);
16499 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16500 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16501 const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
16502 if (isSafariBrowser) (0, import_react9.useEffect)(() => {
16503 if (!focusable2) return;
16504 const element = ref.current;
16505 if (!element) return;
16506 const { type } = element;
16507 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16508 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16509 }, [focusable2]);
16510 const styleProp = props.style;
16511 const style = (0, import_react9.useMemo)(() => {
16512 if (trulyDisabled) return {
16513 pointerEvents: "none",
16514 ...styleProp
16515 };
16516 return styleProp;
16517 }, [trulyDisabled, styleProp]);
16518 props = {
16519 "data-focus-visible": focusable2 && focusVisible || void 0,
16520 "data-autofocus": autoFocus || void 0,
16521 "aria-disabled": disabled2 || void 0,
16522 ...props,
16523 ...metadataProps,
16524 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16525 style,
16526 tabIndex: getTabIndex2({
16527 focusable: focusable2,
16528 trulyDisabled,
16529 nativeTabbable,
16530 supportsDisabled,
16531 safariTabIndex,
16532 tabIndexProp: props.tabIndex
16533 }),
16534 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16535 contentEditable: disabled2 ? void 0 : props.contentEditable,
16536 onKeyPressCapture,
16537 onClickCapture,
16538 onMouseDownCapture,
16539 onKeyDownCapture,
16540 onFocusCapture,
16541 onBlur
16542 };
16543 return removeUndefinedValues(props);
16544 });
16545 var Focusable = forwardRef21(function Focusable2(props) {
16546 return createElement3(TagName, useFocusable(props));
16547 });
16548
16549 // node_modules/@ariakit/react-components/dist/command/command.js
16550 var import_react10 = __toESM(require_react(), 1);
16551 var TagName2 = "button";
16552 function isNativeClick(event) {
16553 if (!event.isTrusted) return false;
16554 const element = event.currentTarget;
16555 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16556 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16557 return false;
16558 }
16559 var symbol = /* @__PURE__ */ Symbol("command");
16560 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16561 const ref = (0, import_react10.useRef)(null);
16562 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
16563 (0, import_react10.useEffect)(() => {
16564 if (!ref.current) return;
16565 setIsNativeButton(isButton(ref.current));
16566 }, []);
16567 const [active, setActive] = (0, import_react10.useState)(false);
16568 const activeRef = (0, import_react10.useRef)(false);
16569 const disabled2 = disabledFromProps(props);
16570 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16571 useSafeLayoutEffect(() => {
16572 if (!disabled2) return;
16573 activeRef.current = false;
16574 setActive(false);
16575 }, [disabled2]);
16576 const onKeyDownProp = props.onKeyDown;
16577 const onKeyDown = useEvent((event) => {
16578 onKeyDownProp?.(event);
16579 const element = event.currentTarget;
16580 if (event.defaultPrevented) return;
16581 if (isDuplicate) return;
16582 if (disabled2) return;
16583 if (!isSelfTarget(event)) return;
16584 if (isTextField(element)) return;
16585 if (element.isContentEditable) return;
16586 const isEnter = clickOnEnter && event.key === "Enter";
16587 const isSpace = clickOnSpace && event.key === " ";
16588 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16589 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16590 if (shouldPreventEnter || shouldPreventSpace) {
16591 event.preventDefault();
16592 return;
16593 }
16594 if (isEnter || isSpace) {
16595 const nativeClick = isNativeClick(event);
16596 if (isEnter) {
16597 if (!nativeClick) {
16598 event.preventDefault();
16599 const { view, ...eventInit } = event;
16600 const click = () => fireClickEvent(element, eventInit);
16601 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16602 else queueMicrotask(click);
16603 }
16604 } else if (isSpace) {
16605 activeRef.current = true;
16606 if (!nativeClick) {
16607 event.preventDefault();
16608 setActive(true);
16609 }
16610 }
16611 }
16612 });
16613 const onKeyUpProp = props.onKeyUp;
16614 const onKeyUp = useEvent((event) => {
16615 onKeyUpProp?.(event);
16616 if (isDuplicate) return;
16617 const isSpace = clickOnSpace && event.key === " ";
16618 if (!activeRef.current || !isSpace) return;
16619 const nativeClick = isNativeClick(event);
16620 activeRef.current = false;
16621 if (!nativeClick) setActive(false);
16622 if (event.defaultPrevented) return;
16623 if (!isSelfTarget(event)) return;
16624 if (disabled2) return;
16625 if (event.metaKey) return;
16626 if (nativeClick) return;
16627 event.preventDefault();
16628 const element = event.currentTarget;
16629 const { view, ...eventInit } = event;
16630 queueMicrotask(() => fireClickEvent(element, eventInit));
16631 });
16632 const onBlurProp = props.onBlur;
16633 const onBlur = useEvent((event) => {
16634 onBlurProp?.(event);
16635 if (!activeRef.current) return;
16636 activeRef.current = false;
16637 setActive(false);
16638 });
16639 props = {
16640 "data-active": active || void 0,
16641 type: isNativeButton ? "button" : void 0,
16642 ...metadataProps,
16643 ...props,
16644 ref: useMergeRefs(ref, props.ref),
16645 onKeyDown,
16646 onKeyUp,
16647 onBlur
16648 };
16649 props = useFocusable(props);
16650 return props;
16651 });
16652 var Command = forwardRef21(function Command2(props) {
16653 return createElement3(TagName2, useCommand(props));
16654 });
16655
16656 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16657 var ctx = createStoreContext();
16658 var useCollectionContext = ctx.useContext;
16659 var useCollectionScopedContext = ctx.useScopedContext;
16660 var useCollectionProviderContext = ctx.useProviderContext;
16661 var CollectionContextProvider = ctx.ContextProvider;
16662 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16663
16664 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16665 var import_react11 = __toESM(require_react(), 1);
16666 var TagName3 = "div";
16667 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16668 const context = useCollectionContext();
16669 store = store || context;
16670 const id = useId4(props.id);
16671 const ref = (0, import_react11.useRef)(element);
16672 (0, import_react11.useEffect)(() => {
16673 const element2 = ref.current;
16674 if (!id) return;
16675 if (!element2) return;
16676 if (!shouldRegisterItem) return;
16677 const item = getItem({
16678 id,
16679 element: element2
16680 });
16681 return store?.renderItem(item);
16682 }, [
16683 id,
16684 shouldRegisterItem,
16685 getItem,
16686 store
16687 ]);
16688 props = {
16689 ...props,
16690 ref: useMergeRefs(ref, props.ref)
16691 };
16692 return removeUndefinedValues(props);
16693 });
16694 var CollectionItem = forwardRef21(function CollectionItem2(props) {
16695 return createElement3(TagName3, useCollectionItem(props));
16696 });
16697
16698 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16699 var import_react12 = __toESM(require_react(), 1);
16700 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16701 var useCompositeContext = ctx2.useContext;
16702 var useCompositeScopedContext = ctx2.useScopedContext;
16703 var useCompositeProviderContext = ctx2.useProviderContext;
16704 var CompositeContextProvider = ctx2.ContextProvider;
16705 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16706 var CompositeItemContext = (0, import_react12.createContext)(void 0);
16707 var CompositeRowContext = (0, import_react12.createContext)(void 0);
16708
16709 // node_modules/@ariakit/store/dist/index.js
16710 function getInternal(store, key) {
16711 const internals = store.__unstableInternals;
16712 invariant(internals, "Invalid store");
16713 return internals[key];
16714 }
16715 function hasUpdatedKey(keys, updatedKey) {
16716 if (!keys) return true;
16717 for (const currentKey of keys) if (updatedKey instanceof Set) {
16718 if (updatedKey.has(currentKey)) return true;
16719 } else if (currentKey === updatedKey) return true;
16720 return false;
16721 }
16722 function isSameValue(value, other) {
16723 return value === other || value !== value && other !== other;
16724 }
16725 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16726 let cleanupPrevState;
16727 for (const key of getKeys(state)) {
16728 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16729 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16730 cleanupPrevState ??= { ...prevState };
16731 cleanupPrevState[key] = state[key];
16732 }
16733 return cleanupPrevState;
16734 }
16735 var MAX_REPAIR_PASSES = 100;
16736 function addKeyedListener(map, keys, listener) {
16737 if (!keys) return;
16738 for (const key of keys) {
16739 let listeners = map.get(key);
16740 if (!listeners) {
16741 listeners = /* @__PURE__ */ new Set();
16742 map.set(key, listeners);
16743 }
16744 listeners.add(listener);
16745 }
16746 }
16747 function deleteKeyedListener(map, keys, listener) {
16748 if (!map) return;
16749 if (!keys) return;
16750 for (const key of keys) {
16751 const listeners = map.get(key);
16752 if (!listeners) continue;
16753 listeners.delete(listener);
16754 if (!listeners.size) map.delete(key);
16755 }
16756 }
16757 function getFastPathNotifiedListeners(frame) {
16758 const notifiedListeners = /* @__PURE__ */ new Set();
16759 const currentListener = frame.currentListener;
16760 if (!currentListener) return notifiedListeners;
16761 for (const listener of frame.keyedListeners) {
16762 notifiedListeners.add(listener);
16763 if (listener === currentListener) return notifiedListeners;
16764 }
16765 notifiedListeners.clear();
16766 notifiedListeners.add(currentListener);
16767 return notifiedListeners;
16768 }
16769 function preserveFastPathNotifiedListeners(frame) {
16770 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16771 }
16772 function hasFastPathPassedListener(frame, listener) {
16773 if (!frame.currentListener) return false;
16774 let foundCurrentKeyedListener = false;
16775 for (const currentListener of frame.keyedListeners) {
16776 if (currentListener === frame.currentListener) {
16777 foundCurrentKeyedListener = true;
16778 continue;
16779 }
16780 if (!foundCurrentKeyedListener) continue;
16781 if (currentListener === listener) return false;
16782 }
16783 let foundListener = false;
16784 for (const currentListener of frame.group.listeners) {
16785 if (currentListener === frame.currentListener) return foundListener;
16786 if (currentListener === listener) foundListener = true;
16787 }
16788 return false;
16789 }
16790 function preserveFastPathFrames(fastPathFrames, group, listener) {
16791 for (const frame of fastPathFrames) {
16792 if (frame.group !== group) continue;
16793 if (frame.recovering) continue;
16794 if (listener && !frame.keyedListeners.has(listener)) continue;
16795 preserveFastPathNotifiedListeners(frame);
16796 for (const currentListener of frame.group.listeners) {
16797 if (currentListener === frame.currentListener) break;
16798 if (!hasFastPathPassedListener(frame, currentListener)) continue;
16799 frame.notifiedListeners?.add(currentListener);
16800 }
16801 }
16802 }
16803 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16804 for (const frame of fastPathFrames) {
16805 if (frame.group !== group) continue;
16806 if (frame.recovering) continue;
16807 if (!hasFastPathPassedListener(frame, listener)) continue;
16808 preserveFastPathNotifiedListeners(frame);
16809 frame.notifiedListeners?.add(listener);
16810 }
16811 }
16812 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16813 const wasRegistered = group.listeners.has(listener);
16814 for (const frame of fastPathFrames) {
16815 if (frame.group !== group) continue;
16816 if (frame.recovering) continue;
16817 if (!keys.includes(frame.updatedKey)) continue;
16818 if (hasFastPathPassedListener(frame, listener)) {
16819 preserveFastPathNotifiedListeners(frame);
16820 frame.notifiedListeners?.add(listener);
16821 } else if (wasRegistered) {
16822 preserveFastPathNotifiedListeners(frame);
16823 frame.recoverToLive = true;
16824 }
16825 }
16826 }
16827 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16828 for (const frame of fastPathFrames) {
16829 if (frame.group !== group) continue;
16830 frame.notifiedListeners?.delete(listener);
16831 }
16832 }
16833 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16834 for (const frame of fastPathFrames) {
16835 if (frame.group !== group) continue;
16836 if (frame.recovering) continue;
16837 if (!keys.includes(frame.updatedKey)) continue;
16838 frame.keyedListeners.add(listener);
16839 }
16840 }
16841 function runPendingCleanup(group, listener) {
16842 if (!group.disposables.size) return;
16843 const cleanup = group.disposables.get(listener);
16844 if (!cleanup) return;
16845 group.disposables.delete(listener);
16846 cleanup();
16847 }
16848 function setListenerCleanup(group, listener, cleanup) {
16849 const currentCleanup = group.disposables.get(listener);
16850 if (!currentCleanup) {
16851 group.disposables.set(listener, cleanup);
16852 return;
16853 }
16854 group.disposables.set(listener, () => {
16855 currentCleanup();
16856 cleanup();
16857 });
16858 }
16859 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16860 if (group.suspendCounts?.has(listener)) return;
16861 const { disposables } = group;
16862 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16863 if (cleanup) {
16864 disposables.delete(listener);
16865 const stateBeforeCleanup = state;
16866 cleanup();
16867 state = getState?.() ?? state;
16868 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16869 }
16870 const result = listener(state, prevState);
16871 if (result) setListenerCleanup(group, listener, result);
16872 }
16873 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16874 const allKeysListeners = group.allKeysListeners;
16875 for (const listener of group.listeners) {
16876 if (notifiedListeners?.has(listener)) continue;
16877 if (!allKeysListeners?.has(listener)) {
16878 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16879 }
16880 notifiedListeners?.add(listener);
16881 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16882 }
16883 }
16884 function createStore(initialState, ...stores) {
16885 let state = initialState;
16886 let prevStateBatch = state;
16887 let destroy = noop5;
16888 let batchPending = false;
16889 let inDispatch = false;
16890 let updatedKeys = /* @__PURE__ */ new Set();
16891 const instances = /* @__PURE__ */ new Set();
16892 const setups = /* @__PURE__ */ new Set();
16893 const syncListenerGroup = {
16894 listeners: /* @__PURE__ */ new Set(),
16895 disposables: /* @__PURE__ */ new Map(),
16896 listenerKeys: /* @__PURE__ */ new WeakMap()
16897 };
16898 const batchListenerGroup = {
16899 listeners: /* @__PURE__ */ new Set(),
16900 disposables: /* @__PURE__ */ new Map(),
16901 listenerKeys: /* @__PURE__ */ new WeakMap()
16902 };
16903 const storeSetup = (callback) => {
16904 setups.add(callback);
16905 return () => setups.delete(callback);
16906 };
16907 const storeInit = () => {
16908 const initializedInstances = instances.size;
16909 const instance = /* @__PURE__ */ Symbol();
16910 instances.add(instance);
16911 const maybeDestroy = () => {
16912 if (!instances.delete(instance)) return;
16913 if (instances.size) return;
16914 destroy();
16915 };
16916 if (initializedInstances) return maybeDestroy;
16917 const stateKeys = getKeys(state);
16918 const desyncs = [];
16919 for (const store of stores) {
16920 const storeState = store?.getState?.();
16921 if (!storeState) continue;
16922 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16923 if (!keys.length) continue;
16924 if (stores.length === 1 || keys.length === stateKeys.length) {
16925 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16926 setState(key, state2[key], true);
16927 }));
16928 continue;
16929 }
16930 desyncs.push(subscribe(store, keys, (state2, prevState) => {
16931 for (const key of keys) {
16932 if (state2[key] === prevState[key]) continue;
16933 setState(key, state2[key], true);
16934 }
16935 }));
16936 for (const key of keys) {
16937 const liveState = store?.getState?.();
16938 if (!liveState) continue;
16939 setState(key, liveState[key], true);
16940 }
16941 }
16942 const teardowns = [];
16943 for (const setup2 of setups) teardowns.push(setup2());
16944 const cleanups = stores.map(init);
16945 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16946 return maybeDestroy;
16947 };
16948 const deleteListenerIndexes = (group, listener, keys) => {
16949 if (keys === void 0) return;
16950 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16951 else group.allKeysListeners?.delete(listener);
16952 };
16953 const fastPathFrames = [];
16954 const registerListener = (keys, listener, group = syncListenerGroup) => {
16955 const listenerKeysValue = keys ? [...keys] : null;
16956 const wasRegistered = group.listeners.has(listener);
16957 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
16958 if (!listenerKeysValue) {
16959 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
16960 preserveFastPathPassedListeners(fastPathFrames, group, listener);
16961 } else preserveFastPathPassedKeyedListeners({
16962 fastPathFrames,
16963 group,
16964 keys: listenerKeysValue,
16965 listener
16966 });
16967 if (wasRegistered) {
16968 preserveFastPathFrames(fastPathFrames, group, listener);
16969 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16970 }
16971 group.listeners.add(listener);
16972 if (listenerKeysValue) {
16973 group.listenersByKey ??= /* @__PURE__ */ new Map();
16974 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16975 addFastPathKeyedListener({
16976 fastPathFrames,
16977 group,
16978 keys: listenerKeysValue,
16979 listener
16980 });
16981 } else {
16982 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16983 group.allKeysListeners.add(listener);
16984 }
16985 group.listenerKeys.set(listener, listenerKeysValue);
16986 return () => {
16987 const cleanup = group.disposables.get(listener);
16988 group.disposables.delete(listener);
16989 preserveFastPathFrames(fastPathFrames, group, listener);
16990 const currentKeys = group.listenerKeys.get(listener);
16991 deleteListenerIndexes(group, listener, listenerKeysValue);
16992 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16993 group.listenerKeys.delete(listener);
16994 group.listeners.delete(listener);
16995 cleanup?.();
16996 };
16997 };
16998 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16999 const runInitialListener = (group, listener, prevState) => {
17000 const shouldSuspend = group.listeners.has(listener);
17001 if (shouldSuspend) {
17002 group.suspendCounts ??= /* @__PURE__ */ new Map();
17003 const count = group.suspendCounts.get(listener) ?? 0;
17004 group.suspendCounts.set(listener, count + 1);
17005 }
17006 let cleanupPrevState;
17007 try {
17008 const stateBeforeCleanups = state;
17009 runPendingCleanup(group, listener);
17010 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
17011 const cleanup = listener(state, cleanupPrevState ?? prevState);
17012 if (cleanup) setListenerCleanup(group, listener, cleanup);
17013 } finally {
17014 if (shouldSuspend) {
17015 const suspendCounts = group.suspendCounts;
17016 const count = suspendCounts?.get(listener);
17017 if (count && count > 1) suspendCounts?.set(listener, count - 1);
17018 else suspendCounts?.delete(listener);
17019 if (!suspendCounts?.size) delete group.suspendCounts;
17020 }
17021 }
17022 };
17023 const storeSync = (keys, listener) => {
17024 runInitialListener(syncListenerGroup, listener, state);
17025 return registerListener(keys, listener);
17026 };
17027 const storeBatch = (keys, listener) => {
17028 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
17029 runInitialListener(batchListenerGroup, listener, prevStateBatch);
17030 return registerListener(keys, listener, batchListenerGroup);
17031 };
17032 const storePick = (keys) => createStore(pick(state, keys), finalStore);
17033 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
17034 const getState = () => state;
17035 const runListeners = (group, prevState, updatedKey) => {
17036 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
17037 const keyedListeners = group.listenersByKey?.get(updatedKey);
17038 if (!keyedListeners) return;
17039 const frame = {
17040 group,
17041 keyedListeners,
17042 updatedKey,
17043 currentListener: null
17044 };
17045 fastPathFrames.push(frame);
17046 try {
17047 for (const listener of keyedListeners) {
17048 if (frame.notifiedListeners?.has(listener)) continue;
17049 frame.currentListener = listener;
17050 frame.notifiedListeners?.add(listener);
17051 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
17052 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
17053 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
17054 frame.notifiedListeners = notifiedListeners;
17055 frame.recovering = true;
17056 runLiveListeners({
17057 group,
17058 getState,
17059 prevState,
17060 updatedKey,
17061 notifiedListeners
17062 });
17063 return;
17064 }
17065 } finally {
17066 fastPathFrames.pop();
17067 }
17068 return;
17069 }
17070 runLiveListeners({
17071 group,
17072 getState,
17073 prevState,
17074 updatedKey
17075 });
17076 };
17077 const setState = (key, value, fromStores = false) => {
17078 if (!hasOwnProperty(state, key)) return;
17079 const currentValue = state[key];
17080 const nextValue = typeof value === "function" ? value(currentValue) : value;
17081 if (isSameValue(nextValue, currentValue)) return;
17082 const wasInDispatch = inDispatch;
17083 inDispatch = true;
17084 const prevState = state;
17085 const nextState = {
17086 ...state,
17087 [key]: nextValue
17088 };
17089 state = nextState;
17090 let superseded = false;
17091 try {
17092 if (!fromStores && stores.length) {
17093 for (const store of stores) {
17094 store?.setState?.(key, nextValue);
17095 if (isSameValue(state[key], nextValue)) continue;
17096 superseded = true;
17097 break;
17098 }
17099 if (superseded) {
17100 let pass = 0;
17101 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
17102 let changed = false;
17103 for (const store of stores) {
17104 const previousValue = state[key];
17105 store?.setState?.(key, previousValue);
17106 if (!isSameValue(state[key], previousValue)) changed = true;
17107 }
17108 if (!changed) break;
17109 }
17110 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
17111 }
17112 }
17113 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
17114 ...state,
17115 [key]: prevState[key]
17116 }, key);
17117 } finally {
17118 inDispatch = wasInDispatch;
17119 }
17120 if (!batchListenerGroup.listeners.size) {
17121 if (!inDispatch) prevStateBatch = state;
17122 return;
17123 }
17124 updatedKeys.add(key);
17125 if (batchPending) return;
17126 batchPending = true;
17127 queueMicrotask(() => {
17128 batchPending = false;
17129 const snapshot = state;
17130 const updatedKeysSnapshot = updatedKeys;
17131 updatedKeys = /* @__PURE__ */ new Set();
17132 const prevStateBatchBefore = prevStateBatch;
17133 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
17134 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
17135 });
17136 };
17137 const finalStore = {
17138 getState,
17139 setState,
17140 __unstableInternals: {
17141 setup: storeSetup,
17142 init: storeInit,
17143 subscribe: storeSubscribe,
17144 sync: storeSync,
17145 batch: storeBatch,
17146 pick: storePick,
17147 omit: storeOmit
17148 }
17149 };
17150 return finalStore;
17151 }
17152 function setup(store, ...args) {
17153 if (!store) return;
17154 return getInternal(store, "setup")(...args);
17155 }
17156 function init(store, ...args) {
17157 if (!store) return;
17158 return getInternal(store, "init")(...args);
17159 }
17160 function subscribe(store, ...args) {
17161 if (!store) return;
17162 return getInternal(store, "subscribe")(...args);
17163 }
17164 function sync(store, ...args) {
17165 if (!store) return;
17166 return getInternal(store, "sync")(...args);
17167 }
17168 function batch(store, ...args) {
17169 if (!store) return;
17170 return getInternal(store, "batch")(...args);
17171 }
17172 function omit2(store, ...args) {
17173 if (!store) return;
17174 return getInternal(store, "omit")(...args);
17175 }
17176 function pick2(store, ...args) {
17177 if (!store) return;
17178 return getInternal(store, "pick")(...args);
17179 }
17180 function mergeStore(...stores) {
17181 const initialState = {};
17182 for (const store2 of stores) {
17183 const nextState = store2?.getState?.();
17184 if (nextState) Object.assign(initialState, nextState);
17185 }
17186 const store = createStore(initialState, ...stores);
17187 return Object.assign({}, ...stores, store);
17188 }
17189 function throwOnConflictingProps(props, store) {
17190 if (false) return;
17191 if (!store) return;
17192 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
17193 const stateKey = key.replace("default", "");
17194 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
17195 });
17196 if (!defaultKeys.length) return;
17197 const storeState = store.getState();
17198 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
17199 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
17200
17201 const store = useSelectStore();
17202 <SelectProvider store={store} defaultValue="Apple" />
17203 ^ ^
17204
17205 Instead, pass the default state to the topmost store:
17206
17207 const store = useSelectStore({ defaultValue: "Apple" });
17208 <SelectProvider store={store} />
17209
17210 See https://github.com/ariakit/ariakit/pull/2745 for more details.
17211
17212 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
17213 `);
17214 }
17215
17216 // node_modules/@ariakit/components/dist/collection/collection-store.js
17217 function getCommonParent(items) {
17218 const firstItem = items.find((item) => !!item.element);
17219 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17220 let parentElement = firstItem?.element?.parentElement;
17221 if (!lastElement) return getDocument(parentElement).body;
17222 while (parentElement) {
17223 if (parentElement.contains(lastElement)) return parentElement;
17224 parentElement = parentElement.parentElement;
17225 }
17226 return getDocument(parentElement).body;
17227 }
17228 function getPrivateStore(store) {
17229 return store?.__unstablePrivateStore;
17230 }
17231 function createCollectionStore(props = {}) {
17232 throwOnConflictingProps(props, props.store);
17233 const syncState = props.store?.getState();
17234 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17235 const itemsMap = new Map(items.map((item) => [item.id, item]));
17236 const initialState = {
17237 items,
17238 renderedItems: defaultValue(syncState?.renderedItems, [])
17239 };
17240 const syncPrivateStore = getPrivateStore(props.store);
17241 const privateStore = createStore({
17242 items,
17243 renderedItems: initialState.renderedItems
17244 }, syncPrivateStore);
17245 const collection = createStore(initialState, props.store);
17246 const sortItems = (renderedItems) => {
17247 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17248 privateStore.setState("renderedItems", sortedItems);
17249 collection.setState("renderedItems", sortedItems);
17250 };
17251 setup(collection, () => init(privateStore));
17252 setup(privateStore, () => {
17253 return batch(privateStore, ["items"], (state) => {
17254 collection.setState("items", state.items);
17255 });
17256 });
17257 setup(privateStore, () => {
17258 return batch(privateStore, ["renderedItems"], (state) => {
17259 let firstRun = true;
17260 let raf = requestAnimationFrame(() => {
17261 const { renderedItems } = collection.getState();
17262 if (state.renderedItems === renderedItems) return;
17263 sortItems(state.renderedItems);
17264 });
17265 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17266 const ioCallback = () => {
17267 if (firstRun) {
17268 firstRun = false;
17269 return;
17270 }
17271 cancelAnimationFrame(raf);
17272 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17273 };
17274 const root = getCommonParent(state.renderedItems);
17275 const observer = new IntersectionObserver(ioCallback, { root });
17276 for (const item of state.renderedItems) {
17277 if (!item.element) continue;
17278 observer.observe(item.element);
17279 }
17280 return () => {
17281 cancelAnimationFrame(raf);
17282 observer.disconnect();
17283 };
17284 });
17285 });
17286 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17287 let prevItem;
17288 setItems((items2) => {
17289 const index2 = items2.findIndex(({ id }) => id === item.id);
17290 const nextItems = items2.slice();
17291 if (index2 !== -1) {
17292 prevItem = items2[index2];
17293 const nextItem = {
17294 ...prevItem,
17295 ...item
17296 };
17297 nextItems[index2] = nextItem;
17298 itemsMap.set(item.id, nextItem);
17299 } else {
17300 nextItems.push(item);
17301 itemsMap.set(item.id, item);
17302 }
17303 return nextItems;
17304 });
17305 const unmergeItem = () => {
17306 setItems((items2) => {
17307 if (!prevItem) {
17308 if (canDeleteFromMap) itemsMap.delete(item.id);
17309 return items2.filter(({ id }) => id !== item.id);
17310 }
17311 const index2 = items2.findIndex(({ id }) => id === item.id);
17312 if (index2 === -1) return items2;
17313 const nextItems = items2.slice();
17314 nextItems[index2] = prevItem;
17315 itemsMap.set(item.id, prevItem);
17316 return nextItems;
17317 });
17318 };
17319 return unmergeItem;
17320 };
17321 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17322 return {
17323 ...collection,
17324 registerItem,
17325 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17326 item: (id) => {
17327 if (!id) return null;
17328 let item = itemsMap.get(id);
17329 if (!item) {
17330 const { items: items2 } = privateStore.getState();
17331 item = items2.find((item2) => item2.id === id);
17332 if (item) itemsMap.set(id, item);
17333 }
17334 return item || null;
17335 },
17336 __unstablePrivateStore: privateStore
17337 };
17338 }
17339
17340 // node_modules/@ariakit/components/dist/composite/composite-store.js
17341 var NULL_ITEM = { id: null };
17342 function findFirstEnabledItem(items, excludeId) {
17343 return items.find((item) => {
17344 if (excludeId) return !item.disabled && item.id !== excludeId;
17345 return !item.disabled;
17346 });
17347 }
17348 function getEnabledItems(items, excludeId) {
17349 return items.filter((item) => {
17350 if (excludeId) return !item.disabled && item.id !== excludeId;
17351 return !item.disabled;
17352 });
17353 }
17354 function getItemsInRow(items, rowId) {
17355 return items.filter((item) => item.rowId === rowId);
17356 }
17357 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
17358 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
17359 const item = items[i2];
17360 if (!item) continue;
17361 if (item.rowId !== rowId) continue;
17362 if (item.disabled) continue;
17363 if (excludeId != null && item.id === excludeId) continue;
17364 return item.id;
17365 }
17366 }
17367 function flipItems(items, activeId, shouldInsertNullItem = false) {
17368 const index2 = items.findIndex((item) => item.id === activeId);
17369 return [
17370 ...items.slice(index2 + 1),
17371 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17372 ...items.slice(0, index2)
17373 ];
17374 }
17375 function groupItemsByRows(items) {
17376 const rows = [];
17377 for (const item of items) {
17378 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17379 if (row) row.push(item);
17380 else rows.push([item]);
17381 }
17382 return rows;
17383 }
17384 function getMaxRowLength(array) {
17385 let maxLength = 0;
17386 for (const { length } of array) if (length > maxLength) maxLength = length;
17387 return maxLength;
17388 }
17389 function createEmptyItem(rowId) {
17390 return {
17391 id: "__EMPTY_ITEM__",
17392 disabled: true,
17393 rowId
17394 };
17395 }
17396 function normalizeRows(rows, activeId, focusShift) {
17397 const maxLength = getMaxRowLength(rows);
17398 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17399 const item = row[i2];
17400 if (!item || focusShift && item.disabled) {
17401 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
17402 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17403 }
17404 }
17405 return rows;
17406 }
17407 function verticalizeItems(items) {
17408 const rows = groupItemsByRows(items);
17409 const maxLength = getMaxRowLength(rows);
17410 const verticalized = [];
17411 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17412 const item = row[i2];
17413 if (item) verticalized.push({
17414 ...item,
17415 rowId: item.rowId ? `${i2}` : void 0
17416 });
17417 }
17418 return verticalized;
17419 }
17420 function createCompositeStore(props = {}) {
17421 const syncState = props.store?.getState();
17422 const collection = createCollectionStore(props);
17423 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17424 const composite = createStore({
17425 ...collection.getState(),
17426 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17427 activeId,
17428 baseElement: defaultValue(syncState?.baseElement, null),
17429 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17430 moves: defaultValue(syncState?.moves, 0),
17431 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17432 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17433 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17434 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17435 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17436 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17437 }, collection, props.store);
17438 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17439 composite.setState("activeId", (activeId2) => {
17440 if (activeId2 !== void 0) return activeId2;
17441 return findFirstEnabledItem(state.renderedItems)?.id;
17442 });
17443 }));
17444 const getNextId = (direction = "next", options = {}) => {
17445 const defaultState = composite.getState();
17446 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;
17447 const isVerticalDirection = direction === "up" || direction === "down";
17448 const isNextDirection = direction === "next" || direction === "down";
17449 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17450 const canShift = focusShift && !skip;
17451 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
17452 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
17453 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
17454 const activeItem2 = renderedItems[activeIndex2];
17455 if (activeItem2) {
17456 const step = canReverse ? -1 : 1;
17457 const nextId = findEnabledItemId({
17458 items: renderedItems,
17459 fromIndex: activeIndex2 + step,
17460 step,
17461 rowId: activeItem2.rowId,
17462 excludeId: activeId2
17463 });
17464 if (nextId !== void 0) return nextId;
17465 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17466 return findEnabledItemId({
17467 items: renderedItems,
17468 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17469 step,
17470 rowId: activeItem2.rowId,
17471 excludeId: activeId2
17472 });
17473 }
17474 }
17475 }
17476 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17477 items = canReverse ? reverseArray(items) : items;
17478 items = isVerticalDirection ? verticalizeItems(items) : items;
17479 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17480 const activeItem = items.find((item) => item.id === activeId2);
17481 if (!activeItem) return findFirstEnabledItem(items)?.id;
17482 const isGrid2 = items.some((item) => item.rowId);
17483 const activeIndex = items.indexOf(activeItem);
17484 const nextItems = items.slice(activeIndex + 1);
17485 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17486 if (skip) {
17487 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17488 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17489 }
17490 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17491 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17492 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17493 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17494 if (canWrap) {
17495 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17496 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17497 }
17498 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17499 if (!nextItem && hasNullItem) return null;
17500 return nextItem?.id;
17501 };
17502 const getNextIdFromOptions = (direction, options) => {
17503 if (typeof options === "number") return getNextId(direction, { skip: options });
17504 return getNextId(direction, options);
17505 };
17506 return {
17507 ...collection,
17508 ...composite,
17509 setBaseElement: (element) => composite.setState("baseElement", element),
17510 setActiveId: (id) => composite.setState("activeId", id),
17511 move: (id) => {
17512 if (id === void 0) return;
17513 composite.setState("activeId", id);
17514 composite.setState("moves", (moves) => moves + 1);
17515 },
17516 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17517 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17518 next: (options) => getNextIdFromOptions("next", options),
17519 previous: (options) => getNextIdFromOptions("previous", options),
17520 down: (options) => getNextIdFromOptions("down", options),
17521 up: (options) => getNextIdFromOptions("up", options)
17522 };
17523 }
17524
17525 // node_modules/@ariakit/react-components/dist/composite/utils.js
17526 var findFirstEnabledItem2 = findFirstEnabledItem;
17527 var groupItemsByRows2 = groupItemsByRows;
17528 function getEnabledItem(store, id) {
17529 if (!id) return null;
17530 return store.item(id) || null;
17531 }
17532 function selectTextField(element, collapseToEnd = false) {
17533 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17534 else if (element.isContentEditable) {
17535 const selection = getDocument(element).getSelection();
17536 selection?.selectAllChildren(element);
17537 if (collapseToEnd) selection?.collapseToEnd();
17538 }
17539 }
17540 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17541 function focusSilently(element) {
17542 element[FOCUS_SILENTLY] = true;
17543 element.focus({ preventScroll: true });
17544 }
17545 function silentlyFocused(element) {
17546 const isSilentlyFocused = element[FOCUS_SILENTLY];
17547 delete element[FOCUS_SILENTLY];
17548 return isSilentlyFocused;
17549 }
17550 function isItem(store, element, exclude) {
17551 if (!element) return false;
17552 if (element === exclude) return false;
17553 const item = store.item(element.id);
17554 if (!item) return false;
17555 if (exclude && item.element === exclude) return false;
17556 return true;
17557 }
17558
17559 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17560 var import_react13 = __toESM(require_react(), 1);
17561 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17562
17563 // node_modules/@ariakit/react-store/dist/index.js
17564 var React48 = __toESM(require_react(), 1);
17565 var import_shim2 = __toESM(require_shim(), 1);
17566 var noopSubscribe = () => () => {
17567 };
17568 function useStoreState(store, keyOrSelector = identity) {
17569 const storeSubscribe = React48.useCallback((callback) => {
17570 if (!store) return noopSubscribe();
17571 return subscribe(store, null, callback);
17572 }, [store]);
17573 const getSnapshot = () => {
17574 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17575 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17576 const state = store?.getState();
17577 if (selector2) return selector2(state);
17578 if (!state) return;
17579 if (!key) return;
17580 if (!hasOwnProperty(state, key)) return;
17581 return state[key];
17582 };
17583 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17584 }
17585 function useStoreStateObject(store, object) {
17586 const objRef = React48.useRef({});
17587 const storeSubscribe = React48.useCallback((callback) => {
17588 if (!store) return noopSubscribe();
17589 return subscribe(store, null, callback);
17590 }, [store]);
17591 const getSnapshot = () => {
17592 const state = store?.getState();
17593 let updated = false;
17594 const obj = objRef.current;
17595 for (const prop in object) {
17596 const keyOrSelector = object[prop];
17597 if (typeof keyOrSelector === "function") {
17598 const value = keyOrSelector(state);
17599 if (!Object.is(value, obj[prop])) {
17600 obj[prop] = value;
17601 updated = true;
17602 }
17603 }
17604 if (typeof keyOrSelector === "string") {
17605 if (!state) continue;
17606 if (!hasOwnProperty(state, keyOrSelector)) continue;
17607 const value = state[keyOrSelector];
17608 if (!Object.is(value, obj[prop])) {
17609 obj[prop] = value;
17610 updated = true;
17611 }
17612 }
17613 }
17614 if (updated) objRef.current = { ...obj };
17615 return objRef.current;
17616 };
17617 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17618 }
17619 function useStoreProps(store, props, key, setKey) {
17620 const value = hasOwnProperty(props, key) ? props[key] : void 0;
17621 const propsRef = useLiveRef({
17622 value,
17623 setValue: setKey ? props[setKey] : void 0
17624 });
17625 useSafeLayoutEffect(() => {
17626 return sync(store, [key], (state, prev) => {
17627 const { value: value2, setValue } = propsRef.current;
17628 if (!setValue) return;
17629 if (state[key] === prev[key]) return;
17630 if (state[key] === value2) return;
17631 setValue(state[key]);
17632 });
17633 }, [store, key]);
17634 useSafeLayoutEffect(() => {
17635 if (value === void 0) return;
17636 store.setState(key, value);
17637 return batch(store, [key], () => {
17638 if (value === void 0) return;
17639 store.setState(key, value);
17640 });
17641 });
17642 }
17643 function useStore2(createStore2, props) {
17644 const [store, setStore] = React48.useState(() => createStore2(props));
17645 useSafeLayoutEffect(() => init(store), [store]);
17646 const useState43 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17647 return [React48.useMemo(() => ({
17648 ...store,
17649 useState: useState43
17650 }), [store, useState43]), useEvent(() => {
17651 setStore((store2) => createStore2({
17652 ...props,
17653 ...store2.getState()
17654 }));
17655 })];
17656 }
17657
17658 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17659 var TagName4 = "button";
17660 function isEditableElement(element) {
17661 if (isTextbox(element)) return true;
17662 return element.tagName === "INPUT" && !isButton(element);
17663 }
17664 function getNextPageOffset(scrollingElement, pageUp = false) {
17665 const height = scrollingElement.clientHeight;
17666 const { top } = scrollingElement.getBoundingClientRect();
17667 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17668 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17669 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17670 return pageOffset;
17671 }
17672 function getItemOffset(itemElement, pageUp = false) {
17673 const { top } = itemElement.getBoundingClientRect();
17674 if (pageUp) return top + itemElement.clientHeight;
17675 return top;
17676 }
17677 function findNextPageItemId(element, store, next, pageUp = false) {
17678 if (!store) return;
17679 if (!next) return;
17680 const { renderedItems } = store.getState();
17681 const scrollingElement = getScrollingElement(element);
17682 if (!scrollingElement) return;
17683 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17684 let id;
17685 let prevDifference;
17686 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17687 const previousId = id;
17688 id = next(i2);
17689 if (!id) break;
17690 if (id === previousId) continue;
17691 const itemElement = getEnabledItem(store, id)?.element;
17692 if (!itemElement) continue;
17693 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17694 const absDifference = Math.abs(difference);
17695 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17696 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17697 break;
17698 }
17699 prevDifference = absDifference;
17700 }
17701 return id;
17702 }
17703 function targetIsAnotherItem(event, store) {
17704 if (isSelfTarget(event)) return false;
17705 return isItem(store, event.target);
17706 }
17707 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17708 const context = useCompositeScopedContext();
17709 store = store || context;
17710 const id = useId4(props.id);
17711 const ref = (0, import_react13.useRef)(null);
17712 const row = (0, import_react13.useContext)(CompositeRowContext);
17713 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17714 const shouldRegisterItem = props.shouldRegisterItem;
17715 const getRowId = (state) => {
17716 if (rowIdProp) return rowIdProp;
17717 if (!state) return;
17718 if (!row?.baseElement) return;
17719 if (row.baseElement !== state.baseElement) return;
17720 return row.id;
17721 };
17722 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17723 rowId: getRowId,
17724 baseElement(state) {
17725 return state?.baseElement || void 0;
17726 },
17727 isActiveItem(state) {
17728 return !!state && state.activeId === id;
17729 },
17730 ariaSetSize(state) {
17731 if (ariaSetSizeProp != null) return ariaSetSizeProp;
17732 if (!state) return;
17733 if (!row?.ariaSetSize) return;
17734 if (row.baseElement !== state.baseElement) return;
17735 return row.ariaSetSize;
17736 },
17737 ariaPosInSet(state) {
17738 if (ariaPosInSetProp != null) return ariaPosInSetProp;
17739 if (!state) return;
17740 if (!row?.ariaPosInSet) return;
17741 if (row.baseElement !== state.baseElement) return;
17742 const rowId2 = getRowId(state);
17743 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17744 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17745 },
17746 isTabbable(state) {
17747 if (!state?.renderedItems.length) return true;
17748 if (state.virtualFocus) return false;
17749 if (tabbable2) return true;
17750 if (state.activeId === null) return false;
17751 const item = store?.item(state.activeId);
17752 if (item?.disabled) return true;
17753 if (!item?.element) return true;
17754 return state.activeId === id;
17755 }
17756 });
17757 const getItem = (0, import_react13.useCallback)((item) => {
17758 const nextItem = {
17759 ...item,
17760 id: id || item.id,
17761 rowId,
17762 disabled: trulyDisabled,
17763 children: item.element?.textContent
17764 };
17765 if (getItemProp) return getItemProp(nextItem);
17766 return nextItem;
17767 }, [
17768 id,
17769 rowId,
17770 trulyDisabled,
17771 getItemProp
17772 ]);
17773 const onFocusProp = props.onFocus;
17774 const hasFocusedComposite = (0, import_react13.useRef)(false);
17775 const cancelScheduledFocusRedirectRef = (0, import_react13.useRef)(null);
17776 const onFocus = useEvent((event) => {
17777 onFocusProp?.(event);
17778 if (event.defaultPrevented) return;
17779 if (isPortalEvent(event)) return;
17780 if (!id) return;
17781 if (!store) return;
17782 if (targetIsAnotherItem(event, store)) return;
17783 const { virtualFocus, baseElement: baseElement2 } = store.getState();
17784 store.setActiveId(id);
17785 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17786 if (!virtualFocus) return;
17787 if (!isSelfTarget(event)) return;
17788 if (isEditableElement(event.currentTarget)) return;
17789 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17790 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17791 block: "nearest",
17792 inline: "nearest"
17793 });
17794 hasFocusedComposite.current = true;
17795 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17796 else baseElement3.focus();
17797 };
17798 if (baseElement2?.isConnected) {
17799 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17800 return;
17801 }
17802 if (shouldRegisterItem === false) return;
17803 const { currentTarget, relatedTarget } = event;
17804 const cancelScheduledFocusRedirect = () => {
17805 cancelScheduledFocusRedirectRef.current?.();
17806 cancelScheduledFocusRedirectRef.current = null;
17807 };
17808 cancelScheduledFocusRedirect();
17809 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17810 if (getActiveElement(currentTarget) !== currentTarget) {
17811 cancelScheduledFocusRedirect();
17812 return;
17813 }
17814 const state = store.getState();
17815 const nextBaseElement = state.baseElement;
17816 if (!nextBaseElement?.isConnected) return;
17817 cancelScheduledFocusRedirect();
17818 if (!state.virtualFocus) return;
17819 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17820 });
17821 });
17822 const onBlurCaptureProp = props.onBlurCapture;
17823 const onBlurCapture = useEvent((event) => {
17824 onBlurCaptureProp?.(event);
17825 if (event.defaultPrevented) return;
17826 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17827 hasFocusedComposite.current = false;
17828 event.preventDefault();
17829 event.stopPropagation();
17830 }
17831 });
17832 const onKeyDownProp = props.onKeyDown;
17833 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17834 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17835 const onKeyDown = useEvent((event) => {
17836 onKeyDownProp?.(event);
17837 if (event.defaultPrevented) return;
17838 if (!isSelfTarget(event)) return;
17839 if (!store) return;
17840 const { currentTarget } = event;
17841 const state = store.getState();
17842 const isGrid2 = !!store.item(id)?.rowId;
17843 const isVertical = state.orientation !== "horizontal";
17844 const isHorizontal = state.orientation !== "vertical";
17845 const canHomeEnd = () => {
17846 if (isGrid2) return true;
17847 if (isHorizontal) return true;
17848 if (!state.baseElement) return true;
17849 if (!isTextField(state.baseElement)) return true;
17850 return false;
17851 };
17852 const action = {
17853 ArrowUp: (isGrid2 || isVertical) && store.up,
17854 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17855 ArrowDown: (isGrid2 || isVertical) && store.down,
17856 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17857 Home: () => {
17858 if (!canHomeEnd()) return;
17859 if (!isGrid2 || event.ctrlKey) return store?.first();
17860 return store?.previous(-1);
17861 },
17862 End: () => {
17863 if (!canHomeEnd()) return;
17864 if (!isGrid2 || event.ctrlKey) return store?.last();
17865 return store?.next(-1);
17866 },
17867 PageUp: () => {
17868 return findNextPageItemId(currentTarget, store, store?.up, true);
17869 },
17870 PageDown: () => {
17871 return findNextPageItemId(currentTarget, store, store?.down);
17872 }
17873 }[event.key];
17874 if (action) {
17875 if (isTextbox(currentTarget)) {
17876 const selection = getTextboxSelection(currentTarget);
17877 const isLeft = isHorizontal && event.key === "ArrowLeft";
17878 const isRight = isHorizontal && event.key === "ArrowRight";
17879 const isUp = isVertical && event.key === "ArrowUp";
17880 const isDown = isVertical && event.key === "ArrowDown";
17881 if (isRight || isDown) {
17882 const { length: valueLength } = getTextboxValue(currentTarget);
17883 if (selection.end !== valueLength) return;
17884 } else if ((isLeft || isUp) && selection.start !== 0) return;
17885 }
17886 const nextId = action();
17887 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17888 if (!moveOnKeyPressProp(event)) return;
17889 event.preventDefault();
17890 store.move(nextId);
17891 }
17892 }
17893 });
17894 const providerValue = (0, import_react13.useMemo)(() => ({
17895 id,
17896 baseElement
17897 }), [id, baseElement]);
17898 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, {
17899 value: providerValue,
17900 children: element
17901 }), [providerValue]);
17902 props = {
17903 "data-active-item": isActiveItem || void 0,
17904 ...props,
17905 id,
17906 ref: useMergeRefs(ref, props.ref),
17907 tabIndex: isTabbable ? props.tabIndex : -1,
17908 onFocus,
17909 onBlurCapture,
17910 onKeyDown
17911 };
17912 props = useCommand(props);
17913 props = useCollectionItem({
17914 store,
17915 ...props,
17916 getItem,
17917 shouldRegisterItem: id ? shouldRegisterItem : false
17918 });
17919 return removeUndefinedValues({
17920 ...props,
17921 "aria-setsize": ariaSetSize,
17922 "aria-posinset": ariaPosInSet
17923 });
17924 });
17925 var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
17926 return createElement3(TagName4, useCompositeItem(props));
17927 }));
17928
17929 // node_modules/@ariakit/react-components/dist/composite/composite.js
17930 var import_react14 = __toESM(require_react(), 1);
17931 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17932 var TagName5 = "div";
17933 function isGrid(items) {
17934 return items.some((item) => !!item.rowId);
17935 }
17936 function isPrintableKey(event) {
17937 const target = event.target;
17938 if (target && !isTextField(target)) return false;
17939 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17940 }
17941 function isModifierKey(event) {
17942 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17943 }
17944 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17945 return useEvent((event) => {
17946 onKeyboardEvent?.(event);
17947 if (event.defaultPrevented) return;
17948 if (event.isPropagationStopped()) return;
17949 if (!isSelfTarget(event)) return;
17950 if (isModifierKey(event)) return;
17951 if (isPrintableKey(event)) return;
17952 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17953 if (!activeElement2) return;
17954 const { view, ...eventInit } = event;
17955 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17956 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17957 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17958 });
17959 }
17960 function findFirstEnabledItemInTheLastRow(items) {
17961 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
17962 }
17963 function withBaseScrollPreserved(store, callback) {
17964 const { virtualFocus, baseElement } = store.getState();
17965 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17966 callback();
17967 return;
17968 }
17969 const savedScrollLeft = baseElement.scrollLeft;
17970 const savedScrollTop = baseElement.scrollTop;
17971 callback();
17972 baseElement.scrollLeft = savedScrollLeft;
17973 baseElement.scrollTop = savedScrollTop;
17974 }
17975 function useScheduleFocus(store) {
17976 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
17977 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
17978 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
17979 (0, import_react14.useEffect)(() => {
17980 const activeElement2 = activeItem?.element;
17981 if (!scheduled) return;
17982 if (!activeElement2) return;
17983 setScheduled(false);
17984 withBaseScrollPreserved(store, () => {
17985 activeElement2.focus({ preventScroll: true });
17986 });
17987 }, [
17988 store,
17989 activeItem,
17990 scheduled
17991 ]);
17992 return schedule;
17993 }
17994 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
17995 const moves = useStoreState(store, "moves");
17996 const baseElement = useStoreState(store, "baseElement");
17997 (0, import_react14.useEffect)(() => {
17998 if (!moves) return;
17999 if (!focusOnMove) return;
18000 const { activeId } = store.getState();
18001 const itemElement = getEnabledItem(store, activeId)?.element;
18002 if (!itemElement) return;
18003 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
18004 }, [
18005 store,
18006 moves,
18007 focusOnMove
18008 ]);
18009 useSafeLayoutEffect(() => {
18010 if (!moves) return;
18011 if (!baseElement) return;
18012 const { activeId } = store.getState();
18013 if (!(activeId === null)) return;
18014 const previousElement = previousElementRef.current;
18015 previousElementRef.current = null;
18016 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
18017 if (!hasFocus(baseElement)) baseElement.focus();
18018 }, [
18019 store,
18020 moves,
18021 baseElement
18022 ]);
18023 return null;
18024 });
18025 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
18026 const context = useCompositeProviderContext();
18027 store = store || context;
18028 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
18029 const ref = (0, import_react14.useRef)(null);
18030 const previousElementRef = (0, import_react14.useRef)(null);
18031 const scheduleFocus = useScheduleFocus(store);
18032 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
18033 const virtualFocus = useStoreState(store, "virtualFocus");
18034 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
18035 useSafeLayoutEffect(() => {
18036 if (!store) return;
18037 if (!composite) return;
18038 if (!virtualFocus) return;
18039 const previousElement = previousElementRef.current;
18040 previousElementRef.current = null;
18041 if (!previousElement) return;
18042 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
18043 if (relatedTarget === previousElement) return;
18044 fireBlurEvent(previousElement, { relatedTarget });
18045 }, [
18046 store,
18047 activeId,
18048 virtualFocus,
18049 composite
18050 ]);
18051 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
18052 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
18053 const onFocusCaptureProp = props.onFocusCapture;
18054 const onFocusCapture = useEvent((event) => {
18055 onFocusCaptureProp?.(event);
18056 if (event.defaultPrevented) return;
18057 if (!store) return;
18058 const { virtualFocus: virtualFocus2 } = store.getState();
18059 if (!virtualFocus2) return;
18060 const previousActiveElement = event.relatedTarget;
18061 const isSilentlyFocused = silentlyFocused(event.currentTarget);
18062 if (isSelfTarget(event) && isSilentlyFocused) {
18063 event.stopPropagation();
18064 previousElementRef.current = previousActiveElement;
18065 }
18066 });
18067 const onFocusProp = props.onFocus;
18068 const onFocus = useEvent((event) => {
18069 onFocusProp?.(event);
18070 if (event.defaultPrevented) return;
18071 if (!composite) return;
18072 if (!store) return;
18073 const { relatedTarget } = event;
18074 const { virtualFocus: virtualFocus2 } = store.getState();
18075 if (virtualFocus2) {
18076 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
18077 } else if (isSelfTarget(event)) store.setActiveId(null);
18078 });
18079 const onBlurCaptureProp = props.onBlurCapture;
18080 const onBlurCapture = useEvent((event) => {
18081 onBlurCaptureProp?.(event);
18082 if (event.defaultPrevented) return;
18083 if (!store) return;
18084 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
18085 if (!virtualFocus2) return;
18086 const activeElement2 = getEnabledItem(store, activeId2)?.element;
18087 const nextActiveElement = event.relatedTarget;
18088 const nextActiveElementIsItem = isItem(store, nextActiveElement);
18089 const previousElement = previousElementRef.current;
18090 previousElementRef.current = null;
18091 if (isSelfTarget(event) && nextActiveElementIsItem) {
18092 if (nextActiveElement === activeElement2) {
18093 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
18094 } else if (activeElement2) fireBlurEvent(activeElement2, event);
18095 else if (previousElement) fireBlurEvent(previousElement, event);
18096 event.stopPropagation();
18097 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
18098 });
18099 const onKeyDownProp = props.onKeyDown;
18100 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18101 const onKeyDown = useEvent((event) => {
18102 onKeyDownProp?.(event);
18103 if (event.nativeEvent.isComposing) return;
18104 if (event.defaultPrevented) return;
18105 if (!store) return;
18106 if (!isSelfTarget(event)) return;
18107 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
18108 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
18109 const isVertical = orientation !== "horizontal";
18110 const isHorizontal = orientation !== "vertical";
18111 const grid = isGrid(renderedItems);
18112 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
18113 const up = () => {
18114 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
18115 return store?.last();
18116 };
18117 const action = {
18118 ArrowUp: (grid || isVertical) && up,
18119 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
18120 ArrowDown: (grid || isVertical) && store.first,
18121 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
18122 Home: store.first,
18123 End: store.last,
18124 PageUp: store.first,
18125 PageDown: store.last
18126 }[event.key];
18127 if (action) {
18128 const id = action();
18129 if (id !== void 0) {
18130 if (!moveOnKeyPressProp(event)) return;
18131 event.preventDefault();
18132 store.move(id);
18133 }
18134 }
18135 });
18136 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(CompositeScopedContextProvider, {
18137 value: store,
18138 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeFocusOnMove, {
18139 store,
18140 focusOnMove,
18141 previousElementRef
18142 })]
18143 }), [
18144 store,
18145 composite,
18146 focusOnMove
18147 ]);
18148 props = {
18149 "aria-activedescendant": useStoreState(store, (state) => {
18150 if (!store) return;
18151 if (!composite) return;
18152 if (!state.virtualFocus) return;
18153 return getEnabledItem(store, state.activeId)?.id;
18154 }),
18155 ...props,
18156 ref: useMergeRefs(ref, setBaseElement, props.ref),
18157 onKeyDownCapture,
18158 onKeyUpCapture,
18159 onFocusCapture,
18160 onFocus,
18161 onBlurCapture,
18162 onKeyDown
18163 };
18164 props = useFocusable({
18165 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
18166 ...props
18167 });
18168 return props;
18169 });
18170 var Composite6 = forwardRef21(function Composite7(props) {
18171 return createElement3(TagName5, useComposite(props));
18172 });
18173
18174 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
18175 var ctx3 = createStoreContext();
18176 var useDisclosureContext = ctx3.useContext;
18177 var useDisclosureScopedContext = ctx3.useScopedContext;
18178 var useDisclosureProviderContext = ctx3.useProviderContext;
18179 var DisclosureContextProvider = ctx3.ContextProvider;
18180 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
18181
18182 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
18183 var import_react15 = __toESM(require_react(), 1);
18184 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
18185 var useDialogContext = ctx4.useContext;
18186 var useDialogScopedContext = ctx4.useScopedContext;
18187 var useDialogProviderContext = ctx4.useProviderContext;
18188 var DialogContextProvider = ctx4.ContextProvider;
18189 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
18190 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
18191 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
18192
18193 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
18194 var import_react16 = __toESM(require_react(), 1);
18195 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18196 var import_react_dom4 = __toESM(require_react_dom(), 1);
18197 var TagName6 = "div";
18198 function afterTimeout(timeoutMs, cb) {
18199 const timeoutId = setTimeout(cb, timeoutMs);
18200 return () => clearTimeout(timeoutId);
18201 }
18202 function parseCSSTime(time) {
18203 const value = time?.trim() || "0s";
18204 const multiplier = value.endsWith("ms") ? 1 : 1e3;
18205 const parsed = Number.parseFloat(value) * multiplier;
18206 return Number.isNaN(parsed) ? 0 : parsed;
18207 }
18208 function getEndTime(names, delays, durations) {
18209 const nameList = names.split(",");
18210 const delayList = delays.split(",");
18211 const durationList = durations.split(",");
18212 let endTime = 0;
18213 for (const [index2, name] of nameList.entries()) {
18214 if (name.trim() === "none") continue;
18215 const delay = parseCSSTime(delayList[index2 % delayList.length]);
18216 const duration = parseCSSTime(durationList[index2 % durationList.length]);
18217 endTime = Math.max(endTime, delay + duration);
18218 }
18219 return endTime;
18220 }
18221 function getElementEndTime(element) {
18222 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
18223 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
18224 }
18225 function isHidden(mounted, hidden, alwaysVisible) {
18226 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
18227 }
18228 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
18229 const context = useDisclosureProviderContext();
18230 store = store || context;
18231 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
18232 const ref = (0, import_react16.useRef)(null);
18233 const id = useId4(props.id);
18234 const [transition, setTransition] = (0, import_react16.useState)(null);
18235 const open = useStoreState(store, "open");
18236 const mounted = useStoreState(store, "mounted");
18237 const animated = useStoreState(store, "animated");
18238 const contentElement = useStoreState(store, "contentElement");
18239 const otherElement = useStoreState(store.disclosure, "contentElement");
18240 const hasClosedRef = (0, import_react16.useRef)(false);
18241 useSafeLayoutEffect(() => {
18242 if (!ref.current) return;
18243 store?.setContentElement(ref.current);
18244 }, [store]);
18245 useSafeLayoutEffect(() => {
18246 let previousAnimated;
18247 store?.setState("animated", (animated2) => {
18248 previousAnimated = animated2;
18249 return true;
18250 });
18251 return () => {
18252 if (previousAnimated === void 0) return;
18253 store?.setState("animated", previousAnimated);
18254 };
18255 }, [store]);
18256 useSafeLayoutEffect(() => {
18257 if (!animated) {
18258 if (!open) {
18259 hasClosedRef.current = true;
18260 setTransition(null);
18261 } else if (hasClosedRef.current) {
18262 hasClosedRef.current = false;
18263 setTransition("enter");
18264 }
18265 return;
18266 }
18267 if (!contentElement?.isConnected) {
18268 setTransition(null);
18269 return;
18270 }
18271 return afterPaint(() => {
18272 setTransition(open ? "enter" : mounted ? "leave" : null);
18273 });
18274 }, [
18275 animated,
18276 contentElement,
18277 open,
18278 mounted
18279 ]);
18280 useSafeLayoutEffect(() => {
18281 if (!store) return;
18282 if (!animated) return;
18283 if (!transition) return;
18284 if (!contentElement) return;
18285 const stopAnimation = () => store?.setState("animating", false);
18286 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
18287 if (transition === "leave" && open) return;
18288 if (transition === "enter" && !open) return;
18289 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
18290 const elements = [contentElement];
18291 if (otherElement) elements.push(otherElement);
18292 const relatedElement = otherElementRef?.current;
18293 if (relatedElement) elements.push(relatedElement);
18294 const timeout = Math.max(...elements.map(getElementEndTime));
18295 if (!timeout) {
18296 if (transition === "enter") store.setState("animated", false);
18297 stopAnimation();
18298 return;
18299 }
18300 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
18301 }, [
18302 store,
18303 animated,
18304 contentElement,
18305 otherElement,
18306 otherElementRef,
18307 open,
18308 transition
18309 ]);
18310 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, {
18311 value: store,
18312 children: element
18313 }), [store]);
18314 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18315 const styleProp = props.style;
18316 const style = (0, import_react16.useMemo)(() => {
18317 if (hidden) return {
18318 ...styleProp,
18319 display: "none"
18320 };
18321 return styleProp;
18322 }, [hidden, styleProp]);
18323 props = {
18324 "data-open": open || void 0,
18325 "data-enter": transition === "enter" || void 0,
18326 "data-leave": transition === "leave" || void 0,
18327 hidden,
18328 ...props,
18329 id,
18330 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
18331 style
18332 };
18333 return removeUndefinedValues(props);
18334 });
18335 var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
18336 return createElement3(TagName6, useDisclosureContent(props));
18337 });
18338 var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
18339 const context = useDisclosureProviderContext();
18340 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
18341 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
18342 });
18343
18344 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
18345 function createDisclosureStore(props = {}) {
18346 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
18347 throwOnConflictingProps(props, store);
18348 const syncState = store?.getState();
18349 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
18350 const animated = defaultValue(props.animated, syncState?.animated, false);
18351 const disclosure = createStore({
18352 open,
18353 animated,
18354 animating: !!animated && open,
18355 mounted: open,
18356 contentElement: defaultValue(syncState?.contentElement, null),
18357 disclosureElement: defaultValue(syncState?.disclosureElement, null)
18358 }, store);
18359 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
18360 if (state.animated) return;
18361 disclosure.setState("animating", false);
18362 }));
18363 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
18364 if (!disclosure.getState().animated) return;
18365 disclosure.setState("animating", true);
18366 }));
18367 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
18368 disclosure.setState("mounted", state.open || state.animating);
18369 }));
18370 return {
18371 ...disclosure,
18372 disclosure: props.disclosure,
18373 setOpen: (value) => disclosure.setState("open", value),
18374 show: () => disclosure.setState("open", true),
18375 hide: () => disclosure.setState("open", false),
18376 toggle: () => disclosure.setState("open", (open2) => !open2),
18377 stopAnimation: () => disclosure.setState("animating", false),
18378 setContentElement: (value) => disclosure.setState("contentElement", value),
18379 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
18380 };
18381 }
18382
18383 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
18384 function useDisclosureStoreProps(store, update2, props) {
18385 useUpdateEffect(update2, [props.store, props.disclosure]);
18386 useStoreProps(store, props, "open", "setOpen");
18387 useStoreProps(store, props, "mounted", "setMounted");
18388 useStoreProps(store, props, "animated");
18389 return Object.assign(store, { disclosure: props.disclosure });
18390 }
18391
18392 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
18393 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
18394 var usePopoverContext = ctx5.useContext;
18395 var usePopoverScopedContext = ctx5.useScopedContext;
18396 var usePopoverProviderContext = ctx5.useProviderContext;
18397 var PopoverContextProvider = ctx5.ContextProvider;
18398 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
18399
18400 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
18401 var import_react17 = __toESM(require_react(), 1);
18402 var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
18403 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
18404 var useComboboxContext = ctx6.useContext;
18405 var useComboboxScopedContext = ctx6.useScopedContext;
18406 var useComboboxProviderContext = ctx6.useProviderContext;
18407 var ComboboxContextProvider = ctx6.ContextProvider;
18408 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18409 var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
18410 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
18411
18412 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
18413 function useCollectionStoreProps(store, update2, props) {
18414 useUpdateEffect(update2, [props.store]);
18415 useStoreProps(store, props, "items", "setItems");
18416 return store;
18417 }
18418
18419 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
18420 function useCompositeStoreOptions(props) {
18421 return {
18422 id: useId4(props.id),
18423 ...props
18424 };
18425 }
18426 function useCompositeStoreProps(store, update2, props) {
18427 store = useCollectionStoreProps(store, update2, props);
18428 useStoreProps(store, props, "activeId", "setActiveId");
18429 useStoreProps(store, props, "includesBaseElement");
18430 useStoreProps(store, props, "virtualFocus");
18431 useStoreProps(store, props, "orientation");
18432 useStoreProps(store, props, "rtl");
18433 useStoreProps(store, props, "focusLoop");
18434 useStoreProps(store, props, "focusWrap");
18435 useStoreProps(store, props, "focusShift");
18436 return store;
18437 }
18438
18439 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
18440 function createDialogStore(props = {}) {
18441 return createDisclosureStore(props);
18442 }
18443
18444 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
18445 function useDialogStoreProps(store, update2, props) {
18446 return useDisclosureStoreProps(store, update2, props);
18447 }
18448
18449 // node_modules/@ariakit/components/dist/popover/popover-store.js
18450 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
18451 const store = mergeStore(props.store, omit2(otherPopover, [
18452 "arrowElement",
18453 "anchorElement",
18454 "contentElement",
18455 "popoverElement",
18456 "disclosureElement"
18457 ]));
18458 throwOnConflictingProps(props, store);
18459 const syncState = store?.getState();
18460 const dialog = createDialogStore({
18461 ...props,
18462 store
18463 });
18464 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18465 const popover = createStore({
18466 ...dialog.getState(),
18467 placement,
18468 currentPlacement: placement,
18469 anchorElement: defaultValue(syncState?.anchorElement, null),
18470 popoverElement: defaultValue(syncState?.popoverElement, null),
18471 arrowElement: defaultValue(syncState?.arrowElement, null),
18472 rendered: /* @__PURE__ */ Symbol("rendered")
18473 }, dialog, store);
18474 return {
18475 ...dialog,
18476 ...popover,
18477 setAnchorElement: (element) => popover.setState("anchorElement", element),
18478 setPopoverElement: (element) => popover.setState("popoverElement", element),
18479 setArrowElement: (element) => popover.setState("arrowElement", element),
18480 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18481 };
18482 }
18483
18484 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18485 function usePopoverStoreProps(store, update2, props) {
18486 useUpdateEffect(update2, [props.popover]);
18487 useStoreProps(store, props, "placement");
18488 return useDialogStoreProps(store, update2, props);
18489 }
18490
18491 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18492 var TagName7 = "div";
18493 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18494 const context = usePopoverProviderContext();
18495 store = store || context;
18496 props = {
18497 ...props,
18498 ref: useMergeRefs(store?.setAnchorElement, props.ref)
18499 };
18500 return props;
18501 });
18502 var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
18503 return createElement3(TagName7, usePopoverAnchor(props));
18504 });
18505
18506 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18507 var import_react18 = __toESM(require_react(), 1);
18508 var TagName8 = "div";
18509 function hoveringInside(event) {
18510 const nextElement = event.relatedTarget;
18511 if (!isElement2(nextElement)) return false;
18512 return contains2(event.currentTarget, nextElement);
18513 }
18514 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18515 function movingToAnotherItem(event) {
18516 const { relatedTarget } = event;
18517 if (!isElement2(relatedTarget)) return false;
18518 let dest = relatedTarget;
18519 do {
18520 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18521 dest = dest.parentElement;
18522 } while (dest);
18523 return false;
18524 }
18525 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18526 const context = useCompositeScopedContext();
18527 store = store || context;
18528 invariant(store, "CompositeHover must be wrapped in a Composite component.");
18529 const isMouseMoving = useIsMouseMoving();
18530 const onMouseMoveProp = props.onMouseMove;
18531 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18532 const onMouseMove = useEvent((event) => {
18533 onMouseMoveProp?.(event);
18534 if (event.defaultPrevented) return;
18535 if (!isMouseMoving()) return;
18536 if (!focusOnHoverProp(event)) return;
18537 if (!hasFocusWithin(event.currentTarget)) {
18538 const baseElement = store?.getState().baseElement;
18539 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18540 }
18541 store?.setActiveId(event.currentTarget.id);
18542 });
18543 const onMouseLeaveProp = props.onMouseLeave;
18544 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18545 const onMouseLeave = useEvent((event) => {
18546 onMouseLeaveProp?.(event);
18547 if (event.defaultPrevented) return;
18548 if (!isMouseMoving()) return;
18549 if (hoveringInside(event)) return;
18550 if (movingToAnotherItem(event)) return;
18551 if (!focusOnHoverProp(event)) return;
18552 if (!blurOnHoverEndProp(event)) return;
18553 store?.setActiveId(null);
18554 store?.getState().baseElement?.focus();
18555 });
18556 const ref = (0, import_react18.useCallback)((element) => {
18557 if (!element) return;
18558 element[symbol2] = true;
18559 }, []);
18560 props = {
18561 ...props,
18562 ref: useMergeRefs(ref, props.ref),
18563 onMouseMove,
18564 onMouseLeave
18565 };
18566 return removeUndefinedValues(props);
18567 });
18568 var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
18569 return createElement3(TagName8, useCompositeHover(props));
18570 }));
18571
18572 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18573 var import_react19 = __toESM(require_react(), 1);
18574 var TagName9 = "input";
18575 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18576 if (!autoSelect) return false;
18577 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18578 }
18579 function hasCompletionString(value, activeValue) {
18580 if (!activeValue) return false;
18581 if (value == null) return false;
18582 const normalizedValue = normalizeString(value);
18583 const normalizedActiveValue = normalizeString(activeValue);
18584 if (normalizedValue.length !== value.length) return false;
18585 if (normalizedActiveValue.length !== activeValue.length) return false;
18586 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18587 }
18588 function isAriaAutoCompleteValue(value) {
18589 return value === "inline" || value === "list" || value === "both" || value === "none";
18590 }
18591 function getDefaultAutoSelectId(items) {
18592 return items.find((item) => {
18593 if (item.disabled) return false;
18594 return item.element?.getAttribute("role") !== "tab";
18595 })?.id;
18596 }
18597 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 }) {
18598 const context = useComboboxProviderContext();
18599 store = store || context;
18600 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18601 const ref = (0, import_react19.useRef)(null);
18602 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18603 const canAutoSelectRef = (0, import_react19.useRef)(false);
18604 const composingRef = (0, import_react19.useRef)(false);
18605 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18606 const inline4 = autoComplete === "inline" || autoComplete === "both";
18607 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
18608 useUpdateLayoutEffect(() => {
18609 if (!inline4) return;
18610 setCanInline(true);
18611 }, [inline4]);
18612 const storeValue = useStoreState(store, "value");
18613 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
18614 (0, import_react19.useEffect)(() => {
18615 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18616 prevSelectedValueRef.current = prev.selectedValue;
18617 });
18618 }, [store]);
18619 const inlineActiveValue = useStoreState(store, (state) => {
18620 if (!inline4) return;
18621 if (!canInline) return;
18622 if (state.activeValue && Array.isArray(state.selectedValue)) {
18623 if (state.selectedValue.includes(state.activeValue)) return;
18624 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18625 }
18626 return state.activeValue;
18627 });
18628 const items = useStoreState(store, "renderedItems");
18629 const open = useStoreState(store, "open");
18630 const contentElement = useStoreState(store, "contentElement");
18631 const value = (0, import_react19.useMemo)(() => {
18632 if (!inline4) return storeValue;
18633 if (!canInline) return storeValue;
18634 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18635 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18636 return storeValue;
18637 }
18638 return inlineActiveValue || storeValue;
18639 }, [
18640 inline4,
18641 canInline,
18642 items,
18643 inlineActiveValue,
18644 autoSelect,
18645 storeValue
18646 ]);
18647 (0, import_react19.useEffect)(() => {
18648 const element = ref.current;
18649 if (!element) return;
18650 const onCompositeItemMove = () => setCanInline(true);
18651 element.addEventListener("combobox-item-move", onCompositeItemMove);
18652 return () => {
18653 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18654 };
18655 }, []);
18656 (0, import_react19.useEffect)(() => {
18657 if (!inline4) return;
18658 if (!canInline) return;
18659 if (!inlineActiveValue) return;
18660 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18661 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18662 let cleanup = noop5;
18663 queueMicrotask(() => {
18664 const element = ref.current;
18665 if (!element) return;
18666 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18667 const nextStart = storeValue.length;
18668 const nextEnd = inlineActiveValue.length;
18669 setSelectionRange(element, nextStart, nextEnd);
18670 cleanup = () => {
18671 if (!hasFocus(element)) return;
18672 const { start, end } = getTextboxSelection(element);
18673 if (start !== nextStart) return;
18674 if (end !== nextEnd) return;
18675 setSelectionRange(element, prevStart, prevEnd);
18676 };
18677 });
18678 return () => cleanup();
18679 }, [
18680 valueUpdated,
18681 inline4,
18682 canInline,
18683 inlineActiveValue,
18684 items,
18685 autoSelect,
18686 storeValue
18687 ]);
18688 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18689 const autoSelectIdRef = (0, import_react19.useRef)(null);
18690 const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
18691 const userScrolledRef = (0, import_react19.useRef)(false);
18692 const isAutoScrollingRef = (0, import_react19.useRef)(false);
18693 (0, import_react19.useEffect)(() => {
18694 if (!open) return;
18695 if (!contentElement) return;
18696 const scrollingElement = getScrollingElement(contentElement);
18697 if (!scrollingElement) return;
18698 const onUserScroll = () => {
18699 canAutoSelectRef.current = false;
18700 userScrolledRef.current = true;
18701 };
18702 const onScroll = () => {
18703 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18704 if (!store) return;
18705 if (!canAutoSelectRef.current) return;
18706 const { activeId } = store.getState();
18707 if (activeId === null) return;
18708 if (activeId === autoSelectIdRef.current) return;
18709 canAutoSelectRef.current = false;
18710 };
18711 const options = {
18712 passive: true,
18713 capture: true
18714 };
18715 scrollingElement.addEventListener("wheel", onUserScroll, options);
18716 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18717 scrollingElement.addEventListener("scroll", onScroll, options);
18718 return () => {
18719 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18720 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18721 scrollingElement.removeEventListener("scroll", onScroll, true);
18722 };
18723 }, [
18724 open,
18725 contentElement,
18726 store
18727 ]);
18728 useSafeLayoutEffect(() => {
18729 userScrolledRef.current = false;
18730 if (!storeValue) return;
18731 if (composingRef.current) return;
18732 canAutoSelectRef.current = true;
18733 }, [storeValue]);
18734 useSafeLayoutEffect(() => {
18735 if (autoSelect !== "always" && open) return;
18736 canAutoSelectRef.current = open;
18737 }, [autoSelect, open]);
18738 useSafeLayoutEffect(() => {
18739 if (open) return;
18740 autoSelectMovedRef.current = void 0;
18741 }, [open]);
18742 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18743 useUpdateEffect(() => {
18744 const canAutoSelect = canAutoSelectRef.current;
18745 if (!store) return;
18746 if (!open) return;
18747 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18748 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18749 if (baseElement && !hasFocus(baseElement)) return;
18750 if (contentElement2?.hasAttribute("data-placing")) {
18751 const observer = new MutationObserver(forceValueUpdate);
18752 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18753 return () => observer.disconnect();
18754 }
18755 if (autoSelect && canAutoSelect) {
18756 const userAutoSelectId = getAutoSelectIdProp(items);
18757 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18758 autoSelectIdRef.current = autoSelectId;
18759 const nextActiveId = autoSelectId ?? null;
18760 const nextActiveValue = store.item(nextActiveId)?.value;
18761 const moved = autoSelectMovedRef.current;
18762 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18763 autoSelectMovedRef.current = {
18764 id: nextActiveId,
18765 value: nextActiveValue
18766 };
18767 store.move(nextActiveId);
18768 } else store.setState("activeValue", nextActiveValue);
18769 } else {
18770 const element = store.item(activeId || store.first())?.element;
18771 if (element && "scrollIntoView" in element) {
18772 isAutoScrollingRef.current = true;
18773 element.scrollIntoView({
18774 block: "nearest",
18775 inline: "nearest"
18776 });
18777 requestAnimationFrame(() => {
18778 isAutoScrollingRef.current = false;
18779 });
18780 }
18781 }
18782 }, [
18783 store,
18784 open,
18785 valueUpdated,
18786 storeValue,
18787 autoSelect,
18788 resetValueOnSelect,
18789 getAutoSelectIdProp,
18790 items
18791 ]);
18792 (0, import_react19.useEffect)(() => {
18793 if (!inline4) return;
18794 const combobox = ref.current;
18795 if (!combobox) return;
18796 const elements = [combobox, contentElement].filter((value2) => !!value2);
18797 const onBlur2 = (event) => {
18798 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18799 };
18800 for (const element of elements) element.addEventListener("focusout", onBlur2);
18801 return () => {
18802 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18803 };
18804 }, [
18805 inline4,
18806 contentElement,
18807 store,
18808 value
18809 ]);
18810 const canShow = (event) => {
18811 return event.currentTarget.value.length >= showMinLength;
18812 };
18813 const onChangeProp = props.onChange;
18814 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18815 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18816 const onChange = useEvent((event) => {
18817 onChangeProp?.(event);
18818 if (event.defaultPrevented) return;
18819 if (!store) return;
18820 const currentTarget = event.currentTarget;
18821 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18822 const nativeEvent = event.nativeEvent;
18823 canAutoSelectRef.current = true;
18824 if (isInputEvent(nativeEvent)) {
18825 if (nativeEvent.isComposing) {
18826 canAutoSelectRef.current = false;
18827 composingRef.current = true;
18828 }
18829 if (inline4) {
18830 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18831 const caretAtEnd = selectionStart === value2.length;
18832 setCanInline(textInserted && caretAtEnd);
18833 }
18834 }
18835 if (setValueOnChangeProp(event)) {
18836 const isSameValue2 = value2 === store.getState().value;
18837 store.setValue(value2);
18838 queueMicrotask(() => {
18839 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18840 });
18841 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18842 }
18843 if (showOnChangeProp(event)) store.show();
18844 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18845 });
18846 const onCompositionEndProp = props.onCompositionEnd;
18847 const onCompositionEnd = useEvent((event) => {
18848 canAutoSelectRef.current = true;
18849 composingRef.current = false;
18850 onCompositionEndProp?.(event);
18851 if (event.defaultPrevented) return;
18852 if (!autoSelect) return;
18853 forceValueUpdate();
18854 });
18855 const onMouseDownProp = props.onMouseDown;
18856 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18857 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18858 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18859 const onMouseDown = useEvent((event) => {
18860 onMouseDownProp?.(event);
18861 if (event.defaultPrevented) return;
18862 if (event.button) return;
18863 if (event.ctrlKey) return;
18864 if (!store) return;
18865 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18866 if (setValueOnClickProp(event)) store.setValue(value);
18867 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18868 });
18869 const onKeyDownProp = props.onKeyDown;
18870 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18871 const onKeyDown = useEvent((event) => {
18872 onKeyDownProp?.(event);
18873 if (!event.repeat) canAutoSelectRef.current = false;
18874 if (event.defaultPrevented) return;
18875 if (!store) return;
18876 const { open: open2 } = store.getState();
18877 if (open2 && event.key === "Enter") {
18878 event.preventDefault();
18879 return;
18880 }
18881 if (event.ctrlKey) return;
18882 if (event.altKey) return;
18883 if (event.shiftKey) return;
18884 if (event.metaKey) return;
18885 if (open2) return;
18886 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18887 if (showOnKeyPressProp(event)) {
18888 event.preventDefault();
18889 store.show();
18890 }
18891 }
18892 });
18893 const onBlurProp = props.onBlur;
18894 const onBlur = useEvent((event) => {
18895 canAutoSelectRef.current = false;
18896 onBlurProp?.(event);
18897 });
18898 const id = useId4(props.id);
18899 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18900 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18901 props = {
18902 role: "combobox",
18903 "aria-autocomplete": ariaAutoComplete,
18904 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18905 "aria-expanded": open,
18906 "aria-controls": contentElement?.id,
18907 "data-active-item": isActiveItem || void 0,
18908 value,
18909 ...props,
18910 id,
18911 ref: useMergeRefs(ref, props.ref),
18912 onChange,
18913 onCompositionEnd,
18914 onMouseDown,
18915 onKeyDown,
18916 onBlur
18917 };
18918 props = useComposite({
18919 store,
18920 focusable: focusable2,
18921 ...props,
18922 moveOnKeyPress: (event) => {
18923 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18924 if (inline4) setCanInline(true);
18925 return true;
18926 }
18927 });
18928 props = usePopoverAnchor({
18929 store,
18930 ...props
18931 });
18932 return {
18933 autoComplete: "off",
18934 ...props
18935 };
18936 });
18937 var Combobox = forwardRef21(function Combobox2(props) {
18938 return createElement3(TagName9, useCombobox(props));
18939 });
18940
18941 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18942 var import_react20 = __toESM(require_react(), 1);
18943 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18944 var TagName10 = "div";
18945 function isSelected(storeValue, itemValue) {
18946 if (itemValue == null) return;
18947 if (storeValue == null) return false;
18948 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18949 return storeValue === itemValue;
18950 }
18951 function getItemRole(popupRole) {
18952 return getItemRoleByPopupRole(popupRole) ?? "option";
18953 }
18954 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18955 const context = useComboboxScopedContext();
18956 store = store || context;
18957 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18958 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18959 resetValueOnSelectState: "resetValueOnSelect",
18960 multiSelectable(state) {
18961 return Array.isArray(state.selectedValue);
18962 },
18963 selected(state) {
18964 return isSelected(state.selectedValue, value);
18965 }
18966 });
18967 const getItem = (0, import_react20.useCallback)((item) => {
18968 const nextItem = {
18969 ...item,
18970 value
18971 };
18972 if (getItemProp) return getItemProp(nextItem);
18973 return nextItem;
18974 }, [value, getItemProp]);
18975 setValueOnClick = setValueOnClick ?? !multiSelectable;
18976 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18977 const onClickProp = props.onClick;
18978 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18979 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18980 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18981 const hideOnClickProp = useBooleanEvent(hideOnClick);
18982 const onClick = useEvent((event) => {
18983 onClickProp?.(event);
18984 if (event.defaultPrevented) return;
18985 if (isDownloading(event)) return;
18986 if (isOpeningInNewTab(event)) return;
18987 if (value != null) {
18988 if (selectValueOnClickProp(event)) {
18989 if (resetValueOnSelectProp(event)) store?.resetValue();
18990 store?.setSelectedValue((prevValue) => {
18991 if (!Array.isArray(prevValue)) return value;
18992 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18993 return [...prevValue, value];
18994 });
18995 }
18996 if (setValueOnClickProp(event)) store?.setValue(value);
18997 }
18998 if (hideOnClickProp(event)) store?.hide();
18999 });
19000 const onKeyDownProp = props.onKeyDown;
19001 const onKeyDown = useEvent((event) => {
19002 onKeyDownProp?.(event);
19003 if (event.defaultPrevented) return;
19004 const baseElement = store?.getState().baseElement;
19005 if (!baseElement) return;
19006 if (hasFocus(baseElement)) return;
19007 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19008 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
19009 const deleteKey = event.key === "Backspace" || event.key === "Delete";
19010 if (printable || paste || deleteKey) {
19011 queueMicrotask(() => baseElement.focus());
19012 if (isTextField(baseElement)) store?.setValue(baseElement.value);
19013 }
19014 });
19015 if (multiSelectable && selected != null) props = {
19016 "aria-selected": selected,
19017 ...props
19018 };
19019 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, {
19020 value,
19021 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, {
19022 value: selected ?? false,
19023 children: element
19024 })
19025 }), [value, selected]);
19026 props = {
19027 role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
19028 children: value,
19029 ...props,
19030 onClick,
19031 onKeyDown
19032 };
19033 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19034 props = useCompositeItem({
19035 store,
19036 ...props,
19037 getItem,
19038 moveOnKeyPress: (event) => {
19039 if (!moveOnKeyPressProp(event)) return false;
19040 const moveEvent = new Event("combobox-item-move");
19041 store?.getState().baseElement?.dispatchEvent(moveEvent);
19042 return true;
19043 }
19044 });
19045 props = useCompositeHover({
19046 store,
19047 focusOnHover,
19048 ...props
19049 });
19050 return props;
19051 });
19052 var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
19053 return createElement3(TagName10, useComboboxItem(props));
19054 }));
19055
19056 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
19057 var import_react21 = __toESM(require_react(), 1);
19058 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
19059 var TagName11 = "span";
19060 function normalizeValue(value) {
19061 return normalizeString(value).toLowerCase();
19062 }
19063 function getOffsets(string, values) {
19064 const offsets = [];
19065 for (const value of values) {
19066 if (!value) continue;
19067 let pos = 0;
19068 const length = value.length;
19069 let index2 = string.indexOf(value, pos);
19070 while (index2 !== -1) {
19071 offsets.push([index2, length]);
19072 pos = index2 + 1;
19073 index2 = string.indexOf(value, pos);
19074 }
19075 }
19076 return offsets;
19077 }
19078 function mergeOverlappingOffsets(offsets) {
19079 offsets.sort(([a2], [b2]) => a2 - b2);
19080 const merged = [];
19081 for (const [offset4, length] of offsets) {
19082 const last = merged[merged.length - 1];
19083 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
19084 else merged.push([offset4, length]);
19085 }
19086 return merged;
19087 }
19088 function getNormalizedIndexes(itemValue) {
19089 const starts = [];
19090 const ends = [];
19091 let index2 = 0;
19092 for (const char of itemValue) {
19093 const normalizedLength = normalizeValue(char).length;
19094 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
19095 starts.push(i2 === 0 ? index2 : -1);
19096 ends.push(index2);
19097 }
19098 index2 += char.length;
19099 }
19100 starts.push(itemValue.length);
19101 ends.push(itemValue.length);
19102 let nextBoundary = itemValue.length;
19103 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
19104 const start = starts[i2];
19105 if (start == null) continue;
19106 if (start === -1) starts[i2] = nextBoundary;
19107 else nextBoundary = start;
19108 }
19109 return {
19110 starts,
19111 ends
19112 };
19113 }
19114 function toOriginalOffsets(itemValue, normalizedOffsets) {
19115 if (!normalizedOffsets.length) return normalizedOffsets;
19116 const { starts, ends } = getNormalizedIndexes(itemValue);
19117 const offsets = [];
19118 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
19119 const start = starts[normalizedOffset];
19120 const end = ends[normalizedOffset + normalizedLength];
19121 if (start == null || end == null) continue;
19122 if (end <= start) continue;
19123 offsets.push([start, end - start]);
19124 }
19125 return offsets;
19126 }
19127 function splitValue(itemValue, userValue) {
19128 if (!itemValue) return itemValue;
19129 if (!userValue) return itemValue;
19130 const userValues = toArray(userValue).map(normalizeValue);
19131 const parts = [];
19132 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {
19133 "data-autocomplete-value": autocomplete ? "" : void 0,
19134 "data-user-value": autocomplete ? void 0 : "",
19135 children: value
19136 }, parts.length);
19137 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
19138 const firstEntry = offsets[0];
19139 if (!firstEntry) {
19140 parts.push(span(itemValue, true));
19141 return parts;
19142 }
19143 const [firstOffset] = firstEntry;
19144 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
19145 const value = itemValue.slice(offset4, offset4 + length);
19146 const nextOffset = offsets[i2 + 1]?.[0];
19147 return [value, itemValue.slice(offset4 + length, nextOffset)];
19148 })].forEach((value, i2) => {
19149 if (!value) return;
19150 parts.push(span(value, i2 % 2 === 0));
19151 });
19152 return parts;
19153 }
19154 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
19155 const context = useComboboxScopedContext();
19156 store = store || context;
19157 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
19158 const itemValue = value ?? itemContext;
19159 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
19160 props = {
19161 children: (0, import_react21.useMemo)(() => {
19162 if (!itemValue) return;
19163 if (!inputValue) return itemValue;
19164 return splitValue(itemValue, inputValue);
19165 }, [itemValue, inputValue]),
19166 ...props
19167 };
19168 return removeUndefinedValues(props);
19169 });
19170 var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
19171 return createElement3(TagName11, useComboboxItemValue(props));
19172 });
19173
19174 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
19175 var TagName12 = "label";
19176 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
19177 const context = useComboboxProviderContext();
19178 store = store || context;
19179 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19180 props = {
19181 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
19182 ...props
19183 };
19184 return removeUndefinedValues(props);
19185 });
19186 var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
19187 return createElement3(TagName12, useComboboxLabel(props));
19188 }));
19189
19190 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
19191 var import_react22 = __toESM(require_react(), 1);
19192 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
19193 var TagName13 = "div";
19194 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
19195 const scopedContext = useComboboxScopedContext(true);
19196 const context = useComboboxContext();
19197 store = store || context;
19198 const scopedContextSameStore = !!store && store === scopedContext;
19199 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19200 const ref = (0, import_react22.useRef)(null);
19201 const id = useId4(props.id);
19202 const mounted = useStoreState(store, "mounted");
19203 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19204 const style = hidden ? {
19205 ...props.style,
19206 display: "none"
19207 } : props.style;
19208 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
19209 const role = useAttribute(ref, "role", props.role);
19210 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
19211 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
19212 const contentElement = useStoreState(store, "contentElement");
19213 useSafeLayoutEffect(() => {
19214 if (!mounted) return;
19215 const element = ref.current;
19216 if (!element) return;
19217 if (contentElement !== element) return;
19218 const callback = () => {
19219 setHasListboxInside(!!element.querySelector("[role='listbox']"));
19220 };
19221 const observer = new MutationObserver(callback);
19222 observer.observe(element, {
19223 subtree: true,
19224 childList: true,
19225 attributeFilter: ["role"]
19226 });
19227 callback();
19228 return () => observer.disconnect();
19229 }, [mounted, contentElement]);
19230 if (!hasListboxInside) props = {
19231 role: "listbox",
19232 "aria-multiselectable": ariaMultiSelectable,
19233 ...props
19234 };
19235 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, {
19236 value: store,
19237 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, {
19238 value: role,
19239 children: element
19240 })
19241 }), [store, role]);
19242 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
19243 props = {
19244 hidden,
19245 ...props,
19246 id,
19247 ref: useMergeRefs(setContentElement, ref, props.ref),
19248 style
19249 };
19250 return removeUndefinedValues(props);
19251 });
19252 var ComboboxList = forwardRef21(function ComboboxList2(props) {
19253 return createElement3(TagName13, useComboboxList(props));
19254 });
19255
19256 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
19257 var import_react23 = __toESM(require_react(), 1);
19258 var TagValueContext = (0, import_react23.createContext)(null);
19259 var TagRemoveIdContext = (0, import_react23.createContext)(null);
19260 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
19261 var useTagContext = ctx7.useContext;
19262 var useTagScopedContext = ctx7.useScopedContext;
19263 var useTagProviderContext = ctx7.useProviderContext;
19264 var TagContextProvider = ctx7.ContextProvider;
19265 var TagScopedContextProvider = ctx7.ScopedContextProvider;
19266
19267 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
19268 var isTouchSafari = isSafari() && isTouchDevice();
19269 function createComboboxStore({ tag, ...props } = {}) {
19270 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19271 throwOnConflictingProps(props, store);
19272 const tagState = tag?.getState();
19273 const syncState = store?.getState();
19274 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
19275 const composite = createCompositeStore({
19276 ...props,
19277 activeId,
19278 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
19279 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
19280 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
19281 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
19282 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
19283 });
19284 const popover = createPopoverStore({
19285 ...props,
19286 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
19287 });
19288 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
19289 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
19290 const multiSelectable = Array.isArray(selectedValue);
19291 const initialState = {
19292 ...composite.getState(),
19293 ...popover.getState(),
19294 value,
19295 selectedValue,
19296 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
19297 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
19298 activeValue: syncState?.activeValue
19299 };
19300 const combobox = createStore(initialState, composite, popover, store);
19301 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
19302 combobox.setState("virtualFocus", false);
19303 }));
19304 setup(combobox, () => {
19305 if (!tag) return;
19306 return chain(sync(combobox, ["selectedValue"], (state) => {
19307 if (!Array.isArray(state.selectedValue)) return;
19308 tag.setValues(state.selectedValue);
19309 }), sync(tag, ["values"], (state) => {
19310 combobox.setState("selectedValue", state.values);
19311 }));
19312 });
19313 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19314 if (!state.resetValueOnHide) return;
19315 if (state.mounted) return;
19316 combobox.setState("value", value);
19317 }));
19318 setup(combobox, () => sync(combobox, ["open"], (state) => {
19319 if (state.open) return;
19320 combobox.setState("activeId", activeId);
19321 combobox.setState("moves", 0);
19322 }));
19323 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19324 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
19325 }));
19326 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19327 if (state.moves === prev.moves) return;
19328 const { activeId: activeId2 } = combobox.getState();
19329 const activeItem = composite.item(activeId2);
19330 combobox.setState("activeValue", activeItem?.value);
19331 }));
19332 return {
19333 ...popover,
19334 ...composite,
19335 ...combobox,
19336 tag,
19337 setValue: (value2) => combobox.setState("value", value2),
19338 resetValue: () => combobox.setState("value", initialState.value),
19339 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19340 };
19341 }
19342
19343 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
19344 function useComboboxStoreOptions(props) {
19345 const tag = useTagContext();
19346 props = {
19347 ...props,
19348 tag: props.tag !== void 0 ? props.tag : tag
19349 };
19350 return useCompositeStoreOptions(props);
19351 }
19352 function useComboboxStoreProps(store, update2, props) {
19353 useUpdateEffect(update2, [props.tag]);
19354 useStoreProps(store, props, "value", "setValue");
19355 useStoreProps(store, props, "selectedValue", "setSelectedValue");
19356 useStoreProps(store, props, "resetValueOnHide");
19357 useStoreProps(store, props, "resetValueOnSelect");
19358 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
19359 }
19360 function useComboboxStore(props = {}) {
19361 props = useComboboxStoreOptions(props);
19362 const [store, update2] = useStore2(createComboboxStore, props);
19363 return useComboboxStoreProps(store, update2, props);
19364 }
19365
19366 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
19367 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19368 function ComboboxProvider(props = {}) {
19369 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, {
19370 value: useComboboxStore(props),
19371 children: props.children
19372 });
19373 }
19374
19375 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19376 var import_remove_accents = __toESM(require_remove_accents(), 1);
19377 var import_compose8 = __toESM(require_compose(), 1);
19378 var import_i18n30 = __toESM(require_i18n(), 1);
19379 var import_element44 = __toESM(require_element(), 1);
19380 var import_components19 = __toESM(require_components(), 1);
19381
19382 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19383 var EMPTY_ARRAY3 = [];
19384 var getCurrentValue = (filterDefinition, currentFilter) => {
19385 if (filterDefinition.singleSelection) {
19386 return currentFilter?.value;
19387 }
19388 if (Array.isArray(currentFilter?.value)) {
19389 return currentFilter.value;
19390 }
19391 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19392 return [currentFilter.value];
19393 }
19394 return EMPTY_ARRAY3;
19395 };
19396
19397 // packages/dataviews/build-module/hooks/use-elements.mjs
19398 var import_element43 = __toESM(require_element(), 1);
19399 var EMPTY_ARRAY4 = [];
19400 function useElements({
19401 elements,
19402 getElements
19403 }) {
19404 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19405 const [records, setRecords] = (0, import_element43.useState)(staticElements);
19406 const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
19407 (0, import_element43.useEffect)(() => {
19408 if (!getElements) {
19409 setRecords(staticElements);
19410 return;
19411 }
19412 let cancelled = false;
19413 setIsLoading(true);
19414 getElements().then((fetchedElements) => {
19415 if (!cancelled) {
19416 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19417 setRecords(dynamicElements);
19418 }
19419 }).catch(() => {
19420 if (!cancelled) {
19421 setRecords(staticElements);
19422 }
19423 }).finally(() => {
19424 if (!cancelled) {
19425 setIsLoading(false);
19426 }
19427 });
19428 return () => {
19429 cancelled = true;
19430 };
19431 }, [getElements, staticElements]);
19432 return {
19433 elements: records,
19434 isLoading
19435 };
19436 }
19437
19438 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19439 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19440 function normalizeSearchInput(input = "") {
19441 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19442 }
19443 var getNewValue = (filterDefinition, currentFilter, value) => {
19444 if (filterDefinition.singleSelection) {
19445 return value;
19446 }
19447 if (Array.isArray(currentFilter?.value)) {
19448 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19449 }
19450 return [value];
19451 };
19452 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19453 return `${prefix}-${filterElementValue}`;
19454 }
19455 var MultiSelectionOption = ({ selected }) => {
19456 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19457 "span",
19458 {
19459 className: clsx_default(
19460 "dataviews-filters__search-widget-listitem-multi-selection",
19461 { "is-selected": selected }
19462 ),
19463 children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
19464 }
19465 );
19466 };
19467 var SingleSelectionOption = ({ selected }) => {
19468 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19469 "span",
19470 {
19471 className: clsx_default(
19472 "dataviews-filters__search-widget-listitem-single-selection",
19473 { "is-selected": selected }
19474 )
19475 }
19476 );
19477 };
19478 function ListBox({ view, filter, onChangeView }) {
19479 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19480 const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
19481 // When there are one or less operators, the first item is set as active
19482 // (by setting the initial `activeId` to `undefined`).
19483 // With 2 or more operators, the focus is moved on the operators control
19484 // (by setting the initial `activeId` to `null`), meaning that there won't
19485 // be an active item initially. Focus is then managed via the
19486 // `onFocusVisible` callback.
19487 filter.operators?.length === 1 ? void 0 : null
19488 );
19489 const currentFilter = view.filters?.find(
19490 (f2) => f2.field === filter.field
19491 );
19492 const currentValue = getCurrentValue(filter, currentFilter);
19493 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19494 import_components19.Composite,
19495 {
19496 virtualFocus: true,
19497 focusLoop: true,
19498 activeId: activeCompositeId,
19499 setActiveId: setActiveCompositeId,
19500 role: "listbox",
19501 className: "dataviews-filters__search-widget-listbox",
19502 "aria-label": (0, import_i18n30.sprintf)(
19503 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19504 (0, import_i18n30.__)("List of: %1$s"),
19505 filter.name
19506 ),
19507 onFocusVisible: () => {
19508 if (!activeCompositeId && filter.elements.length) {
19509 setActiveCompositeId(
19510 generateFilterElementCompositeItemId(
19511 baseId,
19512 filter.elements[0].value
19513 )
19514 );
19515 }
19516 },
19517 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
19518 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19519 import_components19.Composite.Hover,
19520 {
19521 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19522 import_components19.Composite.Item,
19523 {
19524 id: generateFilterElementCompositeItemId(
19525 baseId,
19526 element.value
19527 ),
19528 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19529 "div",
19530 {
19531 "aria-label": element.label,
19532 role: "option",
19533 className: "dataviews-filters__search-widget-listitem"
19534 }
19535 ),
19536 onClick: () => {
19537 const newFilters = currentFilter ? [
19538 ...(view.filters ?? []).map(
19539 (_filter) => {
19540 if (_filter.field === filter.field) {
19541 return {
19542 ..._filter,
19543 operator: currentFilter.operator || filter.operators[0],
19544 value: getNewValue(
19545 filter,
19546 currentFilter,
19547 element.value
19548 )
19549 };
19550 }
19551 return _filter;
19552 }
19553 )
19554 ] : [
19555 ...view.filters ?? [],
19556 {
19557 field: filter.field,
19558 operator: filter.operators[0],
19559 value: getNewValue(
19560 filter,
19561 currentFilter,
19562 element.value
19563 )
19564 }
19565 ];
19566 onChangeView({
19567 ...view,
19568 page: 1,
19569 filters: newFilters
19570 });
19571 }
19572 }
19573 ),
19574 children: [
19575 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19576 SingleSelectionOption,
19577 {
19578 selected: currentValue === element.value
19579 }
19580 ),
19581 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19582 MultiSelectionOption,
19583 {
19584 selected: currentValue.includes(element.value)
19585 }
19586 ),
19587 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19588 "span",
19589 {
19590 className: "dataviews-filters__search-widget-listitem-value",
19591 title: element.label,
19592 children: element.label
19593 }
19594 )
19595 ]
19596 },
19597 element.value
19598 ))
19599 }
19600 );
19601 }
19602 function ComboboxList22({ view, filter, onChangeView }) {
19603 const [searchValue, setSearchValue] = (0, import_element44.useState)("");
19604 const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
19605 const currentFilter = view.filters?.find(
19606 (_filter) => _filter.field === filter.field
19607 );
19608 const currentValue = getCurrentValue(filter, currentFilter);
19609 const matches = (0, import_element44.useMemo)(() => {
19610 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19611 return filter.elements.filter(
19612 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19613 );
19614 }, [filter.elements, deferredSearchValue]);
19615 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19616 ComboboxProvider,
19617 {
19618 selectedValue: currentValue,
19619 setSelectedValue: (value) => {
19620 const newFilters = currentFilter ? [
19621 ...(view.filters ?? []).map((_filter) => {
19622 if (_filter.field === filter.field) {
19623 return {
19624 ..._filter,
19625 operator: currentFilter.operator || filter.operators[0],
19626 value
19627 };
19628 }
19629 return _filter;
19630 })
19631 ] : [
19632 ...view.filters ?? [],
19633 {
19634 field: filter.field,
19635 operator: filter.operators[0],
19636 value
19637 }
19638 ];
19639 onChangeView({
19640 ...view,
19641 page: 1,
19642 filters: newFilters
19643 });
19644 },
19645 setValue: setSearchValue,
19646 children: [
19647 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19648 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n30.__)("Search items") }),
19649 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19650 Combobox,
19651 {
19652 autoSelect: "always",
19653 placeholder: (0, import_i18n30.__)("Search"),
19654 className: "dataviews-filters__search-widget-filter-combobox__input"
19655 }
19656 ),
19657 /* @__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 }) })
19658 ] }),
19659 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19660 ComboboxList,
19661 {
19662 className: "dataviews-filters__search-widget-filter-combobox-list",
19663 alwaysVisible: true,
19664 children: [
19665 matches.map((element) => {
19666 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19667 ComboboxItem,
19668 {
19669 resetValueOnSelect: false,
19670 value: element.value,
19671 className: "dataviews-filters__search-widget-listitem",
19672 hideOnClick: false,
19673 setValueOnClick: false,
19674 focusOnHover: true,
19675 children: [
19676 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19677 SingleSelectionOption,
19678 {
19679 selected: currentValue === element.value
19680 }
19681 ),
19682 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19683 MultiSelectionOption,
19684 {
19685 selected: currentValue.includes(
19686 element.value
19687 )
19688 }
19689 ),
19690 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19691 "span",
19692 {
19693 className: "dataviews-filters__search-widget-listitem-value",
19694 title: element.label,
19695 children: [
19696 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19697 ComboboxItemValue,
19698 {
19699 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19700 value: element.label
19701 }
19702 ),
19703 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19704 ]
19705 }
19706 )
19707 ]
19708 },
19709 element.value
19710 );
19711 }),
19712 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n30.__)("No results found") })
19713 ]
19714 }
19715 )
19716 ]
19717 }
19718 );
19719 }
19720 function SearchWidget(props) {
19721 const { elements, isLoading } = useElements({
19722 elements: props.filter.elements,
19723 getElements: props.filter.getElements
19724 });
19725 if (isLoading) {
19726 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, {}) });
19727 }
19728 if (elements.length === 0) {
19729 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n30.__)("No elements found") });
19730 }
19731 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19732 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19733 }
19734
19735 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19736 var import_es6 = __toESM(require_es6(), 1);
19737 var import_compose9 = __toESM(require_compose(), 1);
19738 var import_element45 = __toESM(require_element(), 1);
19739 var import_components20 = __toESM(require_components(), 1);
19740 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19741 function InputWidget({
19742 filter,
19743 view,
19744 onChangeView,
19745 fields
19746 }) {
19747 const currentFilter = view.filters?.find(
19748 (f2) => f2.field === filter.field
19749 );
19750 const currentValue = getCurrentValue(filter, currentFilter);
19751 const field = (0, import_element45.useMemo)(() => {
19752 const currentField = fields.find((f2) => f2.id === filter.field);
19753 if (currentField) {
19754 return {
19755 ...currentField,
19756 // Deactivate validation for filters.
19757 isValid: {},
19758 // Filter controls are always enabled.
19759 isDisabled: () => false,
19760 // Filter controls are always visible.
19761 isVisible: () => true,
19762 // Configure getValue/setValue as if Item was a plain object.
19763 getValue: ({ item }) => item[currentField.id],
19764 setValue: ({ value }) => ({
19765 [currentField.id]: value
19766 })
19767 };
19768 }
19769 return currentField;
19770 }, [fields, filter.field]);
19771 const data = (0, import_element45.useMemo)(() => {
19772 return (view.filters ?? []).reduce(
19773 (acc, activeFilter) => {
19774 acc[activeFilter.field] = activeFilter.value;
19775 return acc;
19776 },
19777 {}
19778 );
19779 }, [view.filters]);
19780 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19781 if (!field || !currentFilter) {
19782 return;
19783 }
19784 const nextValue = field.getValue({ item: updatedData });
19785 if ((0, import_es6.default)(nextValue, currentValue)) {
19786 return;
19787 }
19788 onChangeView({
19789 ...view,
19790 filters: (view.filters ?? []).map(
19791 (_filter) => _filter.field === filter.field ? {
19792 ..._filter,
19793 operator: currentFilter.operator || filter.operators[0],
19794 // Consider empty strings as undefined:
19795 //
19796 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19797 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19798 //
19799 // In practice, this means the filter will not be able to find an empty string as the value.
19800 value: nextValue === "" ? void 0 : nextValue
19801 } : _filter
19802 )
19803 });
19804 });
19805 if (!field || !field.Edit || !currentFilter) {
19806 return null;
19807 }
19808 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19809 import_components20.Flex,
19810 {
19811 className: "dataviews-filters__user-input-widget",
19812 gap: 2.5,
19813 direction: "column",
19814 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19815 field.Edit,
19816 {
19817 hideLabelFromVision: true,
19818 data,
19819 field,
19820 operator: currentFilter.operator,
19821 onChange: handleChange
19822 }
19823 )
19824 }
19825 );
19826 }
19827
19828 // node_modules/date-fns/constants.js
19829 var daysInYear = 365.2425;
19830 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19831 var minTime = -maxTime;
19832 var millisecondsInWeek = 6048e5;
19833 var millisecondsInDay = 864e5;
19834 var secondsInHour = 3600;
19835 var secondsInDay = secondsInHour * 24;
19836 var secondsInWeek = secondsInDay * 7;
19837 var secondsInYear = secondsInDay * daysInYear;
19838 var secondsInMonth = secondsInYear / 12;
19839 var secondsInQuarter = secondsInMonth * 3;
19840 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19841
19842 // node_modules/date-fns/constructFrom.js
19843 function constructFrom(date, value) {
19844 if (typeof date === "function") return date(value);
19845 if (date && typeof date === "object" && constructFromSymbol in date)
19846 return date[constructFromSymbol](value);
19847 if (date instanceof Date) return new date.constructor(value);
19848 return new Date(value);
19849 }
19850
19851 // node_modules/date-fns/toDate.js
19852 function toDate(argument, context) {
19853 return constructFrom(context || argument, argument);
19854 }
19855
19856 // node_modules/date-fns/addDays.js
19857 function addDays(date, amount, options) {
19858 const _date = toDate(date, options?.in);
19859 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19860 if (!amount) return _date;
19861 _date.setDate(_date.getDate() + amount);
19862 return _date;
19863 }
19864
19865 // node_modules/date-fns/addMonths.js
19866 function addMonths(date, amount, options) {
19867 const _date = toDate(date, options?.in);
19868 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19869 if (!amount) {
19870 return _date;
19871 }
19872 const dayOfMonth = _date.getDate();
19873 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19874 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19875 const daysInMonth = endOfDesiredMonth.getDate();
19876 if (dayOfMonth >= daysInMonth) {
19877 return endOfDesiredMonth;
19878 } else {
19879 _date.setFullYear(
19880 endOfDesiredMonth.getFullYear(),
19881 endOfDesiredMonth.getMonth(),
19882 dayOfMonth
19883 );
19884 return _date;
19885 }
19886 }
19887
19888 // node_modules/date-fns/_lib/defaultOptions.js
19889 var defaultOptions = {};
19890 function getDefaultOptions() {
19891 return defaultOptions;
19892 }
19893
19894 // node_modules/date-fns/startOfWeek.js
19895 function startOfWeek(date, options) {
19896 const defaultOptions2 = getDefaultOptions();
19897 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19898 const _date = toDate(date, options?.in);
19899 const day = _date.getDay();
19900 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19901 _date.setDate(_date.getDate() - diff);
19902 _date.setHours(0, 0, 0, 0);
19903 return _date;
19904 }
19905
19906 // node_modules/date-fns/startOfISOWeek.js
19907 function startOfISOWeek(date, options) {
19908 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19909 }
19910
19911 // node_modules/date-fns/getISOWeekYear.js
19912 function getISOWeekYear(date, options) {
19913 const _date = toDate(date, options?.in);
19914 const year = _date.getFullYear();
19915 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19916 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19917 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19918 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19919 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19920 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19921 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19922 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19923 if (_date.getTime() >= startOfNextYear.getTime()) {
19924 return year + 1;
19925 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19926 return year;
19927 } else {
19928 return year - 1;
19929 }
19930 }
19931
19932 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19933 function getTimezoneOffsetInMilliseconds(date) {
19934 const _date = toDate(date);
19935 const utcDate = new Date(
19936 Date.UTC(
19937 _date.getFullYear(),
19938 _date.getMonth(),
19939 _date.getDate(),
19940 _date.getHours(),
19941 _date.getMinutes(),
19942 _date.getSeconds(),
19943 _date.getMilliseconds()
19944 )
19945 );
19946 utcDate.setUTCFullYear(_date.getFullYear());
19947 return +date - +utcDate;
19948 }
19949
19950 // node_modules/date-fns/_lib/normalizeDates.js
19951 function normalizeDates(context, ...dates) {
19952 const normalize = constructFrom.bind(
19953 null,
19954 context || dates.find((date) => typeof date === "object")
19955 );
19956 return dates.map(normalize);
19957 }
19958
19959 // node_modules/date-fns/startOfDay.js
19960 function startOfDay(date, options) {
19961 const _date = toDate(date, options?.in);
19962 _date.setHours(0, 0, 0, 0);
19963 return _date;
19964 }
19965
19966 // node_modules/date-fns/differenceInCalendarDays.js
19967 function differenceInCalendarDays(laterDate, earlierDate, options) {
19968 const [laterDate_, earlierDate_] = normalizeDates(
19969 options?.in,
19970 laterDate,
19971 earlierDate
19972 );
19973 const laterStartOfDay = startOfDay(laterDate_);
19974 const earlierStartOfDay = startOfDay(earlierDate_);
19975 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19976 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19977 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19978 }
19979
19980 // node_modules/date-fns/startOfISOWeekYear.js
19981 function startOfISOWeekYear(date, options) {
19982 const year = getISOWeekYear(date, options);
19983 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19984 fourthOfJanuary.setFullYear(year, 0, 4);
19985 fourthOfJanuary.setHours(0, 0, 0, 0);
19986 return startOfISOWeek(fourthOfJanuary);
19987 }
19988
19989 // node_modules/date-fns/addWeeks.js
19990 function addWeeks(date, amount, options) {
19991 return addDays(date, amount * 7, options);
19992 }
19993
19994 // node_modules/date-fns/addYears.js
19995 function addYears(date, amount, options) {
19996 return addMonths(date, amount * 12, options);
19997 }
19998
19999 // node_modules/date-fns/isDate.js
20000 function isDate(value) {
20001 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
20002 }
20003
20004 // node_modules/date-fns/isValid.js
20005 function isValid(date) {
20006 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
20007 }
20008
20009 // node_modules/date-fns/startOfMonth.js
20010 function startOfMonth(date, options) {
20011 const _date = toDate(date, options?.in);
20012 _date.setDate(1);
20013 _date.setHours(0, 0, 0, 0);
20014 return _date;
20015 }
20016
20017 // node_modules/date-fns/startOfYear.js
20018 function startOfYear(date, options) {
20019 const date_ = toDate(date, options?.in);
20020 date_.setFullYear(date_.getFullYear(), 0, 1);
20021 date_.setHours(0, 0, 0, 0);
20022 return date_;
20023 }
20024
20025 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
20026 var formatDistanceLocale = {
20027 lessThanXSeconds: {
20028 one: "less than a second",
20029 other: "less than {{count}} seconds"
20030 },
20031 xSeconds: {
20032 one: "1 second",
20033 other: "{{count}} seconds"
20034 },
20035 halfAMinute: "half a minute",
20036 lessThanXMinutes: {
20037 one: "less than a minute",
20038 other: "less than {{count}} minutes"
20039 },
20040 xMinutes: {
20041 one: "1 minute",
20042 other: "{{count}} minutes"
20043 },
20044 aboutXHours: {
20045 one: "about 1 hour",
20046 other: "about {{count}} hours"
20047 },
20048 xHours: {
20049 one: "1 hour",
20050 other: "{{count}} hours"
20051 },
20052 xDays: {
20053 one: "1 day",
20054 other: "{{count}} days"
20055 },
20056 aboutXWeeks: {
20057 one: "about 1 week",
20058 other: "about {{count}} weeks"
20059 },
20060 xWeeks: {
20061 one: "1 week",
20062 other: "{{count}} weeks"
20063 },
20064 aboutXMonths: {
20065 one: "about 1 month",
20066 other: "about {{count}} months"
20067 },
20068 xMonths: {
20069 one: "1 month",
20070 other: "{{count}} months"
20071 },
20072 aboutXYears: {
20073 one: "about 1 year",
20074 other: "about {{count}} years"
20075 },
20076 xYears: {
20077 one: "1 year",
20078 other: "{{count}} years"
20079 },
20080 overXYears: {
20081 one: "over 1 year",
20082 other: "over {{count}} years"
20083 },
20084 almostXYears: {
20085 one: "almost 1 year",
20086 other: "almost {{count}} years"
20087 }
20088 };
20089 var formatDistance = (token, count, options) => {
20090 let result;
20091 const tokenValue = formatDistanceLocale[token];
20092 if (typeof tokenValue === "string") {
20093 result = tokenValue;
20094 } else if (count === 1) {
20095 result = tokenValue.one;
20096 } else {
20097 result = tokenValue.other.replace("{{count}}", count.toString());
20098 }
20099 if (options?.addSuffix) {
20100 if (options.comparison && options.comparison > 0) {
20101 return "in " + result;
20102 } else {
20103 return result + " ago";
20104 }
20105 }
20106 return result;
20107 };
20108
20109 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
20110 function buildFormatLongFn(args) {
20111 return (options = {}) => {
20112 const width = options.width ? String(options.width) : args.defaultWidth;
20113 const format6 = args.formats[width] || args.formats[args.defaultWidth];
20114 return format6;
20115 };
20116 }
20117
20118 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
20119 var dateFormats = {
20120 full: "EEEE, MMMM do, y",
20121 long: "MMMM do, y",
20122 medium: "MMM d, y",
20123 short: "MM/dd/yyyy"
20124 };
20125 var timeFormats = {
20126 full: "h:mm:ss a zzzz",
20127 long: "h:mm:ss a z",
20128 medium: "h:mm:ss a",
20129 short: "h:mm a"
20130 };
20131 var dateTimeFormats = {
20132 full: "{{date}} 'at' {{time}}",
20133 long: "{{date}} 'at' {{time}}",
20134 medium: "{{date}}, {{time}}",
20135 short: "{{date}}, {{time}}"
20136 };
20137 var formatLong = {
20138 date: buildFormatLongFn({
20139 formats: dateFormats,
20140 defaultWidth: "full"
20141 }),
20142 time: buildFormatLongFn({
20143 formats: timeFormats,
20144 defaultWidth: "full"
20145 }),
20146 dateTime: buildFormatLongFn({
20147 formats: dateTimeFormats,
20148 defaultWidth: "full"
20149 })
20150 };
20151
20152 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
20153 var formatRelativeLocale = {
20154 lastWeek: "'last' eeee 'at' p",
20155 yesterday: "'yesterday at' p",
20156 today: "'today at' p",
20157 tomorrow: "'tomorrow at' p",
20158 nextWeek: "eeee 'at' p",
20159 other: "P"
20160 };
20161 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
20162
20163 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
20164 function buildLocalizeFn(args) {
20165 return (value, options) => {
20166 const context = options?.context ? String(options.context) : "standalone";
20167 let valuesArray;
20168 if (context === "formatting" && args.formattingValues) {
20169 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
20170 const width = options?.width ? String(options.width) : defaultWidth;
20171 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
20172 } else {
20173 const defaultWidth = args.defaultWidth;
20174 const width = options?.width ? String(options.width) : args.defaultWidth;
20175 valuesArray = args.values[width] || args.values[defaultWidth];
20176 }
20177 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20178 return valuesArray[index2];
20179 };
20180 }
20181
20182 // node_modules/date-fns/locale/en-US/_lib/localize.js
20183 var eraValues = {
20184 narrow: ["B", "A"],
20185 abbreviated: ["BC", "AD"],
20186 wide: ["Before Christ", "Anno Domini"]
20187 };
20188 var quarterValues = {
20189 narrow: ["1", "2", "3", "4"],
20190 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20191 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20192 };
20193 var monthValues = {
20194 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20195 abbreviated: [
20196 "Jan",
20197 "Feb",
20198 "Mar",
20199 "Apr",
20200 "May",
20201 "Jun",
20202 "Jul",
20203 "Aug",
20204 "Sep",
20205 "Oct",
20206 "Nov",
20207 "Dec"
20208 ],
20209 wide: [
20210 "January",
20211 "February",
20212 "March",
20213 "April",
20214 "May",
20215 "June",
20216 "July",
20217 "August",
20218 "September",
20219 "October",
20220 "November",
20221 "December"
20222 ]
20223 };
20224 var dayValues = {
20225 narrow: ["S", "M", "T", "W", "T", "F", "S"],
20226 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20227 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20228 wide: [
20229 "Sunday",
20230 "Monday",
20231 "Tuesday",
20232 "Wednesday",
20233 "Thursday",
20234 "Friday",
20235 "Saturday"
20236 ]
20237 };
20238 var dayPeriodValues = {
20239 narrow: {
20240 am: "a",
20241 pm: "p",
20242 midnight: "mi",
20243 noon: "n",
20244 morning: "morning",
20245 afternoon: "afternoon",
20246 evening: "evening",
20247 night: "night"
20248 },
20249 abbreviated: {
20250 am: "AM",
20251 pm: "PM",
20252 midnight: "midnight",
20253 noon: "noon",
20254 morning: "morning",
20255 afternoon: "afternoon",
20256 evening: "evening",
20257 night: "night"
20258 },
20259 wide: {
20260 am: "a.m.",
20261 pm: "p.m.",
20262 midnight: "midnight",
20263 noon: "noon",
20264 morning: "morning",
20265 afternoon: "afternoon",
20266 evening: "evening",
20267 night: "night"
20268 }
20269 };
20270 var formattingDayPeriodValues = {
20271 narrow: {
20272 am: "a",
20273 pm: "p",
20274 midnight: "mi",
20275 noon: "n",
20276 morning: "in the morning",
20277 afternoon: "in the afternoon",
20278 evening: "in the evening",
20279 night: "at night"
20280 },
20281 abbreviated: {
20282 am: "AM",
20283 pm: "PM",
20284 midnight: "midnight",
20285 noon: "noon",
20286 morning: "in the morning",
20287 afternoon: "in the afternoon",
20288 evening: "in the evening",
20289 night: "at night"
20290 },
20291 wide: {
20292 am: "a.m.",
20293 pm: "p.m.",
20294 midnight: "midnight",
20295 noon: "noon",
20296 morning: "in the morning",
20297 afternoon: "in the afternoon",
20298 evening: "in the evening",
20299 night: "at night"
20300 }
20301 };
20302 var ordinalNumber = (dirtyNumber, _options) => {
20303 const number = Number(dirtyNumber);
20304 const rem100 = number % 100;
20305 if (rem100 > 20 || rem100 < 10) {
20306 switch (rem100 % 10) {
20307 case 1:
20308 return number + "st";
20309 case 2:
20310 return number + "nd";
20311 case 3:
20312 return number + "rd";
20313 }
20314 }
20315 return number + "th";
20316 };
20317 var localize = {
20318 ordinalNumber,
20319 era: buildLocalizeFn({
20320 values: eraValues,
20321 defaultWidth: "wide"
20322 }),
20323 quarter: buildLocalizeFn({
20324 values: quarterValues,
20325 defaultWidth: "wide",
20326 argumentCallback: (quarter) => quarter - 1
20327 }),
20328 month: buildLocalizeFn({
20329 values: monthValues,
20330 defaultWidth: "wide"
20331 }),
20332 day: buildLocalizeFn({
20333 values: dayValues,
20334 defaultWidth: "wide"
20335 }),
20336 dayPeriod: buildLocalizeFn({
20337 values: dayPeriodValues,
20338 defaultWidth: "wide",
20339 formattingValues: formattingDayPeriodValues,
20340 defaultFormattingWidth: "wide"
20341 })
20342 };
20343
20344 // node_modules/date-fns/locale/_lib/buildMatchFn.js
20345 function buildMatchFn(args) {
20346 return (string, options = {}) => {
20347 const width = options.width;
20348 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20349 const matchResult = string.match(matchPattern);
20350 if (!matchResult) {
20351 return null;
20352 }
20353 const matchedString = matchResult[0];
20354 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20355 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20356 // [TODO] -- I challenge you to fix the type
20357 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20358 );
20359 let value;
20360 value = args.valueCallback ? args.valueCallback(key) : key;
20361 value = options.valueCallback ? (
20362 // [TODO] -- I challenge you to fix the type
20363 options.valueCallback(value)
20364 ) : value;
20365 const rest = string.slice(matchedString.length);
20366 return { value, rest };
20367 };
20368 }
20369 function findKey(object, predicate) {
20370 for (const key in object) {
20371 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20372 return key;
20373 }
20374 }
20375 return void 0;
20376 }
20377 function findIndex(array, predicate) {
20378 for (let key = 0; key < array.length; key++) {
20379 if (predicate(array[key])) {
20380 return key;
20381 }
20382 }
20383 return void 0;
20384 }
20385
20386 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20387 function buildMatchPatternFn(args) {
20388 return (string, options = {}) => {
20389 const matchResult = string.match(args.matchPattern);
20390 if (!matchResult) return null;
20391 const matchedString = matchResult[0];
20392 const parseResult = string.match(args.parsePattern);
20393 if (!parseResult) return null;
20394 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20395 value = options.valueCallback ? options.valueCallback(value) : value;
20396 const rest = string.slice(matchedString.length);
20397 return { value, rest };
20398 };
20399 }
20400
20401 // node_modules/date-fns/locale/en-US/_lib/match.js
20402 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20403 var parseOrdinalNumberPattern = /\d+/i;
20404 var matchEraPatterns = {
20405 narrow: /^(b|a)/i,
20406 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20407 wide: /^(before christ|before common era|anno domini|common era)/i
20408 };
20409 var parseEraPatterns = {
20410 any: [/^b/i, /^(a|c)/i]
20411 };
20412 var matchQuarterPatterns = {
20413 narrow: /^[1234]/i,
20414 abbreviated: /^q[1234]/i,
20415 wide: /^[1234](th|st|nd|rd)? quarter/i
20416 };
20417 var parseQuarterPatterns = {
20418 any: [/1/i, /2/i, /3/i, /4/i]
20419 };
20420 var matchMonthPatterns = {
20421 narrow: /^[jfmasond]/i,
20422 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20423 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20424 };
20425 var parseMonthPatterns = {
20426 narrow: [
20427 /^j/i,
20428 /^f/i,
20429 /^m/i,
20430 /^a/i,
20431 /^m/i,
20432 /^j/i,
20433 /^j/i,
20434 /^a/i,
20435 /^s/i,
20436 /^o/i,
20437 /^n/i,
20438 /^d/i
20439 ],
20440 any: [
20441 /^ja/i,
20442 /^f/i,
20443 /^mar/i,
20444 /^ap/i,
20445 /^may/i,
20446 /^jun/i,
20447 /^jul/i,
20448 /^au/i,
20449 /^s/i,
20450 /^o/i,
20451 /^n/i,
20452 /^d/i
20453 ]
20454 };
20455 var matchDayPatterns = {
20456 narrow: /^[smtwf]/i,
20457 short: /^(su|mo|tu|we|th|fr|sa)/i,
20458 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20459 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20460 };
20461 var parseDayPatterns = {
20462 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20463 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20464 };
20465 var matchDayPeriodPatterns = {
20466 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20467 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20468 };
20469 var parseDayPeriodPatterns = {
20470 any: {
20471 am: /^a/i,
20472 pm: /^p/i,
20473 midnight: /^mi/i,
20474 noon: /^no/i,
20475 morning: /morning/i,
20476 afternoon: /afternoon/i,
20477 evening: /evening/i,
20478 night: /night/i
20479 }
20480 };
20481 var match = {
20482 ordinalNumber: buildMatchPatternFn({
20483 matchPattern: matchOrdinalNumberPattern,
20484 parsePattern: parseOrdinalNumberPattern,
20485 valueCallback: (value) => parseInt(value, 10)
20486 }),
20487 era: buildMatchFn({
20488 matchPatterns: matchEraPatterns,
20489 defaultMatchWidth: "wide",
20490 parsePatterns: parseEraPatterns,
20491 defaultParseWidth: "any"
20492 }),
20493 quarter: buildMatchFn({
20494 matchPatterns: matchQuarterPatterns,
20495 defaultMatchWidth: "wide",
20496 parsePatterns: parseQuarterPatterns,
20497 defaultParseWidth: "any",
20498 valueCallback: (index2) => index2 + 1
20499 }),
20500 month: buildMatchFn({
20501 matchPatterns: matchMonthPatterns,
20502 defaultMatchWidth: "wide",
20503 parsePatterns: parseMonthPatterns,
20504 defaultParseWidth: "any"
20505 }),
20506 day: buildMatchFn({
20507 matchPatterns: matchDayPatterns,
20508 defaultMatchWidth: "wide",
20509 parsePatterns: parseDayPatterns,
20510 defaultParseWidth: "any"
20511 }),
20512 dayPeriod: buildMatchFn({
20513 matchPatterns: matchDayPeriodPatterns,
20514 defaultMatchWidth: "any",
20515 parsePatterns: parseDayPeriodPatterns,
20516 defaultParseWidth: "any"
20517 })
20518 };
20519
20520 // node_modules/date-fns/locale/en-US.js
20521 var enUS = {
20522 code: "en-US",
20523 formatDistance,
20524 formatLong,
20525 formatRelative,
20526 localize,
20527 match,
20528 options: {
20529 weekStartsOn: 0,
20530 firstWeekContainsDate: 1
20531 }
20532 };
20533
20534 // node_modules/date-fns/getDayOfYear.js
20535 function getDayOfYear(date, options) {
20536 const _date = toDate(date, options?.in);
20537 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20538 const dayOfYear = diff + 1;
20539 return dayOfYear;
20540 }
20541
20542 // node_modules/date-fns/getISOWeek.js
20543 function getISOWeek(date, options) {
20544 const _date = toDate(date, options?.in);
20545 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20546 return Math.round(diff / millisecondsInWeek) + 1;
20547 }
20548
20549 // node_modules/date-fns/getWeekYear.js
20550 function getWeekYear(date, options) {
20551 const _date = toDate(date, options?.in);
20552 const year = _date.getFullYear();
20553 const defaultOptions2 = getDefaultOptions();
20554 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20555 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20556 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20557 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20558 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20559 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20560 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20561 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20562 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20563 if (+_date >= +startOfNextYear) {
20564 return year + 1;
20565 } else if (+_date >= +startOfThisYear) {
20566 return year;
20567 } else {
20568 return year - 1;
20569 }
20570 }
20571
20572 // node_modules/date-fns/startOfWeekYear.js
20573 function startOfWeekYear(date, options) {
20574 const defaultOptions2 = getDefaultOptions();
20575 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20576 const year = getWeekYear(date, options);
20577 const firstWeek = constructFrom(options?.in || date, 0);
20578 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20579 firstWeek.setHours(0, 0, 0, 0);
20580 const _date = startOfWeek(firstWeek, options);
20581 return _date;
20582 }
20583
20584 // node_modules/date-fns/getWeek.js
20585 function getWeek(date, options) {
20586 const _date = toDate(date, options?.in);
20587 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20588 return Math.round(diff / millisecondsInWeek) + 1;
20589 }
20590
20591 // node_modules/date-fns/_lib/addLeadingZeros.js
20592 function addLeadingZeros(number, targetLength) {
20593 const sign = number < 0 ? "-" : "";
20594 const output = Math.abs(number).toString().padStart(targetLength, "0");
20595 return sign + output;
20596 }
20597
20598 // node_modules/date-fns/_lib/format/lightFormatters.js
20599 var lightFormatters = {
20600 // Year
20601 y(date, token) {
20602 const signedYear = date.getFullYear();
20603 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20604 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20605 },
20606 // Month
20607 M(date, token) {
20608 const month = date.getMonth();
20609 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20610 },
20611 // Day of the month
20612 d(date, token) {
20613 return addLeadingZeros(date.getDate(), token.length);
20614 },
20615 // AM or PM
20616 a(date, token) {
20617 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20618 switch (token) {
20619 case "a":
20620 case "aa":
20621 return dayPeriodEnumValue.toUpperCase();
20622 case "aaa":
20623 return dayPeriodEnumValue;
20624 case "aaaaa":
20625 return dayPeriodEnumValue[0];
20626 case "aaaa":
20627 default:
20628 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20629 }
20630 },
20631 // Hour [1-12]
20632 h(date, token) {
20633 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20634 },
20635 // Hour [0-23]
20636 H(date, token) {
20637 return addLeadingZeros(date.getHours(), token.length);
20638 },
20639 // Minute
20640 m(date, token) {
20641 return addLeadingZeros(date.getMinutes(), token.length);
20642 },
20643 // Second
20644 s(date, token) {
20645 return addLeadingZeros(date.getSeconds(), token.length);
20646 },
20647 // Fraction of second
20648 S(date, token) {
20649 const numberOfDigits = token.length;
20650 const milliseconds = date.getMilliseconds();
20651 const fractionalSeconds = Math.trunc(
20652 milliseconds * Math.pow(10, numberOfDigits - 3)
20653 );
20654 return addLeadingZeros(fractionalSeconds, token.length);
20655 }
20656 };
20657
20658 // node_modules/date-fns/_lib/format/formatters.js
20659 var dayPeriodEnum = {
20660 am: "am",
20661 pm: "pm",
20662 midnight: "midnight",
20663 noon: "noon",
20664 morning: "morning",
20665 afternoon: "afternoon",
20666 evening: "evening",
20667 night: "night"
20668 };
20669 var formatters = {
20670 // Era
20671 G: function(date, token, localize2) {
20672 const era = date.getFullYear() > 0 ? 1 : 0;
20673 switch (token) {
20674 // AD, BC
20675 case "G":
20676 case "GG":
20677 case "GGG":
20678 return localize2.era(era, { width: "abbreviated" });
20679 // A, B
20680 case "GGGGG":
20681 return localize2.era(era, { width: "narrow" });
20682 // Anno Domini, Before Christ
20683 case "GGGG":
20684 default:
20685 return localize2.era(era, { width: "wide" });
20686 }
20687 },
20688 // Year
20689 y: function(date, token, localize2) {
20690 if (token === "yo") {
20691 const signedYear = date.getFullYear();
20692 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20693 return localize2.ordinalNumber(year, { unit: "year" });
20694 }
20695 return lightFormatters.y(date, token);
20696 },
20697 // Local week-numbering year
20698 Y: function(date, token, localize2, options) {
20699 const signedWeekYear = getWeekYear(date, options);
20700 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20701 if (token === "YY") {
20702 const twoDigitYear = weekYear % 100;
20703 return addLeadingZeros(twoDigitYear, 2);
20704 }
20705 if (token === "Yo") {
20706 return localize2.ordinalNumber(weekYear, { unit: "year" });
20707 }
20708 return addLeadingZeros(weekYear, token.length);
20709 },
20710 // ISO week-numbering year
20711 R: function(date, token) {
20712 const isoWeekYear = getISOWeekYear(date);
20713 return addLeadingZeros(isoWeekYear, token.length);
20714 },
20715 // Extended year. This is a single number designating the year of this calendar system.
20716 // The main difference between `y` and `u` localizers are B.C. years:
20717 // | Year | `y` | `u` |
20718 // |------|-----|-----|
20719 // | AC 1 | 1 | 1 |
20720 // | BC 1 | 1 | 0 |
20721 // | BC 2 | 2 | -1 |
20722 // Also `yy` always returns the last two digits of a year,
20723 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20724 u: function(date, token) {
20725 const year = date.getFullYear();
20726 return addLeadingZeros(year, token.length);
20727 },
20728 // Quarter
20729 Q: function(date, token, localize2) {
20730 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20731 switch (token) {
20732 // 1, 2, 3, 4
20733 case "Q":
20734 return String(quarter);
20735 // 01, 02, 03, 04
20736 case "QQ":
20737 return addLeadingZeros(quarter, 2);
20738 // 1st, 2nd, 3rd, 4th
20739 case "Qo":
20740 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20741 // Q1, Q2, Q3, Q4
20742 case "QQQ":
20743 return localize2.quarter(quarter, {
20744 width: "abbreviated",
20745 context: "formatting"
20746 });
20747 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20748 case "QQQQQ":
20749 return localize2.quarter(quarter, {
20750 width: "narrow",
20751 context: "formatting"
20752 });
20753 // 1st quarter, 2nd quarter, ...
20754 case "QQQQ":
20755 default:
20756 return localize2.quarter(quarter, {
20757 width: "wide",
20758 context: "formatting"
20759 });
20760 }
20761 },
20762 // Stand-alone quarter
20763 q: function(date, token, localize2) {
20764 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20765 switch (token) {
20766 // 1, 2, 3, 4
20767 case "q":
20768 return String(quarter);
20769 // 01, 02, 03, 04
20770 case "qq":
20771 return addLeadingZeros(quarter, 2);
20772 // 1st, 2nd, 3rd, 4th
20773 case "qo":
20774 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20775 // Q1, Q2, Q3, Q4
20776 case "qqq":
20777 return localize2.quarter(quarter, {
20778 width: "abbreviated",
20779 context: "standalone"
20780 });
20781 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20782 case "qqqqq":
20783 return localize2.quarter(quarter, {
20784 width: "narrow",
20785 context: "standalone"
20786 });
20787 // 1st quarter, 2nd quarter, ...
20788 case "qqqq":
20789 default:
20790 return localize2.quarter(quarter, {
20791 width: "wide",
20792 context: "standalone"
20793 });
20794 }
20795 },
20796 // Month
20797 M: function(date, token, localize2) {
20798 const month = date.getMonth();
20799 switch (token) {
20800 case "M":
20801 case "MM":
20802 return lightFormatters.M(date, token);
20803 // 1st, 2nd, ..., 12th
20804 case "Mo":
20805 return localize2.ordinalNumber(month + 1, { unit: "month" });
20806 // Jan, Feb, ..., Dec
20807 case "MMM":
20808 return localize2.month(month, {
20809 width: "abbreviated",
20810 context: "formatting"
20811 });
20812 // J, F, ..., D
20813 case "MMMMM":
20814 return localize2.month(month, {
20815 width: "narrow",
20816 context: "formatting"
20817 });
20818 // January, February, ..., December
20819 case "MMMM":
20820 default:
20821 return localize2.month(month, { width: "wide", context: "formatting" });
20822 }
20823 },
20824 // Stand-alone month
20825 L: function(date, token, localize2) {
20826 const month = date.getMonth();
20827 switch (token) {
20828 // 1, 2, ..., 12
20829 case "L":
20830 return String(month + 1);
20831 // 01, 02, ..., 12
20832 case "LL":
20833 return addLeadingZeros(month + 1, 2);
20834 // 1st, 2nd, ..., 12th
20835 case "Lo":
20836 return localize2.ordinalNumber(month + 1, { unit: "month" });
20837 // Jan, Feb, ..., Dec
20838 case "LLL":
20839 return localize2.month(month, {
20840 width: "abbreviated",
20841 context: "standalone"
20842 });
20843 // J, F, ..., D
20844 case "LLLLL":
20845 return localize2.month(month, {
20846 width: "narrow",
20847 context: "standalone"
20848 });
20849 // January, February, ..., December
20850 case "LLLL":
20851 default:
20852 return localize2.month(month, { width: "wide", context: "standalone" });
20853 }
20854 },
20855 // Local week of year
20856 w: function(date, token, localize2, options) {
20857 const week = getWeek(date, options);
20858 if (token === "wo") {
20859 return localize2.ordinalNumber(week, { unit: "week" });
20860 }
20861 return addLeadingZeros(week, token.length);
20862 },
20863 // ISO week of year
20864 I: function(date, token, localize2) {
20865 const isoWeek = getISOWeek(date);
20866 if (token === "Io") {
20867 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20868 }
20869 return addLeadingZeros(isoWeek, token.length);
20870 },
20871 // Day of the month
20872 d: function(date, token, localize2) {
20873 if (token === "do") {
20874 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20875 }
20876 return lightFormatters.d(date, token);
20877 },
20878 // Day of year
20879 D: function(date, token, localize2) {
20880 const dayOfYear = getDayOfYear(date);
20881 if (token === "Do") {
20882 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20883 }
20884 return addLeadingZeros(dayOfYear, token.length);
20885 },
20886 // Day of week
20887 E: function(date, token, localize2) {
20888 const dayOfWeek = date.getDay();
20889 switch (token) {
20890 // Tue
20891 case "E":
20892 case "EE":
20893 case "EEE":
20894 return localize2.day(dayOfWeek, {
20895 width: "abbreviated",
20896 context: "formatting"
20897 });
20898 // T
20899 case "EEEEE":
20900 return localize2.day(dayOfWeek, {
20901 width: "narrow",
20902 context: "formatting"
20903 });
20904 // Tu
20905 case "EEEEEE":
20906 return localize2.day(dayOfWeek, {
20907 width: "short",
20908 context: "formatting"
20909 });
20910 // Tuesday
20911 case "EEEE":
20912 default:
20913 return localize2.day(dayOfWeek, {
20914 width: "wide",
20915 context: "formatting"
20916 });
20917 }
20918 },
20919 // Local day of week
20920 e: function(date, token, localize2, options) {
20921 const dayOfWeek = date.getDay();
20922 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20923 switch (token) {
20924 // Numerical value (Nth day of week with current locale or weekStartsOn)
20925 case "e":
20926 return String(localDayOfWeek);
20927 // Padded numerical value
20928 case "ee":
20929 return addLeadingZeros(localDayOfWeek, 2);
20930 // 1st, 2nd, ..., 7th
20931 case "eo":
20932 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20933 case "eee":
20934 return localize2.day(dayOfWeek, {
20935 width: "abbreviated",
20936 context: "formatting"
20937 });
20938 // T
20939 case "eeeee":
20940 return localize2.day(dayOfWeek, {
20941 width: "narrow",
20942 context: "formatting"
20943 });
20944 // Tu
20945 case "eeeeee":
20946 return localize2.day(dayOfWeek, {
20947 width: "short",
20948 context: "formatting"
20949 });
20950 // Tuesday
20951 case "eeee":
20952 default:
20953 return localize2.day(dayOfWeek, {
20954 width: "wide",
20955 context: "formatting"
20956 });
20957 }
20958 },
20959 // Stand-alone local day of week
20960 c: function(date, token, localize2, options) {
20961 const dayOfWeek = date.getDay();
20962 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20963 switch (token) {
20964 // Numerical value (same as in `e`)
20965 case "c":
20966 return String(localDayOfWeek);
20967 // Padded numerical value
20968 case "cc":
20969 return addLeadingZeros(localDayOfWeek, token.length);
20970 // 1st, 2nd, ..., 7th
20971 case "co":
20972 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20973 case "ccc":
20974 return localize2.day(dayOfWeek, {
20975 width: "abbreviated",
20976 context: "standalone"
20977 });
20978 // T
20979 case "ccccc":
20980 return localize2.day(dayOfWeek, {
20981 width: "narrow",
20982 context: "standalone"
20983 });
20984 // Tu
20985 case "cccccc":
20986 return localize2.day(dayOfWeek, {
20987 width: "short",
20988 context: "standalone"
20989 });
20990 // Tuesday
20991 case "cccc":
20992 default:
20993 return localize2.day(dayOfWeek, {
20994 width: "wide",
20995 context: "standalone"
20996 });
20997 }
20998 },
20999 // ISO day of week
21000 i: function(date, token, localize2) {
21001 const dayOfWeek = date.getDay();
21002 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
21003 switch (token) {
21004 // 2
21005 case "i":
21006 return String(isoDayOfWeek);
21007 // 02
21008 case "ii":
21009 return addLeadingZeros(isoDayOfWeek, token.length);
21010 // 2nd
21011 case "io":
21012 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
21013 // Tue
21014 case "iii":
21015 return localize2.day(dayOfWeek, {
21016 width: "abbreviated",
21017 context: "formatting"
21018 });
21019 // T
21020 case "iiiii":
21021 return localize2.day(dayOfWeek, {
21022 width: "narrow",
21023 context: "formatting"
21024 });
21025 // Tu
21026 case "iiiiii":
21027 return localize2.day(dayOfWeek, {
21028 width: "short",
21029 context: "formatting"
21030 });
21031 // Tuesday
21032 case "iiii":
21033 default:
21034 return localize2.day(dayOfWeek, {
21035 width: "wide",
21036 context: "formatting"
21037 });
21038 }
21039 },
21040 // AM or PM
21041 a: function(date, token, localize2) {
21042 const hours = date.getHours();
21043 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21044 switch (token) {
21045 case "a":
21046 case "aa":
21047 return localize2.dayPeriod(dayPeriodEnumValue, {
21048 width: "abbreviated",
21049 context: "formatting"
21050 });
21051 case "aaa":
21052 return localize2.dayPeriod(dayPeriodEnumValue, {
21053 width: "abbreviated",
21054 context: "formatting"
21055 }).toLowerCase();
21056 case "aaaaa":
21057 return localize2.dayPeriod(dayPeriodEnumValue, {
21058 width: "narrow",
21059 context: "formatting"
21060 });
21061 case "aaaa":
21062 default:
21063 return localize2.dayPeriod(dayPeriodEnumValue, {
21064 width: "wide",
21065 context: "formatting"
21066 });
21067 }
21068 },
21069 // AM, PM, midnight, noon
21070 b: function(date, token, localize2) {
21071 const hours = date.getHours();
21072 let dayPeriodEnumValue;
21073 if (hours === 12) {
21074 dayPeriodEnumValue = dayPeriodEnum.noon;
21075 } else if (hours === 0) {
21076 dayPeriodEnumValue = dayPeriodEnum.midnight;
21077 } else {
21078 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21079 }
21080 switch (token) {
21081 case "b":
21082 case "bb":
21083 return localize2.dayPeriod(dayPeriodEnumValue, {
21084 width: "abbreviated",
21085 context: "formatting"
21086 });
21087 case "bbb":
21088 return localize2.dayPeriod(dayPeriodEnumValue, {
21089 width: "abbreviated",
21090 context: "formatting"
21091 }).toLowerCase();
21092 case "bbbbb":
21093 return localize2.dayPeriod(dayPeriodEnumValue, {
21094 width: "narrow",
21095 context: "formatting"
21096 });
21097 case "bbbb":
21098 default:
21099 return localize2.dayPeriod(dayPeriodEnumValue, {
21100 width: "wide",
21101 context: "formatting"
21102 });
21103 }
21104 },
21105 // in the morning, in the afternoon, in the evening, at night
21106 B: function(date, token, localize2) {
21107 const hours = date.getHours();
21108 let dayPeriodEnumValue;
21109 if (hours >= 17) {
21110 dayPeriodEnumValue = dayPeriodEnum.evening;
21111 } else if (hours >= 12) {
21112 dayPeriodEnumValue = dayPeriodEnum.afternoon;
21113 } else if (hours >= 4) {
21114 dayPeriodEnumValue = dayPeriodEnum.morning;
21115 } else {
21116 dayPeriodEnumValue = dayPeriodEnum.night;
21117 }
21118 switch (token) {
21119 case "B":
21120 case "BB":
21121 case "BBB":
21122 return localize2.dayPeriod(dayPeriodEnumValue, {
21123 width: "abbreviated",
21124 context: "formatting"
21125 });
21126 case "BBBBB":
21127 return localize2.dayPeriod(dayPeriodEnumValue, {
21128 width: "narrow",
21129 context: "formatting"
21130 });
21131 case "BBBB":
21132 default:
21133 return localize2.dayPeriod(dayPeriodEnumValue, {
21134 width: "wide",
21135 context: "formatting"
21136 });
21137 }
21138 },
21139 // Hour [1-12]
21140 h: function(date, token, localize2) {
21141 if (token === "ho") {
21142 let hours = date.getHours() % 12;
21143 if (hours === 0) hours = 12;
21144 return localize2.ordinalNumber(hours, { unit: "hour" });
21145 }
21146 return lightFormatters.h(date, token);
21147 },
21148 // Hour [0-23]
21149 H: function(date, token, localize2) {
21150 if (token === "Ho") {
21151 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
21152 }
21153 return lightFormatters.H(date, token);
21154 },
21155 // Hour [0-11]
21156 K: function(date, token, localize2) {
21157 const hours = date.getHours() % 12;
21158 if (token === "Ko") {
21159 return localize2.ordinalNumber(hours, { unit: "hour" });
21160 }
21161 return addLeadingZeros(hours, token.length);
21162 },
21163 // Hour [1-24]
21164 k: function(date, token, localize2) {
21165 let hours = date.getHours();
21166 if (hours === 0) hours = 24;
21167 if (token === "ko") {
21168 return localize2.ordinalNumber(hours, { unit: "hour" });
21169 }
21170 return addLeadingZeros(hours, token.length);
21171 },
21172 // Minute
21173 m: function(date, token, localize2) {
21174 if (token === "mo") {
21175 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21176 }
21177 return lightFormatters.m(date, token);
21178 },
21179 // Second
21180 s: function(date, token, localize2) {
21181 if (token === "so") {
21182 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21183 }
21184 return lightFormatters.s(date, token);
21185 },
21186 // Fraction of second
21187 S: function(date, token) {
21188 return lightFormatters.S(date, token);
21189 },
21190 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21191 X: function(date, token, _localize) {
21192 const timezoneOffset = date.getTimezoneOffset();
21193 if (timezoneOffset === 0) {
21194 return "Z";
21195 }
21196 switch (token) {
21197 // Hours and optional minutes
21198 case "X":
21199 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21200 // Hours, minutes and optional seconds without `:` delimiter
21201 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21202 // so this token always has the same output as `XX`
21203 case "XXXX":
21204 case "XX":
21205 return formatTimezone(timezoneOffset);
21206 // Hours, minutes and optional seconds with `:` delimiter
21207 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21208 // so this token always has the same output as `XXX`
21209 case "XXXXX":
21210 case "XXX":
21211 // Hours and minutes with `:` delimiter
21212 default:
21213 return formatTimezone(timezoneOffset, ":");
21214 }
21215 },
21216 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21217 x: function(date, token, _localize) {
21218 const timezoneOffset = date.getTimezoneOffset();
21219 switch (token) {
21220 // Hours and optional minutes
21221 case "x":
21222 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21223 // Hours, minutes and optional seconds without `:` delimiter
21224 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21225 // so this token always has the same output as `xx`
21226 case "xxxx":
21227 case "xx":
21228 return formatTimezone(timezoneOffset);
21229 // Hours, minutes and optional seconds with `:` delimiter
21230 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21231 // so this token always has the same output as `xxx`
21232 case "xxxxx":
21233 case "xxx":
21234 // Hours and minutes with `:` delimiter
21235 default:
21236 return formatTimezone(timezoneOffset, ":");
21237 }
21238 },
21239 // Timezone (GMT)
21240 O: function(date, token, _localize) {
21241 const timezoneOffset = date.getTimezoneOffset();
21242 switch (token) {
21243 // Short
21244 case "O":
21245 case "OO":
21246 case "OOO":
21247 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21248 // Long
21249 case "OOOO":
21250 default:
21251 return "GMT" + formatTimezone(timezoneOffset, ":");
21252 }
21253 },
21254 // Timezone (specific non-location)
21255 z: function(date, token, _localize) {
21256 const timezoneOffset = date.getTimezoneOffset();
21257 switch (token) {
21258 // Short
21259 case "z":
21260 case "zz":
21261 case "zzz":
21262 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21263 // Long
21264 case "zzzz":
21265 default:
21266 return "GMT" + formatTimezone(timezoneOffset, ":");
21267 }
21268 },
21269 // Seconds timestamp
21270 t: function(date, token, _localize) {
21271 const timestamp = Math.trunc(+date / 1e3);
21272 return addLeadingZeros(timestamp, token.length);
21273 },
21274 // Milliseconds timestamp
21275 T: function(date, token, _localize) {
21276 return addLeadingZeros(+date, token.length);
21277 }
21278 };
21279 function formatTimezoneShort(offset4, delimiter = "") {
21280 const sign = offset4 > 0 ? "-" : "+";
21281 const absOffset = Math.abs(offset4);
21282 const hours = Math.trunc(absOffset / 60);
21283 const minutes = absOffset % 60;
21284 if (minutes === 0) {
21285 return sign + String(hours);
21286 }
21287 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21288 }
21289 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21290 if (offset4 % 60 === 0) {
21291 const sign = offset4 > 0 ? "-" : "+";
21292 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21293 }
21294 return formatTimezone(offset4, delimiter);
21295 }
21296 function formatTimezone(offset4, delimiter = "") {
21297 const sign = offset4 > 0 ? "-" : "+";
21298 const absOffset = Math.abs(offset4);
21299 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21300 const minutes = addLeadingZeros(absOffset % 60, 2);
21301 return sign + hours + delimiter + minutes;
21302 }
21303
21304 // node_modules/date-fns/_lib/format/longFormatters.js
21305 var dateLongFormatter = (pattern, formatLong2) => {
21306 switch (pattern) {
21307 case "P":
21308 return formatLong2.date({ width: "short" });
21309 case "PP":
21310 return formatLong2.date({ width: "medium" });
21311 case "PPP":
21312 return formatLong2.date({ width: "long" });
21313 case "PPPP":
21314 default:
21315 return formatLong2.date({ width: "full" });
21316 }
21317 };
21318 var timeLongFormatter = (pattern, formatLong2) => {
21319 switch (pattern) {
21320 case "p":
21321 return formatLong2.time({ width: "short" });
21322 case "pp":
21323 return formatLong2.time({ width: "medium" });
21324 case "ppp":
21325 return formatLong2.time({ width: "long" });
21326 case "pppp":
21327 default:
21328 return formatLong2.time({ width: "full" });
21329 }
21330 };
21331 var dateTimeLongFormatter = (pattern, formatLong2) => {
21332 const matchResult = pattern.match(/(P+)(p+)?/) || [];
21333 const datePattern = matchResult[1];
21334 const timePattern = matchResult[2];
21335 if (!timePattern) {
21336 return dateLongFormatter(pattern, formatLong2);
21337 }
21338 let dateTimeFormat;
21339 switch (datePattern) {
21340 case "P":
21341 dateTimeFormat = formatLong2.dateTime({ width: "short" });
21342 break;
21343 case "PP":
21344 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21345 break;
21346 case "PPP":
21347 dateTimeFormat = formatLong2.dateTime({ width: "long" });
21348 break;
21349 case "PPPP":
21350 default:
21351 dateTimeFormat = formatLong2.dateTime({ width: "full" });
21352 break;
21353 }
21354 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21355 };
21356 var longFormatters = {
21357 p: timeLongFormatter,
21358 P: dateTimeLongFormatter
21359 };
21360
21361 // node_modules/date-fns/_lib/protectedTokens.js
21362 var dayOfYearTokenRE = /^D+$/;
21363 var weekYearTokenRE = /^Y+$/;
21364 var throwTokens = ["D", "DD", "YY", "YYYY"];
21365 function isProtectedDayOfYearToken(token) {
21366 return dayOfYearTokenRE.test(token);
21367 }
21368 function isProtectedWeekYearToken(token) {
21369 return weekYearTokenRE.test(token);
21370 }
21371 function warnOrThrowProtectedError(token, format6, input) {
21372 const _message = message(token, format6, input);
21373 console.warn(_message);
21374 if (throwTokens.includes(token)) throw new RangeError(_message);
21375 }
21376 function message(token, format6, input) {
21377 const subject = token[0] === "Y" ? "years" : "days of the month";
21378 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`;
21379 }
21380
21381 // node_modules/date-fns/format.js
21382 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21383 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21384 var escapedStringRegExp = /^'([^]*?)'?$/;
21385 var doubleQuoteRegExp = /''/g;
21386 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21387 function format(date, formatStr, options) {
21388 const defaultOptions2 = getDefaultOptions();
21389 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21390 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21391 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21392 const originalDate = toDate(date, options?.in);
21393 if (!isValid(originalDate)) {
21394 throw new RangeError("Invalid time value");
21395 }
21396 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21397 const firstCharacter = substring[0];
21398 if (firstCharacter === "p" || firstCharacter === "P") {
21399 const longFormatter = longFormatters[firstCharacter];
21400 return longFormatter(substring, locale.formatLong);
21401 }
21402 return substring;
21403 }).join("").match(formattingTokensRegExp).map((substring) => {
21404 if (substring === "''") {
21405 return { isToken: false, value: "'" };
21406 }
21407 const firstCharacter = substring[0];
21408 if (firstCharacter === "'") {
21409 return { isToken: false, value: cleanEscapedString(substring) };
21410 }
21411 if (formatters[firstCharacter]) {
21412 return { isToken: true, value: substring };
21413 }
21414 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21415 throw new RangeError(
21416 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21417 );
21418 }
21419 return { isToken: false, value: substring };
21420 });
21421 if (locale.localize.preprocessor) {
21422 parts = locale.localize.preprocessor(originalDate, parts);
21423 }
21424 const formatterOptions = {
21425 firstWeekContainsDate,
21426 weekStartsOn,
21427 locale
21428 };
21429 return parts.map((part) => {
21430 if (!part.isToken) return part.value;
21431 const token = part.value;
21432 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21433 warnOrThrowProtectedError(token, formatStr, String(date));
21434 }
21435 const formatter = formatters[token[0]];
21436 return formatter(originalDate, token, locale.localize, formatterOptions);
21437 }).join("");
21438 }
21439 function cleanEscapedString(input) {
21440 const matched = input.match(escapedStringRegExp);
21441 if (!matched) {
21442 return input;
21443 }
21444 return matched[1].replace(doubleQuoteRegExp, "'");
21445 }
21446
21447 // node_modules/date-fns/subDays.js
21448 function subDays(date, amount, options) {
21449 return addDays(date, -amount, options);
21450 }
21451
21452 // node_modules/date-fns/subMonths.js
21453 function subMonths(date, amount, options) {
21454 return addMonths(date, -amount, options);
21455 }
21456
21457 // node_modules/date-fns/subWeeks.js
21458 function subWeeks(date, amount, options) {
21459 return addWeeks(date, -amount, options);
21460 }
21461
21462 // node_modules/date-fns/subYears.js
21463 function subYears(date, amount, options) {
21464 return addYears(date, -amount, options);
21465 }
21466
21467 // packages/dataviews/build-module/utils/operators.mjs
21468 var import_i18n31 = __toESM(require_i18n(), 1);
21469 var import_element46 = __toESM(require_element(), 1);
21470 var import_date = __toESM(require_date(), 1);
21471 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21472 var filterTextWrappers = {
21473 Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21474 Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21475 };
21476 function getRelativeDate(value, unit) {
21477 switch (unit) {
21478 case "days":
21479 return subDays(/* @__PURE__ */ new Date(), value);
21480 case "weeks":
21481 return subWeeks(/* @__PURE__ */ new Date(), value);
21482 case "months":
21483 return subMonths(/* @__PURE__ */ new Date(), value);
21484 case "years":
21485 return subYears(/* @__PURE__ */ new Date(), value);
21486 default:
21487 return /* @__PURE__ */ new Date();
21488 }
21489 }
21490 var isNoneOperatorDefinition = {
21491 /* translators: DataViews operator name */
21492 label: (0, import_i18n31.__)("Is none of"),
21493 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21494 (0, import_i18n31.sprintf)(
21495 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21496 (0, import_i18n31.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21497 filter.name,
21498 activeElements.map((element) => element.label).join(", ")
21499 ),
21500 filterTextWrappers
21501 ),
21502 filter: ((item, field, filterValue) => {
21503 if (!filterValue?.length) {
21504 return true;
21505 }
21506 const fieldValue = field.getValue({ item });
21507 if (Array.isArray(fieldValue)) {
21508 return !filterValue.some(
21509 (fv) => fieldValue.includes(fv)
21510 );
21511 } else if (typeof fieldValue === "string") {
21512 return !filterValue.includes(fieldValue);
21513 }
21514 return false;
21515 }),
21516 selection: "multi"
21517 };
21518 var OPERATORS = [
21519 {
21520 name: OPERATOR_IS_ANY,
21521 /* translators: DataViews operator name */
21522 label: (0, import_i18n31.__)("Includes"),
21523 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21524 (0, import_i18n31.sprintf)(
21525 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21526 (0, import_i18n31.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21527 filter.name,
21528 activeElements.map((element) => element.label).join(", ")
21529 ),
21530 filterTextWrappers
21531 ),
21532 filter(item, field, filterValue) {
21533 if (!filterValue?.length) {
21534 return true;
21535 }
21536 const fieldValue = field.getValue({ item });
21537 if (Array.isArray(fieldValue)) {
21538 return filterValue.some(
21539 (fv) => fieldValue.includes(fv)
21540 );
21541 } else if (typeof fieldValue === "string") {
21542 return filterValue.includes(fieldValue);
21543 }
21544 return false;
21545 },
21546 selection: "multi"
21547 },
21548 {
21549 name: OPERATOR_IS_NONE,
21550 ...isNoneOperatorDefinition
21551 },
21552 {
21553 name: OPERATOR_IS_ALL,
21554 /* translators: DataViews operator name */
21555 label: (0, import_i18n31.__)("Includes all"),
21556 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21557 (0, import_i18n31.sprintf)(
21558 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21559 (0, import_i18n31.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21560 filter.name,
21561 activeElements.map((element) => element.label).join(", ")
21562 ),
21563 filterTextWrappers
21564 ),
21565 filter(item, field, filterValue) {
21566 if (!filterValue?.length) {
21567 return true;
21568 }
21569 return filterValue.every((value) => {
21570 return field.getValue({ item })?.includes(value);
21571 });
21572 },
21573 selection: "multi"
21574 },
21575 {
21576 name: OPERATOR_IS_NOT_ALL,
21577 ...isNoneOperatorDefinition
21578 },
21579 {
21580 name: OPERATOR_BETWEEN,
21581 /* translators: DataViews operator name */
21582 label: (0, import_i18n31.__)("Between (inc)"),
21583 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21584 (0, import_i18n31.sprintf)(
21585 /* 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". */
21586 (0, import_i18n31.__)(
21587 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21588 ),
21589 filter.name,
21590 activeElements[0].label[0],
21591 activeElements[0].label[1]
21592 ),
21593 filterTextWrappers
21594 ),
21595 filter(item, field, filterValue) {
21596 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21597 return true;
21598 }
21599 const fieldValue = field.getValue({ item });
21600 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21601 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21602 }
21603 return false;
21604 },
21605 selection: "custom"
21606 },
21607 {
21608 name: OPERATOR_IN_THE_PAST,
21609 /* translators: DataViews operator name */
21610 label: (0, import_i18n31.__)("In the past"),
21611 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21612 (0, import_i18n31.sprintf)(
21613 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21614 (0, import_i18n31.__)(
21615 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21616 ),
21617 filter.name,
21618 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21619 ),
21620 filterTextWrappers
21621 ),
21622 filter(item, field, filterValue) {
21623 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21624 return true;
21625 }
21626 const targetDate = getRelativeDate(
21627 filterValue.value,
21628 filterValue.unit
21629 );
21630 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21631 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21632 },
21633 selection: "custom"
21634 },
21635 {
21636 name: OPERATOR_OVER,
21637 /* translators: DataViews operator name */
21638 label: (0, import_i18n31.__)("Over"),
21639 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21640 (0, import_i18n31.sprintf)(
21641 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21642 (0, import_i18n31.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21643 filter.name,
21644 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21645 ),
21646 filterTextWrappers
21647 ),
21648 filter(item, field, filterValue) {
21649 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21650 return true;
21651 }
21652 const targetDate = getRelativeDate(
21653 filterValue.value,
21654 filterValue.unit
21655 );
21656 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21657 return fieldValue < targetDate;
21658 },
21659 selection: "custom"
21660 },
21661 {
21662 name: OPERATOR_IS,
21663 /* translators: DataViews operator name */
21664 label: (0, import_i18n31.__)("Is"),
21665 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21666 (0, import_i18n31.sprintf)(
21667 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21668 (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21669 filter.name,
21670 activeElements[0].label
21671 ),
21672 filterTextWrappers
21673 ),
21674 filter(item, field, filterValue) {
21675 return filterValue === field.getValue({ item }) || filterValue === void 0;
21676 },
21677 selection: "single"
21678 },
21679 {
21680 name: OPERATOR_IS_NOT,
21681 /* translators: DataViews operator name */
21682 label: (0, import_i18n31.__)("Is not"),
21683 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21684 (0, import_i18n31.sprintf)(
21685 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21686 (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21687 filter.name,
21688 activeElements[0].label
21689 ),
21690 filterTextWrappers
21691 ),
21692 filter(item, field, filterValue) {
21693 return filterValue !== field.getValue({ item });
21694 },
21695 selection: "single"
21696 },
21697 {
21698 name: OPERATOR_LESS_THAN,
21699 /* translators: DataViews operator name */
21700 label: (0, import_i18n31.__)("Less than"),
21701 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21702 (0, import_i18n31.sprintf)(
21703 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21704 (0, import_i18n31.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21705 filter.name,
21706 activeElements[0].label
21707 ),
21708 filterTextWrappers
21709 ),
21710 filter(item, field, filterValue) {
21711 if (filterValue === void 0) {
21712 return true;
21713 }
21714 const fieldValue = field.getValue({ item });
21715 return fieldValue < filterValue;
21716 },
21717 selection: "single"
21718 },
21719 {
21720 name: OPERATOR_GREATER_THAN,
21721 /* translators: DataViews operator name */
21722 label: (0, import_i18n31.__)("Greater than"),
21723 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21724 (0, import_i18n31.sprintf)(
21725 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21726 (0, import_i18n31.__)(
21727 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21728 ),
21729 filter.name,
21730 activeElements[0].label
21731 ),
21732 filterTextWrappers
21733 ),
21734 filter(item, field, filterValue) {
21735 if (filterValue === void 0) {
21736 return true;
21737 }
21738 const fieldValue = field.getValue({ item });
21739 return fieldValue > filterValue;
21740 },
21741 selection: "single"
21742 },
21743 {
21744 name: OPERATOR_LESS_THAN_OR_EQUAL,
21745 /* translators: DataViews operator name */
21746 label: (0, import_i18n31.__)("Less than or equal"),
21747 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21748 (0, import_i18n31.sprintf)(
21749 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21750 (0, import_i18n31.__)(
21751 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21752 ),
21753 filter.name,
21754 activeElements[0].label
21755 ),
21756 filterTextWrappers
21757 ),
21758 filter(item, field, filterValue) {
21759 if (filterValue === void 0) {
21760 return true;
21761 }
21762 const fieldValue = field.getValue({ item });
21763 return fieldValue <= filterValue;
21764 },
21765 selection: "single"
21766 },
21767 {
21768 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21769 /* translators: DataViews operator name */
21770 label: (0, import_i18n31.__)("Greater than or equal"),
21771 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21772 (0, import_i18n31.sprintf)(
21773 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21774 (0, import_i18n31.__)(
21775 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21776 ),
21777 filter.name,
21778 activeElements[0].label
21779 ),
21780 filterTextWrappers
21781 ),
21782 filter(item, field, filterValue) {
21783 if (filterValue === void 0) {
21784 return true;
21785 }
21786 const fieldValue = field.getValue({ item });
21787 return fieldValue >= filterValue;
21788 },
21789 selection: "single"
21790 },
21791 {
21792 name: OPERATOR_BEFORE,
21793 /* translators: DataViews operator name */
21794 label: (0, import_i18n31.__)("Before"),
21795 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21796 (0, import_i18n31.sprintf)(
21797 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21798 (0, import_i18n31.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21799 filter.name,
21800 activeElements[0].label
21801 ),
21802 filterTextWrappers
21803 ),
21804 filter(item, field, filterValue) {
21805 if (filterValue === void 0) {
21806 return true;
21807 }
21808 const filterDate = (0, import_date.getDate)(filterValue);
21809 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21810 return fieldDate < filterDate;
21811 },
21812 selection: "single"
21813 },
21814 {
21815 name: OPERATOR_AFTER,
21816 /* translators: DataViews operator name */
21817 label: (0, import_i18n31.__)("After"),
21818 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21819 (0, import_i18n31.sprintf)(
21820 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21821 (0, import_i18n31.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21822 filter.name,
21823 activeElements[0].label
21824 ),
21825 filterTextWrappers
21826 ),
21827 filter(item, field, filterValue) {
21828 if (filterValue === void 0) {
21829 return true;
21830 }
21831 const filterDate = (0, import_date.getDate)(filterValue);
21832 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21833 return fieldDate > filterDate;
21834 },
21835 selection: "single"
21836 },
21837 {
21838 name: OPERATOR_BEFORE_INC,
21839 /* translators: DataViews operator name */
21840 label: (0, import_i18n31.__)("Before (inc)"),
21841 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21842 (0, import_i18n31.sprintf)(
21843 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21844 (0, import_i18n31.__)(
21845 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21846 ),
21847 filter.name,
21848 activeElements[0].label
21849 ),
21850 filterTextWrappers
21851 ),
21852 filter(item, field, filterValue) {
21853 if (filterValue === void 0) {
21854 return true;
21855 }
21856 const filterDate = (0, import_date.getDate)(filterValue);
21857 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21858 return fieldDate <= filterDate;
21859 },
21860 selection: "single"
21861 },
21862 {
21863 name: OPERATOR_AFTER_INC,
21864 /* translators: DataViews operator name */
21865 label: (0, import_i18n31.__)("After (inc)"),
21866 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21867 (0, import_i18n31.sprintf)(
21868 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21869 (0, import_i18n31.__)(
21870 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21871 ),
21872 filter.name,
21873 activeElements[0].label
21874 ),
21875 filterTextWrappers
21876 ),
21877 filter(item, field, filterValue) {
21878 if (filterValue === void 0) {
21879 return true;
21880 }
21881 const filterDate = (0, import_date.getDate)(filterValue);
21882 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21883 return fieldDate >= filterDate;
21884 },
21885 selection: "single"
21886 },
21887 {
21888 name: OPERATOR_CONTAINS,
21889 /* translators: DataViews operator name */
21890 label: (0, import_i18n31.__)("Contains"),
21891 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21892 (0, import_i18n31.sprintf)(
21893 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21894 (0, import_i18n31.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21895 filter.name,
21896 activeElements[0].label
21897 ),
21898 filterTextWrappers
21899 ),
21900 filter(item, field, filterValue) {
21901 if (filterValue === void 0) {
21902 return true;
21903 }
21904 const fieldValue = field.getValue({ item });
21905 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21906 },
21907 selection: "single"
21908 },
21909 {
21910 name: OPERATOR_NOT_CONTAINS,
21911 /* translators: DataViews operator name */
21912 label: (0, import_i18n31.__)("Doesn't contain"),
21913 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21914 (0, import_i18n31.sprintf)(
21915 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21916 (0, import_i18n31.__)(
21917 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21918 ),
21919 filter.name,
21920 activeElements[0].label
21921 ),
21922 filterTextWrappers
21923 ),
21924 filter(item, field, filterValue) {
21925 if (filterValue === void 0) {
21926 return true;
21927 }
21928 const fieldValue = field.getValue({ item });
21929 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21930 },
21931 selection: "single"
21932 },
21933 {
21934 name: OPERATOR_STARTS_WITH,
21935 /* translators: DataViews operator name */
21936 label: (0, import_i18n31.__)("Starts with"),
21937 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21938 (0, import_i18n31.sprintf)(
21939 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21940 (0, import_i18n31.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21941 filter.name,
21942 activeElements[0].label
21943 ),
21944 filterTextWrappers
21945 ),
21946 filter(item, field, filterValue) {
21947 if (filterValue === void 0) {
21948 return true;
21949 }
21950 const fieldValue = field.getValue({ item });
21951 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21952 },
21953 selection: "single"
21954 },
21955 {
21956 name: OPERATOR_ON,
21957 /* translators: DataViews operator name */
21958 label: (0, import_i18n31.__)("On"),
21959 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21960 (0, import_i18n31.sprintf)(
21961 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21962 (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21963 filter.name,
21964 activeElements[0].label
21965 ),
21966 filterTextWrappers
21967 ),
21968 filter(item, field, filterValue) {
21969 if (filterValue === void 0) {
21970 return true;
21971 }
21972 const filterDate = (0, import_date.getDate)(filterValue);
21973 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21974 return filterDate.getTime() === fieldDate.getTime();
21975 },
21976 selection: "single"
21977 },
21978 {
21979 name: OPERATOR_NOT_ON,
21980 /* translators: DataViews operator name */
21981 label: (0, import_i18n31.__)("Not on"),
21982 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21983 (0, import_i18n31.sprintf)(
21984 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21985 (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21986 filter.name,
21987 activeElements[0].label
21988 ),
21989 filterTextWrappers
21990 ),
21991 filter(item, field, filterValue) {
21992 if (filterValue === void 0) {
21993 return true;
21994 }
21995 const filterDate = (0, import_date.getDate)(filterValue);
21996 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21997 return filterDate.getTime() !== fieldDate.getTime();
21998 },
21999 selection: "single"
22000 }
22001 ];
22002 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
22003 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
22004 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
22005 (op) => op.name === name
22006 );
22007 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
22008
22009 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
22010 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22011 var ENTER = "Enter";
22012 var SPACE = " ";
22013 var FilterText = ({
22014 activeElements,
22015 filterInView,
22016 filter
22017 }) => {
22018 if (activeElements === void 0 || activeElements.length === 0) {
22019 return filter.name;
22020 }
22021 const operator = getOperatorByName(filterInView?.operator);
22022 if (operator !== void 0) {
22023 return operator.filterText(filter, activeElements);
22024 }
22025 return (0, import_i18n32.sprintf)(
22026 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
22027 (0, import_i18n32.__)("Unknown status for %1$s"),
22028 filter.name
22029 );
22030 };
22031 function OperatorSelector({
22032 filter,
22033 view,
22034 onChangeView
22035 }) {
22036 const operatorOptions = filter.operators?.map((operator) => ({
22037 value: operator,
22038 label: getOperatorByName(operator)?.label || operator
22039 }));
22040 const currentFilter = view.filters?.find(
22041 (_filter) => _filter.field === filter.field
22042 );
22043 const value = currentFilter?.operator || filter.operators[0];
22044 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22045 Stack,
22046 {
22047 direction: "row",
22048 gap: "sm",
22049 justify: "flex-start",
22050 className: "dataviews-filters__summary-operators-container",
22051 align: "center",
22052 children: [
22053 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
22054 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22055 import_components21.SelectControl,
22056 {
22057 className: "dataviews-filters__summary-operators-filter-select",
22058 label: (0, import_i18n32.__)("Conditions"),
22059 value,
22060 options: operatorOptions,
22061 onChange: (newValue) => {
22062 const newOperator = newValue;
22063 const currentOperator = currentFilter?.operator;
22064 const newFilters = currentFilter ? [
22065 ...(view.filters ?? []).map(
22066 (_filter) => {
22067 if (_filter.field === filter.field) {
22068 const currentOpSelectionModel = getOperatorByName(
22069 currentOperator
22070 )?.selection;
22071 const newOpSelectionModel = getOperatorByName(
22072 newOperator
22073 )?.selection;
22074 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
22075 currentOpSelectionModel,
22076 newOpSelectionModel
22077 ].includes("custom");
22078 return {
22079 ..._filter,
22080 value: shouldResetValue ? void 0 : _filter.value,
22081 operator: newOperator
22082 };
22083 }
22084 return _filter;
22085 }
22086 )
22087 ] : [
22088 ...view.filters ?? [],
22089 {
22090 field: filter.field,
22091 operator: newOperator,
22092 value: void 0
22093 }
22094 ];
22095 onChangeView({
22096 ...view,
22097 page: 1,
22098 filters: newFilters
22099 });
22100 },
22101 size: "small",
22102 variant: "minimal",
22103 hideLabelFromVision: true
22104 }
22105 )
22106 ]
22107 }
22108 );
22109 }
22110 function Filter({
22111 addFilterRef,
22112 openedFilter,
22113 fields,
22114 ...commonProps
22115 }) {
22116 const toggleRef = (0, import_element47.useRef)(null);
22117 const { filter, view, onChangeView } = commonProps;
22118 const filterInView = view.filters?.find(
22119 (f2) => f2.field === filter.field
22120 );
22121 let activeElements = [];
22122 const field = (0, import_element47.useMemo)(() => {
22123 const currentField = fields.find((f2) => f2.id === filter.field);
22124 if (currentField) {
22125 return {
22126 ...currentField,
22127 // Configure getValue as if Item was a plain object.
22128 // See related input-widget.tsx
22129 getValue: ({ item }) => item[currentField.id]
22130 };
22131 }
22132 return currentField;
22133 }, [fields, filter.field]);
22134 const { elements } = useElements({
22135 elements: filter.elements,
22136 getElements: filter.getElements
22137 });
22138 if (elements.length > 0) {
22139 activeElements = elements.filter((element) => {
22140 if (filter.singleSelection) {
22141 return element.value === filterInView?.value;
22142 }
22143 return filterInView?.value?.includes(element.value);
22144 });
22145 } else if (Array.isArray(filterInView?.value)) {
22146 const label = filterInView.value.map((v2) => {
22147 const formattedValue = field?.getValueFormatted({
22148 item: { [field.id]: v2 },
22149 field
22150 });
22151 return formattedValue || String(v2);
22152 });
22153 activeElements = [
22154 {
22155 value: filterInView.value,
22156 // @ts-ignore
22157 label
22158 }
22159 ];
22160 } else if (typeof filterInView?.value === "object") {
22161 activeElements = [
22162 { value: filterInView.value, label: filterInView.value }
22163 ];
22164 } else if (filterInView?.value !== void 0) {
22165 const label = field !== void 0 ? field.getValueFormatted({
22166 item: { [field.id]: filterInView.value },
22167 field
22168 }) : String(filterInView.value);
22169 activeElements = [
22170 {
22171 value: filterInView.value,
22172 label
22173 }
22174 ];
22175 }
22176 const isPrimary = filter.isPrimary;
22177 const isLocked = filterInView?.isLocked;
22178 const hasValues = !isLocked && filterInView?.value !== void 0;
22179 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22180 const resetOrRemoveLabel = isPrimary ? (0, import_i18n32.__)("Reset") : (0, import_i18n32.__)("Remove");
22181 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22182 import_components21.Dropdown,
22183 {
22184 defaultOpen: openedFilter === filter.field,
22185 contentClassName: "dataviews-filters__summary-popover",
22186 popoverProps: { placement: "bottom-start", role: "dialog" },
22187 onClose: () => {
22188 toggleRef.current?.focus();
22189 },
22190 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22191 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22192 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22193 tooltip_exports.Trigger,
22194 {
22195 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22196 "div",
22197 {
22198 className: clsx_default(
22199 "dataviews-filters__summary-chip",
22200 {
22201 "has-reset": canResetOrRemove,
22202 "has-values": hasValues,
22203 "is-not-clickable": isLocked
22204 }
22205 ),
22206 role: "button",
22207 tabIndex: isLocked ? -1 : 0,
22208 onClick: () => {
22209 if (!isLocked) {
22210 onToggle();
22211 }
22212 },
22213 onKeyDown: (event) => {
22214 if (!isLocked && [ENTER, SPACE].includes(
22215 event.key
22216 )) {
22217 onToggle();
22218 event.preventDefault();
22219 }
22220 },
22221 "aria-disabled": isLocked,
22222 "aria-pressed": isOpen,
22223 "aria-expanded": isOpen,
22224 ref: toggleRef,
22225 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22226 FilterText,
22227 {
22228 activeElements,
22229 filterInView,
22230 filter
22231 }
22232 )
22233 }
22234 )
22235 }
22236 ),
22237 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n32.sprintf)(
22238 /* translators: 1: Filter name. */
22239 (0, import_i18n32.__)("Filter by: %1$s"),
22240 filter.name.toLowerCase()
22241 ) })
22242 ] }),
22243 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22244 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22245 tooltip_exports.Trigger,
22246 {
22247 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22248 "button",
22249 {
22250 className: clsx_default(
22251 "dataviews-filters__summary-chip-remove",
22252 { "has-values": hasValues }
22253 ),
22254 "aria-label": resetOrRemoveLabel,
22255 onClick: () => {
22256 onChangeView({
22257 ...view,
22258 page: 1,
22259 filters: view.filters?.filter(
22260 (_filter) => _filter.field !== filter.field
22261 )
22262 });
22263 if (!isPrimary) {
22264 addFilterRef.current?.focus();
22265 } else {
22266 toggleRef.current?.focus();
22267 }
22268 },
22269 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
22270 }
22271 )
22272 }
22273 ),
22274 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22275 ] })
22276 ] }),
22277 renderContent: () => {
22278 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22279 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
22280 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22281 SearchWidget,
22282 {
22283 ...commonProps,
22284 filter: {
22285 ...commonProps.filter,
22286 elements
22287 }
22288 }
22289 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
22290 ] });
22291 }
22292 }
22293 );
22294 }
22295
22296 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22297 var import_components22 = __toESM(require_components(), 1);
22298 var import_i18n33 = __toESM(require_i18n(), 1);
22299 var import_element48 = __toESM(require_element(), 1);
22300 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22301 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22302 function AddFilterMenu({
22303 filters,
22304 view,
22305 onChangeView,
22306 setOpenedFilter,
22307 triggerProps
22308 }) {
22309 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22310 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
22311 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22312 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22313 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22314 Menu4.Item,
22315 {
22316 onClick: () => {
22317 setOpenedFilter(filter.field);
22318 onChangeView({
22319 ...view,
22320 page: 1,
22321 filters: [
22322 ...view.filters || [],
22323 {
22324 field: filter.field,
22325 value: void 0,
22326 operator: filter.operators[0]
22327 }
22328 ]
22329 });
22330 },
22331 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
22332 },
22333 filter.field
22334 );
22335 }) })
22336 ] });
22337 }
22338 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22339 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22340 return null;
22341 }
22342 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22343 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22344 AddFilterMenu,
22345 {
22346 triggerProps: {
22347 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22348 import_components22.Button,
22349 {
22350 accessibleWhenDisabled: true,
22351 size: "compact",
22352 className: "dataviews-filters-button",
22353 variant: "tertiary",
22354 disabled: !inactiveFilters.length,
22355 ref
22356 }
22357 ),
22358 children: (0, import_i18n33.__)("Add filter")
22359 },
22360 ...{ filters, view, onChangeView, setOpenedFilter }
22361 }
22362 );
22363 }
22364 var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
22365
22366 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22367 var import_components23 = __toESM(require_components(), 1);
22368 var import_i18n34 = __toESM(require_i18n(), 1);
22369 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22370 function ResetFilter({
22371 filters,
22372 view,
22373 onChangeView
22374 }) {
22375 const isPrimary = (field) => filters.some(
22376 (_filter) => _filter.field === field && _filter.isPrimary
22377 );
22378 const isDisabled = !view.search && !view.filters?.some(
22379 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22380 );
22381 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22382 import_components23.Button,
22383 {
22384 disabled: isDisabled,
22385 accessibleWhenDisabled: true,
22386 size: "compact",
22387 variant: "tertiary",
22388 className: "dataviews-filters__reset-button",
22389 onClick: () => {
22390 onChangeView({
22391 ...view,
22392 page: 1,
22393 search: "",
22394 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22395 });
22396 },
22397 children: (0, import_i18n34.__)("Reset")
22398 }
22399 );
22400 }
22401
22402 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22403 var import_element49 = __toESM(require_element(), 1);
22404 function useFilters(fields, view) {
22405 return (0, import_element49.useMemo)(() => {
22406 const filters = [];
22407 fields.forEach((field) => {
22408 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22409 return;
22410 }
22411 const operators = field.filterBy.operators;
22412 const isPrimary = !!field.filterBy?.isPrimary;
22413 const isLocked = view.filters?.some(
22414 (f2) => f2.field === field.id && !!f2.isLocked
22415 ) ?? false;
22416 filters.push({
22417 field: field.id,
22418 name: field.label,
22419 elements: field.elements,
22420 getElements: field.getElements,
22421 hasElements: field.hasElements,
22422 singleSelection: operators.some(
22423 (op) => isSingleSelectionOperator(op)
22424 ),
22425 operators,
22426 isVisible: isLocked || isPrimary || !!view.filters?.some(
22427 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22428 ),
22429 isPrimary,
22430 isLocked
22431 });
22432 });
22433 filters.sort((a2, b2) => {
22434 if (a2.isLocked && !b2.isLocked) {
22435 return -1;
22436 }
22437 if (!a2.isLocked && b2.isLocked) {
22438 return 1;
22439 }
22440 if (a2.isPrimary && !b2.isPrimary) {
22441 return -1;
22442 }
22443 if (!a2.isPrimary && b2.isPrimary) {
22444 return 1;
22445 }
22446 return a2.name.localeCompare(b2.name);
22447 });
22448 return filters;
22449 }, [fields, view]);
22450 }
22451 var use_filters_default = useFilters;
22452
22453 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22454 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22455 function Filters({ className }) {
22456 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
22457 const addFilterRef = (0, import_element50.useRef)(null);
22458 const filters = use_filters_default(fields, view);
22459 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22460 add_filter_default,
22461 {
22462 filters,
22463 view,
22464 onChangeView,
22465 ref: addFilterRef,
22466 setOpenedFilter
22467 },
22468 "add-filter"
22469 );
22470 const visibleFilters = filters.filter((filter) => filter.isVisible);
22471 if (visibleFilters.length === 0) {
22472 return null;
22473 }
22474 const filterComponents = [
22475 ...visibleFilters.map((filter) => {
22476 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22477 Filter,
22478 {
22479 filter,
22480 view,
22481 fields,
22482 onChangeView,
22483 addFilterRef,
22484 openedFilter
22485 },
22486 filter.field
22487 );
22488 }),
22489 addFilter
22490 ];
22491 filterComponents.push(
22492 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22493 ResetFilter,
22494 {
22495 filters,
22496 view,
22497 onChangeView
22498 },
22499 "reset-filters"
22500 )
22501 );
22502 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22503 Stack,
22504 {
22505 direction: "row",
22506 justify: "flex-start",
22507 gap: "sm",
22508 style: { width: "fit-content" },
22509 wrap: "wrap",
22510 className,
22511 children: filterComponents
22512 }
22513 );
22514 }
22515 var filters_default = (0, import_element50.memo)(Filters);
22516
22517 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22518 var import_element51 = __toESM(require_element(), 1);
22519 var import_components24 = __toESM(require_components(), 1);
22520 var import_i18n35 = __toESM(require_i18n(), 1);
22521 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22522 function FiltersToggle() {
22523 const {
22524 filters,
22525 view,
22526 onChangeView,
22527 setOpenedFilter,
22528 isShowingFilter,
22529 setIsShowingFilter
22530 } = (0, import_element51.useContext)(dataviews_context_default);
22531 const buttonRef = (0, import_element51.useRef)(null);
22532 const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
22533 (_view) => {
22534 onChangeView(_view);
22535 setIsShowingFilter(true);
22536 },
22537 [onChangeView, setIsShowingFilter]
22538 );
22539 if (filters.length === 0) {
22540 return null;
22541 }
22542 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22543 const addFilterButtonProps = {
22544 label: (0, import_i18n35.__)("Add filter"),
22545 "aria-expanded": false,
22546 isPressed: false
22547 };
22548 const toggleFiltersButtonProps = {
22549 label: (0, import_i18n35._x)("Filter", "verb"),
22550 "aria-expanded": isShowingFilter,
22551 isPressed: isShowingFilter,
22552 onClick: () => {
22553 if (!isShowingFilter) {
22554 setOpenedFilter(null);
22555 }
22556 setIsShowingFilter(!isShowingFilter);
22557 }
22558 };
22559 const hasPrimaryOrLockedFilters = filters.some(
22560 (filter) => filter.isPrimary || filter.isLocked
22561 );
22562 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22563 import_components24.Button,
22564 {
22565 ref: buttonRef,
22566 className: "dataviews-filters__visibility-toggle",
22567 size: "compact",
22568 icon: funnel_default,
22569 disabled: hasPrimaryOrLockedFilters,
22570 accessibleWhenDisabled: true,
22571 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22572 }
22573 );
22574 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22575 AddFilterMenu,
22576 {
22577 filters,
22578 view,
22579 onChangeView: onChangeViewWithFilterVisibility,
22580 setOpenedFilter,
22581 triggerProps: { render: buttonComponent }
22582 }
22583 ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22584 FilterVisibilityToggle,
22585 {
22586 buttonRef,
22587 filtersCount: view.filters?.length,
22588 children: buttonComponent
22589 }
22590 ) });
22591 }
22592 function FilterVisibilityToggle({
22593 buttonRef,
22594 filtersCount,
22595 children
22596 }) {
22597 (0, import_element51.useEffect)(
22598 () => () => {
22599 buttonRef.current?.focus();
22600 },
22601 [buttonRef]
22602 );
22603 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
22604 children,
22605 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22606 ] });
22607 }
22608 var toggle_default = FiltersToggle;
22609
22610 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22611 var import_element52 = __toESM(require_element(), 1);
22612 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22613 function FiltersToggled(props) {
22614 const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
22615 if (!isShowingFilter) {
22616 return null;
22617 }
22618 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
22619 }
22620 var filters_toggled_default = FiltersToggled;
22621
22622 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22623 var import_element53 = __toESM(require_element(), 1);
22624 var import_components25 = __toESM(require_components(), 1);
22625 var import_i18n36 = __toESM(require_i18n(), 1);
22626 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22627 function DataViewsLayout({ className }) {
22628 const {
22629 actions = [],
22630 data,
22631 fields,
22632 getItemId,
22633 getItemLevel,
22634 hasInitiallyLoaded,
22635 isLoading,
22636 view,
22637 onChangeView,
22638 selection,
22639 onChangeSelection,
22640 setOpenedFilter,
22641 onClickItem,
22642 isItemClickable: isItemClickable2,
22643 renderItemLink,
22644 defaultLayouts: defaultLayouts2,
22645 containerRef,
22646 empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n36.__)("No results") })
22647 } = (0, import_element53.useContext)(dataviews_context_default);
22648 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22649 delay: 200
22650 });
22651 if (!hasInitiallyLoaded) {
22652 if (!isDelayedInitialLoading) {
22653 return null;
22654 }
22655 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, {}) }) });
22656 }
22657 const ViewComponent = VIEW_LAYOUTS.find(
22658 (v2) => v2.type === view.type && defaultLayouts2[v2.type]
22659 )?.component;
22660 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22661 ViewComponent,
22662 {
22663 className,
22664 actions,
22665 data,
22666 fields,
22667 getItemId,
22668 getItemLevel,
22669 isLoading,
22670 onChangeView,
22671 onChangeSelection,
22672 selection,
22673 setOpenedFilter,
22674 onClickItem,
22675 renderItemLink,
22676 isItemClickable: isItemClickable2,
22677 view,
22678 empty
22679 }
22680 ) });
22681 }
22682
22683 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22684 var import_i18n37 = __toESM(require_i18n(), 1);
22685 var import_element54 = __toESM(require_element(), 1);
22686 var import_components26 = __toESM(require_components(), 1);
22687 var import_compose10 = __toESM(require_compose(), 1);
22688 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22689 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
22690 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
22691 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22692 view.search
22693 );
22694 (0, import_element54.useEffect)(() => {
22695 if (view.search !== debouncedSearch) {
22696 setSearch(view.search ?? "");
22697 }
22698 }, [view.search, setSearch]);
22699 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
22700 const viewRef = (0, import_element54.useRef)(view);
22701 (0, import_element54.useEffect)(() => {
22702 onChangeViewRef.current = onChangeView;
22703 viewRef.current = view;
22704 }, [onChangeView, view]);
22705 (0, import_element54.useEffect)(() => {
22706 if (debouncedSearch !== viewRef.current?.search) {
22707 onChangeViewRef.current({
22708 ...viewRef.current,
22709 page: view.page ? 1 : void 0,
22710 startPosition: view.startPosition ? 1 : void 0,
22711 search: debouncedSearch
22712 });
22713 }
22714 }, [debouncedSearch]);
22715 const searchLabel = label || (0, import_i18n37.__)("Search");
22716 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22717 import_components26.SearchControl,
22718 {
22719 className: "dataviews-search",
22720 onChange: setSearch,
22721 value: search,
22722 label: searchLabel,
22723 placeholder: searchLabel,
22724 size: "compact"
22725 }
22726 );
22727 });
22728 var dataviews_search_default = DataViewsSearch;
22729
22730 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22731 var import_components27 = __toESM(require_components(), 1);
22732 var import_i18n38 = __toESM(require_i18n(), 1);
22733 var import_element55 = __toESM(require_element(), 1);
22734 var import_warning = __toESM(require_warning(), 1);
22735 var import_compose11 = __toESM(require_compose(), 1);
22736 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22737 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22738 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22739 className: "dataviews-config__popover",
22740 placement: "bottom-end",
22741 offset: 9
22742 };
22743 function ViewTypeMenu() {
22744 const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element55.useContext)(dataviews_context_default);
22745 const availableLayouts = Object.keys(defaultLayouts2);
22746 if (availableLayouts.length <= 1) {
22747 return null;
22748 }
22749 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22750 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22751 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22752 Menu5.TriggerButton,
22753 {
22754 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22755 import_components27.Button,
22756 {
22757 size: "compact",
22758 icon: activeView?.icon,
22759 label: (0, import_i18n38.__)("Layout")
22760 }
22761 )
22762 }
22763 ),
22764 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22765 const config = VIEW_LAYOUTS.find(
22766 (v2) => v2.type === layout
22767 );
22768 if (!config) {
22769 return null;
22770 }
22771 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22772 Menu5.RadioItem,
22773 {
22774 value: layout,
22775 name: "view-actions-available-view",
22776 checked: layout === view.type,
22777 hideOnClick: true,
22778 onChange: (e2) => {
22779 switch (e2.target.value) {
22780 case "list":
22781 case "grid":
22782 case "table":
22783 case "pickerGrid":
22784 case "pickerTable":
22785 case "pickerActivity":
22786 case "activity":
22787 const viewWithoutLayout = { ...view };
22788 if ("layout" in viewWithoutLayout) {
22789 delete viewWithoutLayout.layout;
22790 }
22791 return onChangeView({
22792 ...viewWithoutLayout,
22793 type: e2.target.value,
22794 ...defaultLayouts2[e2.target.value]
22795 });
22796 }
22797 (0, import_warning.default)("Invalid dataview");
22798 },
22799 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22800 },
22801 layout
22802 );
22803 }) })
22804 ] });
22805 }
22806 function SortFieldControl() {
22807 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22808 const orderOptions = (0, import_element55.useMemo)(() => {
22809 const sortableFields = fields.filter(
22810 (field) => field.enableSorting !== false
22811 );
22812 return sortableFields.map((field) => {
22813 return {
22814 label: field.label,
22815 value: field.id
22816 };
22817 });
22818 }, [fields]);
22819 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22820 import_components27.SelectControl,
22821 {
22822 label: (0, import_i18n38.__)("Sort by"),
22823 value: view.sort?.field,
22824 options: orderOptions,
22825 onChange: (value) => {
22826 onChangeView({
22827 ...view,
22828 sort: {
22829 direction: view?.sort?.direction || "desc",
22830 field: value
22831 },
22832 showLevels: false
22833 });
22834 }
22835 }
22836 );
22837 }
22838 function SortDirectionControl() {
22839 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22840 const sortableFields = fields.filter(
22841 (field) => field.enableSorting !== false
22842 );
22843 if (sortableFields.length === 0) {
22844 return null;
22845 }
22846 let value = view.sort?.direction;
22847 if (!value && view.sort?.field) {
22848 value = "desc";
22849 }
22850 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22851 import_components27.__experimentalToggleGroupControl,
22852 {
22853 className: "dataviews-view-config__sort-direction",
22854 isBlock: true,
22855 label: (0, import_i18n38.__)("Order"),
22856 value,
22857 onChange: (newDirection) => {
22858 if (newDirection === "asc" || newDirection === "desc") {
22859 onChangeView({
22860 ...view,
22861 sort: {
22862 direction: newDirection,
22863 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22864 fields.find(
22865 (field) => field.enableSorting !== false
22866 )?.id || ""
22867 },
22868 showLevels: false
22869 });
22870 return;
22871 }
22872 (0, import_warning.default)("Invalid direction");
22873 },
22874 children: SORTING_DIRECTIONS.map((direction) => {
22875 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22876 import_components27.__experimentalToggleGroupControlOptionIcon,
22877 {
22878 value: direction,
22879 icon: sortIcons[direction],
22880 label: sortLabels[direction]
22881 },
22882 direction
22883 );
22884 })
22885 }
22886 );
22887 }
22888 function ItemsPerPageControl() {
22889 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22890 const { infiniteScrollEnabled } = view;
22891 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22892 return null;
22893 }
22894 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22895 import_components27.__experimentalToggleGroupControl,
22896 {
22897 isBlock: true,
22898 label: (0, import_i18n38.__)("Items per page"),
22899 value: view.perPage || 10,
22900 disabled: !view?.sort?.field,
22901 onChange: (newItemsPerPage) => {
22902 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22903 onChangeView({
22904 ...view,
22905 perPage: newItemsPerPageNumber,
22906 page: 1
22907 });
22908 },
22909 children: config.perPageSizes.map((value) => {
22910 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22911 import_components27.__experimentalToggleGroupControlOption,
22912 {
22913 value,
22914 label: value.toString()
22915 },
22916 value
22917 );
22918 })
22919 }
22920 );
22921 }
22922 function ResetViewButton() {
22923 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
22924 if (onReset === void 0) {
22925 return null;
22926 }
22927 const isDisabled = onReset === false;
22928 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22929 import_components27.Button,
22930 {
22931 variant: "tertiary",
22932 size: "compact",
22933 disabled: isDisabled,
22934 accessibleWhenDisabled: true,
22935 className: "dataviews-view-config__reset-button",
22936 onClick: () => {
22937 if (typeof onReset === "function") {
22938 onReset();
22939 }
22940 },
22941 children: (0, import_i18n38.__)("Reset view")
22942 }
22943 );
22944 }
22945 function DataviewsViewConfigDropdown() {
22946 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
22947 const popoverId = (0, import_compose11.useInstanceId)(
22948 _DataViewsViewConfig,
22949 "dataviews-view-config-dropdown"
22950 );
22951 const activeLayout = VIEW_LAYOUTS.find(
22952 (layout) => layout.type === view.type
22953 );
22954 const isModified = typeof onReset === "function";
22955 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22956 import_components27.Dropdown,
22957 {
22958 expandOnMobile: true,
22959 popoverProps: {
22960 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22961 id: popoverId
22962 },
22963 renderToggle: ({ onToggle, isOpen }) => {
22964 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22965 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22966 import_components27.Button,
22967 {
22968 size: "compact",
22969 icon: cog_default,
22970 label: (0, import_i18n38._x)(
22971 "View options",
22972 "View is used as a noun"
22973 ),
22974 onClick: onToggle,
22975 "aria-expanded": isOpen ? "true" : "false",
22976 "aria-controls": popoverId
22977 }
22978 ),
22979 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22980 ] });
22981 },
22982 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22983 import_components27.__experimentalDropdownContentWrapper,
22984 {
22985 paddingSize: "medium",
22986 className: "dataviews-config__popover-content-wrapper",
22987 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22988 Stack,
22989 {
22990 direction: "column",
22991 className: "dataviews-view-config",
22992 gap: "xl",
22993 children: [
22994 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22995 Stack,
22996 {
22997 direction: "row",
22998 justify: "space-between",
22999 align: "center",
23000 className: "dataviews-view-config__header",
23001 children: [
23002 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23003 import_components27.__experimentalHeading,
23004 {
23005 level: 2,
23006 className: "dataviews-settings-section__title",
23007 children: (0, import_i18n38.__)("Appearance")
23008 }
23009 ),
23010 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
23011 ]
23012 }
23013 ),
23014 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23015 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
23016 Stack,
23017 {
23018 direction: "row",
23019 gap: "sm",
23020 className: "dataviews-view-config__sort-controls",
23021 children: [
23022 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
23023 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
23024 ]
23025 }
23026 ),
23027 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
23028 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
23029 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
23030 ] })
23031 ]
23032 }
23033 )
23034 }
23035 )
23036 }
23037 );
23038 }
23039 function _DataViewsViewConfig() {
23040 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
23041 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
23042 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
23043 ] });
23044 }
23045 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
23046 var dataviews_view_config_default = DataViewsViewConfig;
23047
23048 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23049 var import_components28 = __toESM(require_components(), 1);
23050 var import_element56 = __toESM(require_element(), 1);
23051
23052 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
23053 function getCustomValidity(isValid2, validity) {
23054 let customValidity;
23055 if (isValid2?.required && validity?.required) {
23056 customValidity = validity?.required?.message ? validity.required : void 0;
23057 } else if (isValid2?.pattern && validity?.pattern) {
23058 customValidity = validity.pattern;
23059 } else if (isValid2?.min && validity?.min) {
23060 customValidity = validity.min;
23061 } else if (isValid2?.max && validity?.max) {
23062 customValidity = validity.max;
23063 } else if (isValid2?.minLength && validity?.minLength) {
23064 customValidity = validity.minLength;
23065 } else if (isValid2?.maxLength && validity?.maxLength) {
23066 customValidity = validity.maxLength;
23067 } else if (isValid2?.elements && validity?.elements) {
23068 customValidity = validity.elements;
23069 } else if (validity?.custom) {
23070 customValidity = validity.custom;
23071 }
23072 return customValidity;
23073 }
23074
23075 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23076 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23077 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
23078 function Checkbox({
23079 field,
23080 onChange,
23081 data,
23082 hideLabelFromVision,
23083 markWhenOptional,
23084 validity
23085 }) {
23086 const { getValue, setValue, label, description, isValid: isValid2 } = field;
23087 const disabled2 = field.isDisabled({ item: data, field });
23088 const onChangeControl = (0, import_element56.useCallback)(() => {
23089 onChange(
23090 setValue({ item: data, value: !getValue({ item: data }) })
23091 );
23092 }, [data, getValue, onChange, setValue]);
23093 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23094 ValidatedCheckboxControl,
23095 {
23096 required: !!field.isValid?.required,
23097 markWhenOptional,
23098 customValidity: getCustomValidity(isValid2, validity),
23099 hidden: hideLabelFromVision,
23100 label,
23101 help: description,
23102 checked: getValue({ item: data }),
23103 onChange: onChangeControl,
23104 disabled: disabled2
23105 }
23106 );
23107 }
23108
23109 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
23110 var import_components29 = __toESM(require_components(), 1);
23111 var import_element57 = __toESM(require_element(), 1);
23112 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23113 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
23114 function Combobox3({
23115 data,
23116 field,
23117 onChange,
23118 hideLabelFromVision,
23119 validity
23120 }) {
23121 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
23122 const value = getValue({ item: data }) ?? "";
23123 const onChangeControl = (0, import_element57.useCallback)(
23124 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
23125 [data, onChange, setValue]
23126 );
23127 const { elements, isLoading } = useElements({
23128 elements: field.elements,
23129 getElements: field.getElements
23130 });
23131 if (isLoading) {
23132 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components29.Spinner, {});
23133 }
23134 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23135 ValidatedComboboxControl,
23136 {
23137 required: !!field.isValid?.required,
23138 customValidity: getCustomValidity(isValid2, validity),
23139 label,
23140 value,
23141 help: description,
23142 placeholder,
23143 options: elements,
23144 onChange: onChangeControl,
23145 hideLabelFromVision,
23146 allowReset: true,
23147 expandOnFocus: true
23148 }
23149 );
23150 }
23151
23152 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23153 var import_components31 = __toESM(require_components(), 1);
23154 var import_element60 = __toESM(require_element(), 1);
23155 var import_i18n40 = __toESM(require_i18n(), 1);
23156 var import_date3 = __toESM(require_date(), 1);
23157
23158 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23159 var import_components30 = __toESM(require_components(), 1);
23160 var import_element58 = __toESM(require_element(), 1);
23161 var import_i18n39 = __toESM(require_i18n(), 1);
23162 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23163 var TIME_UNITS_OPTIONS = {
23164 [OPERATOR_IN_THE_PAST]: [
23165 { value: "days", label: (0, import_i18n39.__)("Days") },
23166 { value: "weeks", label: (0, import_i18n39.__)("Weeks") },
23167 { value: "months", label: (0, import_i18n39.__)("Months") },
23168 { value: "years", label: (0, import_i18n39.__)("Years") }
23169 ],
23170 [OPERATOR_OVER]: [
23171 { value: "days", label: (0, import_i18n39.__)("Days ago") },
23172 { value: "weeks", label: (0, import_i18n39.__)("Weeks ago") },
23173 { value: "months", label: (0, import_i18n39.__)("Months ago") },
23174 { value: "years", label: (0, import_i18n39.__)("Years ago") }
23175 ]
23176 };
23177 function RelativeDateControl({
23178 className,
23179 data,
23180 field,
23181 onChange,
23182 hideLabelFromVision,
23183 operator
23184 }) {
23185 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23186 const { id, label, description, getValue, setValue } = field;
23187 const disabled2 = field.isDisabled({ item: data, field });
23188 const fieldValue = getValue({ item: data });
23189 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23190 const onChangeValue = (0, import_element58.useCallback)(
23191 (newValue) => onChange(
23192 setValue({
23193 item: data,
23194 value: { value: Number(newValue), unit }
23195 })
23196 ),
23197 [onChange, setValue, data, unit]
23198 );
23199 const onChangeUnit = (0, import_element58.useCallback)(
23200 (newUnit) => onChange(
23201 setValue({
23202 item: data,
23203 value: { value: relValue, unit: newUnit }
23204 })
23205 ),
23206 [onChange, setValue, data, relValue]
23207 );
23208 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23209 import_components30.BaseControl,
23210 {
23211 id,
23212 className: clsx_default(className, "dataviews-controls__relative-date"),
23213 label,
23214 hideLabelFromVision,
23215 help: description,
23216 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23217 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23218 import_components30.__experimentalNumberControl,
23219 {
23220 className: "dataviews-controls__relative-date-number",
23221 spinControls: "none",
23222 min: 1,
23223 step: 1,
23224 value: relValue,
23225 onChange: onChangeValue,
23226 disabled: disabled2
23227 }
23228 ),
23229 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23230 import_components30.SelectControl,
23231 {
23232 className: "dataviews-controls__relative-date-unit",
23233 label: (0, import_i18n39.__)("Unit"),
23234 value: unit,
23235 options,
23236 onChange: onChangeUnit,
23237 hideLabelFromVision: true,
23238 disabled: disabled2
23239 }
23240 )
23241 ] })
23242 }
23243 );
23244 }
23245
23246 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23247 var import_element59 = __toESM(require_element(), 1);
23248 function useDisabledDateMatchers(isValid2, parseDateFn) {
23249 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23250 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23251 const disabledMatchers = (0, import_element59.useMemo)(() => {
23252 const matchers = [];
23253 if (minConstraint) {
23254 const minDate = parseDateFn(minConstraint);
23255 if (minDate) {
23256 matchers.push({ before: minDate });
23257 }
23258 }
23259 if (maxConstraint) {
23260 const maxDate = parseDateFn(maxConstraint);
23261 if (maxDate) {
23262 matchers.push({ after: maxDate });
23263 }
23264 }
23265 return matchers.length > 0 ? matchers : void 0;
23266 }, [minConstraint, maxConstraint, parseDateFn]);
23267 return { minConstraint, maxConstraint, disabledMatchers };
23268 }
23269
23270 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23271 var import_date2 = __toESM(require_date(), 1);
23272 function parseDateTime(dateTimeString) {
23273 if (!dateTimeString) {
23274 return null;
23275 }
23276 const parsed = (0, import_date2.getDate)(dateTimeString);
23277 return parsed && isValid(parsed) ? parsed : null;
23278 }
23279
23280 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23281 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23282 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23283 var formatDateTime = (value) => {
23284 if (!value) {
23285 return "";
23286 }
23287 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23288 };
23289 function CalendarDateTimeControl({
23290 data,
23291 field,
23292 onChange,
23293 hideLabelFromVision,
23294 markWhenOptional,
23295 validity,
23296 config
23297 }) {
23298 const { compact } = config || {};
23299 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23300 const disabled2 = field.isDisabled({ item: data, field });
23301 const fieldValue = getValue({ item: data });
23302 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23303 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
23304 const parsedDate = parseDateTime(value);
23305 return parsedDate || /* @__PURE__ */ new Date();
23306 });
23307 const inputControlRef = (0, import_element60.useRef)(null);
23308 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
23309 const previousFocusRef = (0, import_element60.useRef)(null);
23310 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23311 const onChangeCallback = (0, import_element60.useCallback)(
23312 (newValue) => onChange(setValue({ item: data, value: newValue })),
23313 [data, onChange, setValue]
23314 );
23315 (0, import_element60.useEffect)(() => {
23316 return () => {
23317 if (validationTimeoutRef.current) {
23318 clearTimeout(validationTimeoutRef.current);
23319 }
23320 };
23321 }, []);
23322 const onSelectDate = (0, import_element60.useCallback)(
23323 (newDate) => {
23324 let dateTimeValue;
23325 if (newDate) {
23326 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23327 let wpTime;
23328 if (value) {
23329 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23330 } else {
23331 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23332 }
23333 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
23334 dateTimeValue = finalDateTime.toISOString();
23335 onChangeCallback(dateTimeValue);
23336 if (validationTimeoutRef.current) {
23337 clearTimeout(validationTimeoutRef.current);
23338 }
23339 } else {
23340 onChangeCallback(void 0);
23341 }
23342 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23343 validationTimeoutRef.current = setTimeout(() => {
23344 if (inputControlRef.current) {
23345 inputControlRef.current.focus();
23346 inputControlRef.current.blur();
23347 onChangeCallback(dateTimeValue);
23348 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23349 previousFocusRef.current.focus();
23350 }
23351 }
23352 }, 0);
23353 },
23354 [onChangeCallback, value]
23355 );
23356 const handleManualDateTimeChange = (0, import_element60.useCallback)(
23357 (newValue) => {
23358 if (newValue) {
23359 const dateTime = (0, import_date3.getDate)(newValue);
23360 onChangeCallback(dateTime.toISOString());
23361 const parsedDate = parseDateTime(dateTime.toISOString());
23362 if (parsedDate) {
23363 setCalendarMonth(parsedDate);
23364 }
23365 } else {
23366 onChangeCallback(void 0);
23367 }
23368 },
23369 [onChangeCallback]
23370 );
23371 const { format: fieldFormat } = field;
23372 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23373 const {
23374 timezone: { string: timezoneString }
23375 } = (0, import_date3.getSettings)();
23376 let displayLabel = label;
23377 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23378 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
23379 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23380 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
23381 }
23382 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23383 import_components31.BaseControl,
23384 {
23385 id,
23386 label: displayLabel,
23387 help: description,
23388 hideLabelFromVision,
23389 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23390 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23391 ValidatedInputControl,
23392 {
23393 ref: inputControlRef,
23394 required: !!isValid2?.required,
23395 customValidity: getCustomValidity(isValid2, validity),
23396 type: "datetime-local",
23397 label: (0, import_i18n40.__)("Date time"),
23398 hideLabelFromVision: true,
23399 value: formatDateTime(value),
23400 onChange: handleManualDateTimeChange,
23401 disabled: disabled2,
23402 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23403 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23404 }
23405 ),
23406 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23407 DateCalendar,
23408 {
23409 style: { width: "100%" },
23410 selected: value ? parseDateTime(value) || void 0 : void 0,
23411 onSelect: onSelectDate,
23412 month: calendarMonth,
23413 onMonthChange: setCalendarMonth,
23414 timeZone: timezoneString || void 0,
23415 weekStartsOn,
23416 disabled: disabled2 || disabledMatchers
23417 }
23418 )
23419 ] })
23420 }
23421 );
23422 }
23423 function DateTime({
23424 data,
23425 field,
23426 onChange,
23427 hideLabelFromVision,
23428 markWhenOptional,
23429 operator,
23430 validity,
23431 config
23432 }) {
23433 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23434 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23435 RelativeDateControl,
23436 {
23437 className: "dataviews-controls__datetime",
23438 data,
23439 field,
23440 onChange,
23441 hideLabelFromVision,
23442 operator
23443 }
23444 );
23445 }
23446 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23447 CalendarDateTimeControl,
23448 {
23449 data,
23450 field,
23451 onChange,
23452 hideLabelFromVision,
23453 markWhenOptional,
23454 validity,
23455 config
23456 }
23457 );
23458 }
23459
23460 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23461 var import_components32 = __toESM(require_components(), 1);
23462 var import_a11y = __toESM(require_a11y(), 1);
23463 var import_element61 = __toESM(require_element(), 1);
23464 var import_i18n41 = __toESM(require_i18n(), 1);
23465 var import_date4 = __toESM(require_date(), 1);
23466 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23467 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23468 var DATE_PRESETS = [
23469 {
23470 id: "today",
23471 label: (0, import_i18n41.__)("Today"),
23472 getValue: () => (0, import_date4.getDate)(null)
23473 },
23474 {
23475 id: "yesterday",
23476 label: (0, import_i18n41.__)("Yesterday"),
23477 getValue: () => {
23478 const today = (0, import_date4.getDate)(null);
23479 return subDays(today, 1);
23480 }
23481 },
23482 {
23483 id: "past-week",
23484 label: (0, import_i18n41.__)("Past week"),
23485 getValue: () => {
23486 const today = (0, import_date4.getDate)(null);
23487 return subDays(today, 7);
23488 }
23489 },
23490 {
23491 id: "past-month",
23492 label: (0, import_i18n41.__)("Past month"),
23493 getValue: () => {
23494 const today = (0, import_date4.getDate)(null);
23495 return subMonths(today, 1);
23496 }
23497 }
23498 ];
23499 var DATE_RANGE_PRESETS = [
23500 {
23501 id: "last-7-days",
23502 label: (0, import_i18n41.__)("Last 7 days"),
23503 getValue: () => {
23504 const today = (0, import_date4.getDate)(null);
23505 return [subDays(today, 7), today];
23506 }
23507 },
23508 {
23509 id: "last-30-days",
23510 label: (0, import_i18n41.__)("Last 30 days"),
23511 getValue: () => {
23512 const today = (0, import_date4.getDate)(null);
23513 return [subDays(today, 30), today];
23514 }
23515 },
23516 {
23517 id: "month-to-date",
23518 label: (0, import_i18n41.__)("Month to date"),
23519 getValue: () => {
23520 const today = (0, import_date4.getDate)(null);
23521 return [startOfMonth(today), today];
23522 }
23523 },
23524 {
23525 id: "last-year",
23526 label: (0, import_i18n41.__)("Last year"),
23527 getValue: () => {
23528 const today = (0, import_date4.getDate)(null);
23529 return [subYears(today, 1), today];
23530 }
23531 },
23532 {
23533 id: "year-to-date",
23534 label: (0, import_i18n41.__)("Year to date"),
23535 getValue: () => {
23536 const today = (0, import_date4.getDate)(null);
23537 return [startOfYear(today), today];
23538 }
23539 }
23540 ];
23541 var parseDate = (dateString) => {
23542 if (!dateString) {
23543 return null;
23544 }
23545 const parsed = (0, import_date4.getDate)(dateString);
23546 return parsed && isValid(parsed) ? parsed : null;
23547 };
23548 var formatDate = (date) => {
23549 if (!date) {
23550 return "";
23551 }
23552 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23553 };
23554 function ValidatedDateControl({
23555 field,
23556 validity,
23557 inputRefs,
23558 isTouched,
23559 setIsTouched,
23560 children
23561 }) {
23562 const { isValid: isValid2 } = field;
23563 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
23564 const validateRefs = (0, import_element61.useCallback)(() => {
23565 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23566 for (const ref of refs) {
23567 const input = ref.current;
23568 if (input && !input.validity.valid) {
23569 setCustomValidity({
23570 type: "invalid",
23571 message: input.validationMessage
23572 });
23573 return;
23574 }
23575 }
23576 setCustomValidity(void 0);
23577 }, [inputRefs]);
23578 (0, import_element61.useEffect)(() => {
23579 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23580 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23581 for (const ref of refs) {
23582 const input = ref.current;
23583 if (input) {
23584 input.setCustomValidity(
23585 result?.type === "invalid" && result.message ? result.message : ""
23586 );
23587 }
23588 }
23589 }, [inputRefs, isValid2, validity]);
23590 (0, import_element61.useEffect)(() => {
23591 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23592 const handleInvalid = (event) => {
23593 event.preventDefault();
23594 setIsTouched(true);
23595 };
23596 for (const ref of refs) {
23597 ref.current?.addEventListener("invalid", handleInvalid);
23598 }
23599 return () => {
23600 for (const ref of refs) {
23601 ref.current?.removeEventListener("invalid", handleInvalid);
23602 }
23603 };
23604 }, [inputRefs, setIsTouched]);
23605 (0, import_element61.useEffect)(() => {
23606 if (!isTouched) {
23607 return;
23608 }
23609 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23610 if (result) {
23611 setCustomValidity(result);
23612 } else {
23613 validateRefs();
23614 }
23615 }, [isTouched, isValid2, validity, validateRefs]);
23616 (0, import_element61.useEffect)(() => {
23617 if (isTouched && customValidity?.message) {
23618 (0, import_a11y.speak)(customValidity.message);
23619 }
23620 }, [isTouched, customValidity?.message]);
23621 const onBlur = (event) => {
23622 if (isTouched) {
23623 return;
23624 }
23625 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23626 setIsTouched(true);
23627 }
23628 };
23629 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23630 children,
23631 customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23632 "p",
23633 {
23634 className: clsx_default(
23635 "components-validated-control__indicator",
23636 customValidity.type === "invalid" ? "is-invalid" : void 0
23637 ),
23638 children: [
23639 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23640 import_components32.Icon,
23641 {
23642 className: "components-validated-control__indicator-icon",
23643 icon: error_default,
23644 size: 16,
23645 fill: "currentColor"
23646 }
23647 ),
23648 customValidity.message
23649 ]
23650 }
23651 )
23652 ] });
23653 }
23654 function CalendarDateControl({
23655 data,
23656 field,
23657 onChange,
23658 hideLabelFromVision,
23659 markWhenOptional,
23660 validity
23661 }) {
23662 const {
23663 id,
23664 label,
23665 description,
23666 setValue,
23667 getValue,
23668 isValid: isValid2,
23669 format: fieldFormat
23670 } = field;
23671 const disabled2 = field.isDisabled({ item: data, field });
23672 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23673 null
23674 );
23675 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23676 const fieldValue = getValue({ item: data });
23677 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23678 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23679 const parsedDate = parseDate(value);
23680 return parsedDate || /* @__PURE__ */ new Date();
23681 });
23682 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23683 const validityTargetRef = (0, import_element61.useRef)(null);
23684 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23685 const onChangeCallback = (0, import_element61.useCallback)(
23686 (newValue) => onChange(setValue({ item: data, value: newValue })),
23687 [data, onChange, setValue]
23688 );
23689 const onSelectDate = (0, import_element61.useCallback)(
23690 (newDate) => {
23691 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23692 onChangeCallback(dateValue);
23693 setSelectedPresetId(null);
23694 setIsTouched(true);
23695 },
23696 [onChangeCallback]
23697 );
23698 const handlePresetClick = (0, import_element61.useCallback)(
23699 (preset) => {
23700 const presetDate = preset.getValue();
23701 const dateValue = formatDate(presetDate);
23702 setCalendarMonth(presetDate);
23703 onChangeCallback(dateValue);
23704 setSelectedPresetId(preset.id);
23705 setIsTouched(true);
23706 },
23707 [onChangeCallback]
23708 );
23709 const handleManualDateChange = (0, import_element61.useCallback)(
23710 (newValue) => {
23711 onChangeCallback(newValue);
23712 if (newValue) {
23713 const parsedDate = parseDate(newValue);
23714 if (parsedDate) {
23715 setCalendarMonth(parsedDate);
23716 }
23717 }
23718 setSelectedPresetId(null);
23719 setIsTouched(true);
23720 },
23721 [onChangeCallback]
23722 );
23723 const {
23724 timezone: { string: timezoneString }
23725 } = (0, import_date4.getSettings)();
23726 let displayLabel = label;
23727 if (isValid2?.required && !markWhenOptional) {
23728 displayLabel = `${label} (${(0, import_i18n41.__)("Required")})`;
23729 } else if (!isValid2?.required && markWhenOptional) {
23730 displayLabel = `${label} (${(0, import_i18n41.__)("Optional")})`;
23731 }
23732 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23733 ValidatedDateControl,
23734 {
23735 field,
23736 validity,
23737 inputRefs: validityTargetRef,
23738 isTouched,
23739 setIsTouched,
23740 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23741 import_components32.BaseControl,
23742 {
23743 id,
23744 className: "dataviews-controls__date",
23745 label: displayLabel,
23746 help: description,
23747 hideLabelFromVision,
23748 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23749 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23750 Stack,
23751 {
23752 direction: "row",
23753 gap: "sm",
23754 wrap: "wrap",
23755 justify: "flex-start",
23756 children: [
23757 DATE_PRESETS.map((preset) => {
23758 const isSelected2 = selectedPresetId === preset.id;
23759 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23760 import_components32.Button,
23761 {
23762 className: "dataviews-controls__date-preset",
23763 variant: "tertiary",
23764 isPressed: isSelected2,
23765 size: "small",
23766 disabled: disabled2,
23767 accessibleWhenDisabled: true,
23768 onClick: () => handlePresetClick(preset),
23769 children: preset.label
23770 },
23771 preset.id
23772 );
23773 }),
23774 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23775 import_components32.Button,
23776 {
23777 className: "dataviews-controls__date-preset",
23778 variant: "tertiary",
23779 isPressed: !selectedPresetId,
23780 size: "small",
23781 disabled: !!selectedPresetId || disabled2,
23782 accessibleWhenDisabled: true,
23783 children: (0, import_i18n41.__)("Custom")
23784 }
23785 )
23786 ]
23787 }
23788 ),
23789 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23790 import_components32.__experimentalInputControl,
23791 {
23792 ref: validityTargetRef,
23793 type: "date",
23794 label: (0, import_i18n41.__)("Date"),
23795 hideLabelFromVision: true,
23796 value,
23797 onChange: handleManualDateChange,
23798 required: !!field.isValid?.required,
23799 disabled: disabled2,
23800 min: minConstraint,
23801 max: maxConstraint
23802 }
23803 ),
23804 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23805 DateCalendar2,
23806 {
23807 style: { width: "100%" },
23808 selected: value ? parseDate(value) || void 0 : void 0,
23809 onSelect: onSelectDate,
23810 month: calendarMonth,
23811 onMonthChange: setCalendarMonth,
23812 timeZone: timezoneString || void 0,
23813 weekStartsOn,
23814 disabled: disabled2 || disabledMatchers,
23815 disableNavigation: disabled2
23816 }
23817 )
23818 ] })
23819 }
23820 )
23821 }
23822 );
23823 }
23824 function CalendarDateRangeControl({
23825 data,
23826 field,
23827 onChange,
23828 hideLabelFromVision,
23829 markWhenOptional,
23830 validity
23831 }) {
23832 const {
23833 id,
23834 label,
23835 description,
23836 getValue,
23837 setValue,
23838 isValid: isValid2,
23839 format: fieldFormat
23840 } = field;
23841 const disabled2 = field.isDisabled({ item: data, field });
23842 let value;
23843 const fieldValue = getValue({ item: data });
23844 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23845 value = fieldValue;
23846 }
23847 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23848 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23849 const onChangeCallback = (0, import_element61.useCallback)(
23850 (newValue) => {
23851 onChange(
23852 setValue({
23853 item: data,
23854 value: newValue
23855 })
23856 );
23857 },
23858 [data, onChange, setValue]
23859 );
23860 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23861 null
23862 );
23863 const selectedRange = (0, import_element61.useMemo)(() => {
23864 if (!value) {
23865 return { from: void 0, to: void 0 };
23866 }
23867 const [from, to] = value;
23868 return {
23869 from: parseDate(from) || void 0,
23870 to: parseDate(to) || void 0
23871 };
23872 }, [value]);
23873 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23874 return selectedRange.from || /* @__PURE__ */ new Date();
23875 });
23876 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23877 const fromInputRef = (0, import_element61.useRef)(null);
23878 const toInputRef = (0, import_element61.useRef)(null);
23879 const updateDateRange = (0, import_element61.useCallback)(
23880 (fromDate, toDate2) => {
23881 if (fromDate && toDate2) {
23882 onChangeCallback([
23883 formatDate(fromDate),
23884 formatDate(toDate2)
23885 ]);
23886 } else if (!fromDate && !toDate2) {
23887 onChangeCallback(void 0);
23888 }
23889 },
23890 [onChangeCallback]
23891 );
23892 const onSelectCalendarRange = (0, import_element61.useCallback)(
23893 (newRange) => {
23894 updateDateRange(newRange?.from, newRange?.to);
23895 setSelectedPresetId(null);
23896 setIsTouched(true);
23897 },
23898 [updateDateRange]
23899 );
23900 const handlePresetClick = (0, import_element61.useCallback)(
23901 (preset) => {
23902 const [startDate, endDate] = preset.getValue();
23903 setCalendarMonth(startDate);
23904 updateDateRange(startDate, endDate);
23905 setSelectedPresetId(preset.id);
23906 setIsTouched(true);
23907 },
23908 [updateDateRange]
23909 );
23910 const handleManualDateChange = (0, import_element61.useCallback)(
23911 (fromOrTo, newValue) => {
23912 const [currentFrom, currentTo] = value || [
23913 void 0,
23914 void 0
23915 ];
23916 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23917 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23918 updateDateRange(updatedFrom, updatedTo);
23919 if (newValue) {
23920 const parsedDate = parseDate(newValue);
23921 if (parsedDate) {
23922 setCalendarMonth(parsedDate);
23923 }
23924 }
23925 setSelectedPresetId(null);
23926 setIsTouched(true);
23927 },
23928 [value, updateDateRange]
23929 );
23930 const { timezone } = (0, import_date4.getSettings)();
23931 let displayLabel = label;
23932 if (field.isValid?.required && !markWhenOptional) {
23933 displayLabel = `${label} (${(0, import_i18n41.__)("Required")})`;
23934 } else if (!field.isValid?.required && markWhenOptional) {
23935 displayLabel = `${label} (${(0, import_i18n41.__)("Optional")})`;
23936 }
23937 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23938 ValidatedDateControl,
23939 {
23940 field,
23941 validity,
23942 inputRefs: [fromInputRef, toInputRef],
23943 isTouched,
23944 setIsTouched,
23945 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23946 import_components32.BaseControl,
23947 {
23948 id,
23949 className: "dataviews-controls__date",
23950 label: displayLabel,
23951 help: description,
23952 hideLabelFromVision,
23953 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23954 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23955 Stack,
23956 {
23957 direction: "row",
23958 gap: "sm",
23959 wrap: "wrap",
23960 justify: "flex-start",
23961 children: [
23962 DATE_RANGE_PRESETS.map((preset) => {
23963 const isSelected2 = selectedPresetId === preset.id;
23964 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23965 import_components32.Button,
23966 {
23967 className: "dataviews-controls__date-preset",
23968 variant: "tertiary",
23969 isPressed: isSelected2,
23970 size: "small",
23971 disabled: disabled2,
23972 accessibleWhenDisabled: true,
23973 onClick: () => handlePresetClick(preset),
23974 children: preset.label
23975 },
23976 preset.id
23977 );
23978 }),
23979 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23980 import_components32.Button,
23981 {
23982 className: "dataviews-controls__date-preset",
23983 variant: "tertiary",
23984 isPressed: !selectedPresetId,
23985 size: "small",
23986 accessibleWhenDisabled: true,
23987 disabled: !!selectedPresetId || disabled2,
23988 children: (0, import_i18n41.__)("Custom")
23989 }
23990 )
23991 ]
23992 }
23993 ),
23994 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23995 Stack,
23996 {
23997 direction: "row",
23998 gap: "sm",
23999 justify: "space-between",
24000 className: "dataviews-controls__date-range-inputs",
24001 children: [
24002 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24003 import_components32.__experimentalInputControl,
24004 {
24005 ref: fromInputRef,
24006 type: "date",
24007 label: (0, import_i18n41.__)("From"),
24008 hideLabelFromVision: true,
24009 value: value?.[0],
24010 onChange: (newValue) => handleManualDateChange("from", newValue),
24011 required: !!field.isValid?.required,
24012 disabled: disabled2,
24013 min: minConstraint,
24014 max: maxConstraint
24015 }
24016 ),
24017 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24018 import_components32.__experimentalInputControl,
24019 {
24020 ref: toInputRef,
24021 type: "date",
24022 label: (0, import_i18n41.__)("To"),
24023 hideLabelFromVision: true,
24024 value: value?.[1],
24025 onChange: (newValue) => handleManualDateChange("to", newValue),
24026 required: !!field.isValid?.required,
24027 disabled: disabled2,
24028 min: minConstraint,
24029 max: maxConstraint
24030 }
24031 )
24032 ]
24033 }
24034 ),
24035 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24036 DateRangeCalendar,
24037 {
24038 style: { width: "100%" },
24039 selected: selectedRange,
24040 onSelect: onSelectCalendarRange,
24041 month: calendarMonth,
24042 onMonthChange: setCalendarMonth,
24043 timeZone: timezone.string || void 0,
24044 weekStartsOn,
24045 disabled: disabled2 || disabledMatchers
24046 }
24047 )
24048 ] })
24049 }
24050 )
24051 }
24052 );
24053 }
24054 function DateControl({
24055 data,
24056 field,
24057 onChange,
24058 hideLabelFromVision,
24059 markWhenOptional,
24060 operator,
24061 validity
24062 }) {
24063 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
24064 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24065 RelativeDateControl,
24066 {
24067 className: "dataviews-controls__date",
24068 data,
24069 field,
24070 onChange,
24071 hideLabelFromVision,
24072 operator
24073 }
24074 );
24075 }
24076 if (operator === OPERATOR_BETWEEN) {
24077 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24078 CalendarDateRangeControl,
24079 {
24080 data,
24081 field,
24082 onChange,
24083 hideLabelFromVision,
24084 markWhenOptional,
24085 validity
24086 }
24087 );
24088 }
24089 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24090 CalendarDateControl,
24091 {
24092 data,
24093 field,
24094 onChange,
24095 hideLabelFromVision,
24096 markWhenOptional,
24097 validity
24098 }
24099 );
24100 }
24101
24102 // packages/dataviews/build-module/components/dataform-controls/select.mjs
24103 var import_components33 = __toESM(require_components(), 1);
24104 var import_element62 = __toESM(require_element(), 1);
24105 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24106 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
24107 function Select({
24108 data,
24109 field,
24110 onChange,
24111 hideLabelFromVision,
24112 markWhenOptional,
24113 validity
24114 }) {
24115 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
24116 const disabled2 = field.isDisabled({ item: data, field });
24117 const isMultiple = type === "array";
24118 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
24119 const onChangeControl = (0, import_element62.useCallback)(
24120 (newValue) => onChange(setValue({ item: data, value: newValue })),
24121 [data, onChange, setValue]
24122 );
24123 const { elements, isLoading } = useElements({
24124 elements: field.elements,
24125 getElements: field.getElements
24126 });
24127 if (isLoading) {
24128 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components33.Spinner, {});
24129 }
24130 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24131 ValidatedSelectControl,
24132 {
24133 required: !!field.isValid?.required,
24134 markWhenOptional,
24135 customValidity: getCustomValidity(isValid2, validity),
24136 label,
24137 value,
24138 help: description,
24139 options: elements,
24140 onChange: onChangeControl,
24141 hideLabelFromVision,
24142 multiple: isMultiple,
24143 disabled: disabled2
24144 }
24145 );
24146 }
24147
24148 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24149 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24150 var ELEMENTS_THRESHOLD = 10;
24151 function AdaptiveSelect(props) {
24152 const { field } = props;
24153 const { elements } = useElements({
24154 elements: field.elements,
24155 getElements: field.getElements
24156 });
24157 if (elements.length >= ELEMENTS_THRESHOLD) {
24158 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
24159 }
24160 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
24161 }
24162
24163 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24164 var import_components35 = __toESM(require_components(), 1);
24165
24166 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24167 var import_components34 = __toESM(require_components(), 1);
24168 var import_element63 = __toESM(require_element(), 1);
24169 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24170 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24171 function ValidatedText({
24172 data,
24173 field,
24174 onChange,
24175 hideLabelFromVision,
24176 markWhenOptional,
24177 type,
24178 prefix,
24179 suffix,
24180 validity
24181 }) {
24182 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24183 const value = getValue({ item: data });
24184 const disabled2 = field.isDisabled({ item: data, field });
24185 const onChangeControl = (0, import_element63.useCallback)(
24186 (newValue) => onChange(
24187 setValue({
24188 item: data,
24189 value: newValue
24190 })
24191 ),
24192 [data, setValue, onChange]
24193 );
24194 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24195 ValidatedInputControl2,
24196 {
24197 required: !!isValid2.required,
24198 markWhenOptional,
24199 customValidity: getCustomValidity(isValid2, validity),
24200 label,
24201 placeholder,
24202 value: value ?? "",
24203 help: description,
24204 onChange: onChangeControl,
24205 hideLabelFromVision,
24206 type,
24207 prefix,
24208 suffix,
24209 disabled: disabled2,
24210 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24211 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24212 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
24213 }
24214 );
24215 }
24216
24217 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24218 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24219 function Email({
24220 data,
24221 field,
24222 onChange,
24223 hideLabelFromVision,
24224 markWhenOptional,
24225 validity
24226 }) {
24227 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24228 ValidatedText,
24229 {
24230 ...{
24231 data,
24232 field,
24233 onChange,
24234 hideLabelFromVision,
24235 markWhenOptional,
24236 validity,
24237 type: "email",
24238 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: envelope_default }) })
24239 }
24240 }
24241 );
24242 }
24243
24244 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24245 var import_components36 = __toESM(require_components(), 1);
24246 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24247 function Telephone({
24248 data,
24249 field,
24250 onChange,
24251 hideLabelFromVision,
24252 markWhenOptional,
24253 validity
24254 }) {
24255 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24256 ValidatedText,
24257 {
24258 ...{
24259 data,
24260 field,
24261 onChange,
24262 hideLabelFromVision,
24263 markWhenOptional,
24264 validity,
24265 type: "tel",
24266 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: mobile_default }) })
24267 }
24268 }
24269 );
24270 }
24271
24272 // packages/dataviews/build-module/components/dataform-controls/url.mjs
24273 var import_components37 = __toESM(require_components(), 1);
24274 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24275 function Url({
24276 data,
24277 field,
24278 onChange,
24279 hideLabelFromVision,
24280 markWhenOptional,
24281 validity
24282 }) {
24283 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24284 ValidatedText,
24285 {
24286 ...{
24287 data,
24288 field,
24289 onChange,
24290 hideLabelFromVision,
24291 markWhenOptional,
24292 validity,
24293 type: "url",
24294 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.Icon, { icon: link_default }) })
24295 }
24296 }
24297 );
24298 }
24299
24300 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24301 var import_components38 = __toESM(require_components(), 1);
24302 var import_element64 = __toESM(require_element(), 1);
24303 var import_i18n42 = __toESM(require_i18n(), 1);
24304 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24305 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24306 function toNumberOrEmpty(value) {
24307 if (value === "" || value === void 0) {
24308 return "";
24309 }
24310 const number = Number(value);
24311 return Number.isFinite(number) ? number : "";
24312 }
24313 function BetweenControls({
24314 value,
24315 onChange,
24316 hideLabelFromVision,
24317 step
24318 }) {
24319 const [min2 = "", max2 = ""] = value;
24320 const onChangeMin = (0, import_element64.useCallback)(
24321 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24322 [onChange, max2]
24323 );
24324 const onChangeMax = (0, import_element64.useCallback)(
24325 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24326 [onChange, min2]
24327 );
24328 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24329 import_components38.BaseControl,
24330 {
24331 help: (0, import_i18n42.__)("The max. value must be greater than the min. value."),
24332 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24333 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24334 import_components38.__experimentalNumberControl,
24335 {
24336 label: (0, import_i18n42.__)("Min."),
24337 value: min2,
24338 max: max2 ? Number(max2) - step : void 0,
24339 onChange: onChangeMin,
24340 hideLabelFromVision,
24341 step
24342 }
24343 ),
24344 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24345 import_components38.__experimentalNumberControl,
24346 {
24347 label: (0, import_i18n42.__)("Max."),
24348 value: max2,
24349 min: min2 ? Number(min2) + step : void 0,
24350 onChange: onChangeMax,
24351 hideLabelFromVision,
24352 step
24353 }
24354 )
24355 ] })
24356 }
24357 );
24358 }
24359 function ValidatedNumber({
24360 data,
24361 field,
24362 onChange,
24363 hideLabelFromVision,
24364 markWhenOptional,
24365 operator,
24366 validity
24367 }) {
24368 const decimals = field.format?.decimals ?? 0;
24369 const step = Math.pow(10, Math.abs(decimals) * -1);
24370 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24371 const value = getValue({ item: data }) ?? "";
24372 const disabled2 = field.isDisabled({ item: data, field });
24373 const onChangeControl = (0, import_element64.useCallback)(
24374 (newValue) => {
24375 onChange(
24376 setValue({
24377 item: data,
24378 // Do not convert an empty string or undefined to a number,
24379 // otherwise there's a mismatch between the UI control (empty)
24380 // and the data relied by onChange (0).
24381 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24382 })
24383 );
24384 },
24385 [data, onChange, setValue]
24386 );
24387 const onChangeBetweenControls = (0, import_element64.useCallback)(
24388 (newValue) => {
24389 onChange(
24390 setValue({
24391 item: data,
24392 value: newValue
24393 })
24394 );
24395 },
24396 [data, onChange, setValue]
24397 );
24398 if (operator === OPERATOR_BETWEEN) {
24399 let valueBetween = ["", ""];
24400 if (Array.isArray(value) && value.length === 2 && value.every(
24401 (element) => typeof element === "number" || element === ""
24402 )) {
24403 valueBetween = value;
24404 }
24405 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24406 BetweenControls,
24407 {
24408 value: valueBetween,
24409 onChange: onChangeBetweenControls,
24410 hideLabelFromVision,
24411 step
24412 }
24413 );
24414 }
24415 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24416 ValidatedNumberControl,
24417 {
24418 required: !!isValid2.required,
24419 markWhenOptional,
24420 customValidity: getCustomValidity(isValid2, validity),
24421 label,
24422 help: description,
24423 value,
24424 onChange: onChangeControl,
24425 hideLabelFromVision,
24426 step,
24427 min: isValid2.min ? isValid2.min.constraint : void 0,
24428 max: isValid2.max ? isValid2.max.constraint : void 0,
24429 disabled: disabled2
24430 }
24431 );
24432 }
24433
24434 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24435 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24436 function Integer(props) {
24437 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
24438 }
24439
24440 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24441 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24442 function Number2(props) {
24443 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24444 }
24445
24446 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24447 var import_components39 = __toESM(require_components(), 1);
24448 var import_element65 = __toESM(require_element(), 1);
24449 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24450 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24451 function Radio({
24452 data,
24453 field,
24454 onChange,
24455 hideLabelFromVision,
24456 markWhenOptional,
24457 validity
24458 }) {
24459 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24460 const disabled2 = field.isDisabled({ item: data, field });
24461 const { elements, isLoading } = useElements({
24462 elements: field.elements,
24463 getElements: field.getElements
24464 });
24465 const value = getValue({ item: data });
24466 const onChangeControl = (0, import_element65.useCallback)(
24467 (newValue) => onChange(setValue({ item: data, value: newValue })),
24468 [data, onChange, setValue]
24469 );
24470 if (isLoading) {
24471 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components39.Spinner, {});
24472 }
24473 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24474 ValidatedRadioControl,
24475 {
24476 required: !!field.isValid?.required,
24477 markWhenOptional,
24478 customValidity: getCustomValidity(isValid2, validity),
24479 label,
24480 help: description,
24481 onChange: onChangeControl,
24482 options: elements,
24483 selected: value,
24484 hideLabelFromVision,
24485 disabled: disabled2
24486 }
24487 );
24488 }
24489
24490 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24491 var import_element66 = __toESM(require_element(), 1);
24492 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24493 function Text({
24494 data,
24495 field,
24496 onChange,
24497 hideLabelFromVision,
24498 markWhenOptional,
24499 config,
24500 validity
24501 }) {
24502 const { prefix, suffix } = config || {};
24503 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24504 ValidatedText,
24505 {
24506 ...{
24507 data,
24508 field,
24509 onChange,
24510 hideLabelFromVision,
24511 markWhenOptional,
24512 validity,
24513 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
24514 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
24515 }
24516 }
24517 );
24518 }
24519
24520 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24521 var import_components40 = __toESM(require_components(), 1);
24522 var import_element67 = __toESM(require_element(), 1);
24523 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24524 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24525 function Toggle({
24526 field,
24527 onChange,
24528 data,
24529 hideLabelFromVision,
24530 markWhenOptional,
24531 validity
24532 }) {
24533 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24534 const disabled2 = field.isDisabled({ item: data, field });
24535 const onChangeControl = (0, import_element67.useCallback)(() => {
24536 onChange(
24537 setValue({ item: data, value: !getValue({ item: data }) })
24538 );
24539 }, [onChange, setValue, data, getValue]);
24540 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24541 ValidatedToggleControl,
24542 {
24543 required: !!isValid2.required,
24544 markWhenOptional,
24545 customValidity: getCustomValidity(isValid2, validity),
24546 hidden: hideLabelFromVision,
24547 label,
24548 help: description,
24549 checked: getValue({ item: data }),
24550 onChange: onChangeControl,
24551 disabled: disabled2
24552 }
24553 );
24554 }
24555
24556 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24557 var import_components41 = __toESM(require_components(), 1);
24558 var import_element68 = __toESM(require_element(), 1);
24559 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24560 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24561 function Textarea({
24562 data,
24563 field,
24564 onChange,
24565 hideLabelFromVision,
24566 markWhenOptional,
24567 config,
24568 validity
24569 }) {
24570 const { rows = 4 } = config || {};
24571 const disabled2 = field.isDisabled({ item: data, field });
24572 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24573 const value = field.getValue({ item: data });
24574 const onChangeControl = (0, import_element68.useCallback)(
24575 (newValue) => onChange(setValue({ item: data, value: newValue })),
24576 [data, onChange, setValue]
24577 );
24578 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24579 ValidatedTextareaControl,
24580 {
24581 required: !!isValid2.required,
24582 markWhenOptional,
24583 customValidity: getCustomValidity(isValid2, validity),
24584 label,
24585 placeholder,
24586 value: value ?? "",
24587 help: description,
24588 onChange: onChangeControl,
24589 rows,
24590 disabled: disabled2,
24591 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24592 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24593 __next40pxDefaultSize: true,
24594 hideLabelFromVision
24595 }
24596 );
24597 }
24598
24599 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24600 var import_element70 = __toESM(require_element(), 1);
24601
24602 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24603 var import_components42 = __toESM(require_components(), 1);
24604 var import_compose12 = __toESM(require_compose(), 1);
24605 var import_element69 = __toESM(require_element(), 1);
24606 var import_rich_text2 = __toESM(require_rich_text(), 1);
24607
24608 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24609 var EMPTY_ARRAY5 = [];
24610 function getAllowedFormats({
24611 allowedFormats,
24612 disableFormats
24613 }) {
24614 if (disableFormats) {
24615 return EMPTY_ARRAY5;
24616 }
24617 return allowedFormats;
24618 }
24619
24620 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24621 var import_rich_text = __toESM(require_rich_text(), 1);
24622 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24623 var import_react24 = __toESM(require_react(), 1);
24624 var EMPTY_CONTEXT = {};
24625 function Edit({
24626 onChange,
24627 onFocus,
24628 value,
24629 forwardedRef,
24630 settings,
24631 isVisible: isVisible2
24632 }) {
24633 const { name, edit: EditFunction } = settings;
24634 if (!EditFunction) {
24635 return null;
24636 }
24637 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24638 const isActive = activeFormat !== void 0;
24639 const activeObject = (0, import_rich_text.getActiveObject)(value);
24640 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24641 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24642 EditFunction,
24643 {
24644 isActive,
24645 isVisible: isVisible2,
24646 activeAttributes: isActive ? activeFormat.attributes || {} : {},
24647 isObjectActive,
24648 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24649 value,
24650 onChange,
24651 onFocus,
24652 contentRef: forwardedRef,
24653 context: EMPTY_CONTEXT
24654 },
24655 name
24656 );
24657 }
24658 function FormatEdit({
24659 formatTypes,
24660 ...props
24661 }) {
24662 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react24.createElement)(Edit, { settings, ...props, key: settings.name }));
24663 }
24664
24665 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24666 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24667 var {
24668 ValidatedContentEditableControl: RichTextControlShell,
24669 withIgnoreIMEEvents
24670 } = unlock2(import_components42.privateApis);
24671 var {
24672 useRichText,
24673 KeyboardShortcutContext,
24674 InputEventContext,
24675 shortcutsListener,
24676 inputEventsListener
24677 } = unlock2(import_rich_text2.privateApis);
24678 var EMPTY_COMPLETERS = [];
24679 function RichTextControl({
24680 label,
24681 value: attrValue,
24682 onChange,
24683 placeholder,
24684 id,
24685 clientId,
24686 className,
24687 hideLabelFromVision,
24688 help,
24689 disabled: disabled2,
24690 required,
24691 markWhenOptional,
24692 customValidity,
24693 allowedFormats,
24694 disableFormats,
24695 withoutInteractiveFormatting,
24696 preserveWhiteSpace,
24697 disableLineBreaks,
24698 focusOnMount,
24699 completers = EMPTY_COMPLETERS
24700 }) {
24701 const [selection, setSelection] = (0, import_element69.useState)({
24702 start: void 0,
24703 end: void 0
24704 });
24705 const [isSelected2, setIsSelected] = (0, import_element69.useState)(false);
24706 const anchorRef = (0, import_element69.useRef)(void 0);
24707 const inputEvents = (0, import_element69.useRef)(/* @__PURE__ */ new Set());
24708 const keyboardShortcuts = (0, import_element69.useRef)(
24709 /* @__PURE__ */ new Set()
24710 );
24711 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24712 const adjustedAllowedFormats = getAllowedFormats({
24713 allowedFormats,
24714 disableFormats
24715 });
24716 const {
24717 value,
24718 onChange: onRichTextChange,
24719 ref: richTextRef,
24720 formatTypes,
24721 getValue
24722 } = useRichText({
24723 value: attrValue,
24724 onChange,
24725 selectionStart: selection.start,
24726 selectionEnd: selection.end,
24727 onSelectionChange: (start, end) => setSelection({ start, end }),
24728 __unstableIsSelected: isSelected2,
24729 preserveWhiteSpace: !!preserveWhiteSpace,
24730 placeholder,
24731 __unstableDisableFormats: disableFormats,
24732 allowedFormats: adjustedAllowedFormats,
24733 withoutInteractiveFormatting,
24734 __unstableFormatTypeHandlerContext: (0, import_element69.useMemo)(
24735 () => ({
24736 richTextIdentifier: id,
24737 blockClientId: clientId
24738 }),
24739 [id, clientId]
24740 )
24741 });
24742 function onFocus() {
24743 anchorRef.current?.focus();
24744 }
24745 const eventListenersPropsRef = (0, import_element69.useRef)({
24746 keyboardShortcuts,
24747 inputEvents
24748 });
24749 const inputRulePropsRef = (0, import_element69.useRef)({
24750 formatTypes,
24751 getValue,
24752 onChange: onRichTextChange
24753 });
24754 (0, import_element69.useInsertionEffect)(() => {
24755 inputRulePropsRef.current = {
24756 formatTypes,
24757 getValue,
24758 onChange: onRichTextChange
24759 };
24760 });
24761 const enterRef = (0, import_compose12.useRefEffect)(
24762 (element) => {
24763 if (disabled2) {
24764 return;
24765 }
24766 const onKeyDown = withIgnoreIMEEvents((event) => {
24767 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24768 return;
24769 }
24770 event.preventDefault();
24771 if (disableLineBreaks) {
24772 return;
24773 }
24774 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24775 const current = getCurrentValue2();
24776 handleChange(
24777 (0, import_rich_text2.insert)(
24778 current,
24779 "\n",
24780 current.start ?? current.text.length,
24781 current.end ?? current.text.length
24782 )
24783 );
24784 });
24785 element.addEventListener("keydown", onKeyDown);
24786 return () => element.removeEventListener("keydown", onKeyDown);
24787 },
24788 [disableLineBreaks, disabled2]
24789 );
24790 const eventListenersRef = (0, import_compose12.useRefEffect)(
24791 (element) => {
24792 if (!isSelected2) {
24793 return;
24794 }
24795 const cleanupShortcuts = shortcutsListener(
24796 eventListenersPropsRef
24797 )(element);
24798 const cleanupInputEvents = inputEventsListener(
24799 eventListenersPropsRef
24800 )(element);
24801 function onFormatInput(event) {
24802 if (event.inputType !== "insertText" && event.type !== "compositionend") {
24803 return;
24804 }
24805 const {
24806 formatTypes: types,
24807 getValue: getCurrentValue2,
24808 onChange: handleChange
24809 } = inputRulePropsRef.current;
24810 const current = getCurrentValue2();
24811 const transformed = types.reduce(
24812 (accumulator, {
24813 __unstableInputRule
24814 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24815 current
24816 );
24817 if (transformed !== current) {
24818 handleChange({
24819 ...transformed,
24820 activeFormats: current.activeFormats
24821 });
24822 }
24823 }
24824 element.addEventListener("input", onFormatInput);
24825 element.addEventListener("compositionend", onFormatInput);
24826 return () => {
24827 cleanupShortcuts();
24828 cleanupInputEvents();
24829 element.removeEventListener("input", onFormatInput);
24830 element.removeEventListener("compositionend", onFormatInput);
24831 };
24832 },
24833 [isSelected2]
24834 );
24835 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24836 {
24837 completers,
24838 record: value,
24839 onChange: onRichTextChange,
24840 // This control's completers insert their completion into the value;
24841 // none replace the whole value, so the required `onReplace` is a
24842 // no-op here.
24843 onReplace: () => {
24844 }
24845 }
24846 );
24847 const focusOnMountRef = (0, import_compose12.useRefEffect)(
24848 (element) => {
24849 if (focusOnMount && !disabled2) {
24850 element.focus();
24851 }
24852 },
24853 [focusOnMount, disabled2]
24854 );
24855 const editableRef = (0, import_compose12.useMergeRefs)([
24856 richTextRef,
24857 anchorRef,
24858 eventListenersRef,
24859 enterRef,
24860 focusOnMountRef,
24861 autocompleteRef
24862 ]);
24863 return (
24864 // Focus boundary for the field's selection: `onFocus` selects on entry;
24865 // the spread `useFocusOutside` handlers deselect once focus leaves.
24866 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24867 "div",
24868 {
24869 ...focusOutside,
24870 onFocus: (event) => {
24871 setIsSelected(true);
24872 focusOutside.onFocus(event);
24873 },
24874 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_components42.SlotFillProvider, { children: [
24875 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24876 RichTextControlShell,
24877 {
24878 label,
24879 id,
24880 className: clsx_default(
24881 "dataviews-controls__richtext",
24882 className
24883 ),
24884 placeholder,
24885 hideLabelFromVision,
24886 help,
24887 disabled: disabled2,
24888 required,
24889 markWhenOptional,
24890 customValidity,
24891 value: value.text,
24892 "aria-multiline": !disableLineBreaks,
24893 ...autocompleteProps,
24894 ref: editableRef
24895 }
24896 ),
24897 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24898 KeyboardShortcutContext.Provider,
24899 {
24900 value: keyboardShortcuts,
24901 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24902 FormatEdit,
24903 {
24904 value,
24905 onChange: onRichTextChange,
24906 onFocus,
24907 formatTypes,
24908 forwardedRef: anchorRef,
24909 isVisible: true
24910 }
24911 ) })
24912 }
24913 )
24914 ] })
24915 }
24916 )
24917 );
24918 }
24919
24920 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24921 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24922 function RichText({
24923 data,
24924 field,
24925 onChange,
24926 hideLabelFromVision,
24927 markWhenOptional,
24928 config,
24929 validity
24930 }) {
24931 const {
24932 className,
24933 clientId,
24934 allowedFormats,
24935 disableFormats,
24936 withoutInteractiveFormatting,
24937 preserveWhiteSpace,
24938 disableLineBreaks
24939 } = config || {};
24940 const disabled2 = field.isDisabled({ item: data, field });
24941 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24942 const value = field.getValue({ item: data }) ?? "";
24943 const onChangeControl = (0, import_element70.useCallback)(
24944 (newValue) => onChange(setValue({ item: data, value: newValue })),
24945 [data, onChange, setValue]
24946 );
24947 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24948 RichTextControl,
24949 {
24950 label,
24951 value,
24952 onChange: onChangeControl,
24953 placeholder,
24954 id,
24955 hideLabelFromVision,
24956 help: description,
24957 disabled: disabled2,
24958 required: !!isValid2.required,
24959 markWhenOptional,
24960 customValidity: getCustomValidity(isValid2, validity),
24961 className,
24962 clientId,
24963 allowedFormats,
24964 disableFormats,
24965 withoutInteractiveFormatting,
24966 preserveWhiteSpace,
24967 disableLineBreaks
24968 }
24969 );
24970 }
24971
24972 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24973 var import_components43 = __toESM(require_components(), 1);
24974 var import_element71 = __toESM(require_element(), 1);
24975 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24976 var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis);
24977 function ToggleGroup({
24978 data,
24979 field,
24980 onChange,
24981 hideLabelFromVision,
24982 markWhenOptional,
24983 validity
24984 }) {
24985 const { getValue, setValue, isValid: isValid2 } = field;
24986 const disabled2 = field.isDisabled({ item: data, field });
24987 const value = getValue({ item: data });
24988 const onChangeControl = (0, import_element71.useCallback)(
24989 (newValue) => onChange(setValue({ item: data, value: newValue })),
24990 [data, onChange, setValue]
24991 );
24992 const { elements, isLoading } = useElements({
24993 elements: field.elements,
24994 getElements: field.getElements
24995 });
24996 if (isLoading) {
24997 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components43.Spinner, {});
24998 }
24999 if (elements.length === 0) {
25000 return null;
25001 }
25002 const selectedOption = elements.find((el) => el.value === value);
25003 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25004 ValidatedToggleGroupControl,
25005 {
25006 required: !!field.isValid?.required,
25007 markWhenOptional,
25008 customValidity: getCustomValidity(isValid2, validity),
25009 isBlock: true,
25010 label: field.label,
25011 help: selectedOption?.description || field.description,
25012 onChange: onChangeControl,
25013 value,
25014 hideLabelFromVision,
25015 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25016 import_components43.__experimentalToggleGroupControlOption,
25017 {
25018 label: el.label,
25019 value: el.value,
25020 disabled: disabled2
25021 },
25022 el.value
25023 ))
25024 }
25025 );
25026 }
25027
25028 // packages/dataviews/build-module/components/dataform-controls/array.mjs
25029 var import_components44 = __toESM(require_components(), 1);
25030 var import_element72 = __toESM(require_element(), 1);
25031 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25032 var { ValidatedFormTokenField } = unlock2(import_components44.privateApis);
25033 function ArrayControl({
25034 data,
25035 field,
25036 onChange,
25037 hideLabelFromVision,
25038 markWhenOptional,
25039 validity
25040 }) {
25041 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25042 const value = getValue({ item: data });
25043 const disabled2 = field.isDisabled({ item: data, field });
25044 const { elements, isLoading } = useElements({
25045 elements: field.elements,
25046 getElements: field.getElements
25047 });
25048 const arrayValueAsElements = (0, import_element72.useMemo)(
25049 () => Array.isArray(value) ? value.map((token) => {
25050 const element = elements?.find(
25051 (suggestion) => suggestion.value === token
25052 );
25053 return element || { value: token, label: token };
25054 }) : [],
25055 [value, elements]
25056 );
25057 const onChangeControl = (0, import_element72.useCallback)(
25058 (tokens) => {
25059 const valueTokens = tokens.map((token) => {
25060 if (typeof token === "object" && "value" in token) {
25061 return token.value;
25062 }
25063 return token;
25064 });
25065 onChange(setValue({ item: data, value: valueTokens }));
25066 },
25067 [onChange, setValue, data]
25068 );
25069 if (isLoading) {
25070 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components44.Spinner, {});
25071 }
25072 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25073 ValidatedFormTokenField,
25074 {
25075 required: !!isValid2?.required,
25076 markWhenOptional,
25077 customValidity: getCustomValidity(isValid2, validity),
25078 label: hideLabelFromVision ? void 0 : label,
25079 value: arrayValueAsElements,
25080 onChange: onChangeControl,
25081 placeholder,
25082 suggestions: elements?.map((element) => element.value),
25083 disabled: disabled2,
25084 __experimentalValidateInput: (token) => {
25085 if (field.isValid?.elements && elements) {
25086 return elements.some(
25087 (element) => element.value === token || element.label === token
25088 );
25089 }
25090 return true;
25091 },
25092 __experimentalExpandOnFocus: elements && elements.length > 0,
25093 help: description ?? (field.isValid?.elements ? "" : void 0),
25094 displayTransform: (token) => {
25095 if (typeof token === "object" && "label" in token) {
25096 return token.label;
25097 }
25098 if (typeof token === "string" && elements) {
25099 const element = elements.find(
25100 (el) => el.value === token
25101 );
25102 return element?.label || token;
25103 }
25104 return token;
25105 },
25106 __experimentalRenderItem: ({ item }) => {
25107 if (typeof item === "string" && elements) {
25108 const element = elements.find(
25109 (el) => el.value === item
25110 );
25111 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: element?.label || item });
25112 }
25113 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: item });
25114 }
25115 }
25116 );
25117 }
25118
25119 // node_modules/colord/index.mjs
25120 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
25121 var t = function(r3) {
25122 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
25123 };
25124 var n = function(r3, t2, n2) {
25125 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
25126 };
25127 var e = function(r3, t2, n2) {
25128 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
25129 };
25130 var u = function(r3) {
25131 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
25132 };
25133 var a = function(r3) {
25134 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
25135 };
25136 var o = function(r3) {
25137 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
25138 };
25139 var i = /^#([0-9a-f]{3,8})$/i;
25140 var s = function(r3) {
25141 var t2 = r3.toString(16);
25142 return t2.length < 2 ? "0" + t2 : t2;
25143 };
25144 var h = function(r3) {
25145 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;
25146 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
25147 };
25148 var b = function(r3) {
25149 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
25150 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
25151 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;
25152 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 };
25153 };
25154 var g = function(r3) {
25155 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
25156 };
25157 var d = function(r3) {
25158 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
25159 };
25160 var f = function(r3) {
25161 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 }));
25162 var t2, n2, e2;
25163 };
25164 var c = function(r3) {
25165 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 };
25166 var t2, n2, e2, u2;
25167 };
25168 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25169 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25170 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25171 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25172 var y = { string: [[function(r3) {
25173 var t2 = i.exec(r3);
25174 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;
25175 }, "hex"], [function(r3) {
25176 var t2 = v.exec(r3) || m.exec(r3);
25177 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;
25178 }, "rgb"], [function(t2) {
25179 var n2 = l.exec(t2) || p.exec(t2);
25180 if (!n2) return null;
25181 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) });
25182 return f(a2);
25183 }, "hsl"]], object: [[function(r3) {
25184 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
25185 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
25186 }, "rgb"], [function(r3) {
25187 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
25188 if (!t(n2) || !t(e2) || !t(u2)) return null;
25189 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
25190 return f(i2);
25191 }, "hsl"], [function(r3) {
25192 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
25193 if (!t(n2) || !t(a2) || !t(o2)) return null;
25194 var h2 = (function(r4) {
25195 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
25196 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
25197 return b(h2);
25198 }, "hsv"]] };
25199 var N = function(r3, t2) {
25200 for (var n2 = 0; n2 < t2.length; n2++) {
25201 var e2 = t2[n2][0](r3);
25202 if (e2) return [e2, t2[n2][1]];
25203 }
25204 return [null, void 0];
25205 };
25206 var x = function(r3) {
25207 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
25208 };
25209 var M = function(r3, t2) {
25210 var n2 = c(r3);
25211 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
25212 };
25213 var H = function(r3) {
25214 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
25215 };
25216 var $ = function(r3, t2) {
25217 var n2 = c(r3);
25218 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
25219 };
25220 var j = (function() {
25221 function r3(r4) {
25222 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
25223 }
25224 return r3.prototype.isValid = function() {
25225 return null !== this.parsed;
25226 }, r3.prototype.brightness = function() {
25227 return n(H(this.rgba), 2);
25228 }, r3.prototype.isDark = function() {
25229 return H(this.rgba) < 0.5;
25230 }, r3.prototype.isLight = function() {
25231 return H(this.rgba) >= 0.5;
25232 }, r3.prototype.toHex = function() {
25233 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;
25234 var r4, t2, e2, u2, a2, i2;
25235 }, r3.prototype.toRgb = function() {
25236 return o(this.rgba);
25237 }, r3.prototype.toRgbString = function() {
25238 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 + ")";
25239 var r4, t2, n2, e2, u2;
25240 }, r3.prototype.toHsl = function() {
25241 return d(c(this.rgba));
25242 }, r3.prototype.toHslString = function() {
25243 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 + "%)";
25244 var r4, t2, n2, e2, u2;
25245 }, r3.prototype.toHsv = function() {
25246 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
25247 var r4;
25248 }, r3.prototype.invert = function() {
25249 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
25250 var r4;
25251 }, r3.prototype.saturate = function(r4) {
25252 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
25253 }, r3.prototype.desaturate = function(r4) {
25254 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
25255 }, r3.prototype.grayscale = function() {
25256 return w(M(this.rgba, -1));
25257 }, r3.prototype.lighten = function(r4) {
25258 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
25259 }, r3.prototype.darken = function(r4) {
25260 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
25261 }, r3.prototype.rotate = function(r4) {
25262 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
25263 }, r3.prototype.alpha = function(r4) {
25264 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
25265 var t2;
25266 }, r3.prototype.hue = function(r4) {
25267 var t2 = c(this.rgba);
25268 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
25269 }, r3.prototype.isEqual = function(r4) {
25270 return this.toHex() === w(r4).toHex();
25271 }, r3;
25272 })();
25273 var w = function(r3) {
25274 return r3 instanceof j ? r3 : new j(r3);
25275 };
25276
25277 // packages/dataviews/build-module/components/dataform-controls/color.mjs
25278 var import_components45 = __toESM(require_components(), 1);
25279 var import_element73 = __toESM(require_element(), 1);
25280 var import_i18n43 = __toESM(require_i18n(), 1);
25281 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25282 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis);
25283 var ColorPickerDropdown = ({
25284 color,
25285 onColorChange,
25286 disabled: disabled2
25287 }) => {
25288 const validColor = color && w(color).isValid() ? color : "#ffffff";
25289 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25290 import_components45.Dropdown,
25291 {
25292 className: "dataviews-controls__color-picker-dropdown",
25293 popoverProps: { resize: false },
25294 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25295 import_components45.Button,
25296 {
25297 onClick: onToggle,
25298 "aria-label": (0, import_i18n43.__)("Open color picker"),
25299 size: "small",
25300 disabled: disabled2,
25301 accessibleWhenDisabled: true,
25302 icon: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
25303 }
25304 ),
25305 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25306 import_components45.ColorPicker,
25307 {
25308 color: validColor,
25309 onChange: onColorChange,
25310 enableAlpha: true
25311 }
25312 ) })
25313 }
25314 );
25315 };
25316 function Color({
25317 data,
25318 field,
25319 onChange,
25320 hideLabelFromVision,
25321 markWhenOptional,
25322 validity
25323 }) {
25324 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
25325 const disabled2 = field.isDisabled({ item: data, field });
25326 const value = field.getValue({ item: data }) || "";
25327 const handleColorChange = (0, import_element73.useCallback)(
25328 (newColor) => {
25329 onChange(setValue({ item: data, value: newColor }));
25330 },
25331 [data, onChange, setValue]
25332 );
25333 const handleInputChange = (0, import_element73.useCallback)(
25334 (newValue) => {
25335 onChange(setValue({ item: data, value: newValue || "" }));
25336 },
25337 [data, onChange, setValue]
25338 );
25339 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25340 ValidatedInputControl3,
25341 {
25342 required: !!field.isValid?.required,
25343 markWhenOptional,
25344 customValidity: getCustomValidity(isValid2, validity),
25345 label,
25346 placeholder,
25347 value,
25348 help: description,
25349 onChange: handleInputChange,
25350 hideLabelFromVision,
25351 type: "text",
25352 disabled: disabled2,
25353 prefix: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25354 ColorPickerDropdown,
25355 {
25356 color: value,
25357 onColorChange: handleColorChange,
25358 disabled: disabled2
25359 }
25360 ) })
25361 }
25362 );
25363 }
25364
25365 // packages/dataviews/build-module/components/dataform-controls/password.mjs
25366 var import_components46 = __toESM(require_components(), 1);
25367 var import_element74 = __toESM(require_element(), 1);
25368 var import_i18n44 = __toESM(require_i18n(), 1);
25369 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25370 function Password({
25371 data,
25372 field,
25373 onChange,
25374 hideLabelFromVision,
25375 markWhenOptional,
25376 validity
25377 }) {
25378 const [isVisible2, setIsVisible] = (0, import_element74.useState)(false);
25379 const disabled2 = field.isDisabled({ item: data, field });
25380 const toggleVisibility = (0, import_element74.useCallback)(() => {
25381 setIsVisible((prev) => !prev);
25382 }, []);
25383 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25384 ValidatedText,
25385 {
25386 ...{
25387 data,
25388 field,
25389 onChange,
25390 hideLabelFromVision,
25391 markWhenOptional,
25392 validity,
25393 type: isVisible2 ? "text" : "password",
25394 suffix: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25395 import_components46.Button,
25396 {
25397 icon: isVisible2 ? unseen_default : seen_default,
25398 onClick: toggleVisibility,
25399 size: "small",
25400 label: isVisible2 ? (0, import_i18n44.__)("Hide password") : (0, import_i18n44.__)("Show password"),
25401 disabled: disabled2,
25402 accessibleWhenDisabled: true
25403 }
25404 ) })
25405 }
25406 }
25407 );
25408 }
25409
25410 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25411 function hasElements(field) {
25412 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25413 }
25414
25415 // packages/dataviews/build-module/components/dataform-controls/index.mjs
25416 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25417 var FORM_CONTROLS = {
25418 adaptiveSelect: AdaptiveSelect,
25419 array: ArrayControl,
25420 checkbox: Checkbox,
25421 color: Color,
25422 combobox: Combobox3,
25423 datetime: DateTime,
25424 date: DateControl,
25425 email: Email,
25426 telephone: Telephone,
25427 url: Url,
25428 integer: Integer,
25429 number: Number2,
25430 password: Password,
25431 radio: Radio,
25432 select: Select,
25433 text: Text,
25434 toggle: Toggle,
25435 textarea: Textarea,
25436 richtext: RichText,
25437 toggleGroup: ToggleGroup
25438 };
25439 function isEditConfig(value) {
25440 return value && typeof value === "object" && typeof value.control === "string";
25441 }
25442 function createConfiguredControl(config) {
25443 const { control, ...controlConfig } = config;
25444 const BaseControlType = getControlByType(control);
25445 if (BaseControlType === null) {
25446 return null;
25447 }
25448 return function ConfiguredControl(props) {
25449 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(BaseControlType, { ...props, config: controlConfig });
25450 };
25451 }
25452 function getControl(field, fallback) {
25453 if (typeof field.Edit === "function") {
25454 return field.Edit;
25455 }
25456 if (typeof field.Edit === "string") {
25457 return getControlByType(field.Edit);
25458 }
25459 if (isEditConfig(field.Edit)) {
25460 return createConfiguredControl(field.Edit);
25461 }
25462 if (hasElements(field) && field.type !== "array") {
25463 return getControlByType("adaptiveSelect");
25464 }
25465 if (fallback === null) {
25466 return null;
25467 }
25468 return getControlByType(fallback);
25469 }
25470 function getControlByType(type) {
25471 if (Object.keys(FORM_CONTROLS).includes(type)) {
25472 return FORM_CONTROLS[type];
25473 }
25474 return null;
25475 }
25476
25477 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25478 function getFilterBy(field, defaultOperators, validOperators) {
25479 if (field.filterBy === false) {
25480 return false;
25481 }
25482 const operators = field.filterBy?.operators?.filter(
25483 (op) => validOperators.includes(op)
25484 ) ?? defaultOperators;
25485 if (operators.length === 0) {
25486 return false;
25487 }
25488 return {
25489 isPrimary: !!field.filterBy?.isPrimary,
25490 operators
25491 };
25492 }
25493 var get_filter_by_default = getFilterBy;
25494
25495 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25496 var getValueFromId = (id) => ({ item }) => {
25497 const path = id.split(".");
25498 let value = item;
25499 for (const segment of path) {
25500 if (value.hasOwnProperty(segment)) {
25501 value = value[segment];
25502 } else {
25503 value = void 0;
25504 }
25505 }
25506 return value;
25507 };
25508 var get_value_from_id_default = getValueFromId;
25509
25510 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25511 var setValueFromId = (id) => ({ value }) => {
25512 const path = id.split(".");
25513 const result = {};
25514 let current = result;
25515 for (const segment of path.slice(0, -1)) {
25516 current[segment] = {};
25517 current = current[segment];
25518 }
25519 current[path.at(-1)] = value;
25520 return result;
25521 };
25522 var set_value_from_id_default = setValueFromId;
25523
25524 // packages/dataviews/build-module/field-types/email.mjs
25525 var import_i18n45 = __toESM(require_i18n(), 1);
25526
25527 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25528 function RenderFromElements({
25529 item,
25530 field
25531 }) {
25532 const { elements, isLoading } = useElements({
25533 elements: field.elements,
25534 getElements: field.getElements
25535 });
25536 const value = field.getValue({ item });
25537 if (isLoading) {
25538 return value;
25539 }
25540 if (elements.length === 0) {
25541 return value;
25542 }
25543 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25544 }
25545
25546 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25547 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25548 function render({
25549 item,
25550 field
25551 }) {
25552 if (field.hasElements) {
25553 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RenderFromElements, { item, field });
25554 }
25555 return field.getValueFormatted({ item, field });
25556 }
25557
25558 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25559 var sort_text_default = (a2, b2, direction) => {
25560 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25561 };
25562
25563 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25564 function isValidRequired(item, field) {
25565 const value = field.getValue({ item });
25566 return ![void 0, "", null].includes(value);
25567 }
25568
25569 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25570 function isValidMinLength(item, field) {
25571 if (typeof field.isValid.minLength?.constraint !== "number") {
25572 return false;
25573 }
25574 const value = field.getValue({ item });
25575 if ([void 0, "", null].includes(value)) {
25576 return true;
25577 }
25578 return String(value).length >= field.isValid.minLength.constraint;
25579 }
25580
25581 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25582 function isValidMaxLength(item, field) {
25583 if (typeof field.isValid.maxLength?.constraint !== "number") {
25584 return false;
25585 }
25586 const value = field.getValue({ item });
25587 if ([void 0, "", null].includes(value)) {
25588 return true;
25589 }
25590 return String(value).length <= field.isValid.maxLength.constraint;
25591 }
25592
25593 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25594 function isValidPattern(item, field) {
25595 if (field.isValid.pattern?.constraint === void 0) {
25596 return true;
25597 }
25598 try {
25599 const regexp = new RegExp(field.isValid.pattern.constraint);
25600 const value = field.getValue({ item });
25601 if ([void 0, "", null].includes(value)) {
25602 return true;
25603 }
25604 return regexp.test(String(value));
25605 } catch {
25606 return false;
25607 }
25608 }
25609
25610 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25611 function isValidElements(item, field) {
25612 const elements = field.elements ?? [];
25613 const validValues = elements.map((el) => el.value);
25614 if (validValues.length === 0) {
25615 return true;
25616 }
25617 const value = field.getValue({ item });
25618 return [].concat(value).every((v2) => validValues.includes(v2));
25619 }
25620
25621 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25622 function getValueFormatted({
25623 item,
25624 field
25625 }) {
25626 return field.getValue({ item });
25627 }
25628 var get_value_formatted_default_default = getValueFormatted;
25629
25630 // packages/dataviews/build-module/field-types/email.mjs
25631 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])?)*$/;
25632 function isValidCustom(item, field) {
25633 const value = field.getValue({ item });
25634 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25635 return (0, import_i18n45.__)("Value must be a valid email address.");
25636 }
25637 return null;
25638 }
25639 var email_default = {
25640 type: "email",
25641 render,
25642 Edit: "email",
25643 sort: sort_text_default,
25644 enableSorting: true,
25645 enableGlobalSearch: false,
25646 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25647 validOperators: [
25648 OPERATOR_IS,
25649 OPERATOR_IS_NOT,
25650 OPERATOR_CONTAINS,
25651 OPERATOR_NOT_CONTAINS,
25652 OPERATOR_STARTS_WITH,
25653 // Multiple selection
25654 OPERATOR_IS_ANY,
25655 OPERATOR_IS_NONE,
25656 OPERATOR_IS_ALL,
25657 OPERATOR_IS_NOT_ALL
25658 ],
25659 format: {},
25660 getValueFormatted: get_value_formatted_default_default,
25661 validate: {
25662 required: isValidRequired,
25663 pattern: isValidPattern,
25664 minLength: isValidMinLength,
25665 maxLength: isValidMaxLength,
25666 elements: isValidElements,
25667 custom: isValidCustom
25668 }
25669 };
25670
25671 // packages/dataviews/build-module/field-types/integer.mjs
25672 var import_i18n46 = __toESM(require_i18n(), 1);
25673
25674 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25675 var sort_number_default = (a2, b2, direction) => {
25676 return direction === "asc" ? a2 - b2 : b2 - a2;
25677 };
25678
25679 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25680 function isValidMin(item, field) {
25681 if (typeof field.isValid.min?.constraint !== "number") {
25682 return false;
25683 }
25684 const value = field.getValue({ item });
25685 if ([void 0, "", null].includes(value)) {
25686 return true;
25687 }
25688 return Number(value) >= field.isValid.min.constraint;
25689 }
25690
25691 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25692 function isValidMax(item, field) {
25693 if (typeof field.isValid.max?.constraint !== "number") {
25694 return false;
25695 }
25696 const value = field.getValue({ item });
25697 if ([void 0, "", null].includes(value)) {
25698 return true;
25699 }
25700 return Number(value) <= field.isValid.max.constraint;
25701 }
25702
25703 // packages/dataviews/build-module/field-types/integer.mjs
25704 var format2 = {
25705 separatorThousand: ","
25706 };
25707 function getValueFormatted2({
25708 item,
25709 field
25710 }) {
25711 let value = field.getValue({ item });
25712 if (value === null || value === void 0) {
25713 return "";
25714 }
25715 value = Number(value);
25716 if (!Number.isFinite(value)) {
25717 return String(value);
25718 }
25719 let formatInteger;
25720 if (field.type !== "integer") {
25721 formatInteger = format2;
25722 } else {
25723 formatInteger = field.format;
25724 }
25725 const { separatorThousand } = formatInteger;
25726 const integerValue = Math.trunc(value);
25727 if (!separatorThousand) {
25728 return String(integerValue);
25729 }
25730 return String(integerValue).replace(
25731 /\B(?=(\d{3})+(?!\d))/g,
25732 separatorThousand
25733 );
25734 }
25735 function isValidCustom2(item, field) {
25736 const value = field.getValue({ item });
25737 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25738 return (0, import_i18n46.__)("Value must be an integer.");
25739 }
25740 return null;
25741 }
25742 var integer_default = {
25743 type: "integer",
25744 render,
25745 Edit: "integer",
25746 sort: sort_number_default,
25747 enableSorting: true,
25748 enableGlobalSearch: false,
25749 defaultOperators: [
25750 OPERATOR_IS,
25751 OPERATOR_IS_NOT,
25752 OPERATOR_LESS_THAN,
25753 OPERATOR_GREATER_THAN,
25754 OPERATOR_LESS_THAN_OR_EQUAL,
25755 OPERATOR_GREATER_THAN_OR_EQUAL,
25756 OPERATOR_BETWEEN
25757 ],
25758 validOperators: [
25759 // Single-selection
25760 OPERATOR_IS,
25761 OPERATOR_IS_NOT,
25762 OPERATOR_LESS_THAN,
25763 OPERATOR_GREATER_THAN,
25764 OPERATOR_LESS_THAN_OR_EQUAL,
25765 OPERATOR_GREATER_THAN_OR_EQUAL,
25766 OPERATOR_BETWEEN,
25767 // Multiple-selection
25768 OPERATOR_IS_ANY,
25769 OPERATOR_IS_NONE,
25770 OPERATOR_IS_ALL,
25771 OPERATOR_IS_NOT_ALL
25772 ],
25773 format: format2,
25774 getValueFormatted: getValueFormatted2,
25775 validate: {
25776 required: isValidRequired,
25777 min: isValidMin,
25778 max: isValidMax,
25779 elements: isValidElements,
25780 custom: isValidCustom2
25781 }
25782 };
25783
25784 // packages/dataviews/build-module/field-types/number.mjs
25785 var import_i18n47 = __toESM(require_i18n(), 1);
25786 var format3 = {
25787 separatorThousand: ",",
25788 separatorDecimal: ".",
25789 decimals: 2
25790 };
25791 function getValueFormatted3({
25792 item,
25793 field
25794 }) {
25795 let value = field.getValue({ item });
25796 if (value === null || value === void 0) {
25797 return "";
25798 }
25799 value = Number(value);
25800 if (!Number.isFinite(value)) {
25801 return String(value);
25802 }
25803 let formatNumber;
25804 if (field.type !== "number") {
25805 formatNumber = format3;
25806 } else {
25807 formatNumber = field.format;
25808 }
25809 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25810 const fixedValue = value.toFixed(decimals);
25811 const [integerPart, decimalPart] = fixedValue.split(".");
25812 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25813 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25814 }
25815 function isEmpty(value) {
25816 return value === "" || value === void 0 || value === null;
25817 }
25818 function isValidCustom3(item, field) {
25819 const value = field.getValue({ item });
25820 if (!isEmpty(value) && !Number.isFinite(value)) {
25821 return (0, import_i18n47.__)("Value must be a number.");
25822 }
25823 return null;
25824 }
25825 var number_default = {
25826 type: "number",
25827 render,
25828 Edit: "number",
25829 sort: sort_number_default,
25830 enableSorting: true,
25831 enableGlobalSearch: false,
25832 defaultOperators: [
25833 OPERATOR_IS,
25834 OPERATOR_IS_NOT,
25835 OPERATOR_LESS_THAN,
25836 OPERATOR_GREATER_THAN,
25837 OPERATOR_LESS_THAN_OR_EQUAL,
25838 OPERATOR_GREATER_THAN_OR_EQUAL,
25839 OPERATOR_BETWEEN
25840 ],
25841 validOperators: [
25842 // Single-selection
25843 OPERATOR_IS,
25844 OPERATOR_IS_NOT,
25845 OPERATOR_LESS_THAN,
25846 OPERATOR_GREATER_THAN,
25847 OPERATOR_LESS_THAN_OR_EQUAL,
25848 OPERATOR_GREATER_THAN_OR_EQUAL,
25849 OPERATOR_BETWEEN,
25850 // Multiple-selection
25851 OPERATOR_IS_ANY,
25852 OPERATOR_IS_NONE,
25853 OPERATOR_IS_ALL,
25854 OPERATOR_IS_NOT_ALL
25855 ],
25856 format: format3,
25857 getValueFormatted: getValueFormatted3,
25858 validate: {
25859 required: isValidRequired,
25860 min: isValidMin,
25861 max: isValidMax,
25862 elements: isValidElements,
25863 custom: isValidCustom3
25864 }
25865 };
25866
25867 // packages/dataviews/build-module/field-types/text.mjs
25868 var text_default = {
25869 type: "text",
25870 render,
25871 Edit: "text",
25872 sort: sort_text_default,
25873 enableSorting: true,
25874 enableGlobalSearch: false,
25875 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25876 validOperators: [
25877 // Single selection
25878 OPERATOR_IS,
25879 OPERATOR_IS_NOT,
25880 OPERATOR_CONTAINS,
25881 OPERATOR_NOT_CONTAINS,
25882 OPERATOR_STARTS_WITH,
25883 // Multiple selection
25884 OPERATOR_IS_ANY,
25885 OPERATOR_IS_NONE,
25886 OPERATOR_IS_ALL,
25887 OPERATOR_IS_NOT_ALL
25888 ],
25889 format: {},
25890 getValueFormatted: get_value_formatted_default_default,
25891 validate: {
25892 required: isValidRequired,
25893 pattern: isValidPattern,
25894 minLength: isValidMinLength,
25895 maxLength: isValidMaxLength,
25896 elements: isValidElements
25897 }
25898 };
25899
25900 // packages/dataviews/build-module/field-types/datetime.mjs
25901 var import_date7 = __toESM(require_date(), 1);
25902
25903 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25904 var import_date6 = __toESM(require_date(), 1);
25905 function parseDateLike(value) {
25906 if (!value) {
25907 return null;
25908 }
25909 if (!isValid(new Date(value))) {
25910 return null;
25911 }
25912 const parsed = (0, import_date6.getDate)(value);
25913 return parsed && isValid(parsed) ? parsed : null;
25914 }
25915 function validateDateLikeBoundary(item, field, boundary) {
25916 const constraint = field.isValid[boundary]?.constraint;
25917 if (typeof constraint !== "string") {
25918 return false;
25919 }
25920 const value = field.getValue({ item });
25921 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25922 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25923 return true;
25924 }
25925 const parsedConstraint = parseDateLike(constraint);
25926 const parsedValue = parseDateLike(String(boundaryValue));
25927 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25928 }
25929 function isValidMinDate(item, field) {
25930 return validateDateLikeBoundary(item, field, "min");
25931 }
25932 function isValidMaxDate(item, field) {
25933 return validateDateLikeBoundary(item, field, "max");
25934 }
25935
25936 // packages/dataviews/build-module/field-types/datetime.mjs
25937 var format4 = {
25938 datetime: (0, import_date7.getSettings)().formats.datetime,
25939 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25940 };
25941 function getValueFormatted4({
25942 item,
25943 field
25944 }) {
25945 const value = field.getValue({ item });
25946 if (["", void 0, null].includes(value)) {
25947 return "";
25948 }
25949 let formatDatetime;
25950 if (field.type !== "datetime") {
25951 formatDatetime = format4;
25952 } else {
25953 formatDatetime = field.format;
25954 }
25955 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25956 }
25957 var sort = (a2, b2, direction) => {
25958 const timeA = new Date(a2).getTime();
25959 const timeB = new Date(b2).getTime();
25960 return direction === "asc" ? timeA - timeB : timeB - timeA;
25961 };
25962 var datetime_default = {
25963 type: "datetime",
25964 render,
25965 Edit: "datetime",
25966 sort,
25967 enableSorting: true,
25968 enableGlobalSearch: false,
25969 defaultOperators: [
25970 OPERATOR_ON,
25971 OPERATOR_NOT_ON,
25972 OPERATOR_BEFORE,
25973 OPERATOR_AFTER,
25974 OPERATOR_BEFORE_INC,
25975 OPERATOR_AFTER_INC,
25976 OPERATOR_IN_THE_PAST,
25977 OPERATOR_OVER
25978 ],
25979 validOperators: [
25980 OPERATOR_ON,
25981 OPERATOR_NOT_ON,
25982 OPERATOR_BEFORE,
25983 OPERATOR_AFTER,
25984 OPERATOR_BEFORE_INC,
25985 OPERATOR_AFTER_INC,
25986 OPERATOR_IN_THE_PAST,
25987 OPERATOR_OVER
25988 ],
25989 format: format4,
25990 getValueFormatted: getValueFormatted4,
25991 validate: {
25992 required: isValidRequired,
25993 elements: isValidElements,
25994 min: isValidMinDate,
25995 max: isValidMaxDate
25996 }
25997 };
25998
25999 // packages/dataviews/build-module/field-types/date.mjs
26000 var import_date8 = __toESM(require_date(), 1);
26001 var format5 = {
26002 date: (0, import_date8.getSettings)().formats.date,
26003 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
26004 };
26005 function getValueFormatted5({
26006 item,
26007 field
26008 }) {
26009 const value = field.getValue({ item });
26010 if (["", void 0, null].includes(value)) {
26011 return "";
26012 }
26013 let formatDate2;
26014 if (field.type !== "date") {
26015 formatDate2 = format5;
26016 } else {
26017 formatDate2 = field.format;
26018 }
26019 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
26020 }
26021 var sort2 = (a2, b2, direction) => {
26022 const timeA = new Date(a2).getTime();
26023 const timeB = new Date(b2).getTime();
26024 return direction === "asc" ? timeA - timeB : timeB - timeA;
26025 };
26026 var date_default = {
26027 type: "date",
26028 render,
26029 Edit: "date",
26030 sort: sort2,
26031 enableSorting: true,
26032 enableGlobalSearch: false,
26033 defaultOperators: [
26034 OPERATOR_ON,
26035 OPERATOR_NOT_ON,
26036 OPERATOR_BEFORE,
26037 OPERATOR_AFTER,
26038 OPERATOR_BEFORE_INC,
26039 OPERATOR_AFTER_INC,
26040 OPERATOR_IN_THE_PAST,
26041 OPERATOR_OVER,
26042 OPERATOR_BETWEEN
26043 ],
26044 validOperators: [
26045 OPERATOR_ON,
26046 OPERATOR_NOT_ON,
26047 OPERATOR_BEFORE,
26048 OPERATOR_AFTER,
26049 OPERATOR_BEFORE_INC,
26050 OPERATOR_AFTER_INC,
26051 OPERATOR_IN_THE_PAST,
26052 OPERATOR_OVER,
26053 OPERATOR_BETWEEN
26054 ],
26055 format: format5,
26056 getValueFormatted: getValueFormatted5,
26057 validate: {
26058 required: isValidRequired,
26059 elements: isValidElements,
26060 min: isValidMinDate,
26061 max: isValidMaxDate
26062 }
26063 };
26064
26065 // packages/dataviews/build-module/field-types/boolean.mjs
26066 var import_i18n48 = __toESM(require_i18n(), 1);
26067
26068 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
26069 function isValidRequiredForBool(item, field) {
26070 const value = field.getValue({ item });
26071 return value === true;
26072 }
26073
26074 // packages/dataviews/build-module/field-types/boolean.mjs
26075 function getValueFormatted6({
26076 item,
26077 field
26078 }) {
26079 const value = field.getValue({ item });
26080 if (value === true) {
26081 return (0, import_i18n48.__)("True");
26082 }
26083 if (value === false) {
26084 return (0, import_i18n48.__)("False");
26085 }
26086 return "";
26087 }
26088 function isValidCustom4(item, field) {
26089 const value = field.getValue({ item });
26090 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
26091 return (0, import_i18n48.__)("Value must be true, false, or undefined");
26092 }
26093 return null;
26094 }
26095 var sort3 = (a2, b2, direction) => {
26096 const boolA = Boolean(a2);
26097 const boolB = Boolean(b2);
26098 if (boolA === boolB) {
26099 return 0;
26100 }
26101 if (direction === "asc") {
26102 return boolA ? 1 : -1;
26103 }
26104 return boolA ? -1 : 1;
26105 };
26106 var boolean_default = {
26107 type: "boolean",
26108 render,
26109 Edit: "checkbox",
26110 sort: sort3,
26111 validate: {
26112 required: isValidRequiredForBool,
26113 elements: isValidElements,
26114 custom: isValidCustom4
26115 },
26116 enableSorting: true,
26117 enableGlobalSearch: false,
26118 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26119 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26120 format: {},
26121 getValueFormatted: getValueFormatted6
26122 };
26123
26124 // packages/dataviews/build-module/field-types/media.mjs
26125 var media_default = {
26126 type: "media",
26127 render: () => null,
26128 Edit: null,
26129 sort: () => 0,
26130 enableSorting: false,
26131 enableGlobalSearch: false,
26132 defaultOperators: [],
26133 validOperators: [],
26134 format: {},
26135 getValueFormatted: get_value_formatted_default_default,
26136 // cannot validate any constraint, so
26137 // the only available validation for the field author
26138 // would be providing a custom validator.
26139 validate: {}
26140 };
26141
26142 // packages/dataviews/build-module/field-types/array.mjs
26143 var import_i18n49 = __toESM(require_i18n(), 1);
26144
26145 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
26146 function isValidRequiredForArray(item, field) {
26147 const value = field.getValue({ item });
26148 return Array.isArray(value) && value.length > 0 && value.every(
26149 (element) => ![void 0, "", null].includes(element)
26150 );
26151 }
26152
26153 // packages/dataviews/build-module/field-types/array.mjs
26154 function getValueFormatted7({
26155 item,
26156 field
26157 }) {
26158 const value = field.getValue({ item });
26159 const arr = Array.isArray(value) ? value : [];
26160 return arr.join(", ");
26161 }
26162 function render2({ item, field }) {
26163 return getValueFormatted7({ item, field });
26164 }
26165 function isValidCustom5(item, field) {
26166 const value = field.getValue({ item });
26167 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
26168 return (0, import_i18n49.__)("Value must be an array.");
26169 }
26170 if (!value.every((v2) => typeof v2 === "string")) {
26171 return (0, import_i18n49.__)("Every value must be a string.");
26172 }
26173 return null;
26174 }
26175 var sort4 = (a2, b2, direction) => {
26176 const arrA = Array.isArray(a2) ? a2 : [];
26177 const arrB = Array.isArray(b2) ? b2 : [];
26178 if (arrA.length !== arrB.length) {
26179 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
26180 }
26181 const joinedA = arrA.join(",");
26182 const joinedB = arrB.join(",");
26183 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
26184 };
26185 var array_default = {
26186 type: "array",
26187 render: render2,
26188 Edit: "array",
26189 sort: sort4,
26190 enableSorting: true,
26191 enableGlobalSearch: false,
26192 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26193 validOperators: [
26194 OPERATOR_IS_ANY,
26195 OPERATOR_IS_NONE,
26196 OPERATOR_IS_ALL,
26197 OPERATOR_IS_NOT_ALL
26198 ],
26199 format: {},
26200 getValueFormatted: getValueFormatted7,
26201 validate: {
26202 required: isValidRequiredForArray,
26203 elements: isValidElements,
26204 custom: isValidCustom5
26205 }
26206 };
26207
26208 // packages/dataviews/build-module/field-types/password.mjs
26209 function getValueFormatted8({
26210 item,
26211 field
26212 }) {
26213 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
26214 }
26215 var password_default = {
26216 type: "password",
26217 render,
26218 Edit: "password",
26219 sort: () => 0,
26220 // Passwords should not be sortable for security reasons
26221 enableSorting: false,
26222 enableGlobalSearch: false,
26223 defaultOperators: [],
26224 validOperators: [],
26225 format: {},
26226 getValueFormatted: getValueFormatted8,
26227 validate: {
26228 required: isValidRequired,
26229 pattern: isValidPattern,
26230 minLength: isValidMinLength,
26231 maxLength: isValidMaxLength,
26232 elements: isValidElements
26233 }
26234 };
26235
26236 // packages/dataviews/build-module/field-types/telephone.mjs
26237 var telephone_default = {
26238 type: "telephone",
26239 render,
26240 Edit: "telephone",
26241 sort: sort_text_default,
26242 enableSorting: true,
26243 enableGlobalSearch: false,
26244 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26245 validOperators: [
26246 OPERATOR_IS,
26247 OPERATOR_IS_NOT,
26248 OPERATOR_CONTAINS,
26249 OPERATOR_NOT_CONTAINS,
26250 OPERATOR_STARTS_WITH,
26251 // Multiple selection
26252 OPERATOR_IS_ANY,
26253 OPERATOR_IS_NONE,
26254 OPERATOR_IS_ALL,
26255 OPERATOR_IS_NOT_ALL
26256 ],
26257 format: {},
26258 getValueFormatted: get_value_formatted_default_default,
26259 validate: {
26260 required: isValidRequired,
26261 pattern: isValidPattern,
26262 minLength: isValidMinLength,
26263 maxLength: isValidMaxLength,
26264 elements: isValidElements
26265 }
26266 };
26267
26268 // packages/dataviews/build-module/field-types/color.mjs
26269 var import_i18n50 = __toESM(require_i18n(), 1);
26270 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26271 function render3({ item, field }) {
26272 if (field.hasElements) {
26273 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(RenderFromElements, { item, field });
26274 }
26275 const value = get_value_formatted_default_default({ item, field });
26276 if (!value || !w(value).isValid()) {
26277 return value;
26278 }
26279 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
26280 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26281 "div",
26282 {
26283 style: {
26284 width: "16px",
26285 height: "16px",
26286 borderRadius: "50%",
26287 backgroundColor: value,
26288 border: "1px solid #ddd",
26289 flexShrink: 0
26290 }
26291 }
26292 ),
26293 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("span", { children: value })
26294 ] });
26295 }
26296 function isValidCustom6(item, field) {
26297 const value = field.getValue({ item });
26298 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
26299 return (0, import_i18n50.__)("Value must be a valid color.");
26300 }
26301 return null;
26302 }
26303 var sort5 = (a2, b2, direction) => {
26304 const colorA = w(a2);
26305 const colorB = w(b2);
26306 if (!colorA.isValid() && !colorB.isValid()) {
26307 return 0;
26308 }
26309 if (!colorA.isValid()) {
26310 return direction === "asc" ? 1 : -1;
26311 }
26312 if (!colorB.isValid()) {
26313 return direction === "asc" ? -1 : 1;
26314 }
26315 const hslA = colorA.toHsl();
26316 const hslB = colorB.toHsl();
26317 if (hslA.h !== hslB.h) {
26318 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
26319 }
26320 if (hslA.s !== hslB.s) {
26321 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
26322 }
26323 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
26324 };
26325 var color_default = {
26326 type: "color",
26327 render: render3,
26328 Edit: "color",
26329 sort: sort5,
26330 enableSorting: true,
26331 enableGlobalSearch: false,
26332 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26333 validOperators: [
26334 OPERATOR_IS,
26335 OPERATOR_IS_NOT,
26336 OPERATOR_IS_ANY,
26337 OPERATOR_IS_NONE
26338 ],
26339 format: {},
26340 getValueFormatted: get_value_formatted_default_default,
26341 validate: {
26342 required: isValidRequired,
26343 elements: isValidElements,
26344 custom: isValidCustom6
26345 }
26346 };
26347
26348 // packages/dataviews/build-module/field-types/url.mjs
26349 var url_default = {
26350 type: "url",
26351 render,
26352 Edit: "url",
26353 sort: sort_text_default,
26354 enableSorting: true,
26355 enableGlobalSearch: false,
26356 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26357 validOperators: [
26358 OPERATOR_IS,
26359 OPERATOR_IS_NOT,
26360 OPERATOR_CONTAINS,
26361 OPERATOR_NOT_CONTAINS,
26362 OPERATOR_STARTS_WITH,
26363 // Multiple selection
26364 OPERATOR_IS_ANY,
26365 OPERATOR_IS_NONE,
26366 OPERATOR_IS_ALL,
26367 OPERATOR_IS_NOT_ALL
26368 ],
26369 format: {},
26370 getValueFormatted: get_value_formatted_default_default,
26371 validate: {
26372 required: isValidRequired,
26373 pattern: isValidPattern,
26374 minLength: isValidMinLength,
26375 maxLength: isValidMaxLength,
26376 elements: isValidElements
26377 }
26378 };
26379
26380 // packages/dataviews/build-module/field-types/no-type.mjs
26381 var sort6 = (a2, b2, direction) => {
26382 if (typeof a2 === "number" && typeof b2 === "number") {
26383 return sort_number_default(a2, b2, direction);
26384 }
26385 return sort_text_default(a2, b2, direction);
26386 };
26387 var no_type_default = {
26388 // type: no type for this one
26389 render,
26390 Edit: null,
26391 sort: sort6,
26392 enableSorting: true,
26393 enableGlobalSearch: false,
26394 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26395 validOperators: getAllOperatorNames(),
26396 format: {},
26397 getValueFormatted: get_value_formatted_default_default,
26398 validate: {
26399 required: isValidRequired,
26400 elements: isValidElements
26401 }
26402 };
26403
26404 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
26405 function supportsNumericRangeConstraint(type) {
26406 return type === "integer" || type === "number";
26407 }
26408 function supportsDateRangeConstraint(type) {
26409 return type === "date" || type === "datetime";
26410 }
26411 function normalizeRangeRule(value, fieldType, key) {
26412 const validator = fieldType.validate[key];
26413 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26414 return { constraint: value, validate: validator };
26415 }
26416 return void 0;
26417 }
26418 function getIsValid(field, fieldType) {
26419 const rules = field.isValid;
26420 let required;
26421 if (rules?.required === true && fieldType.validate.required !== void 0) {
26422 required = {
26423 constraint: true,
26424 validate: fieldType.validate.required
26425 };
26426 }
26427 let elements;
26428 if ((rules?.elements === true || // elements is enabled unless the field opts-out
26429 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26430 elements = {
26431 constraint: true,
26432 validate: fieldType.validate.elements
26433 };
26434 }
26435 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26436 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26437 const minLengthValue = rules?.minLength;
26438 let minLength;
26439 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26440 minLength = {
26441 constraint: minLengthValue,
26442 validate: fieldType.validate.minLength
26443 };
26444 }
26445 const maxLengthValue = rules?.maxLength;
26446 let maxLength;
26447 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26448 maxLength = {
26449 constraint: maxLengthValue,
26450 validate: fieldType.validate.maxLength
26451 };
26452 }
26453 const patternValue = rules?.pattern;
26454 let pattern;
26455 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26456 pattern = {
26457 constraint: patternValue,
26458 validate: fieldType.validate.pattern
26459 };
26460 }
26461 const custom = rules?.custom ?? fieldType.validate.custom;
26462 return {
26463 required,
26464 elements,
26465 min: min2,
26466 max: max2,
26467 minLength,
26468 maxLength,
26469 pattern,
26470 custom
26471 };
26472 }
26473
26474 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26475 function getFilter(fieldType) {
26476 return fieldType.validOperators.reduce((accumulator, operator) => {
26477 const operatorObj = getOperatorByName(operator);
26478 if (operatorObj?.filter) {
26479 accumulator[operator] = operatorObj.filter;
26480 }
26481 return accumulator;
26482 }, {});
26483 }
26484
26485 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26486 function getFormat(field, fieldType) {
26487 return {
26488 ...fieldType.format,
26489 ...field.format
26490 };
26491 }
26492 var get_format_default = getFormat;
26493
26494 // packages/dataviews/build-module/field-types/index.mjs
26495 function getFieldTypeByName(type) {
26496 const found = [
26497 email_default,
26498 integer_default,
26499 number_default,
26500 text_default,
26501 datetime_default,
26502 date_default,
26503 boolean_default,
26504 media_default,
26505 array_default,
26506 password_default,
26507 telephone_default,
26508 color_default,
26509 url_default
26510 ].find((fieldType) => fieldType?.type === type);
26511 if (!!found) {
26512 return found;
26513 }
26514 return no_type_default;
26515 }
26516 function normalizeFields(fields) {
26517 return fields.map((field) => {
26518 const fieldType = getFieldTypeByName(field.type);
26519 const getValue = field.getValue || get_value_from_id_default(field.id);
26520 const sort7 = function(a2, b2, direction) {
26521 const aValue = getValue({ item: a2 });
26522 const bValue = getValue({ item: b2 });
26523 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26524 };
26525 return {
26526 id: field.id,
26527 label: field.label || field.id,
26528 header: field.header || field.label || field.id,
26529 description: field.description,
26530 placeholder: field.placeholder,
26531 getValue,
26532 setValue: field.setValue || set_value_from_id_default(field.id),
26533 elements: field.elements,
26534 getElements: field.getElements,
26535 hasElements: hasElements(field),
26536 isVisible: field.isVisible,
26537 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26538 enableHiding: field.enableHiding ?? true,
26539 readOnly: field.readOnly ?? false,
26540 // The type provides defaults for the following props
26541 type: fieldType.type,
26542 render: field.render ?? fieldType.render,
26543 Edit: getControl(field, fieldType.Edit),
26544 sort: sort7,
26545 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26546 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26547 isValid: getIsValid(field, fieldType),
26548 filterBy: get_filter_by_default(
26549 field,
26550 fieldType.defaultOperators,
26551 fieldType.validOperators
26552 ),
26553 filter: getFilter(fieldType),
26554 format: get_format_default(field, fieldType),
26555 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26556 };
26557 });
26558 }
26559
26560 // packages/dataviews/build-module/hooks/use-data.mjs
26561 var import_element75 = __toESM(require_element(), 1);
26562 function useData({
26563 view,
26564 data: shownData,
26565 getItemId,
26566 isLoading,
26567 paginationInfo,
26568 selection
26569 }) {
26570 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26571 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element75.useState)(
26572 !isLoading
26573 );
26574 (0, import_element75.useEffect)(() => {
26575 if (!isLoading) {
26576 setHasInitiallyLoaded(true);
26577 }
26578 }, [isLoading]);
26579 const previousDataRef = (0, import_element75.useRef)(shownData);
26580 const previousPaginationInfoRef = (0, import_element75.useRef)(paginationInfo);
26581 (0, import_element75.useEffect)(() => {
26582 if (!isLoading) {
26583 previousDataRef.current = shownData;
26584 previousPaginationInfoRef.current = paginationInfo;
26585 }
26586 }, [shownData, isLoading, paginationInfo]);
26587 const [visibleEntries, setVisibleEntries] = (0, import_element75.useState)([]);
26588 const positionMapRef = (0, import_element75.useRef)(/* @__PURE__ */ new Map());
26589 const allLoadedRecordsRef = (0, import_element75.useRef)([]);
26590 const prevViewParamsRef = (0, import_element75.useRef)({
26591 search: void 0,
26592 filters: void 0,
26593 perPage: void 0
26594 });
26595 const scrollDirectionRef = (0, import_element75.useRef)(void 0);
26596 const prevStartPositionRef = (0, import_element75.useRef)(void 0);
26597 const hasInitializedRef = (0, import_element75.useRef)(false);
26598 const allLoadedRecords = (0, import_element75.useMemo)(() => {
26599 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26600 if (view.startPosition < prevStartPositionRef.current) {
26601 scrollDirectionRef.current = "up";
26602 } else if (view.startPosition > prevStartPositionRef.current) {
26603 scrollDirectionRef.current = "down";
26604 }
26605 }
26606 prevStartPositionRef.current = view.startPosition;
26607 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26608 const prevFiltersKey = prevViewParamsRef.current.filters;
26609 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26610 hasInitializedRef.current = true;
26611 prevViewParamsRef.current = {
26612 search: view.search,
26613 filters: currentFiltersKey,
26614 perPage: view.perPage
26615 };
26616 if (shouldReset) {
26617 positionMapRef.current.clear();
26618 scrollDirectionRef.current = void 0;
26619 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26620 const records = shownData.map((record, index2) => {
26621 const position = startPosition + index2;
26622 positionMapRef.current.set(getItemId(record), position);
26623 return {
26624 ...record,
26625 position
26626 };
26627 });
26628 allLoadedRecordsRef.current = records;
26629 return records;
26630 }
26631 const prev = allLoadedRecordsRef.current;
26632 const shownDataIds = new Set(shownData.map(getItemId));
26633 const scrollDirection = scrollDirectionRef.current;
26634 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26635 const newRecords = shownData.map((record, index2) => {
26636 const itemId = getItemId(record);
26637 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26638 if (position !== void 0) {
26639 positionMapRef.current.set(itemId, position);
26640 }
26641 return {
26642 ...record,
26643 position
26644 };
26645 });
26646 if (newRecords.length === 0) {
26647 return prev;
26648 }
26649 const prevWithoutDuplicates = prev.filter(
26650 (record) => !shownDataIds.has(getItemId(record))
26651 );
26652 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26653 allRecords.sort((a2, b2) => {
26654 const posA = a2.position;
26655 const posB = b2.position;
26656 return posA - posB;
26657 });
26658 let result = allRecords;
26659 if (visibleEntries.length > 0) {
26660 const visibleMin = Math.min(...visibleEntries);
26661 const visibleMax = Math.max(...visibleEntries);
26662 const buffer = 20;
26663 const recordPositions = allRecords.map(
26664 (r3) => r3.position
26665 );
26666 const minRecordPos = Math.min(...recordPositions);
26667 const maxRecordPos = Math.max(...recordPositions);
26668 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26669 if (hasOverlap) {
26670 result = allRecords.filter((record) => {
26671 const itemId = getItemId(record);
26672 const isSelected2 = selection?.includes(itemId);
26673 if (isSelected2) {
26674 return true;
26675 }
26676 const itemPosition = record.position;
26677 if (scrollDirection === "up") {
26678 return itemPosition <= visibleMax + buffer;
26679 } else if (scrollDirection === "down") {
26680 return itemPosition >= visibleMin - buffer;
26681 }
26682 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26683 });
26684 }
26685 }
26686 allLoadedRecordsRef.current = result;
26687 return result;
26688 }, [
26689 shownData,
26690 view.search,
26691 view.filters,
26692 view.perPage,
26693 view.startPosition,
26694 view.infiniteScrollEnabled,
26695 visibleEntries,
26696 selection,
26697 getItemId
26698 ]);
26699 if (!isInfiniteScrollEnabled) {
26700 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26701 return {
26702 data: dataToReturn.map((item) => ({
26703 ...item,
26704 position: void 0
26705 })),
26706 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26707 hasInitiallyLoaded,
26708 setVisibleEntries: void 0
26709 };
26710 }
26711 return {
26712 data: allLoadedRecords,
26713 paginationInfo,
26714 hasInitiallyLoaded,
26715 setVisibleEntries
26716 };
26717 }
26718
26719 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26720 var import_element76 = __toESM(require_element(), 1);
26721 var import_compose13 = __toESM(require_compose(), 1);
26722 function captureAnchorElement(container, anchorElementRef, direction) {
26723 const containerRect = container.getBoundingClientRect();
26724 const centerY = containerRect.top + containerRect.height / 2;
26725 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26726 if (items.length === 0) {
26727 return false;
26728 }
26729 const bestAnchor = items.reduce((best, item) => {
26730 const itemRect = item.getBoundingClientRect();
26731 const itemCenterY = itemRect.top + itemRect.height / 2;
26732 const distance = Math.abs(itemCenterY - centerY);
26733 const bestRect = best.getBoundingClientRect();
26734 const bestCenterY = bestRect.top + bestRect.height / 2;
26735 const bestDistance = Math.abs(bestCenterY - centerY);
26736 return distance < bestDistance ? item : best;
26737 });
26738 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26739 const anchorRect = bestAnchor.getBoundingClientRect();
26740 anchorElementRef.current = {
26741 posinset,
26742 viewportOffset: anchorRect.top - containerRect.top,
26743 scrollTop: container.scrollTop,
26744 direction
26745 };
26746 return true;
26747 }
26748 function useInfiniteScroll({
26749 view,
26750 onChangeView,
26751 isLoading,
26752 paginationInfo,
26753 containerRef,
26754 setVisibleEntries
26755 }) {
26756 const anchorElementRef = (0, import_element76.useRef)(null);
26757 const viewRef = (0, import_element76.useRef)(view);
26758 const isLoadingRef = (0, import_element76.useRef)(isLoading);
26759 const onChangeViewRef = (0, import_element76.useRef)(onChangeView);
26760 const totalItemsRef = (0, import_element76.useRef)(paginationInfo.totalItems);
26761 (0, import_element76.useLayoutEffect)(() => {
26762 viewRef.current = view;
26763 isLoadingRef.current = isLoading;
26764 onChangeViewRef.current = onChangeView;
26765 totalItemsRef.current = paginationInfo.totalItems;
26766 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26767 const intersectionObserverCallback = (0, import_element76.useCallback)(
26768 (entries) => {
26769 if (!setVisibleEntries) {
26770 return;
26771 }
26772 setVisibleEntries((prev) => {
26773 const newVisibleEntries = new Set(prev);
26774 let hasChanged = false;
26775 entries.forEach((entry) => {
26776 const posInSet = Number(
26777 entry.target?.attributes?.getNamedItem(
26778 "aria-posinset"
26779 )?.value
26780 );
26781 if (isNaN(posInSet)) {
26782 return;
26783 }
26784 if (entry.isIntersecting) {
26785 if (!newVisibleEntries.has(posInSet)) {
26786 newVisibleEntries.add(posInSet);
26787 hasChanged = true;
26788 }
26789 } else if (newVisibleEntries.has(posInSet)) {
26790 newVisibleEntries.delete(posInSet);
26791 hasChanged = true;
26792 }
26793 });
26794 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26795 });
26796 },
26797 [setVisibleEntries]
26798 );
26799 (0, import_element76.useLayoutEffect)(() => {
26800 const container = containerRef.current;
26801 const anchor = anchorElementRef.current;
26802 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26803 return;
26804 }
26805 const anchorElement = container.querySelector(
26806 `[aria-posinset="${anchor.posinset}"]`
26807 );
26808 if (anchorElement) {
26809 const containerRect = container.getBoundingClientRect();
26810 const anchorRect = anchorElement.getBoundingClientRect();
26811 const currentOffset = anchorRect.top - containerRect.top;
26812 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26813 if (Math.abs(scrollAdjustment) > 1) {
26814 container.scrollTop += scrollAdjustment;
26815 }
26816 }
26817 anchorElementRef.current = null;
26818 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26819 const intersectionObserverRef = (0, import_element76.useRef)(
26820 null
26821 );
26822 (0, import_element76.useEffect)(() => {
26823 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26824 if (intersectionObserverRef.current) {
26825 intersectionObserverRef.current.disconnect();
26826 intersectionObserverRef.current = null;
26827 }
26828 return;
26829 }
26830 intersectionObserverRef.current = new IntersectionObserver(
26831 intersectionObserverCallback,
26832 { root: null, rootMargin: "0px", threshold: 0.1 }
26833 );
26834 return () => {
26835 if (intersectionObserverRef.current) {
26836 intersectionObserverRef.current.disconnect();
26837 intersectionObserverRef.current = null;
26838 }
26839 };
26840 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26841 (0, import_element76.useEffect)(() => {
26842 if (!view.infiniteScrollEnabled || !containerRef.current) {
26843 return;
26844 }
26845 let lastScrollTop = 0;
26846 const BOTTOM_THRESHOLD = 600;
26847 const TOP_THRESHOLD = 800;
26848 const handleScroll = (0, import_compose13.throttle)((event) => {
26849 const currentView = viewRef.current;
26850 const totalItems = totalItemsRef.current;
26851 const target = event.target;
26852 const scrollTop = target.scrollTop;
26853 const scrollHeight = target.scrollHeight;
26854 const clientHeight = target.clientHeight;
26855 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26856 lastScrollTop = scrollTop;
26857 if (isLoadingRef.current) {
26858 return;
26859 }
26860 const currentStartPosition = currentView.startPosition || 1;
26861 const batchSize = currentView.perPage || 10;
26862 const currentEndPosition = Math.min(
26863 currentStartPosition + batchSize,
26864 totalItems
26865 );
26866 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26867 if (currentEndPosition < totalItems) {
26868 const newStartPosition = currentEndPosition;
26869 captureAnchorElement(target, anchorElementRef, "down");
26870 onChangeViewRef.current({
26871 ...currentView,
26872 startPosition: newStartPosition
26873 });
26874 }
26875 }
26876 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26877 if (currentStartPosition > 1) {
26878 const calculatedStartPosition = currentStartPosition - batchSize;
26879 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26880 captureAnchorElement(target, anchorElementRef, "up");
26881 onChangeViewRef.current({
26882 ...currentView,
26883 startPosition: newStartPosition
26884 });
26885 }
26886 }
26887 }, 50);
26888 const container = containerRef.current;
26889 container.addEventListener("scroll", handleScroll);
26890 return () => {
26891 container.removeEventListener("scroll", handleScroll);
26892 handleScroll.cancel();
26893 };
26894 }, [containerRef, view.infiniteScrollEnabled]);
26895 return {
26896 intersectionObserver: intersectionObserverRef.current
26897 };
26898 }
26899
26900 // packages/dataviews/build-module/dataviews-picker/index.mjs
26901 var import_element77 = __toESM(require_element(), 1);
26902 var import_compose14 = __toESM(require_compose(), 1);
26903 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26904 var isItemClickable = () => false;
26905 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
26906 (viewLayout) => viewLayout.isPicker
26907 );
26908 var defaultGetItemId = (item) => item.id;
26909 var EMPTY_ARRAY6 = [];
26910 var DEFAULT_PICKER_LAYOUTS = {
26911 pickerGrid: true,
26912 pickerTable: true
26913 };
26914 function DefaultUI({
26915 search = true,
26916 searchLabel = void 0
26917 }) {
26918 const { view } = (0, import_element77.useContext)(dataviews_context_default);
26919 const isInfiniteScroll = view.infiniteScrollEnabled;
26920 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
26921 /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26922 Stack,
26923 {
26924 direction: "row",
26925 align: "top",
26926 justify: "space-between",
26927 className: clsx_default("dataviews__view-actions", {
26928 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26929 }),
26930 gap: "xs",
26931 children: [
26932 /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26933 Stack,
26934 {
26935 direction: "row",
26936 gap: "sm",
26937 justify: "start",
26938 className: "dataviews__search",
26939 children: [
26940 search && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_search_default, { label: searchLabel }),
26941 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(toggle_default, {})
26942 ]
26943 }
26944 ),
26945 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_view_config_default, {}) })
26946 ]
26947 }
26948 ),
26949 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26950 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsLayout, {}),
26951 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsPickerFooter, {})
26952 ] });
26953 }
26954 function DataViewsPicker({
26955 view,
26956 onChangeView,
26957 fields,
26958 search = true,
26959 searchLabel = void 0,
26960 actions = EMPTY_ARRAY6,
26961 data,
26962 getItemId = defaultGetItemId,
26963 isLoading = false,
26964 paginationInfo,
26965 defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS,
26966 selection,
26967 onChangeSelection,
26968 children,
26969 config = { perPageSizes: [10, 20, 50, 100] },
26970 itemListLabel,
26971 empty,
26972 onReset
26973 }) {
26974 const { data: displayData, setVisibleEntries } = useData({
26975 view,
26976 data,
26977 getItemId,
26978 selection,
26979 paginationInfo
26980 });
26981 const containerRef = (0, import_element77.useRef)(null);
26982 const [containerWidth, setContainerWidth] = (0, import_element77.useState)(0);
26983 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
26984 (resizeObserverEntries) => {
26985 setContainerWidth(
26986 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26987 );
26988 },
26989 { box: "border-box" }
26990 );
26991 const [openedFilter, setOpenedFilter] = (0, import_element77.useState)(null);
26992 function setSelectionWithChange(value) {
26993 const newValue = typeof value === "function" ? value(selection) : value;
26994 if (onChangeSelection) {
26995 onChangeSelection(newValue);
26996 }
26997 }
26998 const _fields = (0, import_element77.useMemo)(() => normalizeFields(fields), [fields]);
26999 const filters = use_filters_default(_fields, view);
27000 const hasPrimaryOrLockedFilters = (0, import_element77.useMemo)(
27001 () => (filters || []).some(
27002 (filter) => filter.isPrimary || filter.isLocked
27003 ),
27004 [filters]
27005 );
27006 const [isShowingFilter, setIsShowingFilter] = (0, import_element77.useState)(
27007 hasPrimaryOrLockedFilters
27008 );
27009 const { intersectionObserver } = useInfiniteScroll({
27010 view,
27011 onChangeView,
27012 isLoading,
27013 paginationInfo,
27014 containerRef,
27015 setVisibleEntries
27016 });
27017 (0, import_element77.useEffect)(() => {
27018 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
27019 setIsShowingFilter(true);
27020 }
27021 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
27022 const defaultLayouts2 = (0, import_element77.useMemo)(
27023 () => Object.fromEntries(
27024 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
27025 return dataViewsPickerLayouts.some(
27026 (viewLayout) => viewLayout.type === layoutType
27027 );
27028 }).map(([key, value]) => [
27029 key,
27030 value === true ? {} : value
27031 ])
27032 ),
27033 [defaultLayoutsProperty]
27034 );
27035 if (!defaultLayouts2[view.type]) {
27036 return null;
27037 }
27038 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
27039 dataviews_context_default.Provider,
27040 {
27041 value: {
27042 view,
27043 onChangeView,
27044 fields: _fields,
27045 actions,
27046 data: displayData,
27047 isLoading,
27048 paginationInfo,
27049 isItemClickable,
27050 selection,
27051 onChangeSelection: setSelectionWithChange,
27052 openedFilter,
27053 setOpenedFilter,
27054 getItemId,
27055 containerWidth,
27056 containerRef,
27057 resizeObserverRef,
27058 defaultLayouts: defaultLayouts2,
27059 filters,
27060 isShowingFilter,
27061 setIsShowingFilter,
27062 config,
27063 itemListLabel,
27064 empty,
27065 onReset,
27066 hasInitiallyLoaded: true,
27067 intersectionObserver
27068 },
27069 children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DefaultUI, { search, searchLabel }) })
27070 }
27071 );
27072 }
27073 var DataViewsPickerSubComponents = DataViewsPicker;
27074 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerBulkActionToolbar;
27075 DataViewsPickerSubComponents.Footer = DataViewsPickerFooter;
27076 DataViewsPickerSubComponents.Filters = filters_default;
27077 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
27078 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
27079 DataViewsPickerSubComponents.Layout = DataViewsLayout;
27080 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
27081 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
27082 DataViewsPickerSubComponents.Search = dataviews_search_default;
27083 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
27084 var dataviews_picker_default = DataViewsPickerSubComponents;
27085
27086 // node_modules/dequal/dist/index.mjs
27087 var has = Object.prototype.hasOwnProperty;
27088 function find(iter, tar, key) {
27089 for (key of iter.keys()) {
27090 if (dequal(key, tar)) return key;
27091 }
27092 }
27093 function dequal(foo, bar) {
27094 var ctor, len, tmp;
27095 if (foo === bar) return true;
27096 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
27097 if (ctor === Date) return foo.getTime() === bar.getTime();
27098 if (ctor === RegExp) return foo.toString() === bar.toString();
27099 if (ctor === Array) {
27100 if ((len = foo.length) === bar.length) {
27101 while (len-- && dequal(foo[len], bar[len])) ;
27102 }
27103 return len === -1;
27104 }
27105 if (ctor === Set) {
27106 if (foo.size !== bar.size) {
27107 return false;
27108 }
27109 for (len of foo) {
27110 tmp = len;
27111 if (tmp && typeof tmp === "object") {
27112 tmp = find(bar, tmp);
27113 if (!tmp) return false;
27114 }
27115 if (!bar.has(tmp)) return false;
27116 }
27117 return true;
27118 }
27119 if (ctor === Map) {
27120 if (foo.size !== bar.size) {
27121 return false;
27122 }
27123 for (len of foo) {
27124 tmp = len[0];
27125 if (tmp && typeof tmp === "object") {
27126 tmp = find(bar, tmp);
27127 if (!tmp) return false;
27128 }
27129 if (!dequal(len[1], bar.get(tmp))) {
27130 return false;
27131 }
27132 }
27133 return true;
27134 }
27135 if (ctor === ArrayBuffer) {
27136 foo = new Uint8Array(foo);
27137 bar = new Uint8Array(bar);
27138 } else if (ctor === DataView) {
27139 if ((len = foo.byteLength) === bar.byteLength) {
27140 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
27141 }
27142 return len === -1;
27143 }
27144 if (ArrayBuffer.isView(foo)) {
27145 if ((len = foo.byteLength) === bar.byteLength) {
27146 while (len-- && foo[len] === bar[len]) ;
27147 }
27148 return len === -1;
27149 }
27150 if (!ctor || typeof foo === "object") {
27151 len = 0;
27152 for (ctor in foo) {
27153 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
27154 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
27155 }
27156 return Object.keys(bar).length === len;
27157 }
27158 }
27159 return foo !== foo && bar !== bar;
27160 }
27161
27162 // packages/views/build-module/use-view.mjs
27163 var import_element78 = __toESM(require_element(), 1);
27164 var import_data7 = __toESM(require_data(), 1);
27165 var import_preferences = __toESM(require_preferences(), 1);
27166
27167 // packages/views/build-module/preference-keys.mjs
27168 function generatePreferenceKey(kind, name, slug) {
27169 return `dataviews-${kind}-${name}-${slug}`;
27170 }
27171
27172 // packages/views/build-module/filter-utils.mjs
27173 var SCALAR_VALUES = [
27174 "titleField",
27175 "mediaField",
27176 "descriptionField",
27177 "showTitle",
27178 "showMedia",
27179 "showDescription",
27180 "showLevels",
27181 "infiniteScrollEnabled"
27182 ];
27183 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView2) {
27184 if (!activeViewOverrides) {
27185 return view;
27186 }
27187 let result = view;
27188 for (const key of SCALAR_VALUES) {
27189 if (key in activeViewOverrides) {
27190 result = { ...result, [key]: activeViewOverrides[key] };
27191 }
27192 }
27193 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
27194 const activeFields = new Set(
27195 activeViewOverrides.filters.map((f2) => f2.field)
27196 );
27197 const preserved = (view.filters ?? []).filter(
27198 (f2) => !activeFields.has(f2.field)
27199 );
27200 result = {
27201 ...result,
27202 filters: [...preserved, ...activeViewOverrides.filters]
27203 };
27204 }
27205 if (activeViewOverrides.sort) {
27206 const isDefaultSort = defaultView2 && view.sort?.field === defaultView2.sort?.field && view.sort?.direction === defaultView2.sort?.direction;
27207 if (isDefaultSort) {
27208 result = {
27209 ...result,
27210 sort: activeViewOverrides.sort
27211 };
27212 }
27213 }
27214 if (activeViewOverrides.layout) {
27215 result = {
27216 ...result,
27217 layout: {
27218 ...result.layout,
27219 ...activeViewOverrides.layout
27220 }
27221 };
27222 }
27223 if (activeViewOverrides.groupBy) {
27224 result = {
27225 ...result,
27226 groupBy: activeViewOverrides.groupBy
27227 };
27228 }
27229 return result;
27230 }
27231 function stripActiveViewOverrides(view, activeViewOverrides, defaultView2) {
27232 if (!activeViewOverrides) {
27233 return view;
27234 }
27235 let result = view;
27236 for (const key of SCALAR_VALUES) {
27237 if (key in activeViewOverrides) {
27238 const { [key]: _, ...rest } = result;
27239 result = rest;
27240 }
27241 }
27242 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
27243 const activeFields = new Set(
27244 activeViewOverrides.filters.map((f2) => f2.field)
27245 );
27246 result = {
27247 ...result,
27248 filters: (view.filters ?? []).filter(
27249 (f2) => !activeFields.has(f2.field)
27250 )
27251 };
27252 }
27253 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
27254 result = {
27255 ...result,
27256 sort: defaultView2?.sort
27257 };
27258 }
27259 if (activeViewOverrides.layout && "layout" in result && result.layout) {
27260 const layout = { ...result.layout };
27261 for (const key of Object.keys(activeViewOverrides.layout)) {
27262 delete layout[key];
27263 }
27264 result = {
27265 ...result,
27266 layout: Object.keys(layout).length > 0 ? layout : void 0
27267 };
27268 }
27269 if (activeViewOverrides.groupBy && "groupBy" in result) {
27270 const { groupBy: _, ...rest } = result;
27271 result = rest;
27272 }
27273 return result;
27274 }
27275
27276 // packages/views/build-module/use-view.mjs
27277 function omit3(obj, keys) {
27278 const result = { ...obj };
27279 for (const key of keys) {
27280 delete result[key];
27281 }
27282 return result;
27283 }
27284 function useView(config) {
27285 const {
27286 kind,
27287 name,
27288 slug,
27289 defaultView: defaultView2,
27290 activeViewOverrides,
27291 queryParams,
27292 onChangeQueryParams
27293 } = config;
27294 const preferenceKey = generatePreferenceKey(kind, name, slug);
27295 const persistedView = (0, import_data7.useSelect)(
27296 (select3) => {
27297 return select3(import_preferences.store).get(
27298 "core/views",
27299 preferenceKey
27300 );
27301 },
27302 [preferenceKey]
27303 );
27304 const { set: set2 } = (0, import_data7.useDispatch)(import_preferences.store);
27305 const baseView = (0, import_element78.useMemo)(
27306 () => persistedView ?? defaultView2 ?? {},
27307 [persistedView, defaultView2]
27308 );
27309 const page = Number(queryParams?.page ?? baseView.page ?? 1);
27310 const search = queryParams?.search ?? baseView.search ?? "";
27311 const combinedOverrides = (0, import_element78.useMemo)(() => {
27312 const rawDefaults = config.defaultLayouts?.[baseView.type];
27313 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
27314 return { ...layoutTypeDefaults, ...activeViewOverrides };
27315 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
27316 const view = (0, import_element78.useMemo)(() => {
27317 return mergeActiveViewOverrides(
27318 {
27319 ...baseView,
27320 page,
27321 search
27322 },
27323 combinedOverrides,
27324 defaultView2
27325 );
27326 }, [baseView, page, search, combinedOverrides, defaultView2]);
27327 const isModified = !!persistedView;
27328 const updateView = (0, import_element78.useCallback)(
27329 (newView) => {
27330 const urlParams = {
27331 page: newView?.page,
27332 search: newView?.search
27333 };
27334 const preferenceView = stripActiveViewOverrides(
27335 omit3(newView, ["page", "search"]),
27336 combinedOverrides,
27337 defaultView2
27338 );
27339 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
27340 onChangeQueryParams(urlParams);
27341 }
27342 const comparableBaseView = stripActiveViewOverrides(
27343 baseView,
27344 combinedOverrides,
27345 defaultView2
27346 );
27347 const comparableDefaultView = stripActiveViewOverrides(
27348 defaultView2,
27349 combinedOverrides,
27350 defaultView2
27351 );
27352 if (!dequal(comparableBaseView, preferenceView)) {
27353 if (dequal(preferenceView, comparableDefaultView)) {
27354 set2("core/views", preferenceKey, void 0);
27355 } else {
27356 set2("core/views", preferenceKey, preferenceView);
27357 }
27358 }
27359 },
27360 [
27361 onChangeQueryParams,
27362 page,
27363 search,
27364 baseView,
27365 defaultView2,
27366 combinedOverrides,
27367 set2,
27368 preferenceKey
27369 ]
27370 );
27371 const resetToDefault = (0, import_element78.useCallback)(() => {
27372 set2("core/views", preferenceKey, void 0);
27373 }, [preferenceKey, set2]);
27374 return {
27375 view,
27376 isModified,
27377 updateView,
27378 resetToDefault
27379 };
27380 }
27381
27382 // packages/views/build-module/load-view.mjs
27383 var import_data8 = __toESM(require_data(), 1);
27384 var import_preferences2 = __toESM(require_preferences(), 1);
27385
27386 // packages/views/build-module/use-view-config.mjs
27387 var import_data9 = __toESM(require_data(), 1);
27388 var import_core_data2 = __toESM(require_core_data(), 1);
27389
27390 // packages/views/build-module/lock-unlock.mjs
27391 var import_private_apis3 = __toESM(require_private_apis(), 1);
27392 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
27393 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
27394 "@wordpress/views"
27395 );
27396
27397 // packages/media-fields/build-module/alt_text/index.mjs
27398 var import_i18n51 = __toESM(require_i18n(), 1);
27399 var import_components47 = __toESM(require_components(), 1);
27400 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
27401 var altTextField = {
27402 id: "alt_text",
27403 type: "text",
27404 label: (0, import_i18n51.__)("Alt text"),
27405 isVisible: (item) => item?.media_type === "image",
27406 render: ({ item }) => item?.alt_text || "-",
27407 Edit: ({ field, onChange, data }) => {
27408 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27409 import_components47.TextareaControl,
27410 {
27411 label: field.label,
27412 value: data.alt_text || "",
27413 onChange: (value) => onChange({ alt_text: value }),
27414 help: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
27415 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27416 Link,
27417 {
27418 href: (
27419 // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
27420 (0, import_i18n51.__)(
27421 "https://www.w3.org/WAI/tutorials/images/decision-tree/"
27422 )
27423 ),
27424 openInNewTab: true,
27425 children: (0, import_i18n51.__)("Describe the purpose of the image.")
27426 }
27427 ),
27428 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("br", {}),
27429 (0, import_i18n51.__)("Leave empty if decorative.")
27430 ] }),
27431 rows: 2
27432 }
27433 );
27434 },
27435 enableSorting: false,
27436 filterBy: false
27437 };
27438 var alt_text_default = altTextField;
27439
27440 // packages/media-fields/build-module/attached_to/index.mjs
27441 var import_i18n54 = __toESM(require_i18n(), 1);
27442
27443 // packages/media-fields/build-module/attached_to/view.mjs
27444 var import_element79 = __toESM(require_element(), 1);
27445 var import_i18n52 = __toESM(require_i18n(), 1);
27446
27447 // packages/media-fields/build-module/utils/get-rendered-content.mjs
27448 function getRenderedContent(content) {
27449 if (!content) {
27450 return "";
27451 }
27452 if (typeof content === "string") {
27453 return content;
27454 }
27455 if (typeof content === "object") {
27456 return content.rendered || content.raw || "";
27457 }
27458 return "";
27459 }
27460
27461 // packages/media-fields/build-module/attached_to/view.mjs
27462 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
27463 function MediaAttachedToView({
27464 item
27465 }) {
27466 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element79.useState)(null);
27467 const parentId = item.post;
27468 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
27469 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
27470 (0, import_element79.useEffect)(() => {
27471 if (!!parentId && parentId === embeddedPostId) {
27472 setAttachedPostTitle(
27473 getRenderedContent(embeddedPostTitle) || (0, import_i18n52.__)("(no title)")
27474 );
27475 }
27476 if (!parentId) {
27477 setAttachedPostTitle((0, import_i18n52.__)("(Unattached)"));
27478 }
27479 }, [parentId, embeddedPostId, embeddedPostTitle]);
27480 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children: attachedPostTitle });
27481 }
27482
27483 // packages/media-fields/build-module/attached_to/edit.mjs
27484 var import_core_data3 = __toESM(require_core_data(), 1);
27485 var import_components48 = __toESM(require_components(), 1);
27486 var import_i18n53 = __toESM(require_i18n(), 1);
27487 var import_element80 = __toESM(require_element(), 1);
27488 var import_compose15 = __toESM(require_compose(), 1);
27489 var import_data10 = __toESM(require_data(), 1);
27490 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
27491 function MediaAttachedToEdit({
27492 data,
27493 onChange
27494 }) {
27495 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
27496 {
27497 label: getRenderedContent(
27498 data._embedded?.["wp:attached-to"]?.[0]?.title
27499 ),
27500 value: data.post.toString()
27501 }
27502 ] : [];
27503 const [options, setOptions] = (0, import_element80.useState)(defaultPost);
27504 const [searchResults, setSearchResults] = (0, import_element80.useState)(
27505 []
27506 );
27507 const [isLoading, setIsLoading] = (0, import_element80.useState)(false);
27508 const [value, setValue] = (0, import_element80.useState)(
27509 data?.post?.toString() ?? null
27510 );
27511 const postTypes = (0, import_data10.useSelect)(
27512 (select3) => select3(import_core_data3.store).getPostTypes(),
27513 []
27514 );
27515 const handleDetach = () => {
27516 onChange({
27517 post: 0,
27518 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
27519 });
27520 setValue(null);
27521 setOptions([]);
27522 };
27523 const onValueChange = async (filterValue) => {
27524 setIsLoading(true);
27525 const results = await (0, import_core_data3.__experimentalFetchLinkSuggestions)(
27526 filterValue,
27527 /*
27528 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
27529 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
27530 */
27531 { type: "post", isInitialSuggestions: true },
27532 {}
27533 );
27534 setSearchResults(results);
27535 const suggestions = results.map((result) => {
27536 return {
27537 label: result.title,
27538 value: result.id.toString()
27539 };
27540 });
27541 const includeCurrent = !filterValue && suggestions.findIndex((s2) => s2.value === value) === -1;
27542 setOptions(suggestions.concat(includeCurrent ? defaultPost : []));
27543 setIsLoading(false);
27544 };
27545 const handleSelectOption = (selectedPostId) => {
27546 if (!selectedPostId) {
27547 handleDetach();
27548 return;
27549 }
27550 setValue(selectedPostId);
27551 if (selectedPostId) {
27552 const selectedPost = searchResults.find(
27553 (result) => result.id === Number(selectedPostId)
27554 );
27555 if (selectedPost && postTypes) {
27556 const postType = postTypes.find(
27557 (_postType) => _postType.slug === selectedPost?.type
27558 );
27559 const attachedTo = {
27560 ...postType && { type: postType.slug },
27561 id: Number(selectedPostId),
27562 title: {
27563 raw: selectedPost.title,
27564 rendered: selectedPost.title
27565 }
27566 };
27567 onChange({
27568 post: Number(selectedPostId),
27569 _embedded: {
27570 ...data?._embedded,
27571 "wp:attached-to": [attachedTo]
27572 }
27573 });
27574 }
27575 }
27576 };
27577 const help = (0, import_element80.createInterpolateElement)(
27578 (0, import_i18n53.__)(
27579 "Search for a post or page to attach this media to or <button>detach current</button>."
27580 ),
27581 {
27582 button: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27583 import_components48.Button,
27584 {
27585 __next40pxDefaultSize: true,
27586 onClick: handleDetach,
27587 variant: "link",
27588 accessibleWhenDisabled: true,
27589 disabled: !value
27590 }
27591 )
27592 }
27593 );
27594 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27595 import_components48.ComboboxControl,
27596 {
27597 className: "dataviews-media-field__attached-to",
27598 isLoading,
27599 label: (0, import_i18n53.__)("Attached to"),
27600 help,
27601 value,
27602 options,
27603 onFilterValueChange: (0, import_compose15.debounce)(
27604 (filterValue) => onValueChange(filterValue),
27605 300
27606 ),
27607 onChange: handleSelectOption,
27608 hideLabelFromVision: true
27609 }
27610 );
27611 }
27612
27613 // packages/media-fields/build-module/attached_to/index.mjs
27614 var attachedToField = {
27615 id: "attached_to",
27616 type: "text",
27617 label: (0, import_i18n54.__)("Attached to"),
27618 Edit: MediaAttachedToEdit,
27619 render: MediaAttachedToView,
27620 enableSorting: false,
27621 filterBy: false
27622 };
27623 var attached_to_default = attachedToField;
27624
27625 // packages/media-fields/build-module/author/index.mjs
27626 var import_i18n56 = __toESM(require_i18n(), 1);
27627 var import_data11 = __toESM(require_data(), 1);
27628 var import_core_data4 = __toESM(require_core_data(), 1);
27629
27630 // packages/media-fields/build-module/author/view.mjs
27631 var import_i18n55 = __toESM(require_i18n(), 1);
27632 var import_element81 = __toESM(require_element(), 1);
27633 var import_components49 = __toESM(require_components(), 1);
27634 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27635 function AuthorView({
27636 item
27637 }) {
27638 const author = item?._embedded?.author?.[0];
27639 const text = author?.name;
27640 const imageUrl = author?.avatar_urls?.[48];
27641 const [loadingState, setLoadingState] = (0, import_element81.useState)("loading");
27642 (0, import_element81.useEffect)(() => {
27643 setLoadingState("loading");
27644 }, [imageUrl]);
27645 const imgRef = (0, import_element81.useCallback)((img) => {
27646 if (img?.complete) {
27647 setLoadingState("instant");
27648 }
27649 }, []);
27650 const handleLoad = () => {
27651 if (loadingState === "loading") {
27652 setLoadingState("loaded");
27653 }
27654 };
27655 return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_components49.__experimentalHStack, { alignment: "left", spacing: 0, children: [
27656 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27657 "div",
27658 {
27659 className: clsx_default("media-author-field__avatar", {
27660 "is-loading": loadingState === "loading",
27661 "is-loaded": loadingState === "loaded"
27662 }),
27663 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27664 "img",
27665 {
27666 ref: imgRef,
27667 onLoad: handleLoad,
27668 alt: (0, import_i18n55.__)("Author avatar"),
27669 src: imageUrl
27670 }
27671 )
27672 }
27673 ),
27674 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components49.Icon, { icon: comment_author_avatar_default }) }),
27675 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "media-author-field__name", children: text })
27676 ] });
27677 }
27678
27679 // packages/media-fields/build-module/author/index.mjs
27680 var authorField = {
27681 label: (0, import_i18n56.__)("Author"),
27682 id: "author",
27683 type: "integer",
27684 getElements: async () => {
27685 const authors = await (0, import_data11.resolveSelect)(import_core_data4.store).getEntityRecords(
27686 "root",
27687 "user",
27688 {
27689 per_page: -1,
27690 who: "authors",
27691 _fields: "id,name",
27692 context: "view"
27693 }
27694 ) ?? [];
27695 return authors.map(({ id, name }) => ({
27696 value: id,
27697 label: name
27698 }));
27699 },
27700 render: AuthorView,
27701 sort: (a2, b2, direction) => {
27702 const nameA = a2._embedded?.author?.[0]?.name || "";
27703 const nameB = b2._embedded?.author?.[0]?.name || "";
27704 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
27705 },
27706 filterBy: {
27707 operators: ["isAny", "isNone"]
27708 },
27709 readOnly: true
27710 };
27711 var author_default = authorField;
27712
27713 // packages/media-fields/build-module/caption/index.mjs
27714 var import_i18n57 = __toESM(require_i18n(), 1);
27715 var import_components50 = __toESM(require_components(), 1);
27716
27717 // packages/media-fields/build-module/utils/get-raw-content.mjs
27718 function getRawContent(content) {
27719 if (!content) {
27720 return "";
27721 }
27722 if (typeof content === "string") {
27723 return content;
27724 }
27725 if (typeof content === "object" && "raw" in content) {
27726 return content.raw || "";
27727 }
27728 return "";
27729 }
27730
27731 // packages/media-fields/build-module/caption/index.mjs
27732 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27733 var captionField = {
27734 id: "caption",
27735 type: "text",
27736 label: (0, import_i18n57.__)("Caption"),
27737 getValue: ({ item }) => getRawContent(item?.caption),
27738 render: ({ item }) => getRawContent(item?.caption) || "-",
27739 Edit: ({ field, onChange, data }) => {
27740 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27741 import_components50.TextareaControl,
27742 {
27743 label: field.label,
27744 value: getRawContent(data.caption) || "",
27745 onChange: (value) => onChange({ caption: value }),
27746 rows: 2
27747 }
27748 );
27749 },
27750 enableSorting: false,
27751 filterBy: false
27752 };
27753 var caption_default = captionField;
27754
27755 // packages/media-fields/build-module/date_added/index.mjs
27756 var import_i18n58 = __toESM(require_i18n(), 1);
27757 var dateAddedField = {
27758 id: "date",
27759 type: "datetime",
27760 label: (0, import_i18n58.__)("Date added"),
27761 filterBy: {
27762 operators: ["before", "after"]
27763 },
27764 readOnly: true
27765 };
27766 var date_added_default = dateAddedField;
27767
27768 // packages/media-fields/build-module/date_modified/index.mjs
27769 var import_i18n59 = __toESM(require_i18n(), 1);
27770 var dateModifiedField = {
27771 id: "modified",
27772 type: "datetime",
27773 label: (0, import_i18n59.__)("Date modified"),
27774 filterBy: {
27775 operators: ["before", "after"]
27776 },
27777 readOnly: true
27778 };
27779 var date_modified_default = dateModifiedField;
27780
27781 // packages/media-fields/build-module/description/index.mjs
27782 var import_i18n60 = __toESM(require_i18n(), 1);
27783 var import_components51 = __toESM(require_components(), 1);
27784 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
27785 var descriptionField = {
27786 id: "description",
27787 type: "text",
27788 label: (0, import_i18n60.__)("Description"),
27789 getValue: ({ item }) => getRawContent(item?.description),
27790 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { children: getRawContent(item?.description) || "-" }),
27791 Edit: ({ field, onChange, data }) => {
27792 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27793 import_components51.TextareaControl,
27794 {
27795 label: field.label,
27796 value: getRawContent(data.description) || "",
27797 onChange: (value) => onChange({ description: value }),
27798 rows: 5
27799 }
27800 );
27801 },
27802 enableSorting: false,
27803 filterBy: false
27804 };
27805 var description_default = descriptionField;
27806
27807 // packages/media-fields/build-module/filename/index.mjs
27808 var import_i18n61 = __toESM(require_i18n(), 1);
27809 var import_url4 = __toESM(require_url(), 1);
27810
27811 // packages/media-fields/build-module/filename/view.mjs
27812 var import_element82 = __toESM(require_element(), 1);
27813 var import_url3 = __toESM(require_url(), 1);
27814 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
27815 var TRUNCATE_LENGTH = 15;
27816 function FileNameView({
27817 item
27818 }) {
27819 const fileName = (0, import_element82.useMemo)(
27820 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
27821 [item?.source_url]
27822 );
27823 if (!fileName) {
27824 return "";
27825 }
27826 if (fileName.length <= TRUNCATE_LENGTH) {
27827 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
27828 }
27829 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(tooltip_exports.Root, { children: [
27830 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
27831 tooltip_exports.Trigger,
27832 {
27833 render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName })
27834 }
27835 ),
27836 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(tooltip_exports.Popup, { children: fileName })
27837 ] });
27838 }
27839
27840 // packages/media-fields/build-module/filename/index.mjs
27841 var filenameField = {
27842 id: "filename",
27843 type: "text",
27844 label: (0, import_i18n61.__)("File name"),
27845 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
27846 render: FileNameView,
27847 enableSorting: false,
27848 filterBy: false,
27849 readOnly: true
27850 };
27851 var filename_default = filenameField;
27852
27853 // packages/media-fields/build-module/filesize/index.mjs
27854 var import_i18n62 = __toESM(require_i18n(), 1);
27855 var KB_IN_BYTES = 1024;
27856 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
27857 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
27858 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
27859 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
27860 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
27861 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
27862 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
27863 function getBytesString(bytes, unitSymbol, decimals = 2) {
27864 return (0, import_i18n62.sprintf)(
27865 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
27866 (0, import_i18n62._x)("%1$s %2$s", "file size"),
27867 bytes.toLocaleString(void 0, {
27868 minimumFractionDigits: 0,
27869 maximumFractionDigits: decimals
27870 }),
27871 unitSymbol
27872 );
27873 }
27874 function formatFileSize(bytes, decimals = 2) {
27875 if (bytes === 0) {
27876 return getBytesString(0, (0, import_i18n62._x)("B", "unit symbol"), decimals);
27877 }
27878 const quant = {
27879 /* translators: Unit symbol for yottabyte. */
27880 [(0, import_i18n62._x)("YB", "unit symbol")]: YB_IN_BYTES,
27881 /* translators: Unit symbol for zettabyte. */
27882 [(0, import_i18n62._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
27883 /* translators: Unit symbol for exabyte. */
27884 [(0, import_i18n62._x)("EB", "unit symbol")]: EB_IN_BYTES,
27885 /* translators: Unit symbol for petabyte. */
27886 [(0, import_i18n62._x)("PB", "unit symbol")]: PB_IN_BYTES,
27887 /* translators: Unit symbol for terabyte. */
27888 [(0, import_i18n62._x)("TB", "unit symbol")]: TB_IN_BYTES,
27889 /* translators: Unit symbol for gigabyte. */
27890 [(0, import_i18n62._x)("GB", "unit symbol")]: GB_IN_BYTES,
27891 /* translators: Unit symbol for megabyte. */
27892 [(0, import_i18n62._x)("MB", "unit symbol")]: MB_IN_BYTES,
27893 /* translators: Unit symbol for kilobyte. */
27894 [(0, import_i18n62._x)("KB", "unit symbol")]: KB_IN_BYTES,
27895 /* translators: Unit symbol for byte. */
27896 [(0, import_i18n62._x)("B", "unit symbol")]: 1
27897 };
27898 for (const [unit, mag] of Object.entries(quant)) {
27899 if (bytes >= mag) {
27900 return getBytesString(bytes / mag, unit, decimals);
27901 }
27902 }
27903 return "";
27904 }
27905 var filesizeField = {
27906 id: "filesize",
27907 type: "text",
27908 label: (0, import_i18n62.__)("File size"),
27909 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
27910 isVisible: (item) => {
27911 return !!item?.media_details?.filesize;
27912 },
27913 enableSorting: false,
27914 filterBy: false,
27915 readOnly: true
27916 };
27917 var filesize_default = filesizeField;
27918
27919 // packages/media-fields/build-module/media_dimensions/index.mjs
27920 var import_i18n63 = __toESM(require_i18n(), 1);
27921 var mediaDimensionsField = {
27922 id: "media_dimensions",
27923 type: "text",
27924 label: (0, import_i18n63.__)("Dimensions"),
27925 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n63.sprintf)(
27926 // translators: 1: Width. 2: Height.
27927 (0, import_i18n63._x)("%1$s \xD7 %2$s", "image dimensions"),
27928 item?.media_details?.width?.toString(),
27929 item?.media_details?.height?.toString()
27930 ) : "",
27931 isVisible: (item) => {
27932 return !!(item?.media_details?.width && item?.media_details?.height);
27933 },
27934 enableSorting: false,
27935 filterBy: false,
27936 readOnly: true
27937 };
27938 var media_dimensions_default = mediaDimensionsField;
27939
27940 // packages/media-fields/build-module/media_thumbnail/index.mjs
27941 var import_i18n65 = __toESM(require_i18n(), 1);
27942
27943 // packages/media-fields/build-module/media_thumbnail/view.mjs
27944 var import_data12 = __toESM(require_data(), 1);
27945 var import_core_data5 = __toESM(require_core_data(), 1);
27946 var import_components52 = __toESM(require_components(), 1);
27947 var import_element83 = __toESM(require_element(), 1);
27948 var import_url5 = __toESM(require_url(), 1);
27949
27950 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
27951 var import_i18n64 = __toESM(require_i18n(), 1);
27952 function getMediaTypeFromMimeType(mimeType) {
27953 if (mimeType.startsWith("image/")) {
27954 return {
27955 type: "image",
27956 label: (0, import_i18n64.__)("Image"),
27957 icon: image_default
27958 };
27959 }
27960 if (mimeType.startsWith("video/")) {
27961 return {
27962 type: "video",
27963 label: (0, import_i18n64.__)("Video"),
27964 icon: video_default
27965 };
27966 }
27967 if (mimeType.startsWith("audio/")) {
27968 return {
27969 type: "audio",
27970 label: (0, import_i18n64.__)("Audio"),
27971 icon: audio_default
27972 };
27973 }
27974 return {
27975 type: "application",
27976 label: (0, import_i18n64.__)("Application"),
27977 icon: file_default
27978 };
27979 }
27980
27981 // packages/media-fields/build-module/media_thumbnail/view.mjs
27982 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
27983 function getBestImageUrl(featuredMedia, configSizes) {
27984 const sizes = featuredMedia?.media_details?.sizes;
27985 if (!sizes) {
27986 return featuredMedia.source_url;
27987 }
27988 const sizeEntries = Object.values(sizes);
27989 if (!sizeEntries.length) {
27990 return featuredMedia.source_url;
27991 }
27992 const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN;
27993 if (!Number.isNaN(targetWidth)) {
27994 const validEntries = sizeEntries.filter(
27995 (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width)
27996 );
27997 if (!validEntries.length) {
27998 return featuredMedia.source_url;
27999 }
28000 const sorted = [...validEntries].sort(
28001 (a2, b2) => a2.width - b2.width
28002 );
28003 const match2 = sorted.find((s2) => s2.width >= targetWidth);
28004 if (match2) {
28005 return match2.source_url;
28006 }
28007 return sorted[sorted.length - 1].source_url;
28008 }
28009 return featuredMedia.source_url;
28010 }
28011 function FallbackView({
28012 item,
28013 filename
28014 }) {
28015 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(
28016 import_components52.__experimentalVStack,
28017 {
28018 justify: "center",
28019 alignment: "center",
28020 className: "dataviews-media-field__media-thumbnail__stack",
28021 spacing: 0,
28022 children: [
28023 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28024 import_components52.Icon,
28025 {
28026 className: "dataviews-media-field__media-thumbnail--icon",
28027 icon: getMediaTypeFromMimeType(item.mime_type).icon,
28028 size: 24
28029 }
28030 ),
28031 !!filename && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components52.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
28032 ]
28033 }
28034 ) });
28035 }
28036 function ImageView({
28037 item,
28038 configSizes,
28039 onError
28040 }) {
28041 const imageUrl = getBestImageUrl(item, configSizes);
28042 const imgRef = (0, import_element83.useRef)(null);
28043 const [loadingState, setLoadingState] = (0, import_element83.useState)("loading");
28044 (0, import_element83.useLayoutEffect)(() => {
28045 if (imgRef.current?.complete) {
28046 setLoadingState("instant");
28047 } else {
28048 setLoadingState("loading");
28049 }
28050 }, [imageUrl]);
28051 const handleLoad = () => {
28052 if (loadingState === "loading") {
28053 setLoadingState("loaded");
28054 }
28055 };
28056 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28057 "div",
28058 {
28059 className: clsx_default("dataviews-media-field__media-thumbnail", {
28060 "is-loading": loadingState === "loading",
28061 "is-loaded": loadingState === "loaded"
28062 }),
28063 children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28064 "img",
28065 {
28066 ref: imgRef,
28067 className: "dataviews-media-field__media-thumbnail--image",
28068 src: imageUrl,
28069 alt: item.alt_text || item.title.raw,
28070 onLoad: handleLoad,
28071 onError,
28072 loading: "lazy"
28073 }
28074 )
28075 }
28076 );
28077 }
28078 function MediaThumbnailView({
28079 item,
28080 config
28081 }) {
28082 const [imageError, setImageError] = (0, import_element83.useState)(false);
28083 const _featuredMedia = (0, import_data12.useSelect)(
28084 (select3) => {
28085 if (!item.featured_media) {
28086 return;
28087 }
28088 return select3(import_core_data5.store).getEntityRecord(
28089 "postType",
28090 "attachment",
28091 item.featured_media
28092 );
28093 },
28094 [item.featured_media]
28095 );
28096 const featuredMedia = item.featured_media ? _featuredMedia : item;
28097 if (!featuredMedia) {
28098 return null;
28099 }
28100 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
28101 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
28102 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
28103 }
28104 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28105 ImageView,
28106 {
28107 item: featuredMedia,
28108 configSizes: config?.sizes,
28109 onError: () => setImageError(true)
28110 }
28111 );
28112 }
28113
28114 // packages/media-fields/build-module/media_thumbnail/index.mjs
28115 var mediaThumbnailField = {
28116 id: "media_thumbnail",
28117 type: "media",
28118 label: (0, import_i18n65.__)("Thumbnail"),
28119 render: MediaThumbnailView,
28120 enableSorting: false,
28121 filterBy: false
28122 };
28123 var media_thumbnail_default = mediaThumbnailField;
28124
28125 // packages/media-fields/build-module/mime_type/index.mjs
28126 var import_i18n66 = __toESM(require_i18n(), 1);
28127 var mimeTypeField = {
28128 id: "mime_type",
28129 type: "text",
28130 label: (0, import_i18n66.__)("File type"),
28131 getValue: ({ item }) => item?.mime_type || "",
28132 render: ({ item }) => item?.mime_type || "-",
28133 // Disable sorting until REST API support for ordering my `mime_type` is added.
28134 // See: https://core.trac.wordpress.org/ticket/64073
28135 enableSorting: false,
28136 filterBy: false,
28137 readOnly: true
28138 };
28139 var mime_type_default = mimeTypeField;
28140
28141 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28142 var import_notices = __toESM(require_notices(), 1);
28143
28144 // packages/media-utils/build-module/lock-unlock.mjs
28145 var import_private_apis4 = __toESM(require_private_apis(), 1);
28146 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
28147 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
28148 "@wordpress/media-utils"
28149 );
28150
28151 // packages/media-utils/build-module/components/media-upload-modal/upload-status-popover.mjs
28152 var import_element84 = __toESM(require_element(), 1);
28153 var import_i18n67 = __toESM(require_i18n(), 1);
28154 var import_components53 = __toESM(require_components(), 1);
28155 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28156 function UploadStatusPopover({
28157 uploadingFiles,
28158 onDismissError,
28159 onOpenChange
28160 }) {
28161 const [isOpen, setIsOpen] = (0, import_element84.useState)(false);
28162 const [prevHadErrors, setPrevHadErrors] = (0, import_element84.useState)(false);
28163 const triggerRef = (0, import_element84.useRef)(null);
28164 const updateIsOpen = (0, import_element84.useCallback)(
28165 (open) => {
28166 setIsOpen(open);
28167 onOpenChange?.(open);
28168 },
28169 [onOpenChange]
28170 );
28171 const activeFiles = uploadingFiles.filter(
28172 (file) => file.status === "uploading"
28173 );
28174 const errorFiles = uploadingFiles.filter(
28175 (file) => file.status === "error"
28176 );
28177 const hasErrors = errorFiles.length > 0;
28178 const isUploading = activeFiles.length > 0;
28179 (0, import_element84.useEffect)(() => {
28180 if (hasErrors && !prevHadErrors) {
28181 updateIsOpen(true);
28182 }
28183 setPrevHadErrors(hasErrors);
28184 }, [hasErrors, prevHadErrors, updateIsOpen]);
28185 if (uploadingFiles.length === 0) {
28186 return null;
28187 }
28188 let buttonLabel, popoverHeading;
28189 if (isUploading) {
28190 buttonLabel = (0, import_i18n67.sprintf)(
28191 // translators: %s: number of files being uploaded
28192 (0, import_i18n67._n)("Uploading %s file", "Uploading %s files", activeFiles.length),
28193 activeFiles.length.toLocaleString()
28194 );
28195 popoverHeading = (0, import_i18n67.__)("Uploading");
28196 } else if (hasErrors) {
28197 buttonLabel = (0, import_i18n67.sprintf)(
28198 // translators: %s: number of upload errors
28199 (0, import_i18n67._n)("%s upload error", "%s upload errors", errorFiles.length),
28200 errorFiles.length.toLocaleString()
28201 );
28202 popoverHeading = (0, import_i18n67.__)("Upload errors");
28203 } else {
28204 buttonLabel = (0, import_i18n67.__)("Upload complete");
28205 popoverHeading = (0, import_i18n67.__)("Upload complete");
28206 }
28207 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "media-upload-modal__upload-status", children: [
28208 isUploading && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28209 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28210 import_components53.Button,
28211 {
28212 className: "media-upload-modal__upload-status__trigger",
28213 size: "compact",
28214 icon: chevron_down_default,
28215 iconPosition: "right",
28216 onClick: () => updateIsOpen(!isOpen),
28217 "aria-expanded": isOpen,
28218 ref: triggerRef,
28219 children: buttonLabel
28220 }
28221 ),
28222 isOpen && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28223 import_components53.Popover,
28224 {
28225 className: "media-upload-modal__upload-status__popover",
28226 placement: "top-start",
28227 offset: 8,
28228 anchor: triggerRef.current,
28229 focusOnMount: true,
28230 onClose: () => {
28231 if (triggerRef.current?.contains(
28232 triggerRef.current.ownerDocument.activeElement
28233 )) {
28234 return;
28235 }
28236 updateIsOpen(false);
28237 },
28238 children: [
28239 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "media-upload-modal__upload-status__header", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("h3", { children: popoverHeading }) }),
28240 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("ul", { className: "media-upload-modal__upload-status__list", children: uploadingFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28241 "li",
28242 {
28243 className: "media-upload-modal__upload-status__item",
28244 children: [
28245 file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28246 file.status === "uploaded" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Icon, { icon: check_default, size: 16 }),
28247 (file.status === "uploading" || file.status === "uploaded") && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28248 "span",
28249 {
28250 className: "media-upload-modal__upload-status__filename",
28251 title: file.name,
28252 children: file.name
28253 }
28254 ),
28255 file.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28256 import_components53.Notice,
28257 {
28258 status: "error",
28259 isDismissible: !!onDismissError,
28260 onRemove: () => onDismissError?.(file.id),
28261 children: [
28262 file.name,
28263 ": ",
28264 file.error
28265 ]
28266 }
28267 )
28268 ]
28269 },
28270 file.id
28271 )) })
28272 ]
28273 }
28274 )
28275 ] });
28276 }
28277
28278 // packages/media-utils/build-module/components/media-upload-modal/use-invalidate-attachment-resolutions.mjs
28279 var import_element85 = __toESM(require_element(), 1);
28280 var import_data13 = __toESM(require_data(), 1);
28281 function useInvalidateAttachmentResolutions() {
28282 const registry = (0, import_data13.useRegistry)();
28283 return (0, import_element85.useCallback)(
28284 () => invalidateAttachmentResolutions(registry),
28285 [registry]
28286 );
28287 }
28288
28289 // packages/media-utils/build-module/components/media-upload-modal/use-upload-status.mjs
28290 var import_element86 = __toESM(require_element(), 1);
28291 var import_blob2 = __toESM(require_blob(), 1);
28292 var idCounter = 0;
28293 var batchIdCounter = 0;
28294 function useUploadStatus({
28295 onBatchComplete
28296 } = {}) {
28297 const [uploadingFiles, setUploadingFiles] = (0, import_element86.useState)(
28298 []
28299 );
28300 const clearCompleted = (0, import_element86.useCallback)(() => {
28301 setUploadingFiles(
28302 (prev) => prev.filter((item) => item.status !== "uploaded")
28303 );
28304 }, []);
28305 const dismissError = (0, import_element86.useCallback)((fileId) => {
28306 setUploadingFiles(
28307 (prev) => prev.filter((item) => item.id !== fileId)
28308 );
28309 }, []);
28310 const registerBatch = (0, import_element86.useCallback)(
28311 (files) => {
28312 const batchId = String(++batchIdCounter);
28313 const batchSize = files.length;
28314 const newEntries = files.map((file) => ({
28315 id: String(++idCounter),
28316 batchId,
28317 name: file.name,
28318 status: "uploading"
28319 }));
28320 setUploadingFiles((prev) => [...prev, ...newEntries]);
28321 let successCount = 0;
28322 let errorCount = 0;
28323 let batchDone = false;
28324 let successAttachments = [];
28325 const completeBatchIfDone = () => {
28326 if (batchDone || successCount + errorCount < batchSize) {
28327 return;
28328 }
28329 batchDone = true;
28330 setUploadingFiles(
28331 (prev) => prev.map(
28332 (item) => item.batchId === batchId && item.status === "uploading" ? {
28333 ...item,
28334 status: "uploaded"
28335 } : item
28336 )
28337 );
28338 onBatchComplete?.(successAttachments);
28339 };
28340 const onFileChange = (attachments) => {
28341 if (batchDone) {
28342 return;
28343 }
28344 const allReal = attachments.every(
28345 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
28346 );
28347 if (!allReal) {
28348 return;
28349 }
28350 successCount = attachments.length;
28351 successAttachments = attachments;
28352 completeBatchIfDone();
28353 };
28354 const onError = (error) => {
28355 const fileName = error instanceof UploadError ? error.file.name : void 0;
28356 setUploadingFiles((prev) => {
28357 let matched = false;
28358 return prev.map((item) => {
28359 if (!matched && item.batchId === batchId && item.status === "uploading" && (!fileName || item.name === fileName)) {
28360 matched = true;
28361 return {
28362 ...item,
28363 status: "error",
28364 error: error.message
28365 };
28366 }
28367 return item;
28368 });
28369 });
28370 errorCount++;
28371 completeBatchIfDone();
28372 };
28373 return { onFileChange, onError };
28374 },
28375 [onBatchComplete]
28376 );
28377 const allComplete = uploadingFiles.length > 0 && uploadingFiles.every((item) => item.status !== "uploading");
28378 return {
28379 uploadingFiles,
28380 registerBatch,
28381 dismissError,
28382 clearCompleted,
28383 allComplete
28384 };
28385 }
28386
28387 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28388 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28389 var { useEntityRecordsWithPermissions } = unlock4(import_core_data6.privateApis);
28390 var LAYOUT_PICKER_GRID2 = "pickerGrid";
28391 var LAYOUT_PICKER_TABLE2 = "pickerTable";
28392 var NOTICES_CONTEXT = "media-modal";
28393 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
28394 var defaultQueryParams = {
28395 page: 1,
28396 search: ""
28397 };
28398 function getSelectionFromValue(value) {
28399 if (!value) {
28400 return [];
28401 }
28402 return Array.isArray(value) ? value.map(String) : [String(value)];
28403 }
28404 var defaultView = {
28405 type: LAYOUT_PICKER_GRID2,
28406 fields: [],
28407 showTitle: false,
28408 titleField: "title",
28409 mediaField: "media_thumbnail",
28410 perPage: 50,
28411 filters: [],
28412 layout: {
28413 previewSize: 170,
28414 density: "compact"
28415 }
28416 };
28417 var defaultLayouts = {
28418 [LAYOUT_PICKER_GRID2]: {
28419 fields: [],
28420 showTitle: false,
28421 layout: {
28422 previewSize: 170,
28423 density: "compact"
28424 }
28425 },
28426 [LAYOUT_PICKER_TABLE2]: {
28427 fields: [
28428 "filename",
28429 "filesize",
28430 "media_dimensions",
28431 "author",
28432 "date"
28433 ],
28434 showTitle: true
28435 }
28436 };
28437 function MediaUploadModal({
28438 allowedTypes,
28439 multiple = false,
28440 value,
28441 onSelect,
28442 onClose,
28443 onUpload,
28444 title = (0, import_i18n68.__)("Select Media"),
28445 isOpen,
28446 isDismissible = true,
28447 modalClass,
28448 search = true,
28449 searchLabel = (0, import_i18n68.__)("Search media")
28450 }) {
28451 const [selection, setSelection] = (0, import_element87.useState)(
28452 () => getSelectionFromValue(value)
28453 );
28454 const { createSuccessNotice, removeAllNotices } = (0, import_data14.useDispatch)(import_notices.store);
28455 const invalidateAttachmentResolutions2 = useInvalidateAttachmentResolutions();
28456 const [queryParams, setQueryParams] = (0, import_element87.useState)(
28457 () => defaultQueryParams
28458 );
28459 const { view, updateView, isModified, resetToDefault } = useView({
28460 kind: "postType",
28461 name: "attachment",
28462 slug: "media-modal",
28463 defaultView,
28464 queryParams,
28465 onChangeQueryParams: setQueryParams
28466 });
28467 const handleChangeView = (0, import_element87.useCallback)(
28468 (nextView) => {
28469 const normalizedView = { ...nextView };
28470 if (normalizedView.startPosition === void 0) {
28471 delete normalizedView.startPosition;
28472 }
28473 updateView(normalizedView);
28474 },
28475 [updateView]
28476 );
28477 const queryArgs = (0, import_element87.useMemo)(() => {
28478 const filters = {};
28479 view.filters?.forEach((filter) => {
28480 if (filter.field === "media_type") {
28481 filters.media_type = filter.value;
28482 }
28483 if (filter.field === "author") {
28484 if (filter.operator === "isAny") {
28485 filters.author = filter.value;
28486 } else if (filter.operator === "isNone") {
28487 filters.author_exclude = filter.value;
28488 }
28489 }
28490 if (filter.field === "date" || filter.field === "modified") {
28491 if (filter.operator === "before") {
28492 filters.before = filter.value;
28493 } else if (filter.operator === "after") {
28494 filters.after = filter.value;
28495 }
28496 }
28497 if (filter.field === "mime_type") {
28498 filters.mime_type = filter.value;
28499 }
28500 });
28501 if (!filters.media_type && !filters.mime_type && allowedTypes && !allowedTypes.includes("*")) {
28502 const { mediaTypes, mimeTypes } = allowedTypes.reduce(
28503 (acc, type) => {
28504 if (type.endsWith("/*")) {
28505 acc.mediaTypes.push(type.replace("/*", ""));
28506 } else if (type.includes("/")) {
28507 acc.mimeTypes.push(type);
28508 } else {
28509 acc.mediaTypes.push(type);
28510 }
28511 return acc;
28512 },
28513 { mediaTypes: [], mimeTypes: [] }
28514 );
28515 if (mediaTypes.length) {
28516 filters.media_type = mediaTypes;
28517 }
28518 if (mimeTypes.length) {
28519 filters.mime_type = mimeTypes;
28520 }
28521 }
28522 return {
28523 per_page: view.perPage || 20,
28524 page: view.page || 1,
28525 status: "inherit",
28526 order: view.sort?.direction,
28527 orderby: view.sort?.field,
28528 search: view.search,
28529 _embed: "author,wp:attached-to",
28530 ...filters
28531 };
28532 }, [view, allowedTypes]);
28533 const handleBatchComplete = (0, import_element87.useCallback)(
28534 (attachments) => {
28535 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
28536 if (multiple) {
28537 setSelection((prev) => {
28538 const existing = new Set(prev);
28539 const newIds = uploadedIds.filter(
28540 (id) => !existing.has(id)
28541 );
28542 return [...prev, ...newIds];
28543 });
28544 } else {
28545 setSelection(uploadedIds.slice(0, 1));
28546 }
28547 invalidateAttachmentResolutions2();
28548 },
28549 [multiple, invalidateAttachmentResolutions2]
28550 );
28551 const {
28552 uploadingFiles,
28553 registerBatch,
28554 dismissError,
28555 clearCompleted,
28556 allComplete
28557 } = useUploadStatus({ onBatchComplete: handleBatchComplete });
28558 const isPopoverOpenRef = (0, import_element87.useRef)(false);
28559 const handlePopoverOpenChange = (0, import_element87.useCallback)(
28560 (open) => {
28561 isPopoverOpenRef.current = open;
28562 if (!open) {
28563 clearCompleted();
28564 }
28565 },
28566 [clearCompleted]
28567 );
28568 const {
28569 records: mediaRecords,
28570 isResolving: isLoading,
28571 totalItems,
28572 totalPages
28573 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
28574 const fields = (0, import_element87.useMemo)(
28575 () => [
28576 // Media field definitions from @wordpress/media-fields
28577 // Cast is safe because RestAttachment has the same properties as Attachment
28578 {
28579 ...media_thumbnail_default,
28580 enableHiding: false
28581 // Within the modal, the thumbnail should always be shown.
28582 },
28583 {
28584 id: "title",
28585 type: "text",
28586 label: (0, import_i18n68.__)("Title"),
28587 getValue: ({ item }) => {
28588 const titleValue = item.title.raw || item.title.rendered;
28589 return titleValue || (0, import_i18n68.__)("(no title)");
28590 }
28591 },
28592 alt_text_default,
28593 caption_default,
28594 description_default,
28595 date_added_default,
28596 date_modified_default,
28597 author_default,
28598 filename_default,
28599 filesize_default,
28600 media_dimensions_default,
28601 mime_type_default,
28602 attached_to_default
28603 ],
28604 []
28605 );
28606 const actions = (0, import_element87.useMemo)(
28607 () => [
28608 {
28609 id: "select",
28610 label: (0, import_i18n68.__)("Select"),
28611 isPrimary: true,
28612 supportsBulk: multiple,
28613 async callback() {
28614 if (selection.length === 0) {
28615 return;
28616 }
28617 const selectedPostsQuery = {
28618 include: selection,
28619 per_page: -1
28620 };
28621 const selectedPosts = await (0, import_data14.resolveSelect)(
28622 import_core_data6.store
28623 ).getEntityRecords(
28624 "postType",
28625 "attachment",
28626 selectedPostsQuery
28627 );
28628 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
28629 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
28630 removeAllNotices("snackbar", NOTICES_CONTEXT);
28631 onSelect(selectedItems);
28632 }
28633 }
28634 ],
28635 [multiple, onSelect, selection, removeAllNotices]
28636 );
28637 const handleModalClose = (0, import_element87.useCallback)(() => {
28638 removeAllNotices("snackbar", NOTICES_CONTEXT);
28639 onClose?.();
28640 }, [removeAllNotices, onClose]);
28641 const valueRef = (0, import_element87.useRef)(value);
28642 (0, import_element87.useEffect)(() => {
28643 valueRef.current = value;
28644 }, [value]);
28645 (0, import_element87.useEffect)(() => {
28646 if (isOpen) {
28647 setSelection(getSelectionFromValue(valueRef.current));
28648 } else {
28649 setQueryParams(defaultQueryParams);
28650 }
28651 }, [isOpen]);
28652 const handleUpload = onUpload || uploadMedia;
28653 const prevAllCompleteRef = (0, import_element87.useRef)(false);
28654 (0, import_element87.useEffect)(() => {
28655 if (allComplete && !prevAllCompleteRef.current) {
28656 const completeCount = uploadingFiles.filter(
28657 (file) => file.status === "uploaded"
28658 ).length;
28659 if (completeCount > 0) {
28660 createSuccessNotice(
28661 (0, import_i18n68.sprintf)(
28662 // translators: %s: number of files
28663 (0, import_i18n68._n)(
28664 "Uploaded %s file",
28665 "Uploaded %s files",
28666 completeCount
28667 ),
28668 completeCount.toLocaleString()
28669 ),
28670 {
28671 type: "snackbar",
28672 context: NOTICES_CONTEXT,
28673 id: NOTICE_ID_UPLOAD_PROGRESS
28674 }
28675 );
28676 }
28677 if (!isPopoverOpenRef.current) {
28678 clearCompleted();
28679 }
28680 }
28681 prevAllCompleteRef.current = allComplete;
28682 }, [allComplete, uploadingFiles, createSuccessNotice, clearCompleted]);
28683 const handleFileSelect = (0, import_element87.useCallback)(
28684 (event) => {
28685 const files = event.target.files;
28686 if (files && files.length > 0) {
28687 const filesArray = Array.from(files);
28688 const { onFileChange, onError } = registerBatch(filesArray);
28689 handleUpload({
28690 allowedTypes,
28691 filesList: filesArray,
28692 onFileChange,
28693 onError
28694 });
28695 }
28696 },
28697 [allowedTypes, handleUpload, registerBatch]
28698 );
28699 const paginationInfo = (0, import_element87.useMemo)(
28700 () => ({
28701 totalItems,
28702 totalPages
28703 }),
28704 [totalItems, totalPages]
28705 );
28706 const acceptTypes = (0, import_element87.useMemo)(() => {
28707 if (allowedTypes?.includes("*")) {
28708 return void 0;
28709 }
28710 return allowedTypes?.join(",");
28711 }, [allowedTypes]);
28712 if (!isOpen) {
28713 return null;
28714 }
28715 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28716 import_components54.Modal,
28717 {
28718 title,
28719 onRequestClose: handleModalClose,
28720 isDismissible,
28721 className: modalClass,
28722 overlayClassName: "media-upload-modal",
28723 size: "fill",
28724 headerActions: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28725 import_components54.FormFileUpload,
28726 {
28727 accept: acceptTypes,
28728 multiple: true,
28729 onChange: handleFileSelect,
28730 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28731 import_components54.Button,
28732 {
28733 onClick: openFileDialog,
28734 icon: upload_default,
28735 __next40pxDefaultSize: true,
28736 children: (0, import_i18n68.__)("Upload media")
28737 }
28738 )
28739 }
28740 ),
28741 children: [
28742 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28743 import_components54.DropZone,
28744 {
28745 onFilesDrop: (files) => {
28746 let filteredFiles = files;
28747 if (allowedTypes && !allowedTypes.includes("*")) {
28748 filteredFiles = files.filter(
28749 (file) => allowedTypes.some((allowedType) => {
28750 return file.type === allowedType || file.type.startsWith(
28751 allowedType.replace("*", "")
28752 );
28753 })
28754 );
28755 }
28756 if (filteredFiles.length > 0) {
28757 const { onFileChange, onError } = registerBatch(filteredFiles);
28758 handleUpload({
28759 allowedTypes,
28760 filesList: filteredFiles,
28761 onFileChange,
28762 onError
28763 });
28764 }
28765 },
28766 label: (0, import_i18n68.__)("Drop files to upload")
28767 }
28768 ),
28769 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28770 dataviews_picker_default,
28771 {
28772 data: mediaRecords || [],
28773 fields,
28774 view,
28775 onChangeView: handleChangeView,
28776 actions,
28777 selection,
28778 onChangeSelection: setSelection,
28779 isLoading,
28780 paginationInfo,
28781 defaultLayouts,
28782 getItemId: (item) => String(item.id),
28783 itemListLabel: (0, import_i18n68.__)("Media items"),
28784 onReset: isModified ? resetToDefault : false,
28785 children: [
28786 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28787 Stack,
28788 {
28789 direction: "row",
28790 align: "top",
28791 justify: "space-between",
28792 className: "dataviews__view-actions",
28793 gap: "xs",
28794 children: [
28795 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28796 Stack,
28797 {
28798 direction: "row",
28799 gap: "sm",
28800 justify: "start",
28801 className: "dataviews__search",
28802 children: [
28803 search && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Search, { label: searchLabel }),
28804 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggle, {})
28805 ]
28806 }
28807 ),
28808 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28809 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.LayoutSwitcher, {}),
28810 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.ViewConfig, {})
28811 ] })
28812 ]
28813 }
28814 ),
28815 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggled, { className: "dataviews-filters__container" }),
28816 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Layout, {}),
28817 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28818 "div",
28819 {
28820 className: clsx_default("media-upload-modal__footer", {
28821 "is-uploading": uploadingFiles.length > 0
28822 }),
28823 children: [
28824 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28825 UploadStatusPopover,
28826 {
28827 uploadingFiles,
28828 onDismissError: dismissError,
28829 onOpenChange: handlePopoverOpenChange
28830 }
28831 ),
28832 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Footer, {})
28833 ]
28834 }
28835 )
28836 ]
28837 }
28838 ),
28839 (0, import_element87.createPortal)(
28840 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28841 import_notices.SnackbarNotices,
28842 {
28843 className: "media-upload-modal__snackbar",
28844 context: NOTICES_CONTEXT
28845 }
28846 ),
28847 document.body
28848 )
28849 ]
28850 }
28851 );
28852 }
28853
28854 // packages/media-utils/build-module/private-apis.mjs
28855 var privateApis12 = {};
28856 lock4(privateApis12, {
28857 sideloadMedia,
28858 MediaUploadModal
28859 });
28860 return __toCommonJS(index_exports);
28861 })();
28862 /*! Bundled license information:
28863
28864 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
28865 (**
28866 * @license React
28867 * use-sync-external-store-shim.development.js
28868 *
28869 * Copyright (c) Meta Platforms, Inc. and affiliates.
28870 *
28871 * This source code is licensed under the MIT license found in the
28872 * LICENSE file in the root directory of this source tree.
28873 *)
28874
28875 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
28876 (**
28877 * @license React
28878 * use-sync-external-store-shim/with-selector.development.js
28879 *
28880 * Copyright (c) Meta Platforms, Inc. and affiliates.
28881 *
28882 * This source code is licensed under the MIT license found in the
28883 * LICENSE file in the root directory of this source tree.
28884 *)
28885 */
28886 //# sourceMappingURL=index.js.map
28887