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 / routes / guidelines / content.js

content.js in Gutenberg 23.6.2, at build/routes/guidelines/content.js

31,821 lines 1.1 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React60.startTransition || (didWarnOld18Alpha = true, console.error(
76 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState50({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect5(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect43(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error2) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React60 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState50 = React60.useState, useEffect43 = React60.useEffect, useLayoutEffect5 = React60.useLayoutEffect, useDebugValue2 = React60.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
124 exports.useSyncExternalStore = void 0 !== React60.useSyncExternalStore ? React60.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React60 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef58 = React60.useRef, useEffect43 = React60.useEffect, useMemo55 = React60.useMemo, useDebugValue2 = React60.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef58(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo55(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect43(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "\xC0": "A",
275 "\xC1": "A",
276 "\xC2": "A",
277 "\xC3": "A",
278 "\xC4": "A",
279 "\xC5": "A",
280 "\u1EA4": "A",
281 "\u1EAE": "A",
282 "\u1EB2": "A",
283 "\u1EB4": "A",
284 "\u1EB6": "A",
285 "\xC6": "AE",
286 "\u1EA6": "A",
287 "\u1EB0": "A",
288 "\u0202": "A",
289 "\u1EA2": "A",
290 "\u1EA0": "A",
291 "\u1EA8": "A",
292 "\u1EAA": "A",
293 "\u1EAC": "A",
294 "\xC7": "C",
295 "\u1E08": "C",
296 "\xC8": "E",
297 "\xC9": "E",
298 "\xCA": "E",
299 "\xCB": "E",
300 "\u1EBE": "E",
301 "\u1E16": "E",
302 "\u1EC0": "E",
303 "\u1E14": "E",
304 "\u1E1C": "E",
305 "\u0206": "E",
306 "\u1EBA": "E",
307 "\u1EBC": "E",
308 "\u1EB8": "E",
309 "\u1EC2": "E",
310 "\u1EC4": "E",
311 "\u1EC6": "E",
312 "\xCC": "I",
313 "\xCD": "I",
314 "\xCE": "I",
315 "\xCF": "I",
316 "\u1E2E": "I",
317 "\u020A": "I",
318 "\u1EC8": "I",
319 "\u1ECA": "I",
320 "\xD0": "D",
321 "\xD1": "N",
322 "\xD2": "O",
323 "\xD3": "O",
324 "\xD4": "O",
325 "\xD5": "O",
326 "\xD6": "O",
327 "\xD8": "O",
328 "\u1ED0": "O",
329 "\u1E4C": "O",
330 "\u1E52": "O",
331 "\u020E": "O",
332 "\u1ECE": "O",
333 "\u1ECC": "O",
334 "\u1ED4": "O",
335 "\u1ED6": "O",
336 "\u1ED8": "O",
337 "\u1EDC": "O",
338 "\u1EDE": "O",
339 "\u1EE0": "O",
340 "\u1EDA": "O",
341 "\u1EE2": "O",
342 "\xD9": "U",
343 "\xDA": "U",
344 "\xDB": "U",
345 "\xDC": "U",
346 "\u1EE6": "U",
347 "\u1EE4": "U",
348 "\u1EEC": "U",
349 "\u1EEE": "U",
350 "\u1EF0": "U",
351 "\xDD": "Y",
352 "\xE0": "a",
353 "\xE1": "a",
354 "\xE2": "a",
355 "\xE3": "a",
356 "\xE4": "a",
357 "\xE5": "a",
358 "\u1EA5": "a",
359 "\u1EAF": "a",
360 "\u1EB3": "a",
361 "\u1EB5": "a",
362 "\u1EB7": "a",
363 "\xE6": "ae",
364 "\u1EA7": "a",
365 "\u1EB1": "a",
366 "\u0203": "a",
367 "\u1EA3": "a",
368 "\u1EA1": "a",
369 "\u1EA9": "a",
370 "\u1EAB": "a",
371 "\u1EAD": "a",
372 "\xE7": "c",
373 "\u1E09": "c",
374 "\xE8": "e",
375 "\xE9": "e",
376 "\xEA": "e",
377 "\xEB": "e",
378 "\u1EBF": "e",
379 "\u1E17": "e",
380 "\u1EC1": "e",
381 "\u1E15": "e",
382 "\u1E1D": "e",
383 "\u0207": "e",
384 "\u1EBB": "e",
385 "\u1EBD": "e",
386 "\u1EB9": "e",
387 "\u1EC3": "e",
388 "\u1EC5": "e",
389 "\u1EC7": "e",
390 "\xEC": "i",
391 "\xED": "i",
392 "\xEE": "i",
393 "\xEF": "i",
394 "\u1E2F": "i",
395 "\u020B": "i",
396 "\u1EC9": "i",
397 "\u1ECB": "i",
398 "\xF0": "d",
399 "\xF1": "n",
400 "\xF2": "o",
401 "\xF3": "o",
402 "\xF4": "o",
403 "\xF5": "o",
404 "\xF6": "o",
405 "\xF8": "o",
406 "\u1ED1": "o",
407 "\u1E4D": "o",
408 "\u1E53": "o",
409 "\u020F": "o",
410 "\u1ECF": "o",
411 "\u1ECD": "o",
412 "\u1ED5": "o",
413 "\u1ED7": "o",
414 "\u1ED9": "o",
415 "\u1EDD": "o",
416 "\u1EDF": "o",
417 "\u1EE1": "o",
418 "\u1EDB": "o",
419 "\u1EE3": "o",
420 "\xF9": "u",
421 "\xFA": "u",
422 "\xFB": "u",
423 "\xFC": "u",
424 "\u1EE7": "u",
425 "\u1EE5": "u",
426 "\u1EED": "u",
427 "\u1EEF": "u",
428 "\u1EF1": "u",
429 "\xFD": "y",
430 "\xFF": "y",
431 "\u0100": "A",
432 "\u0101": "a",
433 "\u0102": "A",
434 "\u0103": "a",
435 "\u0104": "A",
436 "\u0105": "a",
437 "\u0106": "C",
438 "\u0107": "c",
439 "\u0108": "C",
440 "\u0109": "c",
441 "\u010A": "C",
442 "\u010B": "c",
443 "\u010C": "C",
444 "\u010D": "c",
445 "C\u0306": "C",
446 "c\u0306": "c",
447 "\u010E": "D",
448 "\u010F": "d",
449 "\u0110": "D",
450 "\u0111": "d",
451 "\u0112": "E",
452 "\u0113": "e",
453 "\u0114": "E",
454 "\u0115": "e",
455 "\u0116": "E",
456 "\u0117": "e",
457 "\u0118": "E",
458 "\u0119": "e",
459 "\u011A": "E",
460 "\u011B": "e",
461 "\u011C": "G",
462 "\u01F4": "G",
463 "\u011D": "g",
464 "\u01F5": "g",
465 "\u011E": "G",
466 "\u011F": "g",
467 "\u0120": "G",
468 "\u0121": "g",
469 "\u0122": "G",
470 "\u0123": "g",
471 "\u0124": "H",
472 "\u0125": "h",
473 "\u0126": "H",
474 "\u0127": "h",
475 "\u1E2A": "H",
476 "\u1E2B": "h",
477 "\u0128": "I",
478 "\u0129": "i",
479 "\u012A": "I",
480 "\u012B": "i",
481 "\u012C": "I",
482 "\u012D": "i",
483 "\u012E": "I",
484 "\u012F": "i",
485 "\u0130": "I",
486 "\u0131": "i",
487 "\u0132": "IJ",
488 "\u0133": "ij",
489 "\u0134": "J",
490 "\u0135": "j",
491 "\u0136": "K",
492 "\u0137": "k",
493 "\u1E30": "K",
494 "\u1E31": "k",
495 "K\u0306": "K",
496 "k\u0306": "k",
497 "\u0139": "L",
498 "\u013A": "l",
499 "\u013B": "L",
500 "\u013C": "l",
501 "\u013D": "L",
502 "\u013E": "l",
503 "\u013F": "L",
504 "\u0140": "l",
505 "\u0141": "l",
506 "\u0142": "l",
507 "\u1E3E": "M",
508 "\u1E3F": "m",
509 "M\u0306": "M",
510 "m\u0306": "m",
511 "\u0143": "N",
512 "\u0144": "n",
513 "\u0145": "N",
514 "\u0146": "n",
515 "\u0147": "N",
516 "\u0148": "n",
517 "\u0149": "n",
518 "N\u0306": "N",
519 "n\u0306": "n",
520 "\u014C": "O",
521 "\u014D": "o",
522 "\u014E": "O",
523 "\u014F": "o",
524 "\u0150": "O",
525 "\u0151": "o",
526 "\u0152": "OE",
527 "\u0153": "oe",
528 "P\u0306": "P",
529 "p\u0306": "p",
530 "\u0154": "R",
531 "\u0155": "r",
532 "\u0156": "R",
533 "\u0157": "r",
534 "\u0158": "R",
535 "\u0159": "r",
536 "R\u0306": "R",
537 "r\u0306": "r",
538 "\u0212": "R",
539 "\u0213": "r",
540 "\u015A": "S",
541 "\u015B": "s",
542 "\u015C": "S",
543 "\u015D": "s",
544 "\u015E": "S",
545 "\u0218": "S",
546 "\u0219": "s",
547 "\u015F": "s",
548 "\u0160": "S",
549 "\u0161": "s",
550 "\u0162": "T",
551 "\u0163": "t",
552 "\u021B": "t",
553 "\u021A": "T",
554 "\u0164": "T",
555 "\u0165": "t",
556 "\u0166": "T",
557 "\u0167": "t",
558 "T\u0306": "T",
559 "t\u0306": "t",
560 "\u0168": "U",
561 "\u0169": "u",
562 "\u016A": "U",
563 "\u016B": "u",
564 "\u016C": "U",
565 "\u016D": "u",
566 "\u016E": "U",
567 "\u016F": "u",
568 "\u0170": "U",
569 "\u0171": "u",
570 "\u0172": "U",
571 "\u0173": "u",
572 "\u0216": "U",
573 "\u0217": "u",
574 "V\u0306": "V",
575 "v\u0306": "v",
576 "\u0174": "W",
577 "\u0175": "w",
578 "\u1E82": "W",
579 "\u1E83": "w",
580 "X\u0306": "X",
581 "x\u0306": "x",
582 "\u0176": "Y",
583 "\u0177": "y",
584 "\u0178": "Y",
585 "Y\u0306": "Y",
586 "y\u0306": "y",
587 "\u0179": "Z",
588 "\u017A": "z",
589 "\u017B": "Z",
590 "\u017C": "z",
591 "\u017D": "Z",
592 "\u017E": "z",
593 "\u017F": "s",
594 "\u0192": "f",
595 "\u01A0": "O",
596 "\u01A1": "o",
597 "\u01AF": "U",
598 "\u01B0": "u",
599 "\u01CD": "A",
600 "\u01CE": "a",
601 "\u01CF": "I",
602 "\u01D0": "i",
603 "\u01D1": "O",
604 "\u01D2": "o",
605 "\u01D3": "U",
606 "\u01D4": "u",
607 "\u01D5": "U",
608 "\u01D6": "u",
609 "\u01D7": "U",
610 "\u01D8": "u",
611 "\u01D9": "U",
612 "\u01DA": "u",
613 "\u01DB": "U",
614 "\u01DC": "u",
615 "\u1EE8": "U",
616 "\u1EE9": "u",
617 "\u1E78": "U",
618 "\u1E79": "u",
619 "\u01FA": "A",
620 "\u01FB": "a",
621 "\u01FC": "AE",
622 "\u01FD": "ae",
623 "\u01FE": "O",
624 "\u01FF": "o",
625 "\xDE": "TH",
626 "\xFE": "th",
627 "\u1E54": "P",
628 "\u1E55": "p",
629 "\u1E64": "S",
630 "\u1E65": "s",
631 "X\u0301": "X",
632 "x\u0301": "x",
633 "\u0403": "\u0413",
634 "\u0453": "\u0433",
635 "\u040C": "\u041A",
636 "\u045C": "\u043A",
637 "A\u030B": "A",
638 "a\u030B": "a",
639 "E\u030B": "E",
640 "e\u030B": "e",
641 "I\u030B": "I",
642 "i\u030B": "i",
643 "\u01F8": "N",
644 "\u01F9": "n",
645 "\u1ED2": "O",
646 "\u1ED3": "o",
647 "\u1E50": "O",
648 "\u1E51": "o",
649 "\u1EEA": "U",
650 "\u1EEB": "u",
651 "\u1E80": "W",
652 "\u1E81": "w",
653 "\u1EF2": "Y",
654 "\u1EF3": "y",
655 "\u0200": "A",
656 "\u0201": "a",
657 "\u0204": "E",
658 "\u0205": "e",
659 "\u0208": "I",
660 "\u0209": "i",
661 "\u020C": "O",
662 "\u020D": "o",
663 "\u0210": "R",
664 "\u0211": "r",
665 "\u0214": "U",
666 "\u0215": "u",
667 "B\u030C": "B",
668 "b\u030C": "b",
669 "\u010C\u0323": "C",
670 "\u010D\u0323": "c",
671 "\xCA\u030C": "E",
672 "\xEA\u030C": "e",
673 "F\u030C": "F",
674 "f\u030C": "f",
675 "\u01E6": "G",
676 "\u01E7": "g",
677 "\u021E": "H",
678 "\u021F": "h",
679 "J\u030C": "J",
680 "\u01F0": "j",
681 "\u01E8": "K",
682 "\u01E9": "k",
683 "M\u030C": "M",
684 "m\u030C": "m",
685 "P\u030C": "P",
686 "p\u030C": "p",
687 "Q\u030C": "Q",
688 "q\u030C": "q",
689 "\u0158\u0329": "R",
690 "\u0159\u0329": "r",
691 "\u1E66": "S",
692 "\u1E67": "s",
693 "V\u030C": "V",
694 "v\u030C": "v",
695 "W\u030C": "W",
696 "w\u030C": "w",
697 "X\u030C": "X",
698 "x\u030C": "x",
699 "Y\u030C": "Y",
700 "y\u030C": "y",
701 "A\u0327": "A",
702 "a\u0327": "a",
703 "B\u0327": "B",
704 "b\u0327": "b",
705 "\u1E10": "D",
706 "\u1E11": "d",
707 "\u0228": "E",
708 "\u0229": "e",
709 "\u0190\u0327": "E",
710 "\u025B\u0327": "e",
711 "\u1E28": "H",
712 "\u1E29": "h",
713 "I\u0327": "I",
714 "i\u0327": "i",
715 "\u0197\u0327": "I",
716 "\u0268\u0327": "i",
717 "M\u0327": "M",
718 "m\u0327": "m",
719 "O\u0327": "O",
720 "o\u0327": "o",
721 "Q\u0327": "Q",
722 "q\u0327": "q",
723 "U\u0327": "U",
724 "u\u0327": "u",
725 "X\u0327": "X",
726 "x\u0327": "x",
727 "Z\u0327": "Z",
728 "z\u0327": "z",
729 "\u0439": "\u0438",
730 "\u0419": "\u0418",
731 "\u0451": "\u0435",
732 "\u0401": "\u0415"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents3 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents3;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents3;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // package-external:@wordpress/rich-text
823 var require_rich_text = __commonJS({
824 "package-external:@wordpress/rich-text"(exports, module) {
825 module.exports = window.wp.richText;
826 }
827 });
828
829 // node_modules/deepmerge/dist/cjs.js
830 var require_cjs = __commonJS({
831 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
832 "use strict";
833 var isMergeableObject = function isMergeableObject2(value) {
834 return isNonNullObject(value) && !isSpecial(value);
835 };
836 function isNonNullObject(value) {
837 return !!value && typeof value === "object";
838 }
839 function isSpecial(value) {
840 var stringValue = Object.prototype.toString.call(value);
841 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
842 }
843 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
844 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
845 function isReactElement(value) {
846 return value.$$typeof === REACT_ELEMENT_TYPE;
847 }
848 function emptyTarget(val) {
849 return Array.isArray(val) ? [] : {};
850 }
851 function cloneUnlessOtherwiseSpecified(value, options) {
852 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
853 }
854 function defaultArrayMerge(target, source, options) {
855 return target.concat(source).map(function(element) {
856 return cloneUnlessOtherwiseSpecified(element, options);
857 });
858 }
859 function getMergeFunction(key, options) {
860 if (!options.customMerge) {
861 return deepmerge;
862 }
863 var customMerge = options.customMerge(key);
864 return typeof customMerge === "function" ? customMerge : deepmerge;
865 }
866 function getEnumerableOwnPropertySymbols(target) {
867 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
868 return Object.propertyIsEnumerable.call(target, symbol3);
869 }) : [];
870 }
871 function getKeys2(target) {
872 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
873 }
874 function propertyIsOnObject(object, property) {
875 try {
876 return property in object;
877 } catch (_) {
878 return false;
879 }
880 }
881 function propertyIsUnsafe(target, key) {
882 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
883 }
884 function mergeObject(target, source, options) {
885 var destination = {};
886 if (options.isMergeableObject(target)) {
887 getKeys2(target).forEach(function(key) {
888 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
889 });
890 }
891 getKeys2(source).forEach(function(key) {
892 if (propertyIsUnsafe(target, key)) {
893 return;
894 }
895 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
896 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
897 } else {
898 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
899 }
900 });
901 return destination;
902 }
903 function deepmerge(target, source, options) {
904 options = options || {};
905 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
906 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
907 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
908 var sourceIsArray = Array.isArray(source);
909 var targetIsArray = Array.isArray(target);
910 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
911 if (!sourceAndTargetTypesMatch) {
912 return cloneUnlessOtherwiseSpecified(source, options);
913 } else if (sourceIsArray) {
914 return options.arrayMerge(target, source, options);
915 } else {
916 return mergeObject(target, source, options);
917 }
918 }
919 deepmerge.all = function deepmergeAll(array, options) {
920 if (!Array.isArray(array)) {
921 throw new Error("first argument should be an array");
922 }
923 return array.reduce(function(prev, next) {
924 return deepmerge(prev, next, options);
925 }, {});
926 };
927 var deepmerge_1 = deepmerge;
928 module.exports = deepmerge_1;
929 }
930 });
931
932 // package-external:@wordpress/deprecated
933 var require_deprecated = __commonJS({
934 "package-external:@wordpress/deprecated"(exports, module) {
935 module.exports = window.wp.deprecated;
936 }
937 });
938
939 // package-external:@wordpress/notices
940 var require_notices = __commonJS({
941 "package-external:@wordpress/notices"(exports, module) {
942 module.exports = window.wp.notices;
943 }
944 });
945
946 // package-external:@wordpress/core-data
947 var require_core_data = __commonJS({
948 "package-external:@wordpress/core-data"(exports, module) {
949 module.exports = window.wp.coreData;
950 }
951 });
952
953 // package-external:@wordpress/blocks
954 var require_blocks = __commonJS({
955 "package-external:@wordpress/blocks"(exports, module) {
956 module.exports = window.wp.blocks;
957 }
958 });
959
960 // package-external:@wordpress/blob
961 var require_blob = __commonJS({
962 "package-external:@wordpress/blob"(exports, module) {
963 module.exports = window.wp.blob;
964 }
965 });
966
967 // node_modules/clsx/dist/clsx.mjs
968 function r(e2) {
969 var t2, f2, n2 = "";
970 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
971 else if ("object" == typeof e2) if (Array.isArray(e2)) {
972 var o2 = e2.length;
973 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
974 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
975 return n2;
976 }
977 function clsx() {
978 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
979 return n2;
980 }
981 var clsx_default = clsx;
982
983 // packages/ui/build-module/badge/badge.mjs
984 var import_element11 = __toESM(require_element(), 1);
985
986 // node_modules/@base-ui/utils/useControlled.mjs
987 var React2 = __toESM(require_react(), 1);
988
989 // node_modules/@base-ui/utils/error.mjs
990 var set;
991 if (true) {
992 set = /* @__PURE__ */ new Set();
993 }
994 function error(...messages) {
995 if (true) {
996 const messageKey = messages.join(" ");
997 if (!set.has(messageKey)) {
998 set.add(messageKey);
999 console.error(`Base UI: ${messageKey}`);
1000 }
1001 }
1002 }
1003
1004 // node_modules/@base-ui/utils/useControlled.mjs
1005 function useControlled({
1006 controlled,
1007 default: defaultProp,
1008 name,
1009 state = "value"
1010 }) {
1011 const {
1012 current: isControlled
1013 } = React2.useRef(controlled !== void 0);
1014 const [valueState, setValue] = React2.useState(defaultProp);
1015 const value = isControlled ? controlled : valueState;
1016 if (true) {
1017 React2.useEffect(() => {
1018 if (isControlled !== (controlled !== void 0)) {
1019 error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
1020 }
1021 }, [state, name, controlled]);
1022 const {
1023 current: defaultValue2
1024 } = React2.useRef(defaultProp);
1025 React2.useEffect(() => {
1026 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1027 error([`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`].join("\n"));
1028 }
1029 }, [defaultProp]);
1030 }
1031 const setValueIfUncontrolled = React2.useCallback((newValue) => {
1032 if (!isControlled) {
1033 setValue(newValue);
1034 }
1035 }, []);
1036 return [value, setValueIfUncontrolled];
1037 }
1038 function serializeToDevModeString(input) {
1039 let nextId = 0;
1040 const seen = /* @__PURE__ */ new WeakMap();
1041 try {
1042 const result = JSON.stringify(input, function replacer(key, value) {
1043 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1044 return void 0;
1045 }
1046 if (typeof value === "bigint") {
1047 return `__bigint__:${value}`;
1048 }
1049 if (value !== null && typeof value === "object") {
1050 const id = seen.get(value);
1051 if (id !== void 0) {
1052 return `__object__:${id}`;
1053 }
1054 seen.set(value, nextId);
1055 nextId += 1;
1056 }
1057 return value;
1058 });
1059 return result ?? `__top__:${typeof input}`;
1060 } catch {
1061 return "__unserializable__";
1062 }
1063 }
1064
1065 // node_modules/@base-ui/utils/safeReact.mjs
1066 var React3 = __toESM(require_react(), 1);
1067 var SafeReact = {
1068 ...React3
1069 };
1070
1071 // node_modules/@base-ui/utils/useRefWithInit.mjs
1072 var React4 = __toESM(require_react(), 1);
1073 var UNINITIALIZED = {};
1074 function useRefWithInit(init2, initArg) {
1075 const ref = React4.useRef(UNINITIALIZED);
1076 if (ref.current === UNINITIALIZED) {
1077 ref.current = init2(initArg);
1078 }
1079 return ref;
1080 }
1081
1082 // node_modules/@base-ui/utils/useStableCallback.mjs
1083 var useInsertionEffect = SafeReact.useInsertionEffect;
1084 var useSafeInsertionEffect = (
1085 // React 17 doesn't have useInsertionEffect.
1086 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1087 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1088 );
1089 function useStableCallback(callback) {
1090 const stable = useRefWithInit(createStableCallback).current;
1091 stable.next = callback;
1092 useSafeInsertionEffect(stable.effect);
1093 return stable.trampoline;
1094 }
1095 function createStableCallback() {
1096 const stable = {
1097 next: void 0,
1098 callback: assertNotCalled,
1099 trampoline: (...args) => stable.callback?.(...args),
1100 effect: () => {
1101 stable.callback = stable.next;
1102 }
1103 };
1104 return stable;
1105 }
1106 function assertNotCalled() {
1107 if (true) {
1108 throw (
1109 /* minify-error-disabled */
1110 new Error("Base UI: Cannot call an event handler while rendering.")
1111 );
1112 }
1113 }
1114
1115 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1116 var React5 = __toESM(require_react(), 1);
1117 var noop = () => {
1118 };
1119 var useIsoLayoutEffect = typeof document !== "undefined" ? React5.useLayoutEffect : noop;
1120
1121 // node_modules/@base-ui/utils/warn.mjs
1122 var set2;
1123 if (true) {
1124 set2 = /* @__PURE__ */ new Set();
1125 }
1126 function warn(...messages) {
1127 if (true) {
1128 const messageKey = messages.join(" ");
1129 if (!set2.has(messageKey)) {
1130 set2.add(messageKey);
1131 console.warn(`Base UI: ${messageKey}`);
1132 }
1133 }
1134 }
1135
1136 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1137 var React6 = __toESM(require_react(), 1);
1138 var DirectionContext = /* @__PURE__ */ React6.createContext(void 0);
1139 if (true) DirectionContext.displayName = "DirectionContext";
1140 function useDirection() {
1141 const context = React6.useContext(DirectionContext);
1142 return context?.direction ?? "ltr";
1143 }
1144
1145 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1146 var React9 = __toESM(require_react(), 1);
1147
1148 // node_modules/@base-ui/utils/useMergedRefs.mjs
1149 function useMergedRefs(a2, b2, c2, d2) {
1150 const forkRef = useRefWithInit(createForkRef).current;
1151 if (didChange(forkRef, a2, b2, c2, d2)) {
1152 update(forkRef, [a2, b2, c2, d2]);
1153 }
1154 return forkRef.callback;
1155 }
1156 function useMergedRefsN(refs) {
1157 const forkRef = useRefWithInit(createForkRef).current;
1158 if (didChangeN(forkRef, refs)) {
1159 update(forkRef, refs);
1160 }
1161 return forkRef.callback;
1162 }
1163 function createForkRef() {
1164 return {
1165 callback: null,
1166 cleanup: null,
1167 refs: []
1168 };
1169 }
1170 function didChange(forkRef, a2, b2, c2, d2) {
1171 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1172 }
1173 function didChangeN(forkRef, newRefs) {
1174 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1175 }
1176 function update(forkRef, refs) {
1177 forkRef.refs = refs;
1178 if (refs.every((ref) => ref == null)) {
1179 forkRef.callback = null;
1180 return;
1181 }
1182 forkRef.callback = (instance) => {
1183 if (forkRef.cleanup) {
1184 forkRef.cleanup();
1185 forkRef.cleanup = null;
1186 }
1187 if (instance != null) {
1188 const cleanupCallbacks = Array(refs.length).fill(null);
1189 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1190 const ref = refs[i2];
1191 if (ref == null) {
1192 continue;
1193 }
1194 switch (typeof ref) {
1195 case "function": {
1196 const refCleanup = ref(instance);
1197 if (typeof refCleanup === "function") {
1198 cleanupCallbacks[i2] = refCleanup;
1199 }
1200 break;
1201 }
1202 case "object": {
1203 ref.current = instance;
1204 break;
1205 }
1206 default:
1207 }
1208 }
1209 forkRef.cleanup = () => {
1210 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1211 const ref = refs[i2];
1212 if (ref == null) {
1213 continue;
1214 }
1215 switch (typeof ref) {
1216 case "function": {
1217 const cleanupCallback = cleanupCallbacks[i2];
1218 if (typeof cleanupCallback === "function") {
1219 cleanupCallback();
1220 } else {
1221 ref(null);
1222 }
1223 break;
1224 }
1225 case "object": {
1226 ref.current = null;
1227 break;
1228 }
1229 default:
1230 }
1231 }
1232 };
1233 }
1234 };
1235 }
1236
1237 // node_modules/@base-ui/utils/getReactElementRef.mjs
1238 var React8 = __toESM(require_react(), 1);
1239
1240 // node_modules/@base-ui/utils/reactVersion.mjs
1241 var React7 = __toESM(require_react(), 1);
1242 var majorVersion = parseInt(React7.version, 10);
1243 function isReactVersionAtLeast(reactVersionToCheck) {
1244 return majorVersion >= reactVersionToCheck;
1245 }
1246
1247 // node_modules/@base-ui/utils/getReactElementRef.mjs
1248 function getReactElementRef(element) {
1249 if (!/* @__PURE__ */ React8.isValidElement(element)) {
1250 return null;
1251 }
1252 const reactElement = element;
1253 const propsWithRef = reactElement.props;
1254 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1255 }
1256
1257 // node_modules/@base-ui/utils/mergeObjects.mjs
1258 function mergeObjects(a2, b2) {
1259 if (a2 && !b2) {
1260 return a2;
1261 }
1262 if (!a2 && b2) {
1263 return b2;
1264 }
1265 if (a2 || b2) {
1266 return {
1267 ...a2,
1268 ...b2
1269 };
1270 }
1271 return void 0;
1272 }
1273
1274 // node_modules/@base-ui/utils/empty.mjs
1275 function NOOP() {
1276 }
1277 var EMPTY_ARRAY = Object.freeze([]);
1278 var EMPTY_OBJECT = Object.freeze({});
1279
1280 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1281 function getStateAttributesProps(state, customMapping) {
1282 const props = {};
1283 for (const key in state) {
1284 const value = state[key];
1285 if (customMapping?.hasOwnProperty(key)) {
1286 const customProps = customMapping[key](value);
1287 if (customProps != null) {
1288 Object.assign(props, customProps);
1289 }
1290 continue;
1291 }
1292 if (value === true) {
1293 props[`data-${key.toLowerCase()}`] = "";
1294 } else if (value) {
1295 props[`data-${key.toLowerCase()}`] = value.toString();
1296 }
1297 }
1298 return props;
1299 }
1300
1301 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1302 function resolveClassName(className, state) {
1303 return typeof className === "function" ? className(state) : className;
1304 }
1305
1306 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1307 function resolveStyle(style, state) {
1308 return typeof style === "function" ? style(state) : style;
1309 }
1310
1311 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1312 var EMPTY_PROPS = {};
1313 function mergeProps(a2, b2, c2, d2, e2) {
1314 if (!c2 && !d2 && !e2 && !a2) {
1315 return createInitialMergedProps(b2);
1316 }
1317 let merged = createInitialMergedProps(a2);
1318 if (b2) {
1319 merged = mergeInto(merged, b2);
1320 }
1321 if (c2) {
1322 merged = mergeInto(merged, c2);
1323 }
1324 if (d2) {
1325 merged = mergeInto(merged, d2);
1326 }
1327 if (e2) {
1328 merged = mergeInto(merged, e2);
1329 }
1330 return merged;
1331 }
1332 function mergePropsN(props) {
1333 if (props.length === 0) {
1334 return EMPTY_PROPS;
1335 }
1336 if (props.length === 1) {
1337 return createInitialMergedProps(props[0]);
1338 }
1339 let merged = createInitialMergedProps(props[0]);
1340 for (let i2 = 1; i2 < props.length; i2 += 1) {
1341 merged = mergeInto(merged, props[i2]);
1342 }
1343 return merged;
1344 }
1345 function createInitialMergedProps(inputProps) {
1346 if (isPropsGetter(inputProps)) {
1347 return {
1348 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1349 };
1350 }
1351 return copyInitialProps(inputProps);
1352 }
1353 function mergeInto(merged, inputProps) {
1354 if (isPropsGetter(inputProps)) {
1355 return resolvePropsGetter(inputProps, merged);
1356 }
1357 return mutablyMergeInto(merged, inputProps);
1358 }
1359 function copyInitialProps(inputProps) {
1360 const copiedProps = {
1361 ...inputProps
1362 };
1363 for (const propName in copiedProps) {
1364 const propValue = copiedProps[propName];
1365 if (isEventHandler(propName, propValue)) {
1366 copiedProps[propName] = wrapEventHandler(propValue);
1367 }
1368 }
1369 return copiedProps;
1370 }
1371 function mutablyMergeInto(mergedProps, externalProps) {
1372 if (!externalProps) {
1373 return mergedProps;
1374 }
1375 for (const propName in externalProps) {
1376 const externalPropValue = externalProps[propName];
1377 switch (propName) {
1378 case "style": {
1379 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1380 break;
1381 }
1382 case "className": {
1383 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1384 break;
1385 }
1386 default: {
1387 if (isEventHandler(propName, externalPropValue)) {
1388 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1389 } else {
1390 mergedProps[propName] = externalPropValue;
1391 }
1392 }
1393 }
1394 }
1395 return mergedProps;
1396 }
1397 function isEventHandler(key, value) {
1398 const code0 = key.charCodeAt(0);
1399 const code1 = key.charCodeAt(1);
1400 const code2 = key.charCodeAt(2);
1401 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1402 }
1403 function isPropsGetter(inputProps) {
1404 return typeof inputProps === "function";
1405 }
1406 function resolvePropsGetter(inputProps, previousProps) {
1407 if (isPropsGetter(inputProps)) {
1408 return inputProps(previousProps);
1409 }
1410 return inputProps ?? EMPTY_PROPS;
1411 }
1412 function mergeEventHandlers(ourHandler, theirHandler) {
1413 if (!theirHandler) {
1414 return ourHandler;
1415 }
1416 if (!ourHandler) {
1417 return wrapEventHandler(theirHandler);
1418 }
1419 return (...args) => {
1420 const event = args[0];
1421 if (isSyntheticEvent(event)) {
1422 const baseUIEvent = event;
1423 makeEventPreventable(baseUIEvent);
1424 const result2 = theirHandler(...args);
1425 if (!baseUIEvent.baseUIHandlerPrevented) {
1426 ourHandler?.(...args);
1427 }
1428 return result2;
1429 }
1430 const result = theirHandler(...args);
1431 ourHandler?.(...args);
1432 return result;
1433 };
1434 }
1435 function wrapEventHandler(handler) {
1436 if (!handler) {
1437 return handler;
1438 }
1439 return (...args) => {
1440 const event = args[0];
1441 if (isSyntheticEvent(event)) {
1442 makeEventPreventable(event);
1443 }
1444 return handler(...args);
1445 };
1446 }
1447 function makeEventPreventable(event) {
1448 event.preventBaseUIHandler = () => {
1449 event.baseUIHandlerPrevented = true;
1450 };
1451 return event;
1452 }
1453 function mergeClassNames(ourClassName, theirClassName) {
1454 if (theirClassName) {
1455 if (ourClassName) {
1456 return theirClassName + " " + ourClassName;
1457 }
1458 return theirClassName;
1459 }
1460 return ourClassName;
1461 }
1462 function isSyntheticEvent(event) {
1463 return event != null && typeof event === "object" && "nativeEvent" in event;
1464 }
1465
1466 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1467 var import_react = __toESM(require_react(), 1);
1468 function useRenderElement(element, componentProps, params = {}) {
1469 const renderProp = componentProps.render;
1470 const outProps = useRenderElementProps(componentProps, params);
1471 if (params.enabled === false) {
1472 return null;
1473 }
1474 const state = params.state ?? EMPTY_OBJECT;
1475 return evaluateRenderProp(element, renderProp, outProps, state);
1476 }
1477 function useRenderElementProps(componentProps, params = {}) {
1478 const {
1479 className: classNameProp,
1480 style: styleProp,
1481 render: renderProp
1482 } = componentProps;
1483 const {
1484 state = EMPTY_OBJECT,
1485 ref,
1486 props,
1487 stateAttributesMapping: stateAttributesMapping4,
1488 enabled = true
1489 } = params;
1490 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1491 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1492 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT;
1493 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1494 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1495 if (typeof document !== "undefined") {
1496 if (!enabled) {
1497 useMergedRefs(null, null);
1498 } else if (Array.isArray(ref)) {
1499 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1500 } else {
1501 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1502 }
1503 }
1504 if (!enabled) {
1505 return EMPTY_OBJECT;
1506 }
1507 if (className !== void 0) {
1508 outProps.className = mergeClassNames(outProps.className, className);
1509 }
1510 if (style !== void 0) {
1511 outProps.style = mergeObjects(outProps.style, style);
1512 }
1513 return outProps;
1514 }
1515 function resolveRenderFunctionProps(props) {
1516 if (Array.isArray(props)) {
1517 return mergePropsN(props);
1518 }
1519 return mergeProps(void 0, props);
1520 }
1521 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1522 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1523 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1524 function evaluateRenderProp(element, render4, props, state) {
1525 if (render4) {
1526 if (typeof render4 === "function") {
1527 if (true) {
1528 warnIfRenderPropLooksLikeComponent(render4);
1529 }
1530 return render4(props, state);
1531 }
1532 const mergedProps = mergeProps(props, render4.props);
1533 mergedProps.ref = props.ref;
1534 let newElement = render4;
1535 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1536 const children = React9.Children.toArray(render4);
1537 newElement = children[0];
1538 }
1539 if (true) {
1540 if (!/* @__PURE__ */ React9.isValidElement(newElement)) {
1541 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"));
1542 }
1543 }
1544 return /* @__PURE__ */ React9.cloneElement(newElement, mergedProps);
1545 }
1546 if (element) {
1547 if (typeof element === "string") {
1548 return renderTag(element, props);
1549 }
1550 }
1551 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1552 }
1553 function warnIfRenderPropLooksLikeComponent(renderFn) {
1554 const functionName = renderFn.name;
1555 if (functionName.length === 0) {
1556 return;
1557 }
1558 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1559 return;
1560 }
1561 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1562 return;
1563 }
1564 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");
1565 }
1566 function renderTag(Tag, props) {
1567 if (Tag === "button") {
1568 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1569 type: "button",
1570 ...props,
1571 key: props.key
1572 });
1573 }
1574 if (Tag === "img") {
1575 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1576 alt: "",
1577 ...props,
1578 key: props.key
1579 });
1580 }
1581 return /* @__PURE__ */ React9.createElement(Tag, props);
1582 }
1583
1584 // node_modules/@base-ui/utils/useId.mjs
1585 var React10 = __toESM(require_react(), 1);
1586 var globalId = 0;
1587 function useGlobalId(idOverride, prefix = "mui") {
1588 const [defaultId, setDefaultId] = React10.useState(idOverride);
1589 const id = idOverride || defaultId;
1590 React10.useEffect(() => {
1591 if (defaultId == null) {
1592 globalId += 1;
1593 setDefaultId(`${prefix}-${globalId}`);
1594 }
1595 }, [defaultId, prefix]);
1596 return id;
1597 }
1598 var maybeReactUseId = SafeReact.useId;
1599 function useId(idOverride, prefix) {
1600 if (maybeReactUseId !== void 0) {
1601 const reactId = maybeReactUseId();
1602 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1603 }
1604 return useGlobalId(idOverride, prefix);
1605 }
1606
1607 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1608 function useBaseUiId(idOverride) {
1609 return useId(idOverride, "base-ui");
1610 }
1611
1612 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1613 var React13 = __toESM(require_react(), 1);
1614
1615 // node_modules/@base-ui/react/internals/reason-parts.mjs
1616 var reason_parts_exports = {};
1617 __export(reason_parts_exports, {
1618 cancelOpen: () => cancelOpen,
1619 chipRemovePress: () => chipRemovePress,
1620 clearPress: () => clearPress,
1621 closePress: () => closePress,
1622 closeWatcher: () => closeWatcher,
1623 decrementPress: () => decrementPress,
1624 disabled: () => disabled,
1625 drag: () => drag,
1626 escapeKey: () => escapeKey,
1627 focusOut: () => focusOut,
1628 imperativeAction: () => imperativeAction,
1629 incrementPress: () => incrementPress,
1630 initial: () => initial,
1631 inputBlur: () => inputBlur,
1632 inputChange: () => inputChange,
1633 inputClear: () => inputClear,
1634 inputPaste: () => inputPaste,
1635 inputPress: () => inputPress,
1636 itemPress: () => itemPress,
1637 keyboard: () => keyboard,
1638 linkPress: () => linkPress,
1639 listNavigation: () => listNavigation,
1640 missing: () => missing,
1641 none: () => none,
1642 outsidePress: () => outsidePress,
1643 pointer: () => pointer,
1644 scrub: () => scrub,
1645 siblingOpen: () => siblingOpen,
1646 swipe: () => swipe,
1647 trackPress: () => trackPress,
1648 triggerFocus: () => triggerFocus,
1649 triggerHover: () => triggerHover,
1650 triggerPress: () => triggerPress,
1651 wheel: () => wheel,
1652 windowResize: () => windowResize
1653 });
1654 var none = "none";
1655 var triggerPress = "trigger-press";
1656 var triggerHover = "trigger-hover";
1657 var triggerFocus = "trigger-focus";
1658 var outsidePress = "outside-press";
1659 var itemPress = "item-press";
1660 var closePress = "close-press";
1661 var linkPress = "link-press";
1662 var clearPress = "clear-press";
1663 var chipRemovePress = "chip-remove-press";
1664 var trackPress = "track-press";
1665 var incrementPress = "increment-press";
1666 var decrementPress = "decrement-press";
1667 var inputChange = "input-change";
1668 var inputClear = "input-clear";
1669 var inputBlur = "input-blur";
1670 var inputPaste = "input-paste";
1671 var inputPress = "input-press";
1672 var focusOut = "focus-out";
1673 var escapeKey = "escape-key";
1674 var closeWatcher = "close-watcher";
1675 var listNavigation = "list-navigation";
1676 var keyboard = "keyboard";
1677 var pointer = "pointer";
1678 var drag = "drag";
1679 var wheel = "wheel";
1680 var scrub = "scrub";
1681 var cancelOpen = "cancel-open";
1682 var siblingOpen = "sibling-open";
1683 var disabled = "disabled";
1684 var missing = "missing";
1685 var initial = "initial";
1686 var imperativeAction = "imperative-action";
1687 var swipe = "swipe";
1688 var windowResize = "window-resize";
1689
1690 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1691 function createChangeEventDetails(reason, event, trigger, customProperties) {
1692 let canceled = false;
1693 let allowPropagation = false;
1694 const custom = customProperties ?? EMPTY_OBJECT;
1695 const details = {
1696 reason,
1697 event: event ?? new Event("base-ui"),
1698 cancel() {
1699 canceled = true;
1700 },
1701 allowPropagation() {
1702 allowPropagation = true;
1703 },
1704 get isCanceled() {
1705 return canceled;
1706 },
1707 get isPropagationAllowed() {
1708 return allowPropagation;
1709 },
1710 trigger,
1711 ...custom
1712 };
1713 return details;
1714 }
1715
1716 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1717 var React12 = __toESM(require_react(), 1);
1718
1719 // node_modules/@base-ui/utils/useOnMount.mjs
1720 var React11 = __toESM(require_react(), 1);
1721 var EMPTY = [];
1722 function useOnMount(fn) {
1723 React11.useEffect(fn, EMPTY);
1724 }
1725
1726 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1727 var EMPTY2 = null;
1728 var LAST_RAF = globalThis.requestAnimationFrame;
1729 var Scheduler = class {
1730 /* This implementation uses an array as a backing data-structure for frame callbacks.
1731 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1732 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1733 * be much more efficient if there is a call pattern that alterns as
1734 * "request-cancel-request-cancel-…".
1735 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1736 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1737 callbacks = [];
1738 callbacksCount = 0;
1739 nextId = 1;
1740 startId = 1;
1741 isScheduled = false;
1742 tick = (timestamp) => {
1743 this.isScheduled = false;
1744 const currentCallbacks = this.callbacks;
1745 const currentCallbacksCount = this.callbacksCount;
1746 this.callbacks = [];
1747 this.callbacksCount = 0;
1748 this.startId = this.nextId;
1749 if (currentCallbacksCount > 0) {
1750 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1751 currentCallbacks[i2]?.(timestamp);
1752 }
1753 }
1754 };
1755 request(fn) {
1756 const id = this.nextId;
1757 this.nextId += 1;
1758 this.callbacks.push(fn);
1759 this.callbacksCount += 1;
1760 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1761 if (!this.isScheduled || didRAFChange) {
1762 requestAnimationFrame(this.tick);
1763 this.isScheduled = true;
1764 }
1765 return id;
1766 }
1767 cancel(id) {
1768 const index2 = id - this.startId;
1769 if (index2 < 0 || index2 >= this.callbacks.length) {
1770 return;
1771 }
1772 this.callbacks[index2] = null;
1773 this.callbacksCount -= 1;
1774 }
1775 };
1776 var scheduler = new Scheduler();
1777 var AnimationFrame = class _AnimationFrame {
1778 static create() {
1779 return new _AnimationFrame();
1780 }
1781 static request(fn) {
1782 return scheduler.request(fn);
1783 }
1784 static cancel(id) {
1785 return scheduler.cancel(id);
1786 }
1787 currentId = EMPTY2;
1788 /**
1789 * Executes `fn` after `delay`, clearing any previously scheduled call.
1790 */
1791 request(fn) {
1792 this.cancel();
1793 this.currentId = scheduler.request(() => {
1794 this.currentId = EMPTY2;
1795 fn();
1796 });
1797 }
1798 cancel = () => {
1799 if (this.currentId !== EMPTY2) {
1800 scheduler.cancel(this.currentId);
1801 this.currentId = EMPTY2;
1802 }
1803 };
1804 disposeEffect = () => {
1805 return this.cancel;
1806 };
1807 };
1808 function useAnimationFrame() {
1809 const timeout = useRefWithInit(AnimationFrame.create).current;
1810 useOnMount(timeout.disposeEffect);
1811 return timeout;
1812 }
1813
1814 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1815 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1816 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
1817 const [mounted, setMounted] = React12.useState(open);
1818 if (open && !mounted) {
1819 setMounted(true);
1820 setTransitionStatus("starting");
1821 }
1822 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1823 setTransitionStatus("ending");
1824 }
1825 if (!open && !mounted && transitionStatus === "ending") {
1826 setTransitionStatus(void 0);
1827 }
1828 useIsoLayoutEffect(() => {
1829 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1830 const frame = AnimationFrame.request(() => {
1831 setTransitionStatus("ending");
1832 });
1833 return () => {
1834 AnimationFrame.cancel(frame);
1835 };
1836 }
1837 return void 0;
1838 }, [open, mounted, transitionStatus, deferEndingState]);
1839 useIsoLayoutEffect(() => {
1840 if (!open || enableIdleState) {
1841 return void 0;
1842 }
1843 const frame = AnimationFrame.request(() => {
1844 setTransitionStatus(void 0);
1845 });
1846 return () => {
1847 AnimationFrame.cancel(frame);
1848 };
1849 }, [enableIdleState, open]);
1850 useIsoLayoutEffect(() => {
1851 if (!open || !enableIdleState) {
1852 return void 0;
1853 }
1854 if (open && mounted && transitionStatus !== "idle") {
1855 setTransitionStatus("starting");
1856 }
1857 const frame = AnimationFrame.request(() => {
1858 setTransitionStatus("idle");
1859 });
1860 return () => {
1861 AnimationFrame.cancel(frame);
1862 };
1863 }, [enableIdleState, open, mounted, transitionStatus]);
1864 return {
1865 mounted,
1866 setMounted,
1867 transitionStatus
1868 };
1869 }
1870
1871 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1872 function useCollapsibleRoot(parameters) {
1873 const {
1874 open: openParam,
1875 defaultOpen,
1876 onOpenChange,
1877 disabled: disabled2
1878 } = parameters;
1879 const [open, setOpen] = useControlled({
1880 controlled: openParam,
1881 default: defaultOpen,
1882 name: "Collapsible",
1883 state: "open"
1884 });
1885 const {
1886 mounted,
1887 setMounted,
1888 transitionStatus
1889 } = useTransitionStatus(open, true, true);
1890 const defaultPanelId = useBaseUiId();
1891 const [panelIdState, setPanelIdState] = React13.useState();
1892 const panelId = panelIdState ?? defaultPanelId;
1893 const handleTrigger = useStableCallback((event) => {
1894 const nextOpen = !open;
1895 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1896 onOpenChange(nextOpen, eventDetails);
1897 if (eventDetails.isCanceled) {
1898 return;
1899 }
1900 setOpen(nextOpen);
1901 });
1902 return React13.useMemo(() => ({
1903 disabled: disabled2,
1904 handleTrigger,
1905 mounted,
1906 open,
1907 panelId,
1908 setMounted,
1909 setOpen,
1910 setPanelIdState,
1911 transitionStatus
1912 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1913 }
1914
1915 // node_modules/@base-ui/react/collapsible/root/CollapsibleRootContext.mjs
1916 var React14 = __toESM(require_react(), 1);
1917 var CollapsibleRootContext = /* @__PURE__ */ React14.createContext(void 0);
1918 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1919 function useCollapsibleRootContext() {
1920 const context = React14.useContext(CollapsibleRootContext);
1921 if (context === void 0) {
1922 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1923 }
1924 return context;
1925 }
1926
1927 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
1928 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1929 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1930 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1931 return TransitionStatusDataAttributes2;
1932 })({});
1933 var STARTING_HOOK = {
1934 [TransitionStatusDataAttributes.startingStyle]: ""
1935 };
1936 var ENDING_HOOK = {
1937 [TransitionStatusDataAttributes.endingStyle]: ""
1938 };
1939 var transitionStatusMapping = {
1940 transitionStatus(value) {
1941 if (value === "starting") {
1942 return STARTING_HOOK;
1943 }
1944 if (value === "ending") {
1945 return ENDING_HOOK;
1946 }
1947 return null;
1948 }
1949 };
1950
1951 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelDataAttributes.mjs
1952 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1953 CollapsiblePanelDataAttributes2["open"] = "data-open";
1954 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1955 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1956 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1957 return CollapsiblePanelDataAttributes2;
1958 })({});
1959
1960 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTriggerDataAttributes.mjs
1961 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1962 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1963 return CollapsibleTriggerDataAttributes2;
1964 })({});
1965
1966 // node_modules/@base-ui/react/utils/collapsibleOpenStateMapping.mjs
1967 var PANEL_OPEN_HOOK = {
1968 [CollapsiblePanelDataAttributes.open]: ""
1969 };
1970 var PANEL_CLOSED_HOOK = {
1971 [CollapsiblePanelDataAttributes.closed]: ""
1972 };
1973 var triggerOpenStateMapping = {
1974 open(value) {
1975 if (value) {
1976 return {
1977 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1978 };
1979 }
1980 return null;
1981 }
1982 };
1983 var collapsibleOpenStateMapping = {
1984 open(value) {
1985 if (value) {
1986 return PANEL_OPEN_HOOK;
1987 }
1988 return PANEL_CLOSED_HOOK;
1989 }
1990 };
1991
1992 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
1993 var React17 = __toESM(require_react(), 1);
1994
1995 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1996 function hasWindow() {
1997 return typeof window !== "undefined";
1998 }
1999 function getNodeName(node) {
2000 if (isNode(node)) {
2001 return (node.nodeName || "").toLowerCase();
2002 }
2003 return "#document";
2004 }
2005 function getWindow(node) {
2006 var _node$ownerDocument;
2007 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2008 }
2009 function getDocumentElement(node) {
2010 var _ref;
2011 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2012 }
2013 function isNode(value) {
2014 if (!hasWindow()) {
2015 return false;
2016 }
2017 return value instanceof Node || value instanceof getWindow(value).Node;
2018 }
2019 function isElement(value) {
2020 if (!hasWindow()) {
2021 return false;
2022 }
2023 return value instanceof Element || value instanceof getWindow(value).Element;
2024 }
2025 function isHTMLElement(value) {
2026 if (!hasWindow()) {
2027 return false;
2028 }
2029 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2030 }
2031 function isShadowRoot(value) {
2032 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2033 return false;
2034 }
2035 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2036 }
2037 function isOverflowElement(element) {
2038 const {
2039 overflow,
2040 overflowX,
2041 overflowY,
2042 display
2043 } = getComputedStyle2(element);
2044 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2045 }
2046 function isTableElement(element) {
2047 return /^(table|td|th)$/.test(getNodeName(element));
2048 }
2049 function isTopLayer(element) {
2050 try {
2051 if (element.matches(":popover-open")) {
2052 return true;
2053 }
2054 } catch (_e) {
2055 }
2056 try {
2057 return element.matches(":modal");
2058 } catch (_e) {
2059 return false;
2060 }
2061 }
2062 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2063 var containRe = /paint|layout|strict|content/;
2064 var isNotNone = (value) => !!value && value !== "none";
2065 var isWebKitValue;
2066 function isContainingBlock(elementOrCss) {
2067 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2068 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 || "");
2069 }
2070 function getContainingBlock(element) {
2071 let currentNode = getParentNode(element);
2072 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2073 if (isContainingBlock(currentNode)) {
2074 return currentNode;
2075 } else if (isTopLayer(currentNode)) {
2076 return null;
2077 }
2078 currentNode = getParentNode(currentNode);
2079 }
2080 return null;
2081 }
2082 function isWebKit() {
2083 if (isWebKitValue == null) {
2084 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2085 }
2086 return isWebKitValue;
2087 }
2088 function isLastTraversableNode(node) {
2089 return /^(html|body|#document)$/.test(getNodeName(node));
2090 }
2091 function getComputedStyle2(element) {
2092 return getWindow(element).getComputedStyle(element);
2093 }
2094 function getNodeScroll(element) {
2095 if (isElement(element)) {
2096 return {
2097 scrollLeft: element.scrollLeft,
2098 scrollTop: element.scrollTop
2099 };
2100 }
2101 return {
2102 scrollLeft: element.scrollX,
2103 scrollTop: element.scrollY
2104 };
2105 }
2106 function getParentNode(node) {
2107 if (getNodeName(node) === "html") {
2108 return node;
2109 }
2110 const result = (
2111 // Step into the shadow DOM of the parent of a slotted node.
2112 node.assignedSlot || // DOM Element detected.
2113 node.parentNode || // ShadowRoot detected.
2114 isShadowRoot(node) && node.host || // Fallback.
2115 getDocumentElement(node)
2116 );
2117 return isShadowRoot(result) ? result.host : result;
2118 }
2119 function getNearestOverflowAncestor(node) {
2120 const parentNode = getParentNode(node);
2121 if (isLastTraversableNode(parentNode)) {
2122 return node.ownerDocument ? node.ownerDocument.body : node.body;
2123 }
2124 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2125 return parentNode;
2126 }
2127 return getNearestOverflowAncestor(parentNode);
2128 }
2129 function getOverflowAncestors(node, list, traverseIframes) {
2130 var _node$ownerDocument2;
2131 if (list === void 0) {
2132 list = [];
2133 }
2134 if (traverseIframes === void 0) {
2135 traverseIframes = true;
2136 }
2137 const scrollableAncestor = getNearestOverflowAncestor(node);
2138 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2139 const win = getWindow(scrollableAncestor);
2140 if (isBody) {
2141 const frameElement = getFrameElement(win);
2142 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2143 } else {
2144 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2145 }
2146 }
2147 function getFrameElement(win) {
2148 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2149 }
2150
2151 // node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs
2152 var React15 = __toESM(require_react(), 1);
2153 var CompositeRootContext = /* @__PURE__ */ React15.createContext(void 0);
2154 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2155 function useCompositeRootContext(optional = false) {
2156 const context = React15.useContext(CompositeRootContext);
2157 if (context === void 0 && !optional) {
2158 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2159 }
2160 return context;
2161 }
2162
2163 // node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs
2164 var React16 = __toESM(require_react(), 1);
2165 function useFocusableWhenDisabled(parameters) {
2166 const {
2167 focusableWhenDisabled,
2168 disabled: disabled2,
2169 composite = false,
2170 tabIndex: tabIndexProp = 0,
2171 isNativeButton
2172 } = parameters;
2173 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2174 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2175 const props = React16.useMemo(() => {
2176 const additionalProps = {
2177 // allow Tabbing away from focusableWhenDisabled elements
2178 onKeyDown(event) {
2179 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2180 event.preventDefault();
2181 }
2182 }
2183 };
2184 if (!composite) {
2185 additionalProps.tabIndex = tabIndexProp;
2186 if (!isNativeButton && disabled2) {
2187 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2188 }
2189 }
2190 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2191 additionalProps["aria-disabled"] = disabled2;
2192 }
2193 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2194 additionalProps.disabled = disabled2;
2195 }
2196 return additionalProps;
2197 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2198 return {
2199 props
2200 };
2201 }
2202
2203 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
2204 function useButton(parameters = {}) {
2205 const {
2206 disabled: disabled2 = false,
2207 focusableWhenDisabled,
2208 tabIndex = 0,
2209 native: isNativeButton = true,
2210 composite: compositeProp
2211 } = parameters;
2212 const elementRef = React17.useRef(null);
2213 const compositeRootContext = useCompositeRootContext(true);
2214 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2215 const {
2216 props: focusableWhenDisabledProps
2217 } = useFocusableWhenDisabled({
2218 focusableWhenDisabled,
2219 disabled: disabled2,
2220 composite: isCompositeItem,
2221 tabIndex,
2222 isNativeButton
2223 });
2224 if (true) {
2225 React17.useEffect(() => {
2226 if (!elementRef.current) {
2227 return;
2228 }
2229 const isButtonTag = isButtonElement(elementRef.current);
2230 if (isNativeButton) {
2231 if (!isButtonTag) {
2232 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2233 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
2234 error(`${message2}${ownerStackMessage}`);
2235 }
2236 } else if (isButtonTag) {
2237 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2238 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
2239 error(`${message2}${ownerStackMessage}`);
2240 }
2241 }, [isNativeButton]);
2242 }
2243 const updateDisabled = React17.useCallback(() => {
2244 const element = elementRef.current;
2245 if (!isButtonElement(element)) {
2246 return;
2247 }
2248 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2249 element.disabled = false;
2250 }
2251 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2252 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2253 const getButtonProps = React17.useCallback((externalProps = {}) => {
2254 const {
2255 onClick: externalOnClick,
2256 onMouseDown: externalOnMouseDown,
2257 onKeyUp: externalOnKeyUp,
2258 onKeyDown: externalOnKeyDown,
2259 onPointerDown: externalOnPointerDown,
2260 ...otherExternalProps
2261 } = externalProps;
2262 return mergeProps({
2263 onClick(event) {
2264 if (disabled2) {
2265 event.preventDefault();
2266 return;
2267 }
2268 externalOnClick?.(event);
2269 },
2270 onMouseDown(event) {
2271 if (!disabled2) {
2272 externalOnMouseDown?.(event);
2273 }
2274 },
2275 onKeyDown(event) {
2276 if (disabled2) {
2277 return;
2278 }
2279 makeEventPreventable(event);
2280 externalOnKeyDown?.(event);
2281 if (event.baseUIHandlerPrevented) {
2282 return;
2283 }
2284 const isCurrentTarget = event.target === event.currentTarget;
2285 const currentTarget = event.currentTarget;
2286 const isButton2 = isButtonElement(currentTarget);
2287 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2288 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2289 const isEnterKey = event.key === "Enter";
2290 const isSpaceKey = event.key === " ";
2291 const role = currentTarget.getAttribute("role");
2292 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2293 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2294 if (event.defaultPrevented && isTextNavigationRole) {
2295 return;
2296 }
2297 event.preventDefault();
2298 if (isLink || isNativeButton && isButton2) {
2299 currentTarget.click();
2300 event.preventBaseUIHandler();
2301 } else if (shouldClick) {
2302 externalOnClick?.(event);
2303 event.preventBaseUIHandler();
2304 }
2305 return;
2306 }
2307 if (shouldClick) {
2308 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2309 event.preventDefault();
2310 }
2311 if (!isNativeButton && isEnterKey) {
2312 externalOnClick?.(event);
2313 }
2314 }
2315 },
2316 onKeyUp(event) {
2317 if (disabled2) {
2318 return;
2319 }
2320 makeEventPreventable(event);
2321 externalOnKeyUp?.(event);
2322 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2323 event.preventDefault();
2324 return;
2325 }
2326 if (event.baseUIHandlerPrevented) {
2327 return;
2328 }
2329 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2330 externalOnClick?.(event);
2331 }
2332 },
2333 onPointerDown(event) {
2334 if (disabled2) {
2335 event.preventDefault();
2336 return;
2337 }
2338 externalOnPointerDown?.(event);
2339 }
2340 }, isNativeButton ? {
2341 type: "button"
2342 } : {
2343 role: "button"
2344 }, focusableWhenDisabledProps, otherExternalProps);
2345 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2346 const buttonRef = useStableCallback((element) => {
2347 elementRef.current = element;
2348 updateDisabled();
2349 });
2350 return {
2351 getButtonProps,
2352 buttonRef
2353 };
2354 }
2355 function isButtonElement(elem) {
2356 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2357 }
2358 function isValidLinkElement(elem) {
2359 return Boolean(elem?.tagName === "A" && elem?.href);
2360 }
2361
2362 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2363 var React19 = __toESM(require_react(), 1);
2364
2365 // node_modules/@base-ui/utils/addEventListener.mjs
2366 function addEventListener(target, type, listener, options) {
2367 target.addEventListener(type, listener, options);
2368 return () => {
2369 target.removeEventListener(type, listener, options);
2370 };
2371 }
2372
2373 // node_modules/@base-ui/utils/useValueAsRef.mjs
2374 function useValueAsRef(value) {
2375 const latest = useRefWithInit(createLatestRef, value).current;
2376 latest.next = value;
2377 useIsoLayoutEffect(latest.effect);
2378 return latest;
2379 }
2380 function createLatestRef(value) {
2381 const latest = {
2382 current: value,
2383 next: value,
2384 effect: () => {
2385 latest.current = latest.next;
2386 }
2387 };
2388 return latest;
2389 }
2390
2391 // node_modules/@base-ui/utils/owner.mjs
2392 function ownerDocument(node) {
2393 return node?.ownerDocument || document;
2394 }
2395
2396 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2397 var React18 = __toESM(require_react(), 1);
2398
2399 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2400 var ReactDOM = __toESM(require_react_dom(), 1);
2401
2402 // node_modules/@base-ui/react/utils/resolveRef.mjs
2403 function resolveRef(maybeRef) {
2404 if (maybeRef == null) {
2405 return maybeRef;
2406 }
2407 return "current" in maybeRef ? maybeRef.current : maybeRef;
2408 }
2409
2410 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2411 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2412 const frame = useAnimationFrame();
2413 return useStableCallback((fnToExecute, signal = null) => {
2414 frame.cancel();
2415 const element = resolveRef(elementOrRef);
2416 if (element == null) {
2417 return;
2418 }
2419 const resolvedElement = element;
2420 const done = () => {
2421 ReactDOM.flushSync(fnToExecute);
2422 };
2423 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2424 fnToExecute();
2425 return;
2426 }
2427 function exec() {
2428 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2429 if (!signal?.aborted) {
2430 done();
2431 }
2432 }).catch(() => {
2433 if (treatAbortedAsFinished) {
2434 if (!signal?.aborted) {
2435 done();
2436 }
2437 return;
2438 }
2439 const currentAnimations = resolvedElement.getAnimations();
2440 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2441 exec();
2442 }
2443 });
2444 }
2445 if (waitForStartingStyleRemoved) {
2446 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2447 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2448 frame.request(exec);
2449 return;
2450 }
2451 const attributeObserver = new MutationObserver(() => {
2452 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2453 attributeObserver.disconnect();
2454 exec();
2455 }
2456 });
2457 attributeObserver.observe(resolvedElement, {
2458 attributes: true,
2459 attributeFilter: [startingStyleAttribute]
2460 });
2461 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2462 once: true
2463 });
2464 return;
2465 }
2466 frame.request(exec);
2467 });
2468 }
2469
2470 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2471 function useOpenChangeComplete(parameters) {
2472 const {
2473 enabled = true,
2474 open,
2475 ref,
2476 onComplete: onCompleteParam
2477 } = parameters;
2478 const onComplete = useStableCallback(onCompleteParam);
2479 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2480 React18.useEffect(() => {
2481 if (!enabled) {
2482 return void 0;
2483 }
2484 const abortController = new AbortController();
2485 runOnceAnimationsFinish(onComplete, abortController.signal);
2486 return () => {
2487 abortController.abort();
2488 };
2489 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2490 }
2491
2492 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2493 var EMPTY_DIMENSIONS = {
2494 height: void 0,
2495 width: void 0
2496 };
2497 function useCollapsiblePanel(parameters) {
2498 const {
2499 externalRef,
2500 hiddenUntilFound,
2501 id: idParam,
2502 keepMounted,
2503 mounted,
2504 onOpenChange,
2505 open,
2506 setMounted,
2507 setOpen,
2508 transitionStatus
2509 } = parameters;
2510 const panelRef = React19.useRef(null);
2511 const animationTypeRef = React19.useRef(null);
2512 const [dimensions, setDimensionsUnwrapped] = React19.useState(EMPTY_DIMENSIONS);
2513 const lastMeasuredDimensionsRef = React19.useRef(EMPTY_DIMENSIONS);
2514 const shouldSkipNextOpenRef = React19.useRef(false);
2515 const shouldPreventMountAnimationRef = React19.useRef(open);
2516 const shouldPreventActivityResumeAnimationRef = React19.useRef(false);
2517 const [forcePanelIdle, setForcePanelIdle] = React19.useState(false);
2518 const pendingTemporaryStyleRestoreRef = React19.useRef(null);
2519 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
2520 const latestStateRef = useValueAsRef({
2521 mounted,
2522 open
2523 });
2524 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false);
2525 const hidden = !open && !mounted;
2526 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
2527 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed
2528 // layout/effect paths and gate one-shot motion suppression for the next open
2529 // lifecycle. They intentionally expose the last committed motion snapshot.
2530 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
2531 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed
2532 // animation mode and measurement. This fallback only restores a previously
2533 // measured pixel size after the live dimensions state has been reset back to `auto`.
2534 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
2535 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
2536 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
2537 if (shouldCacheMeasurement) {
2538 lastMeasuredDimensionsRef.current = nextDimensions;
2539 }
2540 setDimensionsUnwrapped(nextDimensions);
2541 });
2542 const restorePendingTemporaryStyle = useStableCallback(() => {
2543 pendingTemporaryStyleRestoreRef.current?.();
2544 pendingTemporaryStyleRestoreRef.current = null;
2545 });
2546 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
2547 restorePendingTemporaryStyle();
2548 pendingTemporaryStyleRestoreRef.current = () => {
2549 pendingTemporaryStyleRestoreRef.current = null;
2550 restore();
2551 };
2552 });
2553 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
2554 if (open && mounted && animationTypeRef.current === "css-animation") {
2555 shouldPreventActivityResumeAnimationRef.current = true;
2556 }
2557 });
2558 useIsoLayoutEffect(() => {
2559 if (!forcePanelIdle || transitionStatus === "starting") {
2560 return;
2561 }
2562 setForcePanelIdle(false);
2563 }, [forcePanelIdle, transitionStatus]);
2564 React19.useEffect(() => {
2565 return () => {
2566 markActivityResumeAnimationSuppressed();
2567 restorePendingTemporaryStyle();
2568 };
2569 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
2570 useIsoLayoutEffect(() => {
2571 const panel = panelRef.current;
2572 if (!panel) {
2573 return void 0;
2574 }
2575 if (!open && pendingTemporaryStyleRestoreRef.current) {
2576 restorePendingTemporaryStyle();
2577 }
2578 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
2579 animationTypeRef.current = animationType;
2580 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
2581 lastMeasuredDimensionsRef.current = getDimensions(panel);
2582 return void 0;
2583 }
2584 if (open && transitionStatus === "starting") {
2585 const skipNextOpen = shouldSkipNextOpenRef.current;
2586 shouldSkipNextOpenRef.current = false;
2587 if (animationType === "none") {
2588 setDimensions(getDimensions(panel));
2589 setForcePanelIdle(true);
2590 return void 0;
2591 }
2592 if (animationType === "css-transition") {
2593 const restoreLayoutStyles = resetLayoutStyles(panel);
2594 setDimensions(getDimensions(panel));
2595 if (!skipNextOpen) {
2596 return restoreLayoutStyles;
2597 }
2598 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
2599 setPendingTemporaryStyleRestore(restoreTransitionDuration);
2600 setForcePanelIdle(true);
2601 return restoreLayoutStyles;
2602 }
2603 if (animationType === "css-animation") {
2604 setDimensions(getDimensions(panel));
2605 if (!skipNextOpen) {
2606 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none");
2607 restoreAnimationName2();
2608 return void 0;
2609 }
2610 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2611 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
2612 restoreAnimationName();
2613 setPendingTemporaryStyleRestore(restoreAnimationDuration);
2614 setForcePanelIdle(true);
2615 return void 0;
2616 }
2617 }
2618 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
2619 shouldPreventMountAnimationRef.current = false;
2620 shouldPreventActivityResumeAnimationRef.current = false;
2621 if (animationType === "none") {
2622 setDimensions(EMPTY_DIMENSIONS, false);
2623 setMounted(false);
2624 return void 0;
2625 }
2626 setDimensions(getDimensions(panel));
2627 return void 0;
2628 }
2629 if (transitionStatus !== "ending") {
2630 return void 0;
2631 }
2632 if (animationType === "none") {
2633 setMounted(false);
2634 return void 0;
2635 }
2636 const nextDimensions = getDimensions(panel);
2637 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0;
2638 if (!hasMeasuredSize) {
2639 setMounted(false);
2640 return void 0;
2641 }
2642 setDimensions(nextDimensions);
2643 if (animationType === "css-animation") {
2644 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2645 restoreAnimationName();
2646 }
2647 return void 0;
2648 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
2649 useOpenChangeComplete({
2650 enabled: open && mounted && panelTransitionStatus === "idle",
2651 open: true,
2652 ref: panelRef,
2653 onComplete() {
2654 if (!open) {
2655 return;
2656 }
2657 setDimensions(EMPTY_DIMENSIONS, false);
2658 }
2659 });
2660 React19.useEffect(() => {
2661 if (open || !mounted || panelTransitionStatus !== "ending") {
2662 return void 0;
2663 }
2664 const panel = panelRef.current;
2665 if (!panel) {
2666 return void 0;
2667 }
2668 const abortController = new AbortController();
2669 let endingStyleFrame = -1;
2670 function handleComplete() {
2671 if (latestStateRef.current.open) {
2672 return;
2673 }
2674 setMounted(false);
2675 setDimensions(EMPTY_DIMENSIONS, false);
2676 }
2677 endingStyleFrame = AnimationFrame.request(() => {
2678 if (!abortController.signal.aborted) {
2679 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
2680 }
2681 });
2682 return () => {
2683 AnimationFrame.cancel(endingStyleFrame);
2684 abortController.abort();
2685 };
2686 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
2687 useIsoLayoutEffect(() => {
2688 const panel = panelRef.current;
2689 if (!panel || !hiddenUntilFound || !hidden) {
2690 return;
2691 }
2692 panel.setAttribute("hidden", "until-found");
2693 }, [hidden, hiddenUntilFound]);
2694 React19.useEffect(function registerBeforeMatchListener() {
2695 const panel = panelRef.current;
2696 if (!panel) {
2697 return void 0;
2698 }
2699 function handleBeforeMatch(event) {
2700 const eventDetails = createChangeEventDetails(reason_parts_exports.none, event);
2701 onOpenChange(true, eventDetails);
2702 if (eventDetails.isCanceled) {
2703 return;
2704 }
2705 shouldSkipNextOpenRef.current = true;
2706 setOpen(true);
2707 }
2708 return addEventListener(panel, "beforematch", handleBeforeMatch);
2709 }, [onOpenChange, setOpen]);
2710 const shouldRender = keepMounted || hiddenUntilFound || mounted || open;
2711 return {
2712 height: renderedDimensions.height,
2713 props: {
2714 ...shouldPersistHiddenTransitionStyles ? {
2715 [CollapsiblePanelDataAttributes.startingStyle]: ""
2716 } : void 0,
2717 hidden,
2718 id: idParam
2719 },
2720 ref: mergedPanelRef,
2721 shouldPreventOpenAnimation,
2722 shouldRender,
2723 transitionStatus: panelTransitionStatus,
2724 width: renderedDimensions.width
2725 };
2726 }
2727 function getDimensions(element) {
2728 return {
2729 height: element.scrollHeight,
2730 width: element.scrollWidth
2731 };
2732 }
2733 function getAnimationType(element, hasSuppressedMountAnimation = false) {
2734 const panelStyles = getWindow(element).getComputedStyle(element);
2735 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
2736 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
2737 if (hasAnimation && hasTransition) {
2738 if (true) {
2739 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
2740 }
2741 return "css-transition";
2742 }
2743 if (hasTransition) {
2744 return "css-transition";
2745 }
2746 if (hasAnimation) {
2747 return "css-animation";
2748 }
2749 return "none";
2750 }
2751 function hasNonZeroDuration(value) {
2752 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
2753 }
2754 function setTemporaryStyle(element, property, value) {
2755 const previousValue = element.style.getPropertyValue(property);
2756 const previousPriority = element.style.getPropertyPriority(property);
2757 element.style.setProperty(property, value);
2758 return () => {
2759 if (previousValue === "") {
2760 element.style.removeProperty(property);
2761 return;
2762 }
2763 element.style.setProperty(property, previousValue, previousPriority);
2764 };
2765 }
2766 function resetLayoutStyles(element) {
2767 const originalLayoutStyles = {
2768 "justify-content": element.style.justifyContent,
2769 "align-items": element.style.alignItems,
2770 "align-content": element.style.alignContent,
2771 "justify-items": element.style.justifyItems
2772 };
2773 Object.keys(originalLayoutStyles).forEach((key) => {
2774 element.style.setProperty(key, "initial", "important");
2775 });
2776 function restoreLayoutStyles() {
2777 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
2778 if (value === "") {
2779 element.style.removeProperty(key);
2780 return;
2781 }
2782 element.style.setProperty(key, value);
2783 });
2784 }
2785 const frame = AnimationFrame.request(restoreLayoutStyles);
2786 return () => {
2787 AnimationFrame.cancel(frame);
2788 restoreLayoutStyles();
2789 };
2790 }
2791
2792 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2793 var React20 = __toESM(require_react(), 1);
2794 function useOnFirstRender(fn) {
2795 const ref = React20.useRef(true);
2796 if (ref.current) {
2797 ref.current = false;
2798 fn();
2799 }
2800 }
2801
2802 // node_modules/@base-ui/utils/platform/parts.mjs
2803 var parts_exports = {};
2804 __export(parts_exports, {
2805 engine: () => engine_exports,
2806 env: () => env_exports,
2807 os: () => os_exports,
2808 screenReader: () => screen_reader_exports
2809 });
2810
2811 // node_modules/@base-ui/utils/platform/os.mjs
2812 var os_exports = {};
2813 __export(os_exports, {
2814 android: () => android,
2815 apple: () => apple,
2816 ios: () => ios,
2817 linux: () => linux,
2818 mac: () => mac,
2819 windows: () => windows
2820 });
2821
2822 // node_modules/@base-ui/utils/platform/shared.mjs
2823 function readRawData() {
2824 if (typeof navigator === "undefined") {
2825 return {
2826 userAgent: "",
2827 platform: "",
2828 maxTouchPoints: 0
2829 };
2830 }
2831 if (true) {
2832 const uaData = navigator.userAgentData;
2833 if (uaData && Array.isArray(uaData.brands)) {
2834 return {
2835 userAgent: uaData.brands.map(({
2836 brand,
2837 version: version2
2838 }) => `${brand}/${version2}`).join(" "),
2839 platform: uaData.platform ?? navigator.platform ?? "",
2840 maxTouchPoints: navigator.maxTouchPoints ?? 0
2841 };
2842 }
2843 }
2844 return {
2845 userAgent: navigator.userAgent,
2846 platform: navigator.platform ?? "",
2847 maxTouchPoints: navigator.maxTouchPoints ?? 0
2848 };
2849 }
2850 var {
2851 userAgent,
2852 platform,
2853 maxTouchPoints
2854 } = readRawData();
2855 var lowerUserAgent = userAgent.toLowerCase();
2856 var lowerPlatform = platform.toLowerCase();
2857
2858 // node_modules/@base-ui/utils/platform/os.mjs
2859 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2860 var ANDROID_STRING = "android";
2861 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2862 var mac = !ios && lowerPlatform.startsWith("mac");
2863 var windows = lowerPlatform.startsWith("win");
2864 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2865 var apple = mac || ios;
2866
2867 // node_modules/@base-ui/utils/platform/engine.mjs
2868 var engine_exports = {};
2869 __export(engine_exports, {
2870 blink: () => blink,
2871 gecko: () => gecko,
2872 webkit: () => webkit
2873 });
2874 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2875 var gecko = !webkit && lowerUserAgent.includes("firefox");
2876 var blink = !webkit && lowerUserAgent.includes("chrom");
2877
2878 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2879 var screen_reader_exports = {};
2880 __export(screen_reader_exports, {
2881 voiceOver: () => voiceOver
2882 });
2883 var voiceOver = apple;
2884
2885 // node_modules/@base-ui/utils/platform/env.mjs
2886 var env_exports = {};
2887 __export(env_exports, {
2888 jsdom: () => jsdom
2889 });
2890 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2891
2892 // node_modules/@base-ui/utils/useTimeout.mjs
2893 var EMPTY3 = 0;
2894 var Timeout = class _Timeout {
2895 static create() {
2896 return new _Timeout();
2897 }
2898 currentId = EMPTY3;
2899 /**
2900 * Executes `fn` after `delay`, clearing any previously scheduled call.
2901 */
2902 start(delay, fn) {
2903 this.clear();
2904 this.currentId = setTimeout(() => {
2905 this.currentId = EMPTY3;
2906 fn();
2907 }, delay);
2908 }
2909 isStarted() {
2910 return this.currentId !== EMPTY3;
2911 }
2912 clear = () => {
2913 if (this.currentId !== EMPTY3) {
2914 clearTimeout(this.currentId);
2915 this.currentId = EMPTY3;
2916 }
2917 };
2918 disposeEffect = () => {
2919 return this.clear;
2920 };
2921 };
2922 function useTimeout() {
2923 const timeout = useRefWithInit(Timeout.create).current;
2924 useOnMount(timeout.disposeEffect);
2925 return timeout;
2926 }
2927
2928 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2929 var React21 = __toESM(require_react(), 1);
2930
2931 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2932 function isReactEvent(event) {
2933 return "nativeEvent" in event;
2934 }
2935 function isMouseLikePointerType(pointerType, strict) {
2936 const values = ["mouse", "pen"];
2937 if (!strict) {
2938 values.push("", void 0);
2939 }
2940 return values.includes(pointerType);
2941 }
2942 function isClickLikeEvent(event) {
2943 const type = event.type;
2944 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2945 }
2946
2947 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2948 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2949 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2950
2951 // node_modules/@base-ui/react/internals/shadowDom.mjs
2952 function activeElement(doc) {
2953 let element = doc.activeElement;
2954 while (element?.shadowRoot?.activeElement != null) {
2955 element = element.shadowRoot.activeElement;
2956 }
2957 return element;
2958 }
2959 function contains(parent, child) {
2960 if (!parent || !child) {
2961 return false;
2962 }
2963 const rootNode = child.getRootNode?.();
2964 if (parent.contains(child)) {
2965 return true;
2966 }
2967 if (rootNode && isShadowRoot(rootNode)) {
2968 let next = child;
2969 while (next) {
2970 if (parent === next) {
2971 return true;
2972 }
2973 next = next.parentNode || next.host;
2974 }
2975 }
2976 return false;
2977 }
2978 function getTarget(event) {
2979 if ("composedPath" in event) {
2980 return event.composedPath()[0];
2981 }
2982 return event.target;
2983 }
2984
2985 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2986 function isTargetInsideEnabledTrigger(target, triggerElements) {
2987 if (!isElement(target)) {
2988 return false;
2989 }
2990 const targetElement = target;
2991 if (triggerElements.hasElement(targetElement)) {
2992 return !targetElement.hasAttribute("data-trigger-disabled");
2993 }
2994 for (const [, trigger] of triggerElements.entries()) {
2995 if (contains(trigger, targetElement)) {
2996 return !trigger.hasAttribute("data-trigger-disabled");
2997 }
2998 }
2999 return false;
3000 }
3001 function isEventTargetWithin(event, node) {
3002 if (node == null) {
3003 return false;
3004 }
3005 if ("composedPath" in event) {
3006 return event.composedPath().includes(node);
3007 }
3008 const eventAgain = event;
3009 return eventAgain.target != null && node.contains(eventAgain.target);
3010 }
3011 function isRootElement(element) {
3012 return element.matches("html,body");
3013 }
3014 function isTypeableElement(element) {
3015 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
3016 }
3017 function isInteractiveElement(element) {
3018 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
3019 }
3020 function matchesFocusVisible(element) {
3021 if (!element || parts_exports.env.jsdom) {
3022 return true;
3023 }
3024 try {
3025 return element.matches(":focus-visible");
3026 } catch (_e) {
3027 return true;
3028 }
3029 }
3030
3031 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
3032 function resolveValue(value, pointerType) {
3033 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3034 return 0;
3035 }
3036 if (typeof value === "function") {
3037 return value();
3038 }
3039 return value;
3040 }
3041 function getDelay(value, prop, pointerType) {
3042 const result = resolveValue(value, pointerType);
3043 if (typeof result === "number") {
3044 return result;
3045 }
3046 return result?.[prop];
3047 }
3048 function getRestMs(value) {
3049 if (typeof value === "function") {
3050 return value();
3051 }
3052 return value;
3053 }
3054 function isClickLikeOpenEvent(openEventType, interactedInside) {
3055 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3056 }
3057 function isHoverOpenEvent(openEventType) {
3058 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3059 }
3060
3061 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3062 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3063 var FloatingDelayGroupContext = /* @__PURE__ */ React21.createContext({
3064 hasProvider: false,
3065 timeoutMs: 0,
3066 delayRef: {
3067 current: 0
3068 },
3069 initialDelayRef: {
3070 current: 0
3071 },
3072 timeout: new Timeout(),
3073 currentIdRef: {
3074 current: null
3075 },
3076 currentContextRef: {
3077 current: null
3078 }
3079 });
3080 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3081 function resetDelayRef(delayRef, initialDelayRef) {
3082 delayRef.current = initialDelayRef.current;
3083 }
3084 function FloatingDelayGroup(props) {
3085 const {
3086 children,
3087 delay,
3088 timeoutMs = 0
3089 } = props;
3090 const delayRef = React21.useRef(delay);
3091 const initialDelayRef = React21.useRef(delay);
3092 const currentIdRef = React21.useRef(null);
3093 const currentContextRef = React21.useRef(null);
3094 const timeout = useTimeout();
3095 useIsoLayoutEffect(() => {
3096 initialDelayRef.current = delay;
3097 if (!currentIdRef.current) {
3098 delayRef.current = delay;
3099 return;
3100 }
3101 delayRef.current = {
3102 open: getDelay(delayRef.current, "open"),
3103 close: getDelay(delay, "close")
3104 };
3105 }, [delay, currentIdRef, delayRef, initialDelayRef]);
3106 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3107 value: React21.useMemo(() => ({
3108 hasProvider: true,
3109 delayRef,
3110 initialDelayRef,
3111 currentIdRef,
3112 timeoutMs,
3113 currentContextRef,
3114 timeout
3115 }), [timeoutMs, timeout]),
3116 children
3117 });
3118 }
3119 function useDelayGroup(context, options = {
3120 open: false
3121 }) {
3122 const {
3123 open
3124 } = options;
3125 const store = "rootStore" in context ? context.rootStore : context;
3126 const floatingId = store.useState("floatingId");
3127 const groupContext = React21.useContext(FloatingDelayGroupContext);
3128 const {
3129 currentIdRef,
3130 delayRef,
3131 timeoutMs,
3132 initialDelayRef,
3133 currentContextRef,
3134 hasProvider,
3135 timeout
3136 } = groupContext;
3137 const [isInstantPhase, setIsInstantPhase] = React21.useState(false);
3138 const openRef = React21.useRef(open);
3139 const isUnmountedRef = React21.useRef(false);
3140 useIsoLayoutEffect(() => {
3141 openRef.current = open;
3142 }, [open]);
3143 useIsoLayoutEffect(() => {
3144 return () => {
3145 isUnmountedRef.current = true;
3146 };
3147 }, []);
3148 useIsoLayoutEffect(() => {
3149 function unset() {
3150 if (!isUnmountedRef.current) {
3151 setIsInstantPhase(false);
3152 }
3153 currentContextRef.current?.setIsInstantPhase(false);
3154 currentIdRef.current = null;
3155 currentContextRef.current = null;
3156 delayRef.current = initialDelayRef.current;
3157 timeout.clear();
3158 }
3159 if (!currentIdRef.current) {
3160 return void 0;
3161 }
3162 if (!open && currentIdRef.current === floatingId) {
3163 setIsInstantPhase(false);
3164 if (timeoutMs) {
3165 const closingId = floatingId;
3166 timeout.start(timeoutMs, () => {
3167 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3168 return;
3169 }
3170 unset();
3171 });
3172 return () => {
3173 if (openRef.current || currentIdRef.current !== closingId) {
3174 timeout.clear();
3175 }
3176 };
3177 }
3178 unset();
3179 }
3180 return void 0;
3181 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3182 useIsoLayoutEffect(() => {
3183 if (!open) {
3184 return;
3185 }
3186 const prevContext = currentContextRef.current;
3187 const prevId = currentIdRef.current;
3188 timeout.clear();
3189 currentContextRef.current = {
3190 onOpenChange: store.setOpen,
3191 setIsInstantPhase
3192 };
3193 currentIdRef.current = floatingId;
3194 delayRef.current = {
3195 open: 0,
3196 close: getDelay(initialDelayRef.current, "close")
3197 };
3198 if (prevId !== null && prevId !== floatingId) {
3199 setIsInstantPhase(true);
3200 prevContext?.setIsInstantPhase(true);
3201 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3202 } else {
3203 setIsInstantPhase(false);
3204 prevContext?.setIsInstantPhase(false);
3205 }
3206 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3207 useIsoLayoutEffect(() => {
3208 return () => {
3209 if (currentIdRef.current === floatingId) {
3210 currentContextRef.current = null;
3211 if (!openRef.current) {
3212 return;
3213 }
3214 currentIdRef.current = null;
3215 resetDelayRef(delayRef, initialDelayRef);
3216 timeout.clear();
3217 }
3218 };
3219 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3220 return React21.useMemo(() => ({
3221 hasProvider,
3222 delayRef,
3223 isInstantPhase
3224 }), [hasProvider, delayRef, isInstantPhase]);
3225 }
3226
3227 // node_modules/@base-ui/utils/mergeCleanups.mjs
3228 function mergeCleanups(...cleanups) {
3229 return () => {
3230 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3231 const cleanup = cleanups[i2];
3232 if (cleanup) {
3233 cleanup();
3234 }
3235 }
3236 };
3237 }
3238
3239 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3240 var React22 = __toESM(require_react(), 1);
3241
3242 // node_modules/@base-ui/utils/visuallyHidden.mjs
3243 var visuallyHiddenBase = {
3244 clipPath: "inset(50%)",
3245 overflow: "hidden",
3246 whiteSpace: "nowrap",
3247 border: 0,
3248 padding: 0,
3249 width: 1,
3250 height: 1,
3251 margin: -1
3252 };
3253 var visuallyHidden = {
3254 ...visuallyHiddenBase,
3255 position: "fixed",
3256 top: 0,
3257 left: 0
3258 };
3259 var visuallyHiddenInput = {
3260 ...visuallyHiddenBase,
3261 position: "absolute"
3262 };
3263
3264 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3265 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3266 var FocusGuard = /* @__PURE__ */ React22.forwardRef(function FocusGuard2(props, ref) {
3267 const [role, setRole] = React22.useState();
3268 useIsoLayoutEffect(() => {
3269 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3270 setRole("button");
3271 }
3272 }, []);
3273 const restProps = {
3274 tabIndex: 0,
3275 // Role is only for VoiceOver
3276 role
3277 };
3278 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3279 ...props,
3280 ref,
3281 style: visuallyHidden,
3282 "aria-hidden": role ? void 0 : true,
3283 ...restProps,
3284 "data-base-ui-focus-guard": ""
3285 });
3286 });
3287 if (true) FocusGuard.displayName = "FocusGuard";
3288
3289 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3290 var sides = ["top", "right", "bottom", "left"];
3291 var min = Math.min;
3292 var max = Math.max;
3293 var round = Math.round;
3294 var floor = Math.floor;
3295 var createCoords = (v2) => ({
3296 x: v2,
3297 y: v2
3298 });
3299 var oppositeSideMap = {
3300 left: "right",
3301 right: "left",
3302 bottom: "top",
3303 top: "bottom"
3304 };
3305 function clamp(start, value, end) {
3306 return max(start, min(value, end));
3307 }
3308 function evaluate(value, param) {
3309 return typeof value === "function" ? value(param) : value;
3310 }
3311 function getSide(placement) {
3312 return placement.split("-")[0];
3313 }
3314 function getAlignment(placement) {
3315 return placement.split("-")[1];
3316 }
3317 function getOppositeAxis(axis) {
3318 return axis === "x" ? "y" : "x";
3319 }
3320 function getAxisLength(axis) {
3321 return axis === "y" ? "height" : "width";
3322 }
3323 function getSideAxis(placement) {
3324 const firstChar = placement[0];
3325 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3326 }
3327 function getAlignmentAxis(placement) {
3328 return getOppositeAxis(getSideAxis(placement));
3329 }
3330 function getAlignmentSides(placement, rects, rtl) {
3331 if (rtl === void 0) {
3332 rtl = false;
3333 }
3334 const alignment = getAlignment(placement);
3335 const alignmentAxis = getAlignmentAxis(placement);
3336 const length = getAxisLength(alignmentAxis);
3337 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3338 if (rects.reference[length] > rects.floating[length]) {
3339 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3340 }
3341 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3342 }
3343 function getExpandedPlacements(placement) {
3344 const oppositePlacement = getOppositePlacement(placement);
3345 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3346 }
3347 function getOppositeAlignmentPlacement(placement) {
3348 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3349 }
3350 var lrPlacement = ["left", "right"];
3351 var rlPlacement = ["right", "left"];
3352 var tbPlacement = ["top", "bottom"];
3353 var btPlacement = ["bottom", "top"];
3354 function getSideList(side, isStart, rtl) {
3355 switch (side) {
3356 case "top":
3357 case "bottom":
3358 if (rtl) return isStart ? rlPlacement : lrPlacement;
3359 return isStart ? lrPlacement : rlPlacement;
3360 case "left":
3361 case "right":
3362 return isStart ? tbPlacement : btPlacement;
3363 default:
3364 return [];
3365 }
3366 }
3367 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3368 const alignment = getAlignment(placement);
3369 let list = getSideList(getSide(placement), direction === "start", rtl);
3370 if (alignment) {
3371 list = list.map((side) => side + "-" + alignment);
3372 if (flipAlignment) {
3373 list = list.concat(list.map(getOppositeAlignmentPlacement));
3374 }
3375 }
3376 return list;
3377 }
3378 function getOppositePlacement(placement) {
3379 const side = getSide(placement);
3380 return oppositeSideMap[side] + placement.slice(side.length);
3381 }
3382 function expandPaddingObject(padding) {
3383 return {
3384 top: 0,
3385 right: 0,
3386 bottom: 0,
3387 left: 0,
3388 ...padding
3389 };
3390 }
3391 function getPaddingObject(padding) {
3392 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3393 top: padding,
3394 right: padding,
3395 bottom: padding,
3396 left: padding
3397 };
3398 }
3399 function rectToClientRect(rect) {
3400 const {
3401 x: x2,
3402 y: y2,
3403 width,
3404 height
3405 } = rect;
3406 return {
3407 width,
3408 height,
3409 top: y2,
3410 left: x2,
3411 right: x2 + width,
3412 bottom: y2 + height,
3413 x: x2,
3414 y: y2
3415 };
3416 }
3417
3418 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3419 function isHiddenByStyles(styles) {
3420 return styles.visibility === "hidden" || styles.visibility === "collapse";
3421 }
3422 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3423 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3424 return false;
3425 }
3426 if (typeof element.checkVisibility === "function") {
3427 return element.checkVisibility();
3428 }
3429 return styles.display !== "none" && styles.display !== "contents";
3430 }
3431
3432 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3433 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3434 function getParentElement(element) {
3435 const assignedSlot = element.assignedSlot;
3436 if (assignedSlot) {
3437 return assignedSlot;
3438 }
3439 if (element.parentElement) {
3440 return element.parentElement;
3441 }
3442 const rootNode = element.getRootNode();
3443 return isShadowRoot(rootNode) ? rootNode.host : null;
3444 }
3445 function getDetailsSummary(details) {
3446 for (const child of Array.from(details.children)) {
3447 if (getNodeName(child) === "summary") {
3448 return child;
3449 }
3450 }
3451 return null;
3452 }
3453 function isWithinOpenDetailsSummary(element, details) {
3454 const summary = getDetailsSummary(details);
3455 return !!summary && (element === summary || contains(summary, element));
3456 }
3457 function isFocusableCandidate(element) {
3458 const nodeName = element ? getNodeName(element) : "";
3459 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");
3460 }
3461 function isFocusableElement(element) {
3462 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3463 return false;
3464 }
3465 for (let current = element; current; current = getParentElement(current)) {
3466 const isAncestor = current !== element;
3467 const isSlot = getNodeName(current) === "slot";
3468 if (current.hasAttribute("inert")) {
3469 return false;
3470 }
3471 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3472 return false;
3473 }
3474 }
3475 return true;
3476 }
3477 function isVisibleInTabbableTree(element, isAncestor) {
3478 const styles = getComputedStyle2(element);
3479 if (!isAncestor) {
3480 return isElementVisible(element, styles);
3481 }
3482 return styles.display !== "none";
3483 }
3484 function getTabIndex(element) {
3485 const tabIndex = element.tabIndex;
3486 if (tabIndex < 0) {
3487 const nodeName = getNodeName(element);
3488 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3489 return 0;
3490 }
3491 }
3492 return tabIndex;
3493 }
3494 function getNamedRadioInput(element) {
3495 if (getNodeName(element) !== "input") {
3496 return null;
3497 }
3498 const input = element;
3499 return input.type === "radio" && input.name !== "" ? input : null;
3500 }
3501 function isTabbableRadio(element, candidates) {
3502 const input = getNamedRadioInput(element);
3503 if (!input) {
3504 return true;
3505 }
3506 const checkedRadio = candidates.find((candidate) => {
3507 const radio = getNamedRadioInput(candidate);
3508 return radio?.name === input.name && radio.form === input.form && radio.checked;
3509 });
3510 if (checkedRadio) {
3511 return checkedRadio === input;
3512 }
3513 return candidates.find((candidate) => {
3514 const radio = getNamedRadioInput(candidate);
3515 return radio?.name === input.name && radio.form === input.form;
3516 }) === input;
3517 }
3518 function getComposedChildren(container) {
3519 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3520 const assignedElements = container.assignedElements({
3521 flatten: true
3522 });
3523 if (assignedElements.length > 0) {
3524 return assignedElements;
3525 }
3526 }
3527 if (isHTMLElement(container) && container.shadowRoot) {
3528 return Array.from(container.shadowRoot.children);
3529 }
3530 return Array.from(container.children);
3531 }
3532 function appendCandidates(container, list) {
3533 getComposedChildren(container).forEach((child) => {
3534 if (isFocusableCandidate(child)) {
3535 list.push(child);
3536 }
3537 appendCandidates(child, list);
3538 });
3539 }
3540 function appendMatchingElements(container, selector2, list) {
3541 getComposedChildren(container).forEach((child) => {
3542 if (isHTMLElement(child) && child.matches(selector2)) {
3543 list.push(child);
3544 }
3545 appendMatchingElements(child, selector2, list);
3546 });
3547 }
3548 function focusable(container) {
3549 const candidates = [];
3550 appendCandidates(container, candidates);
3551 return candidates.filter(isFocusableElement);
3552 }
3553 function tabbable(container) {
3554 const candidates = focusable(container);
3555 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3556 }
3557 function getTabbableIn(container, dir) {
3558 const list = tabbable(container);
3559 const len = list.length;
3560 if (len === 0) {
3561 return void 0;
3562 }
3563 const active = activeElement(ownerDocument(container));
3564 const index2 = list.indexOf(active);
3565 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3566 return list[nextIndex];
3567 }
3568 function getNextTabbable(referenceElement) {
3569 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3570 }
3571 function getPreviousTabbable(referenceElement) {
3572 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3573 }
3574 function isOutsideEvent(event, container) {
3575 const containerElement = container || event.currentTarget;
3576 const relatedTarget = event.relatedTarget;
3577 return !relatedTarget || !contains(containerElement, relatedTarget);
3578 }
3579 function disableFocusInside(container) {
3580 const tabbableElements = tabbable(container);
3581 tabbableElements.forEach((element) => {
3582 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3583 element.setAttribute("tabindex", "-1");
3584 });
3585 }
3586 function enableFocusInside(container) {
3587 const elements = [];
3588 appendMatchingElements(container, "[data-tabindex]", elements);
3589 elements.forEach((element) => {
3590 const tabindex = element.dataset.tabindex;
3591 delete element.dataset.tabindex;
3592 if (tabindex) {
3593 element.setAttribute("tabindex", tabindex);
3594 } else {
3595 element.removeAttribute("tabindex");
3596 }
3597 });
3598 }
3599
3600 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3601 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3602 const directChildren = nodes.filter((node) => node.parentId === id);
3603 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3604 }
3605
3606 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3607 function createAttribute(name) {
3608 return `data-base-ui-${name}`;
3609 }
3610
3611 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3612 var React23 = __toESM(require_react(), 1);
3613 var ReactDOM2 = __toESM(require_react_dom(), 1);
3614
3615 // node_modules/@base-ui/react/internals/constants.mjs
3616 var DISABLED_TRANSITIONS_STYLE = {
3617 style: {
3618 transition: "none"
3619 }
3620 };
3621 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3622 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3623 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3624 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3625 var POPUP_COLLISION_AVOIDANCE = {
3626 fallbackAxisSide: "end"
3627 };
3628 var ownerVisuallyHidden = {
3629 clipPath: "inset(50%)",
3630 position: "fixed",
3631 top: 0,
3632 left: 0
3633 };
3634
3635 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3636 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3637 var PortalContext = /* @__PURE__ */ React23.createContext(null);
3638 if (true) PortalContext.displayName = "PortalContext";
3639 var usePortalContext = () => React23.useContext(PortalContext);
3640 var attr = createAttribute("portal");
3641 function useFloatingPortalNode(props = {}) {
3642 const {
3643 ref,
3644 container: containerProp,
3645 componentProps = EMPTY_OBJECT,
3646 elementProps
3647 } = props;
3648 const uniqueId = useId();
3649 const portalContext = usePortalContext();
3650 const parentPortalNode = portalContext?.portalNode;
3651 const [containerElement, setContainerElement] = React23.useState(null);
3652 const [portalNode, setPortalNode] = React23.useState(null);
3653 const setPortalNodeRef = useStableCallback((node) => {
3654 if (node !== null) {
3655 setPortalNode(node);
3656 }
3657 });
3658 const containerRef = React23.useRef(null);
3659 useIsoLayoutEffect(() => {
3660 if (containerProp === null) {
3661 if (containerRef.current) {
3662 containerRef.current = null;
3663 setPortalNode(null);
3664 setContainerElement(null);
3665 }
3666 return;
3667 }
3668 if (uniqueId == null) {
3669 return;
3670 }
3671 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3672 if (resolvedContainer == null) {
3673 if (containerRef.current) {
3674 containerRef.current = null;
3675 setPortalNode(null);
3676 setContainerElement(null);
3677 }
3678 return;
3679 }
3680 if (containerRef.current !== resolvedContainer) {
3681 containerRef.current = resolvedContainer;
3682 setPortalNode(null);
3683 setContainerElement(resolvedContainer);
3684 }
3685 }, [containerProp, parentPortalNode, uniqueId]);
3686 const portalElement = useRenderElement("div", componentProps, {
3687 ref: [ref, setPortalNodeRef],
3688 props: [{
3689 id: uniqueId,
3690 [attr]: ""
3691 }, elementProps]
3692 });
3693 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3694 return {
3695 portalNode,
3696 portalSubtree
3697 };
3698 }
3699 var FloatingPortal = /* @__PURE__ */ React23.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3700 const {
3701 render: render4,
3702 className,
3703 style,
3704 children,
3705 container,
3706 renderGuards,
3707 ...elementProps
3708 } = componentProps;
3709 const {
3710 portalNode,
3711 portalSubtree
3712 } = useFloatingPortalNode({
3713 container,
3714 ref: forwardedRef,
3715 componentProps,
3716 elementProps
3717 });
3718 const beforeOutsideRef = React23.useRef(null);
3719 const afterOutsideRef = React23.useRef(null);
3720 const beforeInsideRef = React23.useRef(null);
3721 const afterInsideRef = React23.useRef(null);
3722 const [focusManagerState, setFocusManagerState] = React23.useState(null);
3723 const focusInsideDisabledRef = React23.useRef(false);
3724 const modal = focusManagerState?.modal;
3725 const open = focusManagerState?.open;
3726 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3727 React23.useEffect(() => {
3728 if (!portalNode || modal) {
3729 return void 0;
3730 }
3731 function onFocus(event) {
3732 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3733 if (event.type === "focusin") {
3734 if (focusInsideDisabledRef.current) {
3735 enableFocusInside(portalNode);
3736 focusInsideDisabledRef.current = false;
3737 }
3738 } else {
3739 disableFocusInside(portalNode);
3740 focusInsideDisabledRef.current = true;
3741 }
3742 }
3743 }
3744 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3745 }, [portalNode, modal]);
3746 useIsoLayoutEffect(() => {
3747 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3748 return;
3749 }
3750 enableFocusInside(portalNode);
3751 focusInsideDisabledRef.current = false;
3752 }, [open, portalNode]);
3753 const portalContextValue = React23.useMemo(() => ({
3754 beforeOutsideRef,
3755 afterOutsideRef,
3756 beforeInsideRef,
3757 afterInsideRef,
3758 portalNode,
3759 setFocusManagerState
3760 }), [portalNode]);
3761 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React23.Fragment, {
3762 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3763 value: portalContextValue,
3764 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3765 "data-type": "outside",
3766 ref: beforeOutsideRef,
3767 onFocus: (event) => {
3768 if (isOutsideEvent(event, portalNode)) {
3769 beforeInsideRef.current?.focus();
3770 } else {
3771 const domReference = focusManagerState ? focusManagerState.domReference : null;
3772 const prevTabbable = getPreviousTabbable(domReference);
3773 prevTabbable?.focus();
3774 }
3775 }
3776 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3777 "aria-owns": portalNode.id,
3778 style: ownerVisuallyHidden
3779 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3780 "data-type": "outside",
3781 ref: afterOutsideRef,
3782 onFocus: (event) => {
3783 if (isOutsideEvent(event, portalNode)) {
3784 afterInsideRef.current?.focus();
3785 } else {
3786 const domReference = focusManagerState ? focusManagerState.domReference : null;
3787 const nextTabbable = getNextTabbable(domReference);
3788 nextTabbable?.focus();
3789 if (focusManagerState?.closeOnFocusOut) {
3790 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3791 }
3792 }
3793 }
3794 })]
3795 })]
3796 });
3797 });
3798 if (true) FloatingPortal.displayName = "FloatingPortal";
3799
3800 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3801 var React24 = __toESM(require_react(), 1);
3802
3803 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3804 function createEventEmitter() {
3805 const map = /* @__PURE__ */ new Map();
3806 return {
3807 emit(event, data) {
3808 map.get(event)?.forEach((listener) => listener(data));
3809 },
3810 on(event, listener) {
3811 if (!map.has(event)) {
3812 map.set(event, /* @__PURE__ */ new Set());
3813 }
3814 map.get(event).add(listener);
3815 },
3816 off(event, listener) {
3817 map.get(event)?.delete(listener);
3818 }
3819 };
3820 }
3821
3822 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3823 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3824 var FloatingNodeContext = /* @__PURE__ */ React24.createContext(null);
3825 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3826 var FloatingTreeContext = /* @__PURE__ */ React24.createContext(null);
3827 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3828 var useFloatingParentNodeId = () => React24.useContext(FloatingNodeContext)?.id || null;
3829 var useFloatingTree = (externalTree) => {
3830 const contextTree = React24.useContext(FloatingTreeContext);
3831 return externalTree ?? contextTree;
3832 };
3833
3834 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3835 var React25 = __toESM(require_react(), 1);
3836 function createVirtualElement(domElement, data) {
3837 let offsetX = null;
3838 let offsetY = null;
3839 let isAutoUpdateEvent = false;
3840 return {
3841 contextElement: domElement || void 0,
3842 getBoundingClientRect() {
3843 const domRect = domElement?.getBoundingClientRect() || {
3844 width: 0,
3845 height: 0,
3846 x: 0,
3847 y: 0
3848 };
3849 const isXAxis = data.axis === "x" || data.axis === "both";
3850 const isYAxis = data.axis === "y" || data.axis === "both";
3851 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3852 let width = domRect.width;
3853 let height = domRect.height;
3854 let x2 = domRect.x;
3855 let y2 = domRect.y;
3856 if (offsetX == null && data.x && isXAxis) {
3857 offsetX = domRect.x - data.x;
3858 }
3859 if (offsetY == null && data.y && isYAxis) {
3860 offsetY = domRect.y - data.y;
3861 }
3862 x2 -= offsetX || 0;
3863 y2 -= offsetY || 0;
3864 width = 0;
3865 height = 0;
3866 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3867 width = data.axis === "y" ? domRect.width : 0;
3868 height = data.axis === "x" ? domRect.height : 0;
3869 x2 = isXAxis && data.x != null ? data.x : x2;
3870 y2 = isYAxis && data.y != null ? data.y : y2;
3871 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3872 height = data.axis === "x" ? domRect.height : height;
3873 width = data.axis === "y" ? domRect.width : width;
3874 }
3875 isAutoUpdateEvent = true;
3876 return {
3877 width,
3878 height,
3879 x: x2,
3880 y: y2,
3881 top: y2,
3882 right: x2 + width,
3883 bottom: y2 + height,
3884 left: x2
3885 };
3886 }
3887 };
3888 }
3889 function isMouseBasedEvent(event) {
3890 return event != null && event.clientX != null;
3891 }
3892 function useClientPoint(context, props = {}) {
3893 const {
3894 enabled = true,
3895 axis = "both"
3896 } = props;
3897 const store = "rootStore" in context ? context.rootStore : context;
3898 const open = store.useState("open");
3899 const floating = store.useState("floatingElement");
3900 const domReference = store.useState("domReferenceElement");
3901 const dataRef = store.context.dataRef;
3902 const initialRef = React25.useRef(false);
3903 const cleanupListenerRef = React25.useRef(null);
3904 const [pointerType, setPointerType] = React25.useState();
3905 const [reactive, setReactive] = React25.useState([]);
3906 const resetReference = useStableCallback((reference2) => {
3907 store.set("positionReference", reference2);
3908 });
3909 const setReference = useStableCallback((newX, newY, referenceElement) => {
3910 if (initialRef.current) {
3911 return;
3912 }
3913 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3914 return;
3915 }
3916 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3917 x: newX,
3918 y: newY,
3919 axis,
3920 dataRef,
3921 pointerType
3922 }));
3923 });
3924 const handleReferenceEnterOrMove = useStableCallback((event) => {
3925 if (!open) {
3926 setReference(event.clientX, event.clientY, event.currentTarget);
3927 } else if (!cleanupListenerRef.current) {
3928 setReference(event.clientX, event.clientY, event.currentTarget);
3929 setReactive([]);
3930 }
3931 });
3932 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3933 React25.useEffect(() => {
3934 if (!enabled) {
3935 resetReference(domReference);
3936 return void 0;
3937 }
3938 if (!openCheck) {
3939 return void 0;
3940 }
3941 function cleanupListener() {
3942 cleanupListenerRef.current?.();
3943 cleanupListenerRef.current = null;
3944 }
3945 const win = getWindow(floating);
3946 function handleMouseMove(event) {
3947 const target = getTarget(event);
3948 if (!contains(floating, target)) {
3949 setReference(event.clientX, event.clientY);
3950 } else {
3951 cleanupListener();
3952 }
3953 }
3954 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3955 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3956 } else {
3957 resetReference(domReference);
3958 }
3959 return cleanupListener;
3960 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3961 React25.useEffect(() => () => {
3962 store.set("positionReference", null);
3963 }, [store]);
3964 React25.useEffect(() => {
3965 if (enabled && !floating) {
3966 initialRef.current = false;
3967 }
3968 }, [enabled, floating]);
3969 React25.useEffect(() => {
3970 if (!enabled && open) {
3971 initialRef.current = true;
3972 }
3973 }, [enabled, open]);
3974 const reference = React25.useMemo(() => {
3975 function setPointerTypeRef(event) {
3976 setPointerType(event.pointerType);
3977 }
3978 return {
3979 onPointerDown: setPointerTypeRef,
3980 onPointerEnter: setPointerTypeRef,
3981 onMouseMove: handleReferenceEnterOrMove,
3982 onMouseEnter: handleReferenceEnterOrMove
3983 };
3984 }, [handleReferenceEnterOrMove]);
3985 return React25.useMemo(() => enabled ? {
3986 reference,
3987 trigger: reference
3988 } : {}, [enabled, reference]);
3989 }
3990
3991 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
3992 var React26 = __toESM(require_react(), 1);
3993 function alwaysFalse() {
3994 return false;
3995 }
3996 function normalizeProp(normalizable) {
3997 return {
3998 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3999 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4000 };
4001 }
4002 function useDismiss(context, props = {}) {
4003 const {
4004 enabled = true,
4005 escapeKey: escapeKey2 = true,
4006 outsidePress: outsidePressProp = true,
4007 outsidePressEvent = "sloppy",
4008 referencePress = alwaysFalse,
4009 bubbles,
4010 externalTree
4011 } = props;
4012 const store = "rootStore" in context ? context.rootStore : context;
4013 const open = store.useState("open");
4014 const floatingElement = store.useState("floatingElement");
4015 const {
4016 dataRef
4017 } = store.context;
4018 const tree = useFloatingTree(externalTree);
4019 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4020 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4021 const outsidePressEnabled = outsidePress2 !== false;
4022 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4023 const {
4024 escapeKey: escapeKeyBubbles,
4025 outsidePress: outsidePressBubbles
4026 } = normalizeProp(bubbles);
4027 const pressStartedInsideRef = React26.useRef(false);
4028 const pressStartPreventedRef = React26.useRef(false);
4029 const suppressNextOutsideClickRef = React26.useRef(false);
4030 const isComposingRef = React26.useRef(false);
4031 const currentPointerTypeRef = React26.useRef("");
4032 const touchStateRef = React26.useRef(null);
4033 const cancelDismissOnEndTimeout = useTimeout();
4034 const clearInsideReactTreeTimeout = useTimeout();
4035 const clearInsideReactTree = useStableCallback(() => {
4036 clearInsideReactTreeTimeout.clear();
4037 dataRef.current.insideReactTree = false;
4038 });
4039 const hasBlockingChild = useStableCallback((bubbleKey) => {
4040 const nodeId = dataRef.current.floatingContext?.nodeId;
4041 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4042 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
4043 });
4044 const isEventWithinOwnElements = useStableCallback((event) => {
4045 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
4046 });
4047 const closeOnReferencePress = useStableCallback((event) => {
4048 if (!referencePress()) {
4049 return;
4050 }
4051 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4052 });
4053 const closeOnEscapeKeyDown = useStableCallback((event) => {
4054 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4055 return;
4056 }
4057 if (isComposingRef.current) {
4058 return;
4059 }
4060 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4061 return;
4062 }
4063 const native = isReactEvent(event) ? event.nativeEvent : event;
4064 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4065 store.setOpen(false, eventDetails);
4066 if (!eventDetails.isCanceled) {
4067 event.preventDefault();
4068 }
4069 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4070 event.stopPropagation();
4071 }
4072 });
4073 const markInsideReactTree = useStableCallback(() => {
4074 dataRef.current.insideReactTree = true;
4075 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4076 });
4077 const markPressStartedInsideReactTree = useStableCallback((event) => {
4078 if (!open || !enabled || event.button !== 0) {
4079 return;
4080 }
4081 const target = getTarget(event.nativeEvent);
4082 if (!contains(store.select("floatingElement"), target)) {
4083 return;
4084 }
4085 if (!pressStartedInsideRef.current) {
4086 pressStartedInsideRef.current = true;
4087 pressStartPreventedRef.current = false;
4088 }
4089 });
4090 const markInsidePressStartPrevented = useStableCallback((event) => {
4091 if (!open || !enabled) {
4092 return;
4093 }
4094 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4095 return;
4096 }
4097 if (pressStartedInsideRef.current) {
4098 pressStartPreventedRef.current = true;
4099 }
4100 });
4101 React26.useEffect(() => {
4102 if (!open || !enabled) {
4103 return void 0;
4104 }
4105 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4106 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4107 const compositionTimeout = new Timeout();
4108 const preventedPressSuppressionTimeout = new Timeout();
4109 function handleCompositionStart() {
4110 compositionTimeout.clear();
4111 isComposingRef.current = true;
4112 }
4113 function handleCompositionEnd() {
4114 compositionTimeout.start(
4115 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4116 // Only apply to WebKit for the test to remain 0ms.
4117 parts_exports.engine.webkit ? 5 : 0,
4118 () => {
4119 isComposingRef.current = false;
4120 }
4121 );
4122 }
4123 function suppressImmediateOutsideClickAfterPreventedStart() {
4124 suppressNextOutsideClickRef.current = true;
4125 preventedPressSuppressionTimeout.start(0, () => {
4126 suppressNextOutsideClickRef.current = false;
4127 });
4128 }
4129 function resetPressStartState() {
4130 pressStartedInsideRef.current = false;
4131 pressStartPreventedRef.current = false;
4132 }
4133 function getOutsidePressEvent() {
4134 const type = currentPointerTypeRef.current;
4135 const computedType = type === "pen" || !type ? "mouse" : type;
4136 const outsidePressEventValue = getOutsidePressEventProp();
4137 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4138 if (typeof resolved === "string") {
4139 return resolved;
4140 }
4141 return resolved[computedType];
4142 }
4143 function shouldIgnoreEvent(event) {
4144 const computedOutsidePressEvent = getOutsidePressEvent();
4145 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4146 }
4147 function isEventWithinFloatingTree(event) {
4148 const nodeId = dataRef.current.floatingContext?.nodeId;
4149 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4150 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4151 }
4152 function closeOnPressOutside(event) {
4153 if (shouldIgnoreEvent(event)) {
4154 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4155 preventedPressSuppressionTimeout.clear();
4156 suppressNextOutsideClickRef.current = false;
4157 }
4158 clearInsideReactTree();
4159 return;
4160 }
4161 if (dataRef.current.insideReactTree) {
4162 clearInsideReactTree();
4163 return;
4164 }
4165 const target = getTarget(event);
4166 const inertSelector = `[${createAttribute("inert")}]`;
4167 const targetRoot = isElement(target) ? target.getRootNode() : null;
4168 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4169 const triggers = store.context.triggerElements;
4170 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4171 return;
4172 }
4173 let targetRootAncestor = isElement(target) ? target : null;
4174 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4175 const nextParent = getParentNode(targetRootAncestor);
4176 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4177 break;
4178 }
4179 targetRootAncestor = nextParent;
4180 }
4181 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4182 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4183 // element was injected after the floating element rendered.
4184 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4185 return;
4186 }
4187 if (isHTMLElement(target) && !("touches" in event)) {
4188 const lastTraversableNode = isLastTraversableNode(target);
4189 const style = getComputedStyle2(target);
4190 const scrollRe = /auto|scroll/;
4191 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4192 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4193 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4194 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4195 const isRTL7 = style.direction === "rtl";
4196 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4197 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4198 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4199 return;
4200 }
4201 }
4202 if (isEventWithinFloatingTree(event)) {
4203 return;
4204 }
4205 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4206 preventedPressSuppressionTimeout.clear();
4207 suppressNextOutsideClickRef.current = false;
4208 return;
4209 }
4210 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4211 return;
4212 }
4213 if (hasBlockingChild("__outsidePressBubbles")) {
4214 return;
4215 }
4216 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4217 clearInsideReactTree();
4218 }
4219 function handlePointerDown(event) {
4220 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4221 return;
4222 }
4223 closeOnPressOutside(event);
4224 }
4225 function handleTouchStart(event) {
4226 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4227 return;
4228 }
4229 const touch = event.touches[0];
4230 if (touch) {
4231 touchStateRef.current = {
4232 startTime: Date.now(),
4233 startX: touch.clientX,
4234 startY: touch.clientY,
4235 dismissOnTouchEnd: false,
4236 dismissOnMouseDown: true
4237 };
4238 cancelDismissOnEndTimeout.start(1e3, () => {
4239 if (touchStateRef.current) {
4240 touchStateRef.current.dismissOnTouchEnd = false;
4241 touchStateRef.current.dismissOnMouseDown = false;
4242 }
4243 });
4244 }
4245 }
4246 function addTargetEventListenerOnce(event, listener) {
4247 const target = getTarget(event);
4248 if (!target) {
4249 return;
4250 }
4251 const unsubscribe2 = addEventListener(target, event.type, () => {
4252 listener(event);
4253 unsubscribe2();
4254 });
4255 }
4256 function handleTouchStartCapture(event) {
4257 currentPointerTypeRef.current = "touch";
4258 addTargetEventListenerOnce(event, handleTouchStart);
4259 }
4260 function closeOnPressOutsideCapture(event) {
4261 cancelDismissOnEndTimeout.clear();
4262 if (event.type === "pointerdown") {
4263 currentPointerTypeRef.current = event.pointerType;
4264 }
4265 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4266 return;
4267 }
4268 addTargetEventListenerOnce(event, (targetEvent) => {
4269 if (targetEvent.type === "pointerdown") {
4270 handlePointerDown(targetEvent);
4271 } else {
4272 closeOnPressOutside(targetEvent);
4273 }
4274 });
4275 }
4276 function handlePressEndCapture(event) {
4277 if (!pressStartedInsideRef.current) {
4278 return;
4279 }
4280 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4281 resetPressStartState();
4282 if (getOutsidePressEvent() !== "intentional") {
4283 return;
4284 }
4285 if (event.type === "pointercancel") {
4286 if (pressStartedInsideDefaultPrevented) {
4287 suppressImmediateOutsideClickAfterPreventedStart();
4288 }
4289 return;
4290 }
4291 if (isEventWithinFloatingTree(event)) {
4292 return;
4293 }
4294 if (pressStartedInsideDefaultPrevented) {
4295 suppressImmediateOutsideClickAfterPreventedStart();
4296 return;
4297 }
4298 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4299 return;
4300 }
4301 preventedPressSuppressionTimeout.clear();
4302 suppressNextOutsideClickRef.current = true;
4303 clearInsideReactTree();
4304 }
4305 function handleTouchMove(event) {
4306 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4307 return;
4308 }
4309 const touch = event.touches[0];
4310 if (!touch) {
4311 return;
4312 }
4313 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4314 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4315 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4316 if (distance > 5) {
4317 touchStateRef.current.dismissOnTouchEnd = true;
4318 }
4319 if (distance > 10) {
4320 closeOnPressOutside(event);
4321 cancelDismissOnEndTimeout.clear();
4322 touchStateRef.current = null;
4323 }
4324 }
4325 function handleTouchMoveCapture(event) {
4326 addTargetEventListenerOnce(event, handleTouchMove);
4327 }
4328 function handleTouchEnd(event) {
4329 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4330 return;
4331 }
4332 if (touchStateRef.current.dismissOnTouchEnd) {
4333 closeOnPressOutside(event);
4334 }
4335 cancelDismissOnEndTimeout.clear();
4336 touchStateRef.current = null;
4337 }
4338 function handleTouchEndCapture(event) {
4339 addTargetEventListenerOnce(event, handleTouchEnd);
4340 }
4341 const doc = ownerDocument(floatingElement);
4342 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)));
4343 return () => {
4344 unsubscribe();
4345 compositionTimeout.clear();
4346 preventedPressSuppressionTimeout.clear();
4347 resetPressStartState();
4348 suppressNextOutsideClickRef.current = false;
4349 };
4350 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4351 React26.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4352 const reference = React26.useMemo(() => ({
4353 onKeyDown: closeOnEscapeKeyDown,
4354 onPointerDown: closeOnReferencePress,
4355 onClick: closeOnReferencePress
4356 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4357 const floating = React26.useMemo(() => ({
4358 onKeyDown: closeOnEscapeKeyDown,
4359 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4360 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4361 // See https://github.com/mui/base-ui/pull/3379
4362 onPointerDown: markInsidePressStartPrevented,
4363 onMouseDown: markInsidePressStartPrevented,
4364 onClickCapture: markInsideReactTree,
4365 onMouseDownCapture(event) {
4366 markInsideReactTree();
4367 markPressStartedInsideReactTree(event);
4368 },
4369 onPointerDownCapture(event) {
4370 markInsideReactTree();
4371 markPressStartedInsideReactTree(event);
4372 },
4373 onMouseUpCapture: markInsideReactTree,
4374 onTouchEndCapture: markInsideReactTree,
4375 onTouchMoveCapture: markInsideReactTree
4376 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4377 return React26.useMemo(() => enabled ? {
4378 reference,
4379 floating,
4380 trigger: reference
4381 } : {}, [enabled, reference, floating]);
4382 }
4383
4384 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4385 var React33 = __toESM(require_react(), 1);
4386
4387 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4388 function computeCoordsFromPlacement(_ref, placement, rtl) {
4389 let {
4390 reference,
4391 floating
4392 } = _ref;
4393 const sideAxis = getSideAxis(placement);
4394 const alignmentAxis = getAlignmentAxis(placement);
4395 const alignLength = getAxisLength(alignmentAxis);
4396 const side = getSide(placement);
4397 const isVertical = sideAxis === "y";
4398 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4399 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4400 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4401 let coords;
4402 switch (side) {
4403 case "top":
4404 coords = {
4405 x: commonX,
4406 y: reference.y - floating.height
4407 };
4408 break;
4409 case "bottom":
4410 coords = {
4411 x: commonX,
4412 y: reference.y + reference.height
4413 };
4414 break;
4415 case "right":
4416 coords = {
4417 x: reference.x + reference.width,
4418 y: commonY
4419 };
4420 break;
4421 case "left":
4422 coords = {
4423 x: reference.x - floating.width,
4424 y: commonY
4425 };
4426 break;
4427 default:
4428 coords = {
4429 x: reference.x,
4430 y: reference.y
4431 };
4432 }
4433 switch (getAlignment(placement)) {
4434 case "start":
4435 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4436 break;
4437 case "end":
4438 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4439 break;
4440 }
4441 return coords;
4442 }
4443 async function detectOverflow(state, options) {
4444 var _await$platform$isEle;
4445 if (options === void 0) {
4446 options = {};
4447 }
4448 const {
4449 x: x2,
4450 y: y2,
4451 platform: platform3,
4452 rects,
4453 elements,
4454 strategy
4455 } = state;
4456 const {
4457 boundary = "clippingAncestors",
4458 rootBoundary = "viewport",
4459 elementContext = "floating",
4460 altBoundary = false,
4461 padding = 0
4462 } = evaluate(options, state);
4463 const paddingObject = getPaddingObject(padding);
4464 const altContext = elementContext === "floating" ? "reference" : "floating";
4465 const element = elements[altBoundary ? altContext : elementContext];
4466 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4467 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)),
4468 boundary,
4469 rootBoundary,
4470 strategy
4471 }));
4472 const rect = elementContext === "floating" ? {
4473 x: x2,
4474 y: y2,
4475 width: rects.floating.width,
4476 height: rects.floating.height
4477 } : rects.reference;
4478 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4479 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4480 x: 1,
4481 y: 1
4482 } : {
4483 x: 1,
4484 y: 1
4485 };
4486 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4487 elements,
4488 rect,
4489 offsetParent,
4490 strategy
4491 }) : rect);
4492 return {
4493 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4494 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4495 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4496 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4497 };
4498 }
4499 var MAX_RESET_COUNT = 50;
4500 var computePosition = async (reference, floating, config) => {
4501 const {
4502 placement = "bottom",
4503 strategy = "absolute",
4504 middleware = [],
4505 platform: platform3
4506 } = config;
4507 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4508 ...platform3,
4509 detectOverflow
4510 };
4511 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4512 let rects = await platform3.getElementRects({
4513 reference,
4514 floating,
4515 strategy
4516 });
4517 let {
4518 x: x2,
4519 y: y2
4520 } = computeCoordsFromPlacement(rects, placement, rtl);
4521 let statefulPlacement = placement;
4522 let resetCount = 0;
4523 const middlewareData = {};
4524 for (let i2 = 0; i2 < middleware.length; i2++) {
4525 const currentMiddleware = middleware[i2];
4526 if (!currentMiddleware) {
4527 continue;
4528 }
4529 const {
4530 name,
4531 fn
4532 } = currentMiddleware;
4533 const {
4534 x: nextX,
4535 y: nextY,
4536 data,
4537 reset
4538 } = await fn({
4539 x: x2,
4540 y: y2,
4541 initialPlacement: placement,
4542 placement: statefulPlacement,
4543 strategy,
4544 middlewareData,
4545 rects,
4546 platform: platformWithDetectOverflow,
4547 elements: {
4548 reference,
4549 floating
4550 }
4551 });
4552 x2 = nextX != null ? nextX : x2;
4553 y2 = nextY != null ? nextY : y2;
4554 middlewareData[name] = {
4555 ...middlewareData[name],
4556 ...data
4557 };
4558 if (reset && resetCount < MAX_RESET_COUNT) {
4559 resetCount++;
4560 if (typeof reset === "object") {
4561 if (reset.placement) {
4562 statefulPlacement = reset.placement;
4563 }
4564 if (reset.rects) {
4565 rects = reset.rects === true ? await platform3.getElementRects({
4566 reference,
4567 floating,
4568 strategy
4569 }) : reset.rects;
4570 }
4571 ({
4572 x: x2,
4573 y: y2
4574 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4575 }
4576 i2 = -1;
4577 }
4578 }
4579 return {
4580 x: x2,
4581 y: y2,
4582 placement: statefulPlacement,
4583 strategy,
4584 middlewareData
4585 };
4586 };
4587 var flip = function(options) {
4588 if (options === void 0) {
4589 options = {};
4590 }
4591 return {
4592 name: "flip",
4593 options,
4594 async fn(state) {
4595 var _middlewareData$arrow, _middlewareData$flip;
4596 const {
4597 placement,
4598 middlewareData,
4599 rects,
4600 initialPlacement,
4601 platform: platform3,
4602 elements
4603 } = state;
4604 const {
4605 mainAxis: checkMainAxis = true,
4606 crossAxis: checkCrossAxis = true,
4607 fallbackPlacements: specifiedFallbackPlacements,
4608 fallbackStrategy = "bestFit",
4609 fallbackAxisSideDirection = "none",
4610 flipAlignment = true,
4611 ...detectOverflowOptions
4612 } = evaluate(options, state);
4613 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4614 return {};
4615 }
4616 const side = getSide(placement);
4617 const initialSideAxis = getSideAxis(initialPlacement);
4618 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4619 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4620 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4621 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4622 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4623 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4624 }
4625 const placements2 = [initialPlacement, ...fallbackPlacements];
4626 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4627 const overflows = [];
4628 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4629 if (checkMainAxis) {
4630 overflows.push(overflow[side]);
4631 }
4632 if (checkCrossAxis) {
4633 const sides2 = getAlignmentSides(placement, rects, rtl);
4634 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4635 }
4636 overflowsData = [...overflowsData, {
4637 placement,
4638 overflows
4639 }];
4640 if (!overflows.every((side2) => side2 <= 0)) {
4641 var _middlewareData$flip2, _overflowsData$filter;
4642 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4643 const nextPlacement = placements2[nextIndex];
4644 if (nextPlacement) {
4645 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4646 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4647 // overflows the main axis.
4648 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4649 return {
4650 data: {
4651 index: nextIndex,
4652 overflows: overflowsData
4653 },
4654 reset: {
4655 placement: nextPlacement
4656 }
4657 };
4658 }
4659 }
4660 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;
4661 if (!resetPlacement) {
4662 switch (fallbackStrategy) {
4663 case "bestFit": {
4664 var _overflowsData$filter2;
4665 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4666 if (hasFallbackAxisSideDirection) {
4667 const currentSideAxis = getSideAxis(d2.placement);
4668 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4669 // reading directions favoring greater width.
4670 currentSideAxis === "y";
4671 }
4672 return true;
4673 }).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];
4674 if (placement2) {
4675 resetPlacement = placement2;
4676 }
4677 break;
4678 }
4679 case "initialPlacement":
4680 resetPlacement = initialPlacement;
4681 break;
4682 }
4683 }
4684 if (placement !== resetPlacement) {
4685 return {
4686 reset: {
4687 placement: resetPlacement
4688 }
4689 };
4690 }
4691 }
4692 return {};
4693 }
4694 };
4695 };
4696 function getSideOffsets(overflow, rect) {
4697 return {
4698 top: overflow.top - rect.height,
4699 right: overflow.right - rect.width,
4700 bottom: overflow.bottom - rect.height,
4701 left: overflow.left - rect.width
4702 };
4703 }
4704 function isAnySideFullyClipped(overflow) {
4705 return sides.some((side) => overflow[side] >= 0);
4706 }
4707 var hide = function(options) {
4708 if (options === void 0) {
4709 options = {};
4710 }
4711 return {
4712 name: "hide",
4713 options,
4714 async fn(state) {
4715 const {
4716 rects,
4717 platform: platform3
4718 } = state;
4719 const {
4720 strategy = "referenceHidden",
4721 ...detectOverflowOptions
4722 } = evaluate(options, state);
4723 switch (strategy) {
4724 case "referenceHidden": {
4725 const overflow = await platform3.detectOverflow(state, {
4726 ...detectOverflowOptions,
4727 elementContext: "reference"
4728 });
4729 const offsets = getSideOffsets(overflow, rects.reference);
4730 return {
4731 data: {
4732 referenceHiddenOffsets: offsets,
4733 referenceHidden: isAnySideFullyClipped(offsets)
4734 }
4735 };
4736 }
4737 case "escaped": {
4738 const overflow = await platform3.detectOverflow(state, {
4739 ...detectOverflowOptions,
4740 altBoundary: true
4741 });
4742 const offsets = getSideOffsets(overflow, rects.floating);
4743 return {
4744 data: {
4745 escapedOffsets: offsets,
4746 escaped: isAnySideFullyClipped(offsets)
4747 }
4748 };
4749 }
4750 default: {
4751 return {};
4752 }
4753 }
4754 }
4755 };
4756 };
4757 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4758 async function convertValueToCoords(state, options) {
4759 const {
4760 placement,
4761 platform: platform3,
4762 elements
4763 } = state;
4764 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4765 const side = getSide(placement);
4766 const alignment = getAlignment(placement);
4767 const isVertical = getSideAxis(placement) === "y";
4768 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4769 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4770 const rawValue = evaluate(options, state);
4771 let {
4772 mainAxis,
4773 crossAxis,
4774 alignmentAxis
4775 } = typeof rawValue === "number" ? {
4776 mainAxis: rawValue,
4777 crossAxis: 0,
4778 alignmentAxis: null
4779 } : {
4780 mainAxis: rawValue.mainAxis || 0,
4781 crossAxis: rawValue.crossAxis || 0,
4782 alignmentAxis: rawValue.alignmentAxis
4783 };
4784 if (alignment && typeof alignmentAxis === "number") {
4785 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4786 }
4787 return isVertical ? {
4788 x: crossAxis * crossAxisMulti,
4789 y: mainAxis * mainAxisMulti
4790 } : {
4791 x: mainAxis * mainAxisMulti,
4792 y: crossAxis * crossAxisMulti
4793 };
4794 }
4795 var offset = function(options) {
4796 if (options === void 0) {
4797 options = 0;
4798 }
4799 return {
4800 name: "offset",
4801 options,
4802 async fn(state) {
4803 var _middlewareData$offse, _middlewareData$arrow;
4804 const {
4805 x: x2,
4806 y: y2,
4807 placement,
4808 middlewareData
4809 } = state;
4810 const diffCoords = await convertValueToCoords(state, options);
4811 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4812 return {};
4813 }
4814 return {
4815 x: x2 + diffCoords.x,
4816 y: y2 + diffCoords.y,
4817 data: {
4818 ...diffCoords,
4819 placement
4820 }
4821 };
4822 }
4823 };
4824 };
4825 var shift = function(options) {
4826 if (options === void 0) {
4827 options = {};
4828 }
4829 return {
4830 name: "shift",
4831 options,
4832 async fn(state) {
4833 const {
4834 x: x2,
4835 y: y2,
4836 placement,
4837 platform: platform3
4838 } = state;
4839 const {
4840 mainAxis: checkMainAxis = true,
4841 crossAxis: checkCrossAxis = false,
4842 limiter = {
4843 fn: (_ref) => {
4844 let {
4845 x: x3,
4846 y: y3
4847 } = _ref;
4848 return {
4849 x: x3,
4850 y: y3
4851 };
4852 }
4853 },
4854 ...detectOverflowOptions
4855 } = evaluate(options, state);
4856 const coords = {
4857 x: x2,
4858 y: y2
4859 };
4860 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4861 const crossAxis = getSideAxis(getSide(placement));
4862 const mainAxis = getOppositeAxis(crossAxis);
4863 let mainAxisCoord = coords[mainAxis];
4864 let crossAxisCoord = coords[crossAxis];
4865 if (checkMainAxis) {
4866 const minSide = mainAxis === "y" ? "top" : "left";
4867 const maxSide = mainAxis === "y" ? "bottom" : "right";
4868 const min2 = mainAxisCoord + overflow[minSide];
4869 const max2 = mainAxisCoord - overflow[maxSide];
4870 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4871 }
4872 if (checkCrossAxis) {
4873 const minSide = crossAxis === "y" ? "top" : "left";
4874 const maxSide = crossAxis === "y" ? "bottom" : "right";
4875 const min2 = crossAxisCoord + overflow[minSide];
4876 const max2 = crossAxisCoord - overflow[maxSide];
4877 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4878 }
4879 const limitedCoords = limiter.fn({
4880 ...state,
4881 [mainAxis]: mainAxisCoord,
4882 [crossAxis]: crossAxisCoord
4883 });
4884 return {
4885 ...limitedCoords,
4886 data: {
4887 x: limitedCoords.x - x2,
4888 y: limitedCoords.y - y2,
4889 enabled: {
4890 [mainAxis]: checkMainAxis,
4891 [crossAxis]: checkCrossAxis
4892 }
4893 }
4894 };
4895 }
4896 };
4897 };
4898 var limitShift = function(options) {
4899 if (options === void 0) {
4900 options = {};
4901 }
4902 return {
4903 options,
4904 fn(state) {
4905 const {
4906 x: x2,
4907 y: y2,
4908 placement,
4909 rects,
4910 middlewareData
4911 } = state;
4912 const {
4913 offset: offset4 = 0,
4914 mainAxis: checkMainAxis = true,
4915 crossAxis: checkCrossAxis = true
4916 } = evaluate(options, state);
4917 const coords = {
4918 x: x2,
4919 y: y2
4920 };
4921 const crossAxis = getSideAxis(placement);
4922 const mainAxis = getOppositeAxis(crossAxis);
4923 let mainAxisCoord = coords[mainAxis];
4924 let crossAxisCoord = coords[crossAxis];
4925 const rawOffset = evaluate(offset4, state);
4926 const computedOffset = typeof rawOffset === "number" ? {
4927 mainAxis: rawOffset,
4928 crossAxis: 0
4929 } : {
4930 mainAxis: 0,
4931 crossAxis: 0,
4932 ...rawOffset
4933 };
4934 if (checkMainAxis) {
4935 const len = mainAxis === "y" ? "height" : "width";
4936 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4937 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4938 if (mainAxisCoord < limitMin) {
4939 mainAxisCoord = limitMin;
4940 } else if (mainAxisCoord > limitMax) {
4941 mainAxisCoord = limitMax;
4942 }
4943 }
4944 if (checkCrossAxis) {
4945 var _middlewareData$offse, _middlewareData$offse2;
4946 const len = mainAxis === "y" ? "width" : "height";
4947 const isOriginSide = originSides.has(getSide(placement));
4948 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);
4949 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);
4950 if (crossAxisCoord < limitMin) {
4951 crossAxisCoord = limitMin;
4952 } else if (crossAxisCoord > limitMax) {
4953 crossAxisCoord = limitMax;
4954 }
4955 }
4956 return {
4957 [mainAxis]: mainAxisCoord,
4958 [crossAxis]: crossAxisCoord
4959 };
4960 }
4961 };
4962 };
4963 var size = function(options) {
4964 if (options === void 0) {
4965 options = {};
4966 }
4967 return {
4968 name: "size",
4969 options,
4970 async fn(state) {
4971 var _state$middlewareData, _state$middlewareData2;
4972 const {
4973 placement,
4974 rects,
4975 platform: platform3,
4976 elements
4977 } = state;
4978 const {
4979 apply = () => {
4980 },
4981 ...detectOverflowOptions
4982 } = evaluate(options, state);
4983 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4984 const side = getSide(placement);
4985 const alignment = getAlignment(placement);
4986 const isYAxis = getSideAxis(placement) === "y";
4987 const {
4988 width,
4989 height
4990 } = rects.floating;
4991 let heightSide;
4992 let widthSide;
4993 if (side === "top" || side === "bottom") {
4994 heightSide = side;
4995 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4996 } else {
4997 widthSide = side;
4998 heightSide = alignment === "end" ? "top" : "bottom";
4999 }
5000 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5001 const maximumClippingWidth = width - overflow.left - overflow.right;
5002 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5003 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5004 const noShift = !state.middlewareData.shift;
5005 let availableHeight = overflowAvailableHeight;
5006 let availableWidth = overflowAvailableWidth;
5007 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5008 availableWidth = maximumClippingWidth;
5009 }
5010 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5011 availableHeight = maximumClippingHeight;
5012 }
5013 if (noShift && !alignment) {
5014 const xMin = max(overflow.left, 0);
5015 const xMax = max(overflow.right, 0);
5016 const yMin = max(overflow.top, 0);
5017 const yMax = max(overflow.bottom, 0);
5018 if (isYAxis) {
5019 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5020 } else {
5021 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5022 }
5023 }
5024 await apply({
5025 ...state,
5026 availableWidth,
5027 availableHeight
5028 });
5029 const nextDimensions = await platform3.getDimensions(elements.floating);
5030 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5031 return {
5032 reset: {
5033 rects: true
5034 }
5035 };
5036 }
5037 return {};
5038 }
5039 };
5040 };
5041
5042 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5043 function getCssDimensions(element) {
5044 const css = getComputedStyle2(element);
5045 let width = parseFloat(css.width) || 0;
5046 let height = parseFloat(css.height) || 0;
5047 const hasOffset = isHTMLElement(element);
5048 const offsetWidth = hasOffset ? element.offsetWidth : width;
5049 const offsetHeight = hasOffset ? element.offsetHeight : height;
5050 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5051 if (shouldFallback) {
5052 width = offsetWidth;
5053 height = offsetHeight;
5054 }
5055 return {
5056 width,
5057 height,
5058 $: shouldFallback
5059 };
5060 }
5061 function unwrapElement(element) {
5062 return !isElement(element) ? element.contextElement : element;
5063 }
5064 function getScale(element) {
5065 const domElement = unwrapElement(element);
5066 if (!isHTMLElement(domElement)) {
5067 return createCoords(1);
5068 }
5069 const rect = domElement.getBoundingClientRect();
5070 const {
5071 width,
5072 height,
5073 $: $2
5074 } = getCssDimensions(domElement);
5075 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5076 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5077 if (!x2 || !Number.isFinite(x2)) {
5078 x2 = 1;
5079 }
5080 if (!y2 || !Number.isFinite(y2)) {
5081 y2 = 1;
5082 }
5083 return {
5084 x: x2,
5085 y: y2
5086 };
5087 }
5088 var noOffsets = /* @__PURE__ */ createCoords(0);
5089 function getVisualOffsets(element) {
5090 const win = getWindow(element);
5091 if (!isWebKit() || !win.visualViewport) {
5092 return noOffsets;
5093 }
5094 return {
5095 x: win.visualViewport.offsetLeft,
5096 y: win.visualViewport.offsetTop
5097 };
5098 }
5099 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5100 if (isFixed === void 0) {
5101 isFixed = false;
5102 }
5103 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5104 return false;
5105 }
5106 return isFixed;
5107 }
5108 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5109 if (includeScale === void 0) {
5110 includeScale = false;
5111 }
5112 if (isFixedStrategy === void 0) {
5113 isFixedStrategy = false;
5114 }
5115 const clientRect = element.getBoundingClientRect();
5116 const domElement = unwrapElement(element);
5117 let scale = createCoords(1);
5118 if (includeScale) {
5119 if (offsetParent) {
5120 if (isElement(offsetParent)) {
5121 scale = getScale(offsetParent);
5122 }
5123 } else {
5124 scale = getScale(element);
5125 }
5126 }
5127 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5128 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5129 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5130 let width = clientRect.width / scale.x;
5131 let height = clientRect.height / scale.y;
5132 if (domElement) {
5133 const win = getWindow(domElement);
5134 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5135 let currentWin = win;
5136 let currentIFrame = getFrameElement(currentWin);
5137 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5138 const iframeScale = getScale(currentIFrame);
5139 const iframeRect = currentIFrame.getBoundingClientRect();
5140 const css = getComputedStyle2(currentIFrame);
5141 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5142 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5143 x2 *= iframeScale.x;
5144 y2 *= iframeScale.y;
5145 width *= iframeScale.x;
5146 height *= iframeScale.y;
5147 x2 += left;
5148 y2 += top;
5149 currentWin = getWindow(currentIFrame);
5150 currentIFrame = getFrameElement(currentWin);
5151 }
5152 }
5153 return rectToClientRect({
5154 width,
5155 height,
5156 x: x2,
5157 y: y2
5158 });
5159 }
5160 function getWindowScrollBarX(element, rect) {
5161 const leftScroll = getNodeScroll(element).scrollLeft;
5162 if (!rect) {
5163 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5164 }
5165 return rect.left + leftScroll;
5166 }
5167 function getHTMLOffset(documentElement, scroll) {
5168 const htmlRect = documentElement.getBoundingClientRect();
5169 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5170 const y2 = htmlRect.top + scroll.scrollTop;
5171 return {
5172 x: x2,
5173 y: y2
5174 };
5175 }
5176 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5177 let {
5178 elements,
5179 rect,
5180 offsetParent,
5181 strategy
5182 } = _ref;
5183 const isFixed = strategy === "fixed";
5184 const documentElement = getDocumentElement(offsetParent);
5185 const topLayer = elements ? isTopLayer(elements.floating) : false;
5186 if (offsetParent === documentElement || topLayer && isFixed) {
5187 return rect;
5188 }
5189 let scroll = {
5190 scrollLeft: 0,
5191 scrollTop: 0
5192 };
5193 let scale = createCoords(1);
5194 const offsets = createCoords(0);
5195 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5196 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5197 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5198 scroll = getNodeScroll(offsetParent);
5199 }
5200 if (isOffsetParentAnElement) {
5201 const offsetRect = getBoundingClientRect(offsetParent);
5202 scale = getScale(offsetParent);
5203 offsets.x = offsetRect.x + offsetParent.clientLeft;
5204 offsets.y = offsetRect.y + offsetParent.clientTop;
5205 }
5206 }
5207 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5208 return {
5209 width: rect.width * scale.x,
5210 height: rect.height * scale.y,
5211 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5212 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5213 };
5214 }
5215 function getClientRects(element) {
5216 return Array.from(element.getClientRects());
5217 }
5218 function getDocumentRect(element) {
5219 const html = getDocumentElement(element);
5220 const scroll = getNodeScroll(element);
5221 const body = element.ownerDocument.body;
5222 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5223 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5224 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5225 const y2 = -scroll.scrollTop;
5226 if (getComputedStyle2(body).direction === "rtl") {
5227 x2 += max(html.clientWidth, body.clientWidth) - width;
5228 }
5229 return {
5230 width,
5231 height,
5232 x: x2,
5233 y: y2
5234 };
5235 }
5236 var SCROLLBAR_MAX = 25;
5237 function getViewportRect(element, strategy) {
5238 const win = getWindow(element);
5239 const html = getDocumentElement(element);
5240 const visualViewport = win.visualViewport;
5241 let width = html.clientWidth;
5242 let height = html.clientHeight;
5243 let x2 = 0;
5244 let y2 = 0;
5245 if (visualViewport) {
5246 width = visualViewport.width;
5247 height = visualViewport.height;
5248 const visualViewportBased = isWebKit();
5249 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5250 x2 = visualViewport.offsetLeft;
5251 y2 = visualViewport.offsetTop;
5252 }
5253 }
5254 const windowScrollbarX = getWindowScrollBarX(html);
5255 if (windowScrollbarX <= 0) {
5256 const doc = html.ownerDocument;
5257 const body = doc.body;
5258 const bodyStyles = getComputedStyle(body);
5259 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5260 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5261 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5262 width -= clippingStableScrollbarWidth;
5263 }
5264 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5265 width += windowScrollbarX;
5266 }
5267 return {
5268 width,
5269 height,
5270 x: x2,
5271 y: y2
5272 };
5273 }
5274 function getInnerBoundingClientRect(element, strategy) {
5275 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5276 const top = clientRect.top + element.clientTop;
5277 const left = clientRect.left + element.clientLeft;
5278 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5279 const width = element.clientWidth * scale.x;
5280 const height = element.clientHeight * scale.y;
5281 const x2 = left * scale.x;
5282 const y2 = top * scale.y;
5283 return {
5284 width,
5285 height,
5286 x: x2,
5287 y: y2
5288 };
5289 }
5290 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5291 let rect;
5292 if (clippingAncestor === "viewport") {
5293 rect = getViewportRect(element, strategy);
5294 } else if (clippingAncestor === "document") {
5295 rect = getDocumentRect(getDocumentElement(element));
5296 } else if (isElement(clippingAncestor)) {
5297 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5298 } else {
5299 const visualOffsets = getVisualOffsets(element);
5300 rect = {
5301 x: clippingAncestor.x - visualOffsets.x,
5302 y: clippingAncestor.y - visualOffsets.y,
5303 width: clippingAncestor.width,
5304 height: clippingAncestor.height
5305 };
5306 }
5307 return rectToClientRect(rect);
5308 }
5309 function hasFixedPositionAncestor(element, stopNode) {
5310 const parentNode = getParentNode(element);
5311 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5312 return false;
5313 }
5314 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5315 }
5316 function getClippingElementAncestors(element, cache) {
5317 const cachedResult = cache.get(element);
5318 if (cachedResult) {
5319 return cachedResult;
5320 }
5321 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5322 let currentContainingBlockComputedStyle = null;
5323 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5324 let currentNode = elementIsFixed ? getParentNode(element) : element;
5325 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5326 const computedStyle = getComputedStyle2(currentNode);
5327 const currentNodeIsContaining = isContainingBlock(currentNode);
5328 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5329 currentContainingBlockComputedStyle = null;
5330 }
5331 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5332 if (shouldDropCurrentNode) {
5333 result = result.filter((ancestor) => ancestor !== currentNode);
5334 } else {
5335 currentContainingBlockComputedStyle = computedStyle;
5336 }
5337 currentNode = getParentNode(currentNode);
5338 }
5339 cache.set(element, result);
5340 return result;
5341 }
5342 function getClippingRect(_ref) {
5343 let {
5344 element,
5345 boundary,
5346 rootBoundary,
5347 strategy
5348 } = _ref;
5349 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5350 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5351 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5352 let top = firstRect.top;
5353 let right = firstRect.right;
5354 let bottom = firstRect.bottom;
5355 let left = firstRect.left;
5356 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5357 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5358 top = max(rect.top, top);
5359 right = min(rect.right, right);
5360 bottom = min(rect.bottom, bottom);
5361 left = max(rect.left, left);
5362 }
5363 return {
5364 width: right - left,
5365 height: bottom - top,
5366 x: left,
5367 y: top
5368 };
5369 }
5370 function getDimensions2(element) {
5371 const {
5372 width,
5373 height
5374 } = getCssDimensions(element);
5375 return {
5376 width,
5377 height
5378 };
5379 }
5380 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5381 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5382 const documentElement = getDocumentElement(offsetParent);
5383 const isFixed = strategy === "fixed";
5384 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5385 let scroll = {
5386 scrollLeft: 0,
5387 scrollTop: 0
5388 };
5389 const offsets = createCoords(0);
5390 function setLeftRTLScrollbarOffset() {
5391 offsets.x = getWindowScrollBarX(documentElement);
5392 }
5393 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5394 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5395 scroll = getNodeScroll(offsetParent);
5396 }
5397 if (isOffsetParentAnElement) {
5398 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5399 offsets.x = offsetRect.x + offsetParent.clientLeft;
5400 offsets.y = offsetRect.y + offsetParent.clientTop;
5401 } else if (documentElement) {
5402 setLeftRTLScrollbarOffset();
5403 }
5404 }
5405 if (isFixed && !isOffsetParentAnElement && documentElement) {
5406 setLeftRTLScrollbarOffset();
5407 }
5408 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5409 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5410 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5411 return {
5412 x: x2,
5413 y: y2,
5414 width: rect.width,
5415 height: rect.height
5416 };
5417 }
5418 function isStaticPositioned(element) {
5419 return getComputedStyle2(element).position === "static";
5420 }
5421 function getTrueOffsetParent(element, polyfill) {
5422 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5423 return null;
5424 }
5425 if (polyfill) {
5426 return polyfill(element);
5427 }
5428 let rawOffsetParent = element.offsetParent;
5429 if (getDocumentElement(element) === rawOffsetParent) {
5430 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5431 }
5432 return rawOffsetParent;
5433 }
5434 function getOffsetParent(element, polyfill) {
5435 const win = getWindow(element);
5436 if (isTopLayer(element)) {
5437 return win;
5438 }
5439 if (!isHTMLElement(element)) {
5440 let svgOffsetParent = getParentNode(element);
5441 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5442 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5443 return svgOffsetParent;
5444 }
5445 svgOffsetParent = getParentNode(svgOffsetParent);
5446 }
5447 return win;
5448 }
5449 let offsetParent = getTrueOffsetParent(element, polyfill);
5450 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5451 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5452 }
5453 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5454 return win;
5455 }
5456 return offsetParent || getContainingBlock(element) || win;
5457 }
5458 var getElementRects = async function(data) {
5459 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5460 const getDimensionsFn = this.getDimensions;
5461 const floatingDimensions = await getDimensionsFn(data.floating);
5462 return {
5463 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5464 floating: {
5465 x: 0,
5466 y: 0,
5467 width: floatingDimensions.width,
5468 height: floatingDimensions.height
5469 }
5470 };
5471 };
5472 function isRTL(element) {
5473 return getComputedStyle2(element).direction === "rtl";
5474 }
5475 var platform2 = {
5476 convertOffsetParentRelativeRectToViewportRelativeRect,
5477 getDocumentElement,
5478 getClippingRect,
5479 getOffsetParent,
5480 getElementRects,
5481 getClientRects,
5482 getDimensions: getDimensions2,
5483 getScale,
5484 isElement,
5485 isRTL
5486 };
5487 function rectsAreEqual(a2, b2) {
5488 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5489 }
5490 function observeMove(element, onMove) {
5491 let io = null;
5492 let timeoutId;
5493 const root = getDocumentElement(element);
5494 function cleanup() {
5495 var _io;
5496 clearTimeout(timeoutId);
5497 (_io = io) == null || _io.disconnect();
5498 io = null;
5499 }
5500 function refresh(skip, threshold) {
5501 if (skip === void 0) {
5502 skip = false;
5503 }
5504 if (threshold === void 0) {
5505 threshold = 1;
5506 }
5507 cleanup();
5508 const elementRectForRootMargin = element.getBoundingClientRect();
5509 const {
5510 left,
5511 top,
5512 width,
5513 height
5514 } = elementRectForRootMargin;
5515 if (!skip) {
5516 onMove();
5517 }
5518 if (!width || !height) {
5519 return;
5520 }
5521 const insetTop = floor(top);
5522 const insetRight = floor(root.clientWidth - (left + width));
5523 const insetBottom = floor(root.clientHeight - (top + height));
5524 const insetLeft = floor(left);
5525 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5526 const options = {
5527 rootMargin,
5528 threshold: max(0, min(1, threshold)) || 1
5529 };
5530 let isFirstUpdate = true;
5531 function handleObserve(entries) {
5532 const ratio = entries[0].intersectionRatio;
5533 if (ratio !== threshold) {
5534 if (!isFirstUpdate) {
5535 return refresh();
5536 }
5537 if (!ratio) {
5538 timeoutId = setTimeout(() => {
5539 refresh(false, 1e-7);
5540 }, 1e3);
5541 } else {
5542 refresh(false, ratio);
5543 }
5544 }
5545 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5546 refresh();
5547 }
5548 isFirstUpdate = false;
5549 }
5550 try {
5551 io = new IntersectionObserver(handleObserve, {
5552 ...options,
5553 // Handle <iframe>s
5554 root: root.ownerDocument
5555 });
5556 } catch (_e) {
5557 io = new IntersectionObserver(handleObserve, options);
5558 }
5559 io.observe(element);
5560 }
5561 refresh(true);
5562 return cleanup;
5563 }
5564 function autoUpdate(reference, floating, update2, options) {
5565 if (options === void 0) {
5566 options = {};
5567 }
5568 const {
5569 ancestorScroll = true,
5570 ancestorResize = true,
5571 elementResize = typeof ResizeObserver === "function",
5572 layoutShift = typeof IntersectionObserver === "function",
5573 animationFrame = false
5574 } = options;
5575 const referenceEl = unwrapElement(reference);
5576 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5577 ancestors.forEach((ancestor) => {
5578 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5579 passive: true
5580 });
5581 ancestorResize && ancestor.addEventListener("resize", update2);
5582 });
5583 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5584 let reobserveFrame = -1;
5585 let resizeObserver = null;
5586 if (elementResize) {
5587 resizeObserver = new ResizeObserver((_ref) => {
5588 let [firstEntry] = _ref;
5589 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5590 resizeObserver.unobserve(floating);
5591 cancelAnimationFrame(reobserveFrame);
5592 reobserveFrame = requestAnimationFrame(() => {
5593 var _resizeObserver;
5594 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5595 });
5596 }
5597 update2();
5598 });
5599 if (referenceEl && !animationFrame) {
5600 resizeObserver.observe(referenceEl);
5601 }
5602 if (floating) {
5603 resizeObserver.observe(floating);
5604 }
5605 }
5606 let frameId;
5607 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5608 if (animationFrame) {
5609 frameLoop();
5610 }
5611 function frameLoop() {
5612 const nextRefRect = getBoundingClientRect(reference);
5613 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5614 update2();
5615 }
5616 prevRefRect = nextRefRect;
5617 frameId = requestAnimationFrame(frameLoop);
5618 }
5619 update2();
5620 return () => {
5621 var _resizeObserver2;
5622 ancestors.forEach((ancestor) => {
5623 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5624 ancestorResize && ancestor.removeEventListener("resize", update2);
5625 });
5626 cleanupIo == null || cleanupIo();
5627 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5628 resizeObserver = null;
5629 if (animationFrame) {
5630 cancelAnimationFrame(frameId);
5631 }
5632 };
5633 }
5634 var offset2 = offset;
5635 var shift2 = shift;
5636 var flip2 = flip;
5637 var size2 = size;
5638 var hide2 = hide;
5639 var limitShift2 = limitShift;
5640 var computePosition2 = (reference, floating, options) => {
5641 const cache = /* @__PURE__ */ new Map();
5642 const mergedOptions = {
5643 platform: platform2,
5644 ...options
5645 };
5646 const platformWithCache = {
5647 ...mergedOptions.platform,
5648 _c: cache
5649 };
5650 return computePosition(reference, floating, {
5651 ...mergedOptions,
5652 platform: platformWithCache
5653 });
5654 };
5655
5656 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5657 var React27 = __toESM(require_react(), 1);
5658 var import_react2 = __toESM(require_react(), 1);
5659 var ReactDOM3 = __toESM(require_react_dom(), 1);
5660 var isClient = typeof document !== "undefined";
5661 var noop2 = function noop3() {
5662 };
5663 var index = isClient ? import_react2.useLayoutEffect : noop2;
5664 function deepEqual(a2, b2) {
5665 if (a2 === b2) {
5666 return true;
5667 }
5668 if (typeof a2 !== typeof b2) {
5669 return false;
5670 }
5671 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5672 return true;
5673 }
5674 let length;
5675 let i2;
5676 let keys;
5677 if (a2 && b2 && typeof a2 === "object") {
5678 if (Array.isArray(a2)) {
5679 length = a2.length;
5680 if (length !== b2.length) return false;
5681 for (i2 = length; i2-- !== 0; ) {
5682 if (!deepEqual(a2[i2], b2[i2])) {
5683 return false;
5684 }
5685 }
5686 return true;
5687 }
5688 keys = Object.keys(a2);
5689 length = keys.length;
5690 if (length !== Object.keys(b2).length) {
5691 return false;
5692 }
5693 for (i2 = length; i2-- !== 0; ) {
5694 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5695 return false;
5696 }
5697 }
5698 for (i2 = length; i2-- !== 0; ) {
5699 const key = keys[i2];
5700 if (key === "_owner" && a2.$$typeof) {
5701 continue;
5702 }
5703 if (!deepEqual(a2[key], b2[key])) {
5704 return false;
5705 }
5706 }
5707 return true;
5708 }
5709 return a2 !== a2 && b2 !== b2;
5710 }
5711 function getDPR(element) {
5712 if (typeof window === "undefined") {
5713 return 1;
5714 }
5715 const win = element.ownerDocument.defaultView || window;
5716 return win.devicePixelRatio || 1;
5717 }
5718 function roundByDPR(element, value) {
5719 const dpr = getDPR(element);
5720 return Math.round(value * dpr) / dpr;
5721 }
5722 function useLatestRef(value) {
5723 const ref = React27.useRef(value);
5724 index(() => {
5725 ref.current = value;
5726 });
5727 return ref;
5728 }
5729 function useFloating(options) {
5730 if (options === void 0) {
5731 options = {};
5732 }
5733 const {
5734 placement = "bottom",
5735 strategy = "absolute",
5736 middleware = [],
5737 platform: platform3,
5738 elements: {
5739 reference: externalReference,
5740 floating: externalFloating
5741 } = {},
5742 transform = true,
5743 whileElementsMounted,
5744 open
5745 } = options;
5746 const [data, setData] = React27.useState({
5747 x: 0,
5748 y: 0,
5749 strategy,
5750 placement,
5751 middlewareData: {},
5752 isPositioned: false
5753 });
5754 const [latestMiddleware, setLatestMiddleware] = React27.useState(middleware);
5755 if (!deepEqual(latestMiddleware, middleware)) {
5756 setLatestMiddleware(middleware);
5757 }
5758 const [_reference, _setReference] = React27.useState(null);
5759 const [_floating, _setFloating] = React27.useState(null);
5760 const setReference = React27.useCallback((node) => {
5761 if (node !== referenceRef.current) {
5762 referenceRef.current = node;
5763 _setReference(node);
5764 }
5765 }, []);
5766 const setFloating = React27.useCallback((node) => {
5767 if (node !== floatingRef.current) {
5768 floatingRef.current = node;
5769 _setFloating(node);
5770 }
5771 }, []);
5772 const referenceEl = externalReference || _reference;
5773 const floatingEl = externalFloating || _floating;
5774 const referenceRef = React27.useRef(null);
5775 const floatingRef = React27.useRef(null);
5776 const dataRef = React27.useRef(data);
5777 const hasWhileElementsMounted = whileElementsMounted != null;
5778 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5779 const platformRef = useLatestRef(platform3);
5780 const openRef = useLatestRef(open);
5781 const update2 = React27.useCallback(() => {
5782 if (!referenceRef.current || !floatingRef.current) {
5783 return;
5784 }
5785 const config = {
5786 placement,
5787 strategy,
5788 middleware: latestMiddleware
5789 };
5790 if (platformRef.current) {
5791 config.platform = platformRef.current;
5792 }
5793 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5794 const fullData = {
5795 ...data2,
5796 // The floating element's position may be recomputed while it's closed
5797 // but still mounted (such as when transitioning out). To ensure
5798 // `isPositioned` will be `false` initially on the next open, avoid
5799 // setting it to `true` when `open === false` (must be specified).
5800 isPositioned: openRef.current !== false
5801 };
5802 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5803 dataRef.current = fullData;
5804 ReactDOM3.flushSync(() => {
5805 setData(fullData);
5806 });
5807 }
5808 });
5809 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5810 index(() => {
5811 if (open === false && dataRef.current.isPositioned) {
5812 dataRef.current.isPositioned = false;
5813 setData((data2) => ({
5814 ...data2,
5815 isPositioned: false
5816 }));
5817 }
5818 }, [open]);
5819 const isMountedRef = React27.useRef(false);
5820 index(() => {
5821 isMountedRef.current = true;
5822 return () => {
5823 isMountedRef.current = false;
5824 };
5825 }, []);
5826 index(() => {
5827 if (referenceEl) referenceRef.current = referenceEl;
5828 if (floatingEl) floatingRef.current = floatingEl;
5829 if (referenceEl && floatingEl) {
5830 if (whileElementsMountedRef.current) {
5831 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5832 }
5833 update2();
5834 }
5835 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5836 const refs = React27.useMemo(() => ({
5837 reference: referenceRef,
5838 floating: floatingRef,
5839 setReference,
5840 setFloating
5841 }), [setReference, setFloating]);
5842 const elements = React27.useMemo(() => ({
5843 reference: referenceEl,
5844 floating: floatingEl
5845 }), [referenceEl, floatingEl]);
5846 const floatingStyles = React27.useMemo(() => {
5847 const initialStyles = {
5848 position: strategy,
5849 left: 0,
5850 top: 0
5851 };
5852 if (!elements.floating) {
5853 return initialStyles;
5854 }
5855 const x2 = roundByDPR(elements.floating, data.x);
5856 const y2 = roundByDPR(elements.floating, data.y);
5857 if (transform) {
5858 return {
5859 ...initialStyles,
5860 transform: "translate(" + x2 + "px, " + y2 + "px)",
5861 ...getDPR(elements.floating) >= 1.5 && {
5862 willChange: "transform"
5863 }
5864 };
5865 }
5866 return {
5867 position: strategy,
5868 left: x2,
5869 top: y2
5870 };
5871 }, [strategy, transform, elements.floating, data.x, data.y]);
5872 return React27.useMemo(() => ({
5873 ...data,
5874 update: update2,
5875 refs,
5876 elements,
5877 floatingStyles
5878 }), [data, update2, refs, elements, floatingStyles]);
5879 }
5880 var offset3 = (options, deps) => {
5881 const result = offset2(options);
5882 return {
5883 name: result.name,
5884 fn: result.fn,
5885 options: [options, deps]
5886 };
5887 };
5888 var shift3 = (options, deps) => {
5889 const result = shift2(options);
5890 return {
5891 name: result.name,
5892 fn: result.fn,
5893 options: [options, deps]
5894 };
5895 };
5896 var limitShift3 = (options, deps) => {
5897 const result = limitShift2(options);
5898 return {
5899 fn: result.fn,
5900 options: [options, deps]
5901 };
5902 };
5903 var flip3 = (options, deps) => {
5904 const result = flip2(options);
5905 return {
5906 name: result.name,
5907 fn: result.fn,
5908 options: [options, deps]
5909 };
5910 };
5911 var size3 = (options, deps) => {
5912 const result = size2(options);
5913 return {
5914 name: result.name,
5915 fn: result.fn,
5916 options: [options, deps]
5917 };
5918 };
5919 var hide3 = (options, deps) => {
5920 const result = hide2(options);
5921 return {
5922 name: result.name,
5923 fn: result.fn,
5924 options: [options, deps]
5925 };
5926 };
5927
5928 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5929 var React32 = __toESM(require_react(), 1);
5930 var ReactDOM4 = __toESM(require_react_dom(), 1);
5931
5932 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5933 var React31 = __toESM(require_react(), 1);
5934
5935 // node_modules/@base-ui/utils/store/createSelector.mjs
5936 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5937 if (other.length > 0) {
5938 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5939 }
5940 let selector2;
5941 if (a2 && b2 && c2 && d2 && e2 && f2) {
5942 selector2 = (state, a1, a22, a3) => {
5943 const va = a2(state, a1, a22, a3);
5944 const vb = b2(state, a1, a22, a3);
5945 const vc = c2(state, a1, a22, a3);
5946 const vd = d2(state, a1, a22, a3);
5947 const ve = e2(state, a1, a22, a3);
5948 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5949 };
5950 } else if (a2 && b2 && c2 && d2 && e2) {
5951 selector2 = (state, a1, a22, a3) => {
5952 const va = a2(state, a1, a22, a3);
5953 const vb = b2(state, a1, a22, a3);
5954 const vc = c2(state, a1, a22, a3);
5955 const vd = d2(state, a1, a22, a3);
5956 return e2(va, vb, vc, vd, a1, a22, a3);
5957 };
5958 } else if (a2 && b2 && c2 && d2) {
5959 selector2 = (state, a1, a22, a3) => {
5960 const va = a2(state, a1, a22, a3);
5961 const vb = b2(state, a1, a22, a3);
5962 const vc = c2(state, a1, a22, a3);
5963 return d2(va, vb, vc, a1, a22, a3);
5964 };
5965 } else if (a2 && b2 && c2) {
5966 selector2 = (state, a1, a22, a3) => {
5967 const va = a2(state, a1, a22, a3);
5968 const vb = b2(state, a1, a22, a3);
5969 return c2(va, vb, a1, a22, a3);
5970 };
5971 } else if (a2 && b2) {
5972 selector2 = (state, a1, a22, a3) => {
5973 const va = a2(state, a1, a22, a3);
5974 return b2(va, a1, a22, a3);
5975 };
5976 } else if (a2) {
5977 selector2 = a2;
5978 } else {
5979 throw (
5980 /* minify-error-disabled */
5981 new Error("Missing arguments")
5982 );
5983 }
5984 return selector2;
5985 };
5986
5987 // node_modules/@base-ui/utils/store/useStore.mjs
5988 var React29 = __toESM(require_react(), 1);
5989 var import_shim = __toESM(require_shim(), 1);
5990 var import_with_selector = __toESM(require_with_selector(), 1);
5991
5992 // node_modules/@base-ui/utils/fastHooks.mjs
5993 var React28 = __toESM(require_react(), 1);
5994 var hooks = [];
5995 var currentInstance = void 0;
5996 function getInstance() {
5997 return currentInstance;
5998 }
5999 function register(hook) {
6000 hooks.push(hook);
6001 }
6002 function fastComponent(fn) {
6003 const FastComponent = (props, forwardedRef) => {
6004 const instance = useRefWithInit(createInstance).current;
6005 let result;
6006 try {
6007 currentInstance = instance;
6008 for (const hook of hooks) {
6009 hook.before(instance);
6010 }
6011 result = fn(props, forwardedRef);
6012 for (const hook of hooks) {
6013 hook.after(instance);
6014 }
6015 instance.didInitialize = true;
6016 } finally {
6017 currentInstance = void 0;
6018 }
6019 return result;
6020 };
6021 FastComponent.displayName = fn.displayName || fn.name;
6022 return FastComponent;
6023 }
6024 function fastComponentRef(fn) {
6025 return /* @__PURE__ */ React28.forwardRef(fastComponent(fn));
6026 }
6027 function createInstance() {
6028 return {
6029 didInitialize: false
6030 };
6031 }
6032
6033 // node_modules/@base-ui/utils/store/useStore.mjs
6034 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6035 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6036 function useStore(store, selector2, a1, a2, a3) {
6037 return useStoreImplementation(store, selector2, a1, a2, a3);
6038 }
6039 function useStoreR19(store, selector2, a1, a2, a3) {
6040 const getSelection = React29.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6041 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6042 }
6043 register({
6044 before(instance) {
6045 instance.syncIndex = 0;
6046 if (!instance.didInitialize) {
6047 instance.syncTick = 1;
6048 instance.syncHooks = [];
6049 instance.didChangeStore = true;
6050 instance.getSnapshot = () => {
6051 let didChange2 = false;
6052 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6053 const hook = instance.syncHooks[i2];
6054 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6055 if (!Object.is(hook.value, value)) {
6056 didChange2 = true;
6057 hook.value = value;
6058 }
6059 }
6060 if (didChange2) {
6061 instance.syncTick += 1;
6062 }
6063 return instance.syncTick;
6064 };
6065 }
6066 },
6067 after(instance) {
6068 if (instance.syncHooks.length > 0) {
6069 if (instance.didChangeStore) {
6070 instance.didChangeStore = false;
6071 instance.subscribe = (onStoreChange) => {
6072 const stores = /* @__PURE__ */ new Set();
6073 for (const hook of instance.syncHooks) {
6074 stores.add(hook.store);
6075 }
6076 const unsubscribes = [];
6077 for (const store of stores) {
6078 unsubscribes.push(store.subscribe(onStoreChange));
6079 }
6080 return () => {
6081 for (const unsubscribe of unsubscribes) {
6082 unsubscribe();
6083 }
6084 };
6085 };
6086 }
6087 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6088 }
6089 }
6090 });
6091 function useStoreFast(store, selector2, a1, a2, a3) {
6092 const instance = getInstance();
6093 if (!instance) {
6094 return useStoreR19(store, selector2, a1, a2, a3);
6095 }
6096 const index2 = instance.syncIndex;
6097 instance.syncIndex += 1;
6098 let hook;
6099 if (!instance.didInitialize) {
6100 hook = {
6101 store,
6102 selector: selector2,
6103 a1,
6104 a2,
6105 a3,
6106 value: selector2(store.getSnapshot(), a1, a2, a3)
6107 };
6108 instance.syncHooks.push(hook);
6109 } else {
6110 hook = instance.syncHooks[index2];
6111 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6112 if (hook.store !== store) {
6113 instance.didChangeStore = true;
6114 }
6115 hook.store = store;
6116 hook.selector = selector2;
6117 hook.a1 = a1;
6118 hook.a2 = a2;
6119 hook.a3 = a3;
6120 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
6121 }
6122 }
6123 return hook.value;
6124 }
6125 function useStoreLegacy(store, selector2, a1, a2, a3) {
6126 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6127 }
6128
6129 // node_modules/@base-ui/utils/store/Store.mjs
6130 var Store = class {
6131 /**
6132 * The current state of the store.
6133 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6134 * 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).
6135 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6136 *
6137 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6138 */
6139 // Internal state to handle recursive `setState()` calls
6140 constructor(state) {
6141 this.state = state;
6142 this.listeners = /* @__PURE__ */ new Set();
6143 this.updateTick = 0;
6144 }
6145 /**
6146 * Registers a listener that will be called whenever the store's state changes.
6147 *
6148 * @param fn The listener function to be called on state changes.
6149 * @returns A function to unsubscribe the listener.
6150 */
6151 subscribe = (fn) => {
6152 this.listeners.add(fn);
6153 return () => {
6154 this.listeners.delete(fn);
6155 };
6156 };
6157 /**
6158 * Returns the current state of the store.
6159 */
6160 getSnapshot = () => {
6161 return this.state;
6162 };
6163 /**
6164 * Updates the entire store's state and notifies all registered listeners.
6165 *
6166 * @param newState The new state to set for the store.
6167 */
6168 setState(newState) {
6169 if (this.state === newState) {
6170 return;
6171 }
6172 this.state = newState;
6173 this.updateTick += 1;
6174 const currentTick = this.updateTick;
6175 for (const listener of this.listeners) {
6176 if (currentTick !== this.updateTick) {
6177 return;
6178 }
6179 listener(newState);
6180 }
6181 }
6182 /**
6183 * Merges the provided changes into the current state and notifies listeners if there are changes.
6184 *
6185 * @param changes An object containing the changes to apply to the current state.
6186 */
6187 update(changes) {
6188 for (const key in changes) {
6189 if (!Object.is(this.state[key], changes[key])) {
6190 this.setState({
6191 ...this.state,
6192 ...changes
6193 });
6194 return;
6195 }
6196 }
6197 }
6198 /**
6199 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6200 *
6201 * @param key The key in the store's state to update.
6202 * @param value The new value to set for the specified key.
6203 */
6204 set(key, value) {
6205 if (!Object.is(this.state[key], value)) {
6206 this.setState({
6207 ...this.state,
6208 [key]: value
6209 });
6210 }
6211 }
6212 /**
6213 * Gives the state a new reference and updates all registered listeners.
6214 */
6215 notifyAll() {
6216 const newState = {
6217 ...this.state
6218 };
6219 this.setState(newState);
6220 }
6221 use(selector2, a1, a2, a3) {
6222 return useStore(this, selector2, a1, a2, a3);
6223 }
6224 };
6225
6226 // node_modules/@base-ui/utils/store/ReactStore.mjs
6227 var React30 = __toESM(require_react(), 1);
6228 var ReactStore = class extends Store {
6229 /**
6230 * Creates a new ReactStore instance.
6231 *
6232 * @param state Initial state of the store.
6233 * @param context Non-reactive context values.
6234 * @param selectors Optional selectors for use with `useState`.
6235 */
6236 constructor(state, context = {}, selectors3) {
6237 super(state);
6238 this.context = context;
6239 this.selectors = selectors3;
6240 }
6241 /**
6242 * Non-reactive values such as refs, callbacks, etc.
6243 */
6244 /**
6245 * Synchronizes a single external value into the store.
6246 *
6247 * Note that the while the value in `state` is updated immediately, the value returned
6248 * by `useState` is updated before the next render (similarly to React's `useState`).
6249 */
6250 useSyncedValue(key, value) {
6251 React30.useDebugValue(key);
6252 const store = this;
6253 useIsoLayoutEffect(() => {
6254 if (store.state[key] !== value) {
6255 store.set(key, value);
6256 }
6257 }, [store, key, value]);
6258 }
6259 /**
6260 * Synchronizes a single external value into the store and
6261 * cleans it up (sets to `undefined`) on unmount.
6262 *
6263 * Note that the while the value in `state` is updated immediately, the value returned
6264 * by `useState` is updated before the next render (similarly to React's `useState`).
6265 */
6266 useSyncedValueWithCleanup(key, value) {
6267 const store = this;
6268 useIsoLayoutEffect(() => {
6269 if (store.state[key] !== value) {
6270 store.set(key, value);
6271 }
6272 return () => {
6273 store.set(key, void 0);
6274 };
6275 }, [store, key, value]);
6276 }
6277 /**
6278 * Synchronizes multiple external values into the store.
6279 *
6280 * Note that the while the values in `state` are updated immediately, the values returned
6281 * by `useState` are updated before the next render (similarly to React's `useState`).
6282 */
6283 useSyncedValues(statePart) {
6284 const store = this;
6285 if (true) {
6286 React30.useDebugValue(statePart, (p2) => Object.keys(p2));
6287 const keys = React30.useRef(Object.keys(statePart)).current;
6288 const nextKeys = Object.keys(statePart);
6289 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6290 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6291 }
6292 }
6293 const dependencies = Object.values(statePart);
6294 useIsoLayoutEffect(() => {
6295 store.update(statePart);
6296 }, [store, ...dependencies]);
6297 }
6298 /**
6299 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6300 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6301 */
6302 useControlledProp(key, controlled) {
6303 React30.useDebugValue(key);
6304 const store = this;
6305 const isControlled = controlled !== void 0;
6306 useIsoLayoutEffect(() => {
6307 if (isControlled && !Object.is(store.state[key], controlled)) {
6308 store.setState({
6309 ...store.state,
6310 [key]: controlled
6311 });
6312 }
6313 }, [store, key, controlled, isControlled]);
6314 if (true) {
6315 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6316 if (!cache.has(key)) {
6317 cache.set(key, isControlled);
6318 }
6319 const previouslyControlled = cache.get(key);
6320 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6321 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).`);
6322 }
6323 }
6324 }
6325 /** Gets the current value from the store using a selector with the provided key.
6326 *
6327 * @param key Key of the selector to use.
6328 */
6329 select(key, a1, a2, a3) {
6330 const selector2 = this.selectors[key];
6331 return selector2(this.state, a1, a2, a3);
6332 }
6333 /**
6334 * Returns a value from the store's state using a selector function.
6335 * Used to subscribe to specific parts of the state.
6336 * This methods causes a rerender whenever the selected state changes.
6337 *
6338 * @param key Key of the selector to use.
6339 */
6340 useState(key, a1, a2, a3) {
6341 React30.useDebugValue(key);
6342 return useStore(this, this.selectors[key], a1, a2, a3);
6343 }
6344 /**
6345 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6346 * and assigns it to the context.
6347 *
6348 * @param key Key of the event callback. Must be a function in the context.
6349 * @param fn Function to assign.
6350 */
6351 useContextCallback(key, fn) {
6352 React30.useDebugValue(key);
6353 const stableFunction = useStableCallback(fn ?? NOOP);
6354 this.context[key] = stableFunction;
6355 }
6356 /**
6357 * Returns a stable setter function for a specific key in the store's state.
6358 * It's commonly used to pass as a ref callback to React elements.
6359 *
6360 * @param key Key of the state to set.
6361 */
6362 useStateSetter(key) {
6363 const ref = React30.useRef(void 0);
6364 if (ref.current === void 0) {
6365 ref.current = (value) => {
6366 this.set(key, value);
6367 };
6368 }
6369 return ref.current;
6370 }
6371 /**
6372 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6373 *
6374 * @param key Key of the selector to observe.
6375 * @param listener Listener function called when the selector result changes.
6376 */
6377 observe(selector2, listener) {
6378 let selectFn;
6379 if (typeof selector2 === "function") {
6380 selectFn = selector2;
6381 } else {
6382 selectFn = this.selectors[selector2];
6383 }
6384 let prevValue = selectFn(this.state);
6385 listener(prevValue, prevValue, this);
6386 return this.subscribe((nextState) => {
6387 const nextValue = selectFn(nextState);
6388 if (!Object.is(prevValue, nextValue)) {
6389 const oldValue = prevValue;
6390 prevValue = nextValue;
6391 listener(nextValue, oldValue, this);
6392 }
6393 });
6394 }
6395 };
6396
6397 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6398 var selectors = {
6399 open: createSelector((state) => state.open),
6400 transitionStatus: createSelector((state) => state.transitionStatus),
6401 domReferenceElement: createSelector((state) => state.domReferenceElement),
6402 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6403 floatingElement: createSelector((state) => state.floatingElement),
6404 floatingId: createSelector((state) => state.floatingId)
6405 };
6406 var FloatingRootStore = class extends ReactStore {
6407 constructor(options) {
6408 const {
6409 syncOnly,
6410 nested,
6411 onOpenChange,
6412 triggerElements,
6413 ...initialState
6414 } = options;
6415 super({
6416 ...initialState,
6417 positionReference: initialState.referenceElement,
6418 domReferenceElement: initialState.referenceElement
6419 }, {
6420 onOpenChange,
6421 dataRef: {
6422 current: {}
6423 },
6424 events: createEventEmitter(),
6425 nested,
6426 triggerElements
6427 }, selectors);
6428 this.syncOnly = syncOnly;
6429 }
6430 /**
6431 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6432 */
6433 syncOpenEvent = (newOpen, event) => {
6434 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6435 // click events to upgrade a hover-open.
6436 event != null && isClickLikeEvent(event)) {
6437 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6438 }
6439 };
6440 /**
6441 * Runs the root-owned side effects for an open state change.
6442 */
6443 dispatchOpenChange = (newOpen, eventDetails) => {
6444 this.syncOpenEvent(newOpen, eventDetails.event);
6445 const details = {
6446 open: newOpen,
6447 reason: eventDetails.reason,
6448 nativeEvent: eventDetails.event,
6449 nested: this.context.nested,
6450 triggerElement: eventDetails.trigger
6451 };
6452 this.context.events.emit("openchange", details);
6453 };
6454 /**
6455 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6456 *
6457 * @param newOpen The new open state.
6458 * @param eventDetails Details about the event that triggered the open state change.
6459 */
6460 setOpen = (newOpen, eventDetails) => {
6461 if (this.syncOnly) {
6462 this.context.onOpenChange?.(newOpen, eventDetails);
6463 return;
6464 }
6465 this.dispatchOpenChange(newOpen, eventDetails);
6466 this.context.onOpenChange?.(newOpen, eventDetails);
6467 };
6468 };
6469
6470 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6471 function useSyncedFloatingRootContext(options) {
6472 const {
6473 popupStore,
6474 treatPopupAsFloatingElement = false,
6475 floatingRootContext: floatingRootContextProp,
6476 floatingId,
6477 nested,
6478 onOpenChange
6479 } = options;
6480 const open = popupStore.useState("open");
6481 const referenceElement = popupStore.useState("activeTriggerElement");
6482 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6483 const triggerElements = popupStore.context.triggerElements;
6484 const handleOpenChange = onOpenChange;
6485 const internalStoreRef = React31.useRef(null);
6486 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6487 internalStoreRef.current = new FloatingRootStore({
6488 open,
6489 transitionStatus: void 0,
6490 referenceElement,
6491 floatingElement,
6492 triggerElements,
6493 onOpenChange: handleOpenChange,
6494 floatingId,
6495 syncOnly: true,
6496 nested
6497 });
6498 }
6499 const store = floatingRootContextProp ?? internalStoreRef.current;
6500 popupStore.useSyncedValue("floatingId", floatingId);
6501 useIsoLayoutEffect(() => {
6502 const valuesToSync = {
6503 open,
6504 floatingId,
6505 referenceElement,
6506 floatingElement
6507 };
6508 if (isElement(referenceElement)) {
6509 valuesToSync.domReferenceElement = referenceElement;
6510 }
6511 if (store.state.positionReference === store.state.referenceElement) {
6512 valuesToSync.positionReference = referenceElement;
6513 }
6514 store.update(valuesToSync);
6515 }, [open, floatingId, referenceElement, floatingElement, store]);
6516 store.context.onOpenChange = handleOpenChange;
6517 store.context.nested = nested;
6518 return store;
6519 }
6520
6521 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6522 var FOCUSABLE_POPUP_PROPS = {
6523 tabIndex: -1,
6524 [FOCUSABLE_ATTRIBUTE]: ""
6525 };
6526 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6527 const floatingId = useId();
6528 const nested = useFloatingParentNodeId() != null;
6529 const internalStoreRef = React32.useRef(null);
6530 if (externalStore === void 0 && internalStoreRef.current === null) {
6531 internalStoreRef.current = createStore2(floatingId, nested);
6532 }
6533 const store = externalStore ?? internalStoreRef.current;
6534 useSyncedFloatingRootContext({
6535 popupStore: store,
6536 treatPopupAsFloatingElement,
6537 floatingRootContext: store.state.floatingRootContext,
6538 floatingId,
6539 nested,
6540 onOpenChange: store.setOpen
6541 });
6542 return {
6543 store,
6544 internalStore: internalStoreRef.current
6545 };
6546 }
6547 function useTriggerRegistration(id, store) {
6548 const registeredElementIdRef = React32.useRef(null);
6549 const registeredElementRef = React32.useRef(null);
6550 return React32.useCallback((element) => {
6551 if (id === void 0) {
6552 return;
6553 }
6554 let shouldSyncTriggerCount = false;
6555 if (registeredElementIdRef.current !== null) {
6556 const registeredId = registeredElementIdRef.current;
6557 const registeredElement = registeredElementRef.current;
6558 const currentElement = store.context.triggerElements.getById(registeredId);
6559 if (registeredElement && currentElement === registeredElement) {
6560 store.context.triggerElements.delete(registeredId);
6561 shouldSyncTriggerCount = true;
6562 }
6563 registeredElementIdRef.current = null;
6564 registeredElementRef.current = null;
6565 }
6566 if (element !== null) {
6567 registeredElementIdRef.current = id;
6568 registeredElementRef.current = element;
6569 store.context.triggerElements.add(id, element);
6570 shouldSyncTriggerCount = true;
6571 }
6572 if (shouldSyncTriggerCount) {
6573 const triggerCount = store.context.triggerElements.size;
6574 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6575 store.set("triggerCount", triggerCount);
6576 }
6577 }
6578 }, [store, id]);
6579 }
6580 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6581 if (open) {
6582 state.preventUnmountingOnClose = false;
6583 } else if (preventUnmountOnClose) {
6584 state.preventUnmountingOnClose = true;
6585 }
6586 const triggerId = trigger?.id ?? null;
6587 if (triggerId || open) {
6588 state.activeTriggerId = triggerId;
6589 state.activeTriggerElement = trigger ?? null;
6590 }
6591 }
6592 function attachPreventUnmountOnClose(eventDetails) {
6593 let preventUnmountOnClose = false;
6594 eventDetails.preventUnmountOnClose = () => {
6595 preventUnmountOnClose = true;
6596 };
6597 return () => preventUnmountOnClose;
6598 }
6599 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6600 const reason = eventDetails.reason;
6601 const isHover = reason === reason_parts_exports.triggerHover;
6602 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6603 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6604 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6605 store.context.onOpenChange?.(nextOpen, eventDetails);
6606 if (eventDetails.isCanceled) {
6607 return;
6608 }
6609 options.onBeforeDispatch?.();
6610 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6611 const changeState = () => {
6612 const updatedState = {
6613 ...options.extraState,
6614 open: nextOpen
6615 };
6616 if (isFocusOpen) {
6617 updatedState.instantType = "focus";
6618 } else if (isDismissClose) {
6619 updatedState.instantType = "dismiss";
6620 } else if (isHover) {
6621 updatedState.instantType = void 0;
6622 }
6623 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6624 store.update(updatedState);
6625 };
6626 if (isHover) {
6627 ReactDOM4.flushSync(changeState);
6628 } else {
6629 changeState();
6630 }
6631 }
6632 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6633 useOnFirstRender(() => {
6634 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6635 store.state = {
6636 ...store.state,
6637 open: true,
6638 activeTriggerId: defaultTriggerId,
6639 preventUnmountingOnClose: false
6640 };
6641 }
6642 });
6643 }
6644 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6645 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6646 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6647 const registerTrigger = useStableCallback((element) => {
6648 baseRegisterTrigger(element);
6649 if (!element) {
6650 return;
6651 }
6652 const open = store.select("open");
6653 const activeTriggerId = store.select("activeTriggerId");
6654 if (activeTriggerId === triggerId) {
6655 store.update({
6656 activeTriggerElement: element,
6657 ...open ? stateUpdates : null
6658 });
6659 return;
6660 }
6661 if (activeTriggerId == null && open) {
6662 store.update({
6663 activeTriggerId: triggerId,
6664 activeTriggerElement: element,
6665 ...stateUpdates
6666 });
6667 }
6668 });
6669 useIsoLayoutEffect(() => {
6670 if (isMountedByThisTrigger) {
6671 store.update({
6672 activeTriggerElement: triggerElementRef.current,
6673 ...stateUpdates
6674 });
6675 }
6676 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6677 return {
6678 registerTrigger,
6679 isMountedByThisTrigger
6680 };
6681 }
6682 function useImplicitActiveTrigger(store, options = {}) {
6683 const {
6684 closeOnActiveTriggerUnmount = false
6685 } = options;
6686 const open = store.useState("open");
6687 const reactiveTriggerCount = store.useState("triggerCount");
6688 useIsoLayoutEffect(() => {
6689 if (!open) {
6690 if (store.state.triggerCount !== 0) {
6691 store.set("triggerCount", 0);
6692 }
6693 return;
6694 }
6695 const triggerCount = store.context.triggerElements.size;
6696 const stateUpdates = {};
6697 if (store.state.triggerCount !== triggerCount) {
6698 stateUpdates.triggerCount = triggerCount;
6699 }
6700 const activeTriggerId = store.select("activeTriggerId");
6701 let lostActiveTriggerId = null;
6702 if (activeTriggerId) {
6703 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6704 if (!activeTriggerElement) {
6705 lostActiveTriggerId = activeTriggerId;
6706 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6707 stateUpdates.activeTriggerElement = activeTriggerElement;
6708 }
6709 }
6710 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6711 const iteratorResult = store.context.triggerElements.entries().next();
6712 if (!iteratorResult.done) {
6713 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6714 stateUpdates.activeTriggerId = implicitTriggerId;
6715 stateUpdates.activeTriggerElement = implicitTriggerElement;
6716 }
6717 }
6718 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6719 store.update(stateUpdates);
6720 }
6721 if (lostActiveTriggerId) {
6722 if (closeOnActiveTriggerUnmount) {
6723 queueMicrotask(() => {
6724 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6725 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6726 store.setOpen(false, eventDetails);
6727 if (!eventDetails.isCanceled) {
6728 store.update({
6729 activeTriggerId: null,
6730 activeTriggerElement: null
6731 });
6732 }
6733 }
6734 });
6735 }
6736 }
6737 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6738 }
6739 function useOpenStateTransitions(open, store, onUnmount) {
6740 const {
6741 mounted,
6742 setMounted,
6743 transitionStatus
6744 } = useTransitionStatus(open);
6745 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6746 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6747 store.useSyncedValues({
6748 mounted,
6749 transitionStatus,
6750 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6751 });
6752 const forceUnmount = useStableCallback(() => {
6753 setMounted(false);
6754 store.update({
6755 activeTriggerId: null,
6756 activeTriggerElement: null,
6757 mounted: false,
6758 preventUnmountingOnClose: false
6759 });
6760 onUnmount?.();
6761 store.context.onOpenChangeComplete?.(false);
6762 });
6763 useOpenChangeComplete({
6764 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6765 open,
6766 ref: store.context.popupRef,
6767 onComplete() {
6768 if (!open) {
6769 forceUnmount();
6770 }
6771 }
6772 });
6773 return {
6774 forceUnmount,
6775 transitionStatus
6776 };
6777 }
6778 function usePopupInteractionProps(store, statePart) {
6779 store.useSyncedValues(statePart);
6780 useIsoLayoutEffect(() => () => {
6781 store.update({
6782 activeTriggerProps: EMPTY_OBJECT,
6783 inactiveTriggerProps: EMPTY_OBJECT,
6784 popupProps: EMPTY_OBJECT
6785 });
6786 }, [store]);
6787 }
6788
6789 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6790 var PopupTriggerMap = class {
6791 constructor() {
6792 this.elementsSet = /* @__PURE__ */ new Set();
6793 this.idMap = /* @__PURE__ */ new Map();
6794 }
6795 /**
6796 * Adds a trigger element with the given ID.
6797 *
6798 * Note: The provided element is assumed to not be registered under multiple IDs.
6799 */
6800 add(id, element) {
6801 const existingElement = this.idMap.get(id);
6802 if (existingElement === element) {
6803 return;
6804 }
6805 if (existingElement !== void 0) {
6806 this.elementsSet.delete(existingElement);
6807 }
6808 this.elementsSet.add(element);
6809 this.idMap.set(id, element);
6810 if (true) {
6811 if (this.elementsSet.size !== this.idMap.size) {
6812 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6813 }
6814 }
6815 }
6816 /**
6817 * Removes the trigger element with the given ID.
6818 */
6819 delete(id) {
6820 const element = this.idMap.get(id);
6821 if (element) {
6822 this.elementsSet.delete(element);
6823 this.idMap.delete(id);
6824 }
6825 }
6826 /**
6827 * Whether the given element is registered as a trigger.
6828 */
6829 hasElement(element) {
6830 return this.elementsSet.has(element);
6831 }
6832 /**
6833 * Whether there is a registered trigger element matching the given predicate.
6834 */
6835 hasMatchingElement(predicate) {
6836 for (const element of this.elementsSet) {
6837 if (predicate(element)) {
6838 return true;
6839 }
6840 }
6841 return false;
6842 }
6843 /**
6844 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6845 */
6846 getById(id) {
6847 return this.idMap.get(id);
6848 }
6849 /**
6850 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6851 */
6852 entries() {
6853 return this.idMap.entries();
6854 }
6855 /**
6856 * Returns an iterable of all registered trigger elements.
6857 */
6858 elements() {
6859 return this.elementsSet.values();
6860 }
6861 /**
6862 * Returns the number of registered trigger elements.
6863 */
6864 get size() {
6865 return this.idMap.size;
6866 }
6867 };
6868
6869 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
6870 function getEmptyRootContext() {
6871 return new FloatingRootStore({
6872 open: false,
6873 transitionStatus: void 0,
6874 floatingElement: null,
6875 referenceElement: null,
6876 triggerElements: new PopupTriggerMap(),
6877 floatingId: void 0,
6878 syncOnly: false,
6879 nested: false,
6880 onOpenChange: void 0
6881 });
6882 }
6883
6884 // node_modules/@base-ui/react/utils/popups/store.mjs
6885 function createInitialPopupStoreState() {
6886 return {
6887 open: false,
6888 openProp: void 0,
6889 mounted: false,
6890 transitionStatus: void 0,
6891 floatingRootContext: getEmptyRootContext(),
6892 floatingId: void 0,
6893 triggerCount: 0,
6894 preventUnmountingOnClose: false,
6895 payload: void 0,
6896 activeTriggerId: null,
6897 activeTriggerElement: null,
6898 triggerIdProp: void 0,
6899 popupElement: null,
6900 positionerElement: null,
6901 activeTriggerProps: EMPTY_OBJECT,
6902 inactiveTriggerProps: EMPTY_OBJECT,
6903 popupProps: EMPTY_OBJECT
6904 };
6905 }
6906 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6907 return new FloatingRootStore({
6908 open: false,
6909 transitionStatus: void 0,
6910 floatingElement: null,
6911 referenceElement: null,
6912 triggerElements,
6913 floatingId,
6914 syncOnly: true,
6915 nested,
6916 onOpenChange: void 0
6917 });
6918 }
6919 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6920 var openSelector = createSelector((state) => state.openProp ?? state.open);
6921 var popupIdSelector = createSelector((state) => {
6922 const popupId = state.popupElement?.id ?? state.floatingId;
6923 return popupId || void 0;
6924 });
6925 function triggerOwnsOpenPopup(state, triggerId) {
6926 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6927 }
6928 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6929 if (triggerOwnsOpenPopup(state, triggerId)) {
6930 return true;
6931 }
6932 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6933 }
6934 var popupStoreSelectors = {
6935 open: openSelector,
6936 mounted: createSelector((state) => state.mounted),
6937 transitionStatus: createSelector((state) => state.transitionStatus),
6938 floatingRootContext: createSelector((state) => state.floatingRootContext),
6939 triggerCount: createSelector((state) => state.triggerCount),
6940 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6941 payload: createSelector((state) => state.payload),
6942 activeTriggerId: activeTriggerIdSelector,
6943 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6944 popupId: popupIdSelector,
6945 /**
6946 * Whether the trigger with the given ID was used to open the popup.
6947 */
6948 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6949 /**
6950 * Whether the popup is open and was activated by a trigger with the given ID.
6951 */
6952 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6953 /**
6954 * Whether the popup is mounted and was activated by a trigger with the given ID.
6955 */
6956 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6957 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6958 /**
6959 * Popup id for the trigger that currently owns the open popup.
6960 */
6961 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6962 popupProps: createSelector((state) => state.popupProps),
6963 popupElement: createSelector((state) => state.popupElement),
6964 positionerElement: createSelector((state) => state.positionerElement)
6965 };
6966
6967 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
6968 function useFloatingRootContext(options) {
6969 const {
6970 open = false,
6971 onOpenChange,
6972 elements = {}
6973 } = options;
6974 const floatingId = useId();
6975 const nested = useFloatingParentNodeId() != null;
6976 if (true) {
6977 const optionDomReference = elements.reference;
6978 if (optionDomReference && !isElement(optionDomReference)) {
6979 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6980 }
6981 }
6982 const store = useRefWithInit(() => new FloatingRootStore({
6983 open,
6984 transitionStatus: void 0,
6985 onOpenChange,
6986 referenceElement: elements.reference ?? null,
6987 floatingElement: elements.floating ?? null,
6988 triggerElements: new PopupTriggerMap(),
6989 floatingId,
6990 syncOnly: false,
6991 nested
6992 })).current;
6993 useIsoLayoutEffect(() => {
6994 const valuesToSync = {
6995 open,
6996 floatingId
6997 };
6998 if (elements.reference !== void 0) {
6999 valuesToSync.referenceElement = elements.reference;
7000 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7001 }
7002 if (elements.floating !== void 0) {
7003 valuesToSync.floatingElement = elements.floating;
7004 }
7005 store.update(valuesToSync);
7006 }, [open, floatingId, elements.reference, elements.floating, store]);
7007 store.context.onOpenChange = onOpenChange;
7008 store.context.nested = nested;
7009 return store;
7010 }
7011
7012 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7013 function useFloating2(options = {}) {
7014 const {
7015 nodeId,
7016 externalTree
7017 } = options;
7018 const internalStore = useFloatingRootContext(options);
7019 const store = options.rootContext || internalStore;
7020 const referenceElement = store.useState("referenceElement");
7021 const floatingElement = store.useState("floatingElement");
7022 const domReferenceElement = store.useState("domReferenceElement");
7023 const open = store.useState("open");
7024 const floatingId = store.useState("floatingId");
7025 const [positionReference, setPositionReferenceRaw] = React33.useState(null);
7026 const [localDomReference, setLocalDomReference] = React33.useState(void 0);
7027 const [localFloatingElement, setLocalFloatingElement] = React33.useState(void 0);
7028 const domReferenceRef = React33.useRef(null);
7029 const tree = useFloatingTree(externalTree);
7030 const storeElements = React33.useMemo(() => ({
7031 reference: referenceElement,
7032 floating: floatingElement,
7033 domReference: domReferenceElement
7034 }), [referenceElement, floatingElement, domReferenceElement]);
7035 const position = useFloating({
7036 ...options,
7037 elements: {
7038 ...storeElements,
7039 ...positionReference && {
7040 reference: positionReference
7041 }
7042 }
7043 });
7044 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7045 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7046 store.useSyncedValue("referenceElement", localDomReference ?? null);
7047 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7048 store.useSyncedValue("floatingElement", syncedFloatingElement);
7049 const setPositionReference = React33.useCallback((node) => {
7050 const computedPositionReference = isElement(node) ? {
7051 getBoundingClientRect: () => node.getBoundingClientRect(),
7052 getClientRects: () => node.getClientRects(),
7053 contextElement: node
7054 } : node;
7055 setPositionReferenceRaw(computedPositionReference);
7056 position.refs.setReference(computedPositionReference);
7057 }, [position.refs]);
7058 const setReference = React33.useCallback((node) => {
7059 if (isElement(node) || node === null) {
7060 domReferenceRef.current = node;
7061 setLocalDomReference(node);
7062 }
7063 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7064 // `null` to support `positionReference` + an unstable `reference`
7065 // callback ref.
7066 node !== null && !isElement(node)) {
7067 position.refs.setReference(node);
7068 }
7069 }, [position.refs, setLocalDomReference]);
7070 const setFloating = React33.useCallback((node) => {
7071 setLocalFloatingElement(node);
7072 position.refs.setFloating(node);
7073 }, [position.refs]);
7074 const refs = React33.useMemo(() => ({
7075 ...position.refs,
7076 setReference,
7077 setFloating,
7078 setPositionReference,
7079 domReference: domReferenceRef
7080 }), [position.refs, setReference, setFloating, setPositionReference]);
7081 const elements = React33.useMemo(() => ({
7082 ...position.elements,
7083 domReference: domReferenceElement
7084 }), [position.elements, domReferenceElement]);
7085 const context = React33.useMemo(() => ({
7086 ...position,
7087 dataRef: store.context.dataRef,
7088 open,
7089 onOpenChange: store.setOpen,
7090 events: store.context.events,
7091 floatingId,
7092 refs,
7093 elements,
7094 nodeId,
7095 rootStore: store
7096 }), [position, refs, elements, nodeId, store, open, floatingId]);
7097 useIsoLayoutEffect(() => {
7098 if (domReferenceElement) {
7099 domReferenceRef.current = domReferenceElement;
7100 }
7101 }, [domReferenceElement]);
7102 useIsoLayoutEffect(() => {
7103 store.context.dataRef.current.floatingContext = context;
7104 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7105 if (node) {
7106 node.context = context;
7107 }
7108 });
7109 return React33.useMemo(() => ({
7110 ...position,
7111 context,
7112 refs,
7113 elements,
7114 rootStore: store
7115 }), [position, refs, elements, context, store]);
7116 }
7117
7118 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7119 var React34 = __toESM(require_react(), 1);
7120 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7121 function useFocus(context, props = {}) {
7122 const {
7123 enabled = true,
7124 delay
7125 } = props;
7126 const store = "rootStore" in context ? context.rootStore : context;
7127 const {
7128 events,
7129 dataRef
7130 } = store.context;
7131 const blockFocusRef = React34.useRef(false);
7132 const blockedReferenceRef = React34.useRef(null);
7133 const keyboardModalityRef = React34.useRef(true);
7134 const timeout = useTimeout();
7135 React34.useEffect(() => {
7136 const domReference = store.select("domReferenceElement");
7137 if (!enabled) {
7138 return void 0;
7139 }
7140 const win = getWindow(domReference);
7141 function onBlur() {
7142 const currentDomReference = store.select("domReferenceElement");
7143 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7144 blockFocusRef.current = true;
7145 }
7146 }
7147 function onKeyDown() {
7148 keyboardModalityRef.current = true;
7149 }
7150 function onPointerDown() {
7151 keyboardModalityRef.current = false;
7152 }
7153 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7154 }, [store, enabled]);
7155 React34.useEffect(() => {
7156 if (!enabled) {
7157 return void 0;
7158 }
7159 function onOpenChangeLocal(details) {
7160 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7161 const referenceElement = store.select("domReferenceElement");
7162 if (isElement(referenceElement)) {
7163 blockedReferenceRef.current = referenceElement;
7164 blockFocusRef.current = true;
7165 }
7166 }
7167 }
7168 events.on("openchange", onOpenChangeLocal);
7169 return () => {
7170 events.off("openchange", onOpenChangeLocal);
7171 };
7172 }, [events, enabled, store]);
7173 const reference = React34.useMemo(() => {
7174 function resetBlockedFocus() {
7175 blockFocusRef.current = false;
7176 blockedReferenceRef.current = null;
7177 }
7178 return {
7179 onMouseLeave() {
7180 resetBlockedFocus();
7181 },
7182 onFocus(event) {
7183 const focusTarget = event.currentTarget;
7184 if (blockFocusRef.current) {
7185 if (blockedReferenceRef.current === focusTarget) {
7186 return;
7187 }
7188 resetBlockedFocus();
7189 }
7190 const target = getTarget(event.nativeEvent);
7191 if (isElement(target)) {
7192 if (isMacSafari && !event.relatedTarget) {
7193 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7194 return;
7195 }
7196 } else if (!matchesFocusVisible(target)) {
7197 return;
7198 }
7199 }
7200 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7201 const {
7202 nativeEvent,
7203 currentTarget
7204 } = event;
7205 const delayValue = typeof delay === "function" ? delay() : delay;
7206 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7207 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7208 return;
7209 }
7210 timeout.start(delayValue, () => {
7211 if (blockFocusRef.current) {
7212 return;
7213 }
7214 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7215 });
7216 },
7217 onBlur(event) {
7218 resetBlockedFocus();
7219 const relatedTarget = event.relatedTarget;
7220 const nativeEvent = event.nativeEvent;
7221 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7222 timeout.start(0, () => {
7223 const domReference = store.select("domReferenceElement");
7224 const activeEl = activeElement(ownerDocument(domReference));
7225 if (!relatedTarget && activeEl === domReference) {
7226 return;
7227 }
7228 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7229 return;
7230 }
7231 const nextFocusedElement = relatedTarget ?? activeEl;
7232 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7233 return;
7234 }
7235 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7236 });
7237 }
7238 };
7239 }, [dataRef, delay, store, timeout]);
7240 return React34.useMemo(() => enabled ? {
7241 reference,
7242 trigger: reference
7243 } : {}, [enabled, reference]);
7244 }
7245
7246 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7247 var React35 = __toESM(require_react(), 1);
7248
7249 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7250 var HoverInteraction = class _HoverInteraction {
7251 constructor() {
7252 this.pointerType = void 0;
7253 this.interactedInside = false;
7254 this.handler = void 0;
7255 this.blockMouseMove = true;
7256 this.performedPointerEventsMutation = false;
7257 this.pointerEventsScopeElement = null;
7258 this.pointerEventsReferenceElement = null;
7259 this.pointerEventsFloatingElement = null;
7260 this.restTimeoutPending = false;
7261 this.openChangeTimeout = new Timeout();
7262 this.restTimeout = new Timeout();
7263 this.handleCloseOptions = void 0;
7264 }
7265 static create() {
7266 return new _HoverInteraction();
7267 }
7268 dispose = () => {
7269 this.openChangeTimeout.clear();
7270 this.restTimeout.clear();
7271 };
7272 disposeEffect = () => {
7273 return this.dispose;
7274 };
7275 };
7276 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7277 function clearSafePolygonPointerEventsMutation(instance) {
7278 if (!instance.performedPointerEventsMutation) {
7279 return;
7280 }
7281 const scopeElement = instance.pointerEventsScopeElement;
7282 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7283 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7284 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7285 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7286 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7287 }
7288 instance.performedPointerEventsMutation = false;
7289 instance.pointerEventsScopeElement = null;
7290 instance.pointerEventsReferenceElement = null;
7291 instance.pointerEventsFloatingElement = null;
7292 }
7293 function applySafePolygonPointerEventsMutation(instance, options) {
7294 const {
7295 scopeElement,
7296 referenceElement,
7297 floatingElement
7298 } = options;
7299 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7300 if (existingOwner && existingOwner !== instance) {
7301 clearSafePolygonPointerEventsMutation(existingOwner);
7302 }
7303 clearSafePolygonPointerEventsMutation(instance);
7304 instance.performedPointerEventsMutation = true;
7305 instance.pointerEventsScopeElement = scopeElement;
7306 instance.pointerEventsReferenceElement = referenceElement;
7307 instance.pointerEventsFloatingElement = floatingElement;
7308 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7309 scopeElement.style.pointerEvents = "none";
7310 referenceElement.style.pointerEvents = "auto";
7311 floatingElement.style.pointerEvents = "auto";
7312 }
7313 function useHoverInteractionSharedState(store) {
7314 const data = store.context.dataRef.current;
7315 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7316 if (!data.hoverInteractionState) {
7317 data.hoverInteractionState = instance;
7318 }
7319 useOnMount(data.hoverInteractionState.disposeEffect);
7320 return data.hoverInteractionState;
7321 }
7322
7323 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7324 function useHoverFloatingInteraction(context, parameters = {}) {
7325 const {
7326 enabled = true,
7327 closeDelay: closeDelayProp = 0,
7328 nodeId: nodeIdProp
7329 } = parameters;
7330 const store = "rootStore" in context ? context.rootStore : context;
7331 const open = store.useState("open");
7332 const floatingElement = store.useState("floatingElement");
7333 const domReferenceElement = store.useState("domReferenceElement");
7334 const {
7335 dataRef
7336 } = store.context;
7337 const tree = useFloatingTree();
7338 const parentId = useFloatingParentNodeId();
7339 const instance = useHoverInteractionSharedState(store);
7340 const childClosedTimeout = useTimeout();
7341 const isClickLikeOpenEvent2 = useStableCallback(() => {
7342 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7343 });
7344 const isHoverOpen = useStableCallback(() => {
7345 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7346 });
7347 const clearPointerEvents = useStableCallback(() => {
7348 clearSafePolygonPointerEventsMutation(instance);
7349 });
7350 useIsoLayoutEffect(() => {
7351 if (!open) {
7352 instance.pointerType = void 0;
7353 instance.restTimeoutPending = false;
7354 instance.interactedInside = false;
7355 clearPointerEvents();
7356 }
7357 }, [open, instance, clearPointerEvents]);
7358 React35.useEffect(() => {
7359 return clearPointerEvents;
7360 }, [clearPointerEvents]);
7361 useIsoLayoutEffect(() => {
7362 if (!enabled) {
7363 return void 0;
7364 }
7365 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7366 const ref = domReferenceElement;
7367 const floatingEl = floatingElement;
7368 const doc = ownerDocument(floatingElement);
7369 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7370 if (parentFloating) {
7371 parentFloating.style.pointerEvents = "";
7372 }
7373 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7374 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7375 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7376 applySafePolygonPointerEventsMutation(instance, {
7377 scopeElement,
7378 referenceElement: ref,
7379 floatingElement: floatingEl
7380 });
7381 return () => {
7382 clearPointerEvents();
7383 };
7384 }
7385 return void 0;
7386 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7387 React35.useEffect(() => {
7388 if (!enabled) {
7389 return void 0;
7390 }
7391 function hasParentChildren() {
7392 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7393 }
7394 function closeWithDelay(event) {
7395 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7396 const close = () => {
7397 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7398 tree?.events.emit("floating.closed", event);
7399 };
7400 if (closeDelay) {
7401 instance.openChangeTimeout.start(closeDelay, close);
7402 } else {
7403 instance.openChangeTimeout.clear();
7404 close();
7405 }
7406 }
7407 function handleInteractInside(event) {
7408 const target = getTarget(event);
7409 if (!isInteractiveElement(target)) {
7410 instance.interactedInside = false;
7411 return;
7412 }
7413 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7414 }
7415 function onFloatingMouseEnter() {
7416 instance.openChangeTimeout.clear();
7417 childClosedTimeout.clear();
7418 tree?.events.off("floating.closed", onNodeClosed);
7419 clearPointerEvents();
7420 }
7421 function onFloatingMouseLeave(event) {
7422 if (hasParentChildren() && tree) {
7423 tree.events.on("floating.closed", onNodeClosed);
7424 return;
7425 }
7426 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7427 return;
7428 }
7429 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7430 const relatedTarget = event.relatedTarget;
7431 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7432 if (isMovingIntoDescendantFloating) {
7433 return;
7434 }
7435 if (instance.handler) {
7436 instance.handler(event);
7437 return;
7438 }
7439 clearPointerEvents();
7440 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7441 closeWithDelay(event);
7442 }
7443 }
7444 function onNodeClosed(event) {
7445 if (!tree || !parentId || hasParentChildren()) {
7446 return;
7447 }
7448 childClosedTimeout.start(0, () => {
7449 tree.events.off("floating.closed", onNodeClosed);
7450 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7451 tree.events.emit("floating.closed", event);
7452 });
7453 }
7454 const floating = floatingElement;
7455 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7456 tree?.events.off("floating.closed", onNodeClosed);
7457 });
7458 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7459 }
7460
7461 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7462 var React36 = __toESM(require_react(), 1);
7463 var ReactDOM5 = __toESM(require_react_dom(), 1);
7464 var EMPTY_REF = {
7465 current: null
7466 };
7467 function useHoverReferenceInteraction(context, props = {}) {
7468 const {
7469 enabled = true,
7470 delay = 0,
7471 handleClose = null,
7472 mouseOnly = false,
7473 restMs = 0,
7474 move = true,
7475 triggerElementRef = EMPTY_REF,
7476 externalTree,
7477 isActiveTrigger = true,
7478 getHandleCloseContext,
7479 isClosing,
7480 shouldOpen: shouldOpenProp
7481 } = props;
7482 const store = "rootStore" in context ? context.rootStore : context;
7483 const {
7484 dataRef,
7485 events
7486 } = store.context;
7487 const tree = useFloatingTree(externalTree);
7488 const instance = useHoverInteractionSharedState(store);
7489 const isHoverCloseActiveRef = React36.useRef(false);
7490 const handleCloseRef = useValueAsRef(handleClose);
7491 const delayRef = useValueAsRef(delay);
7492 const restMsRef = useValueAsRef(restMs);
7493 const enabledRef = useValueAsRef(enabled);
7494 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7495 const isClosingRef = useValueAsRef(isClosing);
7496 const isClickLikeOpenEvent2 = useStableCallback(() => {
7497 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7498 });
7499 const checkShouldOpen = useStableCallback(() => {
7500 return shouldOpenRef.current?.() !== false;
7501 });
7502 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7503 const allTriggers = store.context.triggerElements;
7504 if (allTriggers.hasElement(currentTarget)) {
7505 return !currentDomReference || !contains(currentDomReference, currentTarget);
7506 }
7507 if (!isElement(target)) {
7508 return false;
7509 }
7510 const targetElement = target;
7511 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7512 });
7513 const cleanupMouseMoveHandler = useStableCallback(() => {
7514 if (!instance.handler) {
7515 return;
7516 }
7517 const doc = ownerDocument(store.select("domReferenceElement"));
7518 doc.removeEventListener("mousemove", instance.handler);
7519 instance.handler = void 0;
7520 });
7521 const clearPointerEvents = useStableCallback(() => {
7522 clearSafePolygonPointerEventsMutation(instance);
7523 });
7524 if (isActiveTrigger) {
7525 instance.handleCloseOptions = handleCloseRef.current?.__options;
7526 }
7527 React36.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7528 React36.useEffect(() => {
7529 if (!enabled) {
7530 return void 0;
7531 }
7532 function onOpenChangeLocal(details) {
7533 if (!details.open) {
7534 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7535 cleanupMouseMoveHandler();
7536 instance.openChangeTimeout.clear();
7537 instance.restTimeout.clear();
7538 instance.blockMouseMove = true;
7539 instance.restTimeoutPending = false;
7540 } else {
7541 isHoverCloseActiveRef.current = false;
7542 }
7543 }
7544 events.on("openchange", onOpenChangeLocal);
7545 return () => {
7546 events.off("openchange", onOpenChangeLocal);
7547 };
7548 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7549 React36.useEffect(() => {
7550 if (!enabled) {
7551 return void 0;
7552 }
7553 function closeWithDelay(event, runElseBranch = true) {
7554 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7555 if (closeDelay) {
7556 instance.openChangeTimeout.start(closeDelay, () => {
7557 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7558 tree?.events.emit("floating.closed", event);
7559 });
7560 } else if (runElseBranch) {
7561 instance.openChangeTimeout.clear();
7562 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7563 tree?.events.emit("floating.closed", event);
7564 }
7565 }
7566 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7567 if (!isElement(trigger)) {
7568 return void 0;
7569 }
7570 function onMouseEnter(event) {
7571 instance.openChangeTimeout.clear();
7572 instance.blockMouseMove = false;
7573 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7574 return;
7575 }
7576 const restMsValue = getRestMs(restMsRef.current);
7577 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7578 const eventTarget = getTarget(event);
7579 const currentTarget = event.currentTarget ?? null;
7580 const currentDomReference = store.select("domReferenceElement");
7581 let triggerNode = currentTarget;
7582 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7583 for (const triggerElement of store.context.triggerElements.elements()) {
7584 if (contains(triggerElement, eventTarget)) {
7585 triggerNode = triggerElement;
7586 break;
7587 }
7588 }
7589 }
7590 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7591 triggerNode = currentDomReference;
7592 }
7593 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7594 const isOpen = store.select("open");
7595 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7596 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7597 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7598 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7599 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7600 const shouldOpen = !isOpen || isOverInactive;
7601 if (shouldOpenImmediately) {
7602 if (checkShouldOpen()) {
7603 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7604 }
7605 return;
7606 }
7607 if (isRestOnlyDelay) {
7608 return;
7609 }
7610 if (openDelay) {
7611 instance.openChangeTimeout.start(openDelay, () => {
7612 if (shouldOpen && checkShouldOpen()) {
7613 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7614 }
7615 });
7616 } else if (shouldOpen) {
7617 if (checkShouldOpen()) {
7618 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7619 }
7620 }
7621 }
7622 function onMouseLeave(event) {
7623 if (isClickLikeOpenEvent2()) {
7624 clearPointerEvents();
7625 return;
7626 }
7627 cleanupMouseMoveHandler();
7628 const domReferenceElement = store.select("domReferenceElement");
7629 const doc = ownerDocument(domReferenceElement);
7630 instance.restTimeout.clear();
7631 instance.restTimeoutPending = false;
7632 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7633 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7634 return;
7635 }
7636 if (handleCloseRef.current && handleCloseContextBase) {
7637 if (!store.select("open")) {
7638 instance.openChangeTimeout.clear();
7639 }
7640 const currentTrigger = triggerElementRef.current;
7641 instance.handler = handleCloseRef.current({
7642 ...handleCloseContextBase,
7643 tree,
7644 x: event.clientX,
7645 y: event.clientY,
7646 onClose() {
7647 clearPointerEvents();
7648 cleanupMouseMoveHandler();
7649 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7650 closeWithDelay(event, true);
7651 }
7652 }
7653 });
7654 doc.addEventListener("mousemove", instance.handler);
7655 instance.handler(event);
7656 return;
7657 }
7658 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7659 if (shouldClose) {
7660 closeWithDelay(event);
7661 }
7662 }
7663 if (move) {
7664 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7665 once: true
7666 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7667 }
7668 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7669 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7670 return React36.useMemo(() => {
7671 if (!enabled) {
7672 return void 0;
7673 }
7674 function setPointerRef(event) {
7675 instance.pointerType = event.pointerType;
7676 }
7677 return {
7678 onPointerDown: setPointerRef,
7679 onPointerEnter: setPointerRef,
7680 onMouseMove(event) {
7681 const {
7682 nativeEvent
7683 } = event;
7684 const trigger = event.currentTarget;
7685 const currentDomReference = store.select("domReferenceElement");
7686 const currentOpen = store.select("open");
7687 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7688 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7689 return;
7690 }
7691 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7692 const floatingElement = store.select("floatingElement");
7693 if (floatingElement) {
7694 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7695 applySafePolygonPointerEventsMutation(instance, {
7696 scopeElement,
7697 referenceElement: trigger,
7698 floatingElement
7699 });
7700 }
7701 }
7702 const restMsValue = getRestMs(restMsRef.current);
7703 if (currentOpen && !isOverInactive || restMsValue === 0) {
7704 return;
7705 }
7706 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7707 return;
7708 }
7709 instance.restTimeout.clear();
7710 function handleMouseMove() {
7711 instance.restTimeoutPending = false;
7712 if (isClickLikeOpenEvent2()) {
7713 return;
7714 }
7715 const latestOpen = store.select("open");
7716 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7717 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7718 }
7719 }
7720 if (instance.pointerType === "touch") {
7721 ReactDOM5.flushSync(() => {
7722 handleMouseMove();
7723 });
7724 } else if (isOverInactive && currentOpen) {
7725 handleMouseMove();
7726 } else {
7727 instance.restTimeoutPending = true;
7728 instance.restTimeout.start(restMsValue, handleMouseMove);
7729 }
7730 }
7731 };
7732 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7733 }
7734
7735 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7736 var CURSOR_SPEED_THRESHOLD = 0.1;
7737 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7738 var POLYGON_BUFFER = 0.5;
7739 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7740 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7741 }
7742 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7743 let isInsideValue = false;
7744 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7745 isInsideValue = !isInsideValue;
7746 }
7747 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7748 isInsideValue = !isInsideValue;
7749 }
7750 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7751 isInsideValue = !isInsideValue;
7752 }
7753 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7754 isInsideValue = !isInsideValue;
7755 }
7756 return isInsideValue;
7757 }
7758 function isInsideRect(pointX, pointY, rect) {
7759 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7760 }
7761 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7762 const minX = Math.min(x1, x2);
7763 const maxX = Math.max(x1, x2);
7764 const minY = Math.min(y1, y2);
7765 const maxY = Math.max(y1, y2);
7766 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7767 }
7768 function safePolygon(options = {}) {
7769 const {
7770 blockPointerEvents = false
7771 } = options;
7772 const timeout = new Timeout();
7773 const fn = ({
7774 x: x2,
7775 y: y2,
7776 placement,
7777 elements,
7778 onClose,
7779 nodeId,
7780 tree
7781 }) => {
7782 const side = placement?.split("-")[0];
7783 let hasLanded = false;
7784 let lastX = null;
7785 let lastY = null;
7786 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7787 function isCursorMovingSlowly(nextX, nextY) {
7788 const currentTime = performance.now();
7789 const elapsedTime = currentTime - lastCursorTime;
7790 if (lastX === null || lastY === null || elapsedTime === 0) {
7791 lastX = nextX;
7792 lastY = nextY;
7793 lastCursorTime = currentTime;
7794 return false;
7795 }
7796 const deltaX = nextX - lastX;
7797 const deltaY = nextY - lastY;
7798 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7799 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7800 lastX = nextX;
7801 lastY = nextY;
7802 lastCursorTime = currentTime;
7803 return distanceSquared < thresholdSquared;
7804 }
7805 function close() {
7806 timeout.clear();
7807 onClose();
7808 }
7809 return function onMouseMove(event) {
7810 timeout.clear();
7811 const domReference = elements.domReference;
7812 const floating = elements.floating;
7813 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7814 return void 0;
7815 }
7816 const {
7817 clientX,
7818 clientY
7819 } = event;
7820 const target = getTarget(event);
7821 const isLeave = event.type === "mouseleave";
7822 const isOverFloatingEl = contains(floating, target);
7823 const isOverReferenceEl = contains(domReference, target);
7824 if (isOverFloatingEl) {
7825 hasLanded = true;
7826 if (!isLeave) {
7827 return void 0;
7828 }
7829 }
7830 if (isOverReferenceEl) {
7831 hasLanded = false;
7832 if (!isLeave) {
7833 hasLanded = true;
7834 return void 0;
7835 }
7836 }
7837 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7838 return void 0;
7839 }
7840 function hasOpenChildNode() {
7841 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7842 }
7843 function closeIfNoOpenChild() {
7844 if (!hasOpenChildNode()) {
7845 close();
7846 }
7847 }
7848 if (hasOpenChildNode()) {
7849 return void 0;
7850 }
7851 const refRect = domReference.getBoundingClientRect();
7852 const rect = floating.getBoundingClientRect();
7853 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7854 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7855 const isFloatingWider = rect.width > refRect.width;
7856 const isFloatingTaller = rect.height > refRect.height;
7857 const left = (isFloatingWider ? refRect : rect).left;
7858 const right = (isFloatingWider ? refRect : rect).right;
7859 const top = (isFloatingTaller ? refRect : rect).top;
7860 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7861 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) {
7862 closeIfNoOpenChild();
7863 return void 0;
7864 }
7865 let isInsideTroughRect = false;
7866 switch (side) {
7867 case "top":
7868 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7869 break;
7870 case "bottom":
7871 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7872 break;
7873 case "left":
7874 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7875 break;
7876 case "right":
7877 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7878 break;
7879 default:
7880 }
7881 if (isInsideTroughRect) {
7882 return void 0;
7883 }
7884 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7885 closeIfNoOpenChild();
7886 return void 0;
7887 }
7888 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7889 closeIfNoOpenChild();
7890 return void 0;
7891 }
7892 let isInsidePolygon = false;
7893 switch (side) {
7894 case "top": {
7895 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7896 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7897 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7898 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7899 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7900 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7901 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7902 break;
7903 }
7904 case "bottom": {
7905 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7906 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7907 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7908 const cursorPointY = y2 - POLYGON_BUFFER;
7909 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7910 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7911 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7912 break;
7913 }
7914 case "left": {
7915 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7916 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7917 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7918 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7919 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7920 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7921 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7922 break;
7923 }
7924 case "right": {
7925 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7926 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7927 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7928 const cursorPointX = x2 - POLYGON_BUFFER;
7929 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7930 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7931 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7932 break;
7933 }
7934 default:
7935 }
7936 if (!isInsidePolygon) {
7937 closeIfNoOpenChild();
7938 } else if (!hasLanded) {
7939 timeout.start(40, closeIfNoOpenChild);
7940 }
7941 return void 0;
7942 };
7943 };
7944 fn.__options = {
7945 ...options,
7946 blockPointerEvents
7947 };
7948 return fn;
7949 }
7950
7951 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
7952 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7953 CommonPopupDataAttributes2["open"] = "data-open";
7954 CommonPopupDataAttributes2["closed"] = "data-closed";
7955 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7956 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7957 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7958 CommonPopupDataAttributes2["side"] = "data-side";
7959 CommonPopupDataAttributes2["align"] = "data-align";
7960 return CommonPopupDataAttributes2;
7961 })({});
7962 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7963 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7964 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7965 return CommonTriggerDataAttributes2;
7966 })({});
7967 var TRIGGER_HOOK = {
7968 [CommonTriggerDataAttributes.popupOpen]: ""
7969 };
7970 var PRESSABLE_TRIGGER_HOOK = {
7971 [CommonTriggerDataAttributes.popupOpen]: "",
7972 [CommonTriggerDataAttributes.pressed]: ""
7973 };
7974 var POPUP_OPEN_HOOK = {
7975 [CommonPopupDataAttributes.open]: ""
7976 };
7977 var POPUP_CLOSED_HOOK = {
7978 [CommonPopupDataAttributes.closed]: ""
7979 };
7980 var ANCHOR_HIDDEN_HOOK = {
7981 [CommonPopupDataAttributes.anchorHidden]: ""
7982 };
7983 var triggerOpenStateMapping2 = {
7984 open(value) {
7985 if (value) {
7986 return TRIGGER_HOOK;
7987 }
7988 return null;
7989 }
7990 };
7991 var popupStateMapping = {
7992 open(value) {
7993 if (value) {
7994 return POPUP_OPEN_HOOK;
7995 }
7996 return POPUP_CLOSED_HOOK;
7997 },
7998 anchorHidden(value) {
7999 if (value) {
8000 return ANCHOR_HIDDEN_HOOK;
8001 }
8002 return null;
8003 }
8004 };
8005
8006 // node_modules/@base-ui/utils/inertValue.mjs
8007 function inertValue(value) {
8008 if (isReactVersionAtLeast(19)) {
8009 return value;
8010 }
8011 return value ? "true" : void 0;
8012 }
8013
8014 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8015 var React37 = __toESM(require_react(), 1);
8016
8017 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8018 var baseArrow = (options) => ({
8019 name: "arrow",
8020 options,
8021 async fn(state) {
8022 const {
8023 x: x2,
8024 y: y2,
8025 placement,
8026 rects,
8027 platform: platform3,
8028 elements,
8029 middlewareData
8030 } = state;
8031 const {
8032 element,
8033 padding = 0,
8034 offsetParent = "real"
8035 } = evaluate(options, state) || {};
8036 if (element == null) {
8037 return {};
8038 }
8039 const paddingObject = getPaddingObject(padding);
8040 const coords = {
8041 x: x2,
8042 y: y2
8043 };
8044 const axis = getAlignmentAxis(placement);
8045 const length = getAxisLength(axis);
8046 const arrowDimensions = await platform3.getDimensions(element);
8047 const isYAxis = axis === "y";
8048 const minProp = isYAxis ? "top" : "left";
8049 const maxProp = isYAxis ? "bottom" : "right";
8050 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8051 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8052 const startDiff = coords[axis] - rects.reference[axis];
8053 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8054 let clientSize = elements.floating[clientProp] || rects.floating[length];
8055 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8056 clientSize = elements.floating[clientProp] || rects.floating[length];
8057 }
8058 const centerToReference = endDiff / 2 - startDiff / 2;
8059 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8060 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8061 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8062 const min2 = minPadding;
8063 const max2 = clientSize - arrowDimensions[length] - maxPadding;
8064 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8065 const offset4 = clamp(min2, center, max2);
8066 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8067 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
8068 return {
8069 [axis]: coords[axis] + alignmentOffset,
8070 data: {
8071 [axis]: offset4,
8072 centerOffset: center - offset4 - alignmentOffset,
8073 ...shouldAddOffset && {
8074 alignmentOffset
8075 }
8076 },
8077 reset: shouldAddOffset
8078 };
8079 }
8080 });
8081 var arrow4 = (options, deps) => ({
8082 ...baseArrow(options),
8083 options: [options, deps]
8084 });
8085
8086 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8087 var nativeHideFn = hide3().fn;
8088 var hide4 = {
8089 name: "hide",
8090 async fn(state) {
8091 const {
8092 width,
8093 height,
8094 x: x2,
8095 y: y2
8096 } = state.rects.reference;
8097 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8098 const nativeHideResult = await nativeHideFn(state);
8099 return {
8100 data: {
8101 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8102 }
8103 };
8104 }
8105 };
8106
8107 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
8108 var DEFAULT_SIDES = {
8109 sideX: "left",
8110 sideY: "top"
8111 };
8112 var adaptiveOrigin = {
8113 name: "adaptiveOrigin",
8114 async fn(state) {
8115 const {
8116 x: rawX,
8117 y: rawY,
8118 rects: {
8119 floating: floatRect
8120 },
8121 elements: {
8122 floating
8123 },
8124 platform: platform3,
8125 strategy,
8126 placement
8127 } = state;
8128 const win = getWindow(floating);
8129 const styles = win.getComputedStyle(floating);
8130 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8131 if (!hasTransition) {
8132 return {
8133 x: rawX,
8134 y: rawY,
8135 data: DEFAULT_SIDES
8136 };
8137 }
8138 const offsetParent = await platform3.getOffsetParent?.(floating);
8139 let offsetDimensions = {
8140 width: 0,
8141 height: 0
8142 };
8143 if (strategy === "fixed" && win?.visualViewport) {
8144 offsetDimensions = {
8145 width: win.visualViewport.width,
8146 height: win.visualViewport.height
8147 };
8148 } else if (offsetParent === win) {
8149 const doc = ownerDocument(floating);
8150 offsetDimensions = {
8151 width: doc.documentElement.clientWidth,
8152 height: doc.documentElement.clientHeight
8153 };
8154 } else if (await platform3.isElement?.(offsetParent)) {
8155 offsetDimensions = await platform3.getDimensions(offsetParent);
8156 }
8157 const currentSide = getSide(placement);
8158 let x2 = rawX;
8159 let y2 = rawY;
8160 if (currentSide === "left") {
8161 x2 = offsetDimensions.width - (rawX + floatRect.width);
8162 }
8163 if (currentSide === "top") {
8164 y2 = offsetDimensions.height - (rawY + floatRect.height);
8165 }
8166 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8167 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8168 return {
8169 x: x2,
8170 y: y2,
8171 data: {
8172 sideX,
8173 sideY
8174 }
8175 };
8176 }
8177 };
8178
8179 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8180 function getLogicalSide(sideParam, renderedSide, isRtl) {
8181 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8182 const logicalRight = isRtl ? "inline-start" : "inline-end";
8183 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8184 return {
8185 top: "top",
8186 right: isLogicalSideParam ? logicalRight : "right",
8187 bottom: "bottom",
8188 left: isLogicalSideParam ? logicalLeft : "left"
8189 }[renderedSide];
8190 }
8191 function getOffsetData(state, sideParam, isRtl) {
8192 const {
8193 rects,
8194 placement
8195 } = state;
8196 const data = {
8197 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8198 align: getAlignment(placement) || "center",
8199 anchor: {
8200 width: rects.reference.width,
8201 height: rects.reference.height
8202 },
8203 positioner: {
8204 width: rects.floating.width,
8205 height: rects.floating.height
8206 }
8207 };
8208 return data;
8209 }
8210 function useAnchorPositioning(params) {
8211 const {
8212 // Public parameters
8213 anchor,
8214 positionMethod = "absolute",
8215 side: sideParam = "bottom",
8216 sideOffset = 0,
8217 align = "center",
8218 alignOffset = 0,
8219 collisionBoundary,
8220 collisionPadding: collisionPaddingParam = 5,
8221 sticky = false,
8222 arrowPadding = 5,
8223 disableAnchorTracking = false,
8224 inline: inlineMiddleware,
8225 // Private parameters
8226 keepMounted = false,
8227 floatingRootContext,
8228 mounted,
8229 collisionAvoidance,
8230 shiftCrossAxis = false,
8231 nodeId,
8232 adaptiveOrigin: adaptiveOrigin2,
8233 lazyFlip = false,
8234 externalTree
8235 } = params;
8236 const [mountSide, setMountSide] = React37.useState(null);
8237 if (!mounted && mountSide !== null) {
8238 setMountSide(null);
8239 }
8240 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8241 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8242 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8243 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8244 const anchorFnCallback = useStableCallback(anchorFn);
8245 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8246 const anchorValueRef = useValueAsRef(anchor);
8247 const mountedRef = useValueAsRef(mounted);
8248 const direction = useDirection();
8249 const isRtl = direction === "rtl";
8250 const side = mountSide || {
8251 top: "top",
8252 right: "right",
8253 bottom: "bottom",
8254 left: "left",
8255 "inline-end": isRtl ? "left" : "right",
8256 "inline-start": isRtl ? "right" : "left"
8257 }[sideParam];
8258 const placement = align === "center" ? side : `${side}-${align}`;
8259 let collisionPadding = collisionPaddingParam;
8260 const bias = 1;
8261 const biasTop = sideParam === "bottom" ? bias : 0;
8262 const biasBottom = sideParam === "top" ? bias : 0;
8263 const biasLeft = sideParam === "right" ? bias : 0;
8264 const biasRight = sideParam === "left" ? bias : 0;
8265 if (typeof collisionPadding === "number") {
8266 collisionPadding = {
8267 top: collisionPadding + biasTop,
8268 right: collisionPadding + biasRight,
8269 bottom: collisionPadding + biasBottom,
8270 left: collisionPadding + biasLeft
8271 };
8272 } else if (collisionPadding) {
8273 collisionPadding = {
8274 top: (collisionPadding.top || 0) + biasTop,
8275 right: (collisionPadding.right || 0) + biasRight,
8276 bottom: (collisionPadding.bottom || 0) + biasBottom,
8277 left: (collisionPadding.left || 0) + biasLeft
8278 };
8279 }
8280 const commonCollisionProps = {
8281 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8282 padding: collisionPadding
8283 };
8284 const arrowRef = React37.useRef(null);
8285 const sideOffsetRef = useValueAsRef(sideOffset);
8286 const alignOffsetRef = useValueAsRef(alignOffset);
8287 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8288 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8289 const middleware = [];
8290 if (inlineMiddleware) {
8291 middleware.push(inlineMiddleware);
8292 }
8293 middleware.push(offset3((state) => {
8294 const data = getOffsetData(state, sideParam, isRtl);
8295 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8296 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8297 return {
8298 mainAxis: sideAxis,
8299 crossAxis: alignAxis,
8300 alignmentAxis: alignAxis
8301 };
8302 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8303 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8304 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8305 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8306 ...commonCollisionProps,
8307 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8308 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8309 padding: {
8310 top: collisionPadding.top + bias,
8311 right: collisionPadding.right + bias,
8312 bottom: collisionPadding.bottom + bias,
8313 left: collisionPadding.left + bias
8314 },
8315 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8316 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8317 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8318 });
8319 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8320 const html = ownerDocument(data.elements.floating).documentElement;
8321 return {
8322 ...commonCollisionProps,
8323 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8324 // for context menus.
8325 rootBoundary: shiftCrossAxis ? {
8326 x: 0,
8327 y: 0,
8328 width: html.clientWidth,
8329 height: html.clientHeight
8330 } : void 0,
8331 mainAxis: collisionAvoidanceAlign !== "none",
8332 crossAxis: crossAxisShiftEnabled,
8333 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8334 if (!arrowRef.current) {
8335 return {};
8336 }
8337 const {
8338 width,
8339 height
8340 } = arrowRef.current.getBoundingClientRect();
8341 const sideAxis = getSideAxis(getSide(limitData.placement));
8342 const arrowSize = sideAxis === "y" ? width : height;
8343 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8344 return {
8345 offset: arrowSize / 2 + offsetAmount / 2
8346 };
8347 })
8348 };
8349 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8350 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8351 middleware.push(shiftMiddleware, flipMiddleware);
8352 } else {
8353 middleware.push(flipMiddleware, shiftMiddleware);
8354 }
8355 middleware.push(size3({
8356 ...commonCollisionProps,
8357 apply({
8358 elements: {
8359 floating
8360 },
8361 availableWidth,
8362 availableHeight,
8363 rects
8364 }) {
8365 if (!mountedRef.current) {
8366 return;
8367 }
8368 const floatingStyle = floating.style;
8369 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8370 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8371 const dpr = getWindow(floating).devicePixelRatio || 1;
8372 const {
8373 x: x3,
8374 y: y3,
8375 width,
8376 height
8377 } = rects.reference;
8378 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8379 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8380 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8381 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8382 }
8383 }), arrow4((state) => ({
8384 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8385 // we'll create a fake element.
8386 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8387 padding: arrowPadding,
8388 offsetParent: "floating"
8389 }), [arrowPadding]), {
8390 name: "transformOrigin",
8391 fn(state) {
8392 const {
8393 elements: elements2,
8394 middlewareData: middlewareData2,
8395 placement: renderedPlacement2,
8396 rects,
8397 y: y3
8398 } = state;
8399 const currentRenderedSide = getSide(renderedPlacement2);
8400 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8401 const arrowEl = arrowRef.current;
8402 const arrowX = middlewareData2.arrow?.x || 0;
8403 const arrowY = middlewareData2.arrow?.y || 0;
8404 const arrowWidth = arrowEl?.clientWidth || 0;
8405 const arrowHeight = arrowEl?.clientHeight || 0;
8406 const transformX = arrowX + arrowWidth / 2;
8407 const transformY = arrowY + arrowHeight / 2;
8408 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8409 const halfAnchorHeight = rects.reference.height / 2;
8410 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8411 const isOverlappingAnchor = shiftY > sideOffsetValue;
8412 const adjacentTransformOrigin = {
8413 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8414 bottom: `${transformX}px ${-sideOffsetValue}px`,
8415 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8416 right: `${-sideOffsetValue}px ${transformY}px`
8417 }[currentRenderedSide];
8418 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8419 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8420 return {};
8421 }
8422 }, hide4, adaptiveOrigin2);
8423 useIsoLayoutEffect(() => {
8424 if (!mounted && floatingRootContext) {
8425 floatingRootContext.update({
8426 referenceElement: null,
8427 floatingElement: null,
8428 domReferenceElement: null,
8429 positionReference: null
8430 });
8431 }
8432 }, [mounted, floatingRootContext]);
8433 const autoUpdateOptions = React37.useMemo(() => ({
8434 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8435 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8436 }), [disableAnchorTracking]);
8437 const {
8438 refs,
8439 elements,
8440 x: x2,
8441 y: y2,
8442 middlewareData,
8443 update: update2,
8444 placement: renderedPlacement,
8445 context,
8446 isPositioned,
8447 floatingStyles: originalFloatingStyles
8448 } = useFloating2({
8449 rootContext: floatingRootContext,
8450 open: keepMounted ? mounted : void 0,
8451 placement,
8452 middleware,
8453 strategy: positionMethod,
8454 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8455 nodeId,
8456 externalTree
8457 });
8458 const {
8459 sideX,
8460 sideY
8461 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8462 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8463 const floatingStyles = React37.useMemo(() => {
8464 const base = adaptiveOrigin2 ? {
8465 position: resolvedPosition,
8466 [sideX]: x2,
8467 [sideY]: y2
8468 } : {
8469 position: resolvedPosition,
8470 ...originalFloatingStyles
8471 };
8472 if (!isPositioned) {
8473 base.opacity = 0;
8474 }
8475 return base;
8476 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8477 const registeredPositionReferenceRef = React37.useRef(null);
8478 useIsoLayoutEffect(() => {
8479 if (!mounted) {
8480 return;
8481 }
8482 const anchorValue = anchorValueRef.current;
8483 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8484 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8485 const finalAnchor = unwrappedElement || null;
8486 if (finalAnchor !== registeredPositionReferenceRef.current) {
8487 refs.setPositionReference(finalAnchor);
8488 registeredPositionReferenceRef.current = finalAnchor;
8489 }
8490 }, [mounted, refs, anchorDep, anchorValueRef]);
8491 React37.useEffect(() => {
8492 if (!mounted) {
8493 return;
8494 }
8495 const anchorValue = anchorValueRef.current;
8496 if (typeof anchorValue === "function") {
8497 return;
8498 }
8499 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8500 refs.setPositionReference(anchorValue.current);
8501 registeredPositionReferenceRef.current = anchorValue.current;
8502 }
8503 }, [mounted, refs, anchorDep, anchorValueRef]);
8504 React37.useEffect(() => {
8505 if (keepMounted && mounted && elements.reference && elements.floating) {
8506 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8507 }
8508 return void 0;
8509 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8510 const renderedSide = getSide(renderedPlacement);
8511 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8512 const renderedAlign = getAlignment(renderedPlacement) || "center";
8513 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8514 useIsoLayoutEffect(() => {
8515 if (lazyFlip && mounted && isPositioned) {
8516 setMountSide(renderedSide);
8517 }
8518 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8519 const arrowStyles = React37.useMemo(() => ({
8520 position: "absolute",
8521 top: middlewareData.arrow?.y,
8522 left: middlewareData.arrow?.x
8523 }), [middlewareData.arrow]);
8524 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8525 return React37.useMemo(() => ({
8526 positionerStyles: floatingStyles,
8527 arrowStyles,
8528 arrowRef,
8529 arrowUncentered,
8530 side: logicalRenderedSide,
8531 align: renderedAlign,
8532 physicalSide: renderedSide,
8533 anchorHidden,
8534 refs,
8535 context,
8536 isPositioned,
8537 update: update2
8538 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8539 }
8540 function isRef(param) {
8541 return param != null && "current" in param;
8542 }
8543
8544 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8545 function getDisabledMountTransitionStyles(transitionStatus) {
8546 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8547 }
8548
8549 // node_modules/@base-ui/react/utils/usePositioner.mjs
8550 function usePositioner(componentProps, state, {
8551 styles,
8552 transitionStatus,
8553 props,
8554 refs,
8555 hidden,
8556 inert = false
8557 }) {
8558 const style = {
8559 ...styles
8560 };
8561 if (inert) {
8562 style.pointerEvents = "none";
8563 }
8564 return useRenderElement("div", componentProps, {
8565 state,
8566 ref: refs,
8567 props: [{
8568 role: "presentation",
8569 hidden,
8570 style
8571 }, getDisabledMountTransitionStyles(transitionStatus), props],
8572 stateAttributesMapping: popupStateMapping
8573 });
8574 }
8575
8576 // node_modules/@base-ui/react/collapsible/index.parts.mjs
8577 var index_parts_exports = {};
8578 __export(index_parts_exports, {
8579 Panel: () => CollapsiblePanel,
8580 Root: () => CollapsibleRoot,
8581 Trigger: () => CollapsibleTrigger
8582 });
8583
8584 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
8585 var React38 = __toESM(require_react(), 1);
8586
8587 // node_modules/@base-ui/react/collapsible/root/stateAttributesMapping.mjs
8588 var collapsibleStateAttributesMapping = {
8589 ...collapsibleOpenStateMapping,
8590 ...transitionStatusMapping
8591 };
8592
8593 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
8594 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8595 var CollapsibleRoot = /* @__PURE__ */ React38.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
8596 const {
8597 render: render4,
8598 className,
8599 defaultOpen = false,
8600 disabled: disabled2 = false,
8601 onOpenChange: onOpenChangeProp,
8602 open,
8603 style,
8604 ...elementProps
8605 } = componentProps;
8606 const onOpenChange = useStableCallback(onOpenChangeProp);
8607 const collapsible = useCollapsibleRoot({
8608 open,
8609 defaultOpen,
8610 onOpenChange,
8611 disabled: disabled2
8612 });
8613 const state = React38.useMemo(() => ({
8614 open: collapsible.open,
8615 disabled: collapsible.disabled,
8616 transitionStatus: collapsible.transitionStatus
8617 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
8618 const contextValue = React38.useMemo(() => ({
8619 ...collapsible,
8620 onOpenChange,
8621 state
8622 }), [collapsible, onOpenChange, state]);
8623 const element = useRenderElement("div", componentProps, {
8624 state,
8625 ref: forwardedRef,
8626 props: elementProps,
8627 stateAttributesMapping: collapsibleStateAttributesMapping
8628 });
8629 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, {
8630 value: contextValue,
8631 children: element
8632 });
8633 });
8634 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
8635
8636 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTrigger.mjs
8637 var React39 = __toESM(require_react(), 1);
8638 var stateAttributesMapping = {
8639 ...triggerOpenStateMapping,
8640 ...transitionStatusMapping
8641 };
8642 var CollapsibleTrigger = /* @__PURE__ */ React39.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
8643 const {
8644 panelId,
8645 open,
8646 handleTrigger,
8647 state,
8648 disabled: contextDisabled
8649 } = useCollapsibleRootContext();
8650 const {
8651 className,
8652 disabled: disabled2 = contextDisabled,
8653 render: render4,
8654 nativeButton = true,
8655 style,
8656 ...elementProps
8657 } = componentProps;
8658 const {
8659 getButtonProps,
8660 buttonRef
8661 } = useButton({
8662 disabled: disabled2,
8663 focusableWhenDisabled: true,
8664 native: nativeButton
8665 });
8666 const element = useRenderElement("button", componentProps, {
8667 state,
8668 ref: [forwardedRef, buttonRef],
8669 props: [{
8670 "aria-controls": open ? panelId : void 0,
8671 "aria-expanded": open,
8672 onClick: handleTrigger
8673 }, elementProps, getButtonProps],
8674 stateAttributesMapping
8675 });
8676 return element;
8677 });
8678 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
8679
8680 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
8681 var React40 = __toESM(require_react(), 1);
8682
8683 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelCssVars.mjs
8684 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
8685 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
8686 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
8687 return CollapsiblePanelCssVars2;
8688 })({});
8689
8690 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
8691 var CollapsiblePanel = /* @__PURE__ */ React40.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
8692 const {
8693 className,
8694 hiddenUntilFound: hiddenUntilFoundProp,
8695 keepMounted: keepMountedProp,
8696 render: render4,
8697 id: idProp,
8698 style,
8699 ...elementProps
8700 } = componentProps;
8701 if (true) {
8702 useIsoLayoutEffect(() => {
8703 if (hiddenUntilFoundProp && keepMountedProp === false) {
8704 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
8705 }
8706 }, [hiddenUntilFoundProp, keepMountedProp]);
8707 }
8708 const {
8709 mounted,
8710 onOpenChange,
8711 open,
8712 panelId,
8713 setMounted,
8714 setPanelIdState,
8715 setOpen,
8716 state,
8717 transitionStatus
8718 } = useCollapsibleRootContext();
8719 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
8720 const keepMounted = keepMountedProp ?? false;
8721 useIsoLayoutEffect(() => {
8722 if (idProp) {
8723 setPanelIdState(idProp);
8724 return () => {
8725 setPanelIdState(void 0);
8726 };
8727 }
8728 return void 0;
8729 }, [idProp, setPanelIdState]);
8730 const {
8731 height,
8732 props,
8733 ref,
8734 shouldPreventOpenAnimation,
8735 shouldRender,
8736 transitionStatus: panelTransitionStatus,
8737 width
8738 } = useCollapsiblePanel({
8739 externalRef: forwardedRef,
8740 hiddenUntilFound,
8741 id: panelId,
8742 keepMounted,
8743 mounted,
8744 onOpenChange,
8745 open,
8746 setMounted,
8747 setOpen,
8748 transitionStatus
8749 });
8750 const panelState = {
8751 ...state,
8752 transitionStatus: panelTransitionStatus
8753 };
8754 const resolvedStyle = resolveStyle(style, panelState);
8755 const element = useRenderElement("div", {
8756 ...componentProps,
8757 style: void 0
8758 }, {
8759 state: panelState,
8760 ref,
8761 props: [
8762 props,
8763 {
8764 style: {
8765 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
8766 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
8767 }
8768 },
8769 elementProps,
8770 resolvedStyle ? {
8771 style: resolvedStyle
8772 } : void 0,
8773 // Resolve the public `style` prop so temporary `animationName: 'none'`
8774 // can still win after user's inline styles have been merged.
8775 shouldPreventOpenAnimation ? {
8776 style: {
8777 animationName: "none"
8778 }
8779 } : void 0
8780 ],
8781 stateAttributesMapping: collapsibleStateAttributesMapping
8782 });
8783 if (!shouldRender) {
8784 return null;
8785 }
8786 return element;
8787 });
8788 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
8789
8790 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8791 var React43 = __toESM(require_react(), 1);
8792 var ReactDOM6 = __toESM(require_react_dom(), 1);
8793
8794 // node_modules/@base-ui/utils/usePreviousValue.mjs
8795 var React41 = __toESM(require_react(), 1);
8796 function usePreviousValue(value) {
8797 const [state, setState] = React41.useState({
8798 current: value,
8799 previous: null
8800 });
8801 if (value !== state.current) {
8802 setState({
8803 current: value,
8804 previous: state.current
8805 });
8806 }
8807 return state.previous;
8808 }
8809
8810 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8811 var React42 = __toESM(require_react(), 1);
8812
8813 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8814 function getCssDimensions2(element) {
8815 const css = getComputedStyle2(element);
8816 let width = parseFloat(css.width) || 0;
8817 let height = parseFloat(css.height) || 0;
8818 const hasOffset = isHTMLElement(element);
8819 const offsetWidth = hasOffset ? element.offsetWidth : width;
8820 const offsetHeight = hasOffset ? element.offsetHeight : height;
8821 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8822 if (shouldFallback) {
8823 width = offsetWidth;
8824 height = offsetHeight;
8825 }
8826 return {
8827 width,
8828 height
8829 };
8830 }
8831
8832 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8833 function usePopupAutoResize(parameters) {
8834 const {
8835 popupElement,
8836 positionerElement,
8837 content,
8838 mounted,
8839 onMeasureLayout: onMeasureLayoutParam,
8840 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8841 side,
8842 direction
8843 } = parameters;
8844 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8845 const animationFrame = useAnimationFrame();
8846 const committedDimensionsRef = React42.useRef(null);
8847 const isInitialRenderRef = React42.useRef(true);
8848 const restoreAnchoringStylesRef = React42.useRef(NOOP);
8849 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8850 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8851 const anchoringStyles = React42.useMemo(() => {
8852 let isOriginSide = side === "top";
8853 let isPhysicalLeft = side === "left";
8854 if (direction === "rtl") {
8855 isOriginSide = isOriginSide || side === "inline-end";
8856 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8857 } else {
8858 isOriginSide = isOriginSide || side === "inline-start";
8859 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8860 }
8861 return isOriginSide ? {
8862 position: "absolute",
8863 [side === "top" ? "bottom" : "top"]: "0",
8864 [isPhysicalLeft ? "right" : "left"]: "0"
8865 } : EMPTY_OBJECT;
8866 }, [side, direction]);
8867 useIsoLayoutEffect(() => {
8868 if (!mounted) {
8869 restoreAnchoringStylesRef.current = NOOP;
8870 isInitialRenderRef.current = true;
8871 committedDimensionsRef.current = null;
8872 return void 0;
8873 }
8874 if (!popupElement || !positionerElement) {
8875 return void 0;
8876 }
8877 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8878 setPopupCssSize(popupElement, "auto");
8879 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8880 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8881 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8882 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8883 "--available-width": "max-content",
8884 "--available-height": "max-content"
8885 });
8886 function restoreMeasurementOverrides() {
8887 restorePopupPosition();
8888 restorePopupTransform();
8889 restorePositionerAvailableSize();
8890 }
8891 function restoreMeasurementOverridesIncludingScale() {
8892 restoreMeasurementOverrides();
8893 restorePopupScale();
8894 }
8895 onMeasureLayout?.();
8896 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8897 setPositionerCssSize(positionerElement, "max-content");
8898 const dimensions = getCssDimensions2(popupElement);
8899 committedDimensionsRef.current = dimensions;
8900 setPositionerCssSize(positionerElement, dimensions);
8901 restoreMeasurementOverridesIncludingScale();
8902 onMeasureLayoutComplete?.(null, dimensions);
8903 isInitialRenderRef.current = false;
8904 return () => {
8905 restoreAnchoringStylesRef.current();
8906 restoreAnchoringStylesRef.current = NOOP;
8907 };
8908 }
8909 setPositionerCssSize(positionerElement, "max-content");
8910 const previousDimensions = committedDimensionsRef.current;
8911 const newDimensions = getCssDimensions2(popupElement);
8912 committedDimensionsRef.current = newDimensions;
8913 setPopupCssSize(popupElement, previousDimensions);
8914 restoreMeasurementOverridesIncludingScale();
8915 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8916 setPositionerCssSize(positionerElement, newDimensions);
8917 const abortController = new AbortController();
8918 animationFrame.request(() => {
8919 setPopupCssSize(popupElement, newDimensions);
8920 runOnceAnimationsFinish(() => {
8921 popupElement.style.setProperty("--popup-width", "auto");
8922 popupElement.style.setProperty("--popup-height", "auto");
8923 }, abortController.signal);
8924 });
8925 return () => {
8926 abortController.abort();
8927 animationFrame.cancel();
8928 restoreAnchoringStylesRef.current();
8929 restoreAnchoringStylesRef.current = NOOP;
8930 };
8931 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8932 }
8933 function overrideElementStyle(element, property, value) {
8934 const originalValue = element.style.getPropertyValue(property);
8935 element.style.setProperty(property, value);
8936 return () => {
8937 element.style.setProperty(property, originalValue);
8938 };
8939 }
8940 function applyElementStyles(element, styles) {
8941 const restorers = [];
8942 for (const [key, value] of Object.entries(styles)) {
8943 restorers.push(overrideElementStyle(element, key, value));
8944 }
8945 return restorers.length ? () => {
8946 restorers.forEach((restore) => restore());
8947 } : NOOP;
8948 }
8949 function setPopupCssSize(popupElement, size4) {
8950 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8951 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8952 popupElement.style.setProperty("--popup-width", width);
8953 popupElement.style.setProperty("--popup-height", height);
8954 }
8955 function setPositionerCssSize(positionerElement, size4) {
8956 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8957 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8958 positionerElement.style.setProperty("--positioner-width", width);
8959 positionerElement.style.setProperty("--positioner-height", height);
8960 }
8961
8962 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8963 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8964 function usePopupViewport(parameters) {
8965 const {
8966 store,
8967 side,
8968 cssVars,
8969 children
8970 } = parameters;
8971 const direction = useDirection();
8972 const activeTrigger = store.useState("activeTriggerElement");
8973 const activeTriggerId = store.useState("activeTriggerId");
8974 const open = store.useState("open");
8975 const payload = store.useState("payload");
8976 const mounted = store.useState("mounted");
8977 const popupElement = store.useState("popupElement");
8978 const positionerElement = store.useState("positionerElement");
8979 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8980 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8981 const capturedNodeRef = React43.useRef(null);
8982 const [previousContentNode, setPreviousContentNode] = React43.useState(null);
8983 const [newTriggerOffset, setNewTriggerOffset] = React43.useState(null);
8984 const currentContainerRef = React43.useRef(null);
8985 const previousContainerRef = React43.useRef(null);
8986 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8987 const cleanupFrame = useAnimationFrame();
8988 const [previousContentDimensions, setPreviousContentDimensions] = React43.useState(null);
8989 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React43.useState(false);
8990 useIsoLayoutEffect(() => {
8991 store.set("hasViewport", true);
8992 return () => {
8993 store.set("hasViewport", false);
8994 };
8995 }, [store]);
8996 const handleMeasureLayout = useStableCallback(() => {
8997 currentContainerRef.current?.style.setProperty("animation", "none");
8998 currentContainerRef.current?.style.setProperty("transition", "none");
8999 previousContainerRef.current?.style.setProperty("display", "none");
9000 });
9001 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
9002 currentContainerRef.current?.style.removeProperty("animation");
9003 currentContainerRef.current?.style.removeProperty("transition");
9004 previousContainerRef.current?.style.removeProperty("display");
9005 if (previousDimensions) {
9006 setPreviousContentDimensions(previousDimensions);
9007 }
9008 });
9009 const lastHandledTriggerRef = React43.useRef(null);
9010 useIsoLayoutEffect(() => {
9011 if (!open || !mounted) {
9012 lastHandledTriggerRef.current = null;
9013 }
9014 }, [open, mounted]);
9015 useIsoLayoutEffect(() => {
9016 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
9017 setPreviousContentNode(capturedNodeRef.current);
9018 setShowStartingStyleAttribute(true);
9019 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
9020 setNewTriggerOffset(offset4);
9021 cleanupFrame.request(() => {
9022 ReactDOM6.flushSync(() => {
9023 setShowStartingStyleAttribute(false);
9024 });
9025 onAnimationsFinished(() => {
9026 setPreviousContentNode(null);
9027 setPreviousContentDimensions(null);
9028 capturedNodeRef.current = null;
9029 });
9030 });
9031 lastHandledTriggerRef.current = activeTrigger;
9032 }
9033 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
9034 useIsoLayoutEffect(() => {
9035 const source = currentContainerRef.current;
9036 if (!source) {
9037 return;
9038 }
9039 const wrapper = ownerDocument(source).createElement("div");
9040 for (const child of Array.from(source.childNodes)) {
9041 wrapper.appendChild(child.cloneNode(true));
9042 }
9043 capturedNodeRef.current = wrapper;
9044 });
9045 const isTransitioning = previousContentNode != null;
9046 let childrenToRender;
9047 if (!isTransitioning) {
9048 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9049 "data-current": true,
9050 ref: currentContainerRef,
9051 children
9052 }, currentContentKey);
9053 } else {
9054 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React43.Fragment, {
9055 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9056 "data-previous": true,
9057 inert: inertValue(true),
9058 ref: previousContainerRef,
9059 style: {
9060 ...previousContentDimensions ? {
9061 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
9062 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
9063 } : null,
9064 position: "absolute"
9065 },
9066 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
9067 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9068 "data-current": true,
9069 ref: currentContainerRef,
9070 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
9071 children
9072 }, currentContentKey)]
9073 });
9074 }
9075 useIsoLayoutEffect(() => {
9076 const container = previousContainerRef.current;
9077 if (!container || !previousContentNode) {
9078 return;
9079 }
9080 container.replaceChildren(...Array.from(previousContentNode.childNodes));
9081 }, [previousContentNode]);
9082 usePopupAutoResize({
9083 popupElement,
9084 positionerElement,
9085 mounted,
9086 content: payload,
9087 onMeasureLayout: handleMeasureLayout,
9088 onMeasureLayoutComplete: handleMeasureLayoutComplete,
9089 side,
9090 direction
9091 });
9092 const state = {
9093 activationDirection: getActivationDirection(newTriggerOffset),
9094 transitioning: isTransitioning
9095 };
9096 return {
9097 children: childrenToRender,
9098 state
9099 };
9100 }
9101 function getActivationDirection(offset4) {
9102 if (!offset4) {
9103 return void 0;
9104 }
9105 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9106 }
9107 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9108 if (value > tolerance) {
9109 return positiveLabel;
9110 }
9111 if (value < -tolerance) {
9112 return negativeLabel;
9113 }
9114 return "";
9115 }
9116 function calculateRelativePosition(from, to) {
9117 const fromRect = from.getBoundingClientRect();
9118 const toRect = to.getBoundingClientRect();
9119 const fromCenter = {
9120 x: fromRect.left + fromRect.width / 2,
9121 y: fromRect.top + fromRect.height / 2
9122 };
9123 const toCenter = {
9124 x: toRect.left + toRect.width / 2,
9125 y: toRect.top + toRect.height / 2
9126 };
9127 return {
9128 horizontal: toCenter.x - fromCenter.x,
9129 vertical: toCenter.y - fromCenter.y
9130 };
9131 }
9132 function usePopupContentKey(activeTriggerId, payload) {
9133 const [contentKey, setContentKey] = React43.useState(0);
9134 const previousActiveTriggerIdRef = React43.useRef(activeTriggerId);
9135 const previousPayloadRef = React43.useRef(payload);
9136 const pendingPayloadUpdateRef = React43.useRef(false);
9137 useIsoLayoutEffect(() => {
9138 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9139 const previousPayload = previousPayloadRef.current;
9140 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9141 const payloadChanged = payload !== previousPayload;
9142 if (triggerIdChanged) {
9143 setContentKey((value) => value + 1);
9144 pendingPayloadUpdateRef.current = !payloadChanged;
9145 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9146 setContentKey((value) => value + 1);
9147 pendingPayloadUpdateRef.current = false;
9148 }
9149 previousActiveTriggerIdRef.current = activeTriggerId;
9150 previousPayloadRef.current = payload;
9151 }, [activeTriggerId, payload]);
9152 return `${activeTriggerId ?? "current"}-${contentKey}`;
9153 }
9154
9155 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
9156 var React44 = __toESM(require_react(), 1);
9157 var ReactDOM7 = __toESM(require_react_dom(), 1);
9158 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9159 var FloatingPortalLite = /* @__PURE__ */ React44.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9160 const {
9161 children,
9162 container,
9163 className,
9164 render: render4,
9165 style,
9166 ...elementProps
9167 } = componentProps;
9168 const {
9169 portalNode,
9170 portalSubtree
9171 } = useFloatingPortalNode({
9172 container,
9173 ref: forwardedRef,
9174 componentProps,
9175 elementProps
9176 });
9177 if (!portalSubtree && !portalNode) {
9178 return null;
9179 }
9180 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React44.Fragment, {
9181 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
9182 });
9183 });
9184 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9185
9186 // node_modules/@base-ui/react/tooltip/index.parts.mjs
9187 var index_parts_exports2 = {};
9188 __export(index_parts_exports2, {
9189 Arrow: () => TooltipArrow,
9190 Handle: () => TooltipHandle,
9191 Popup: () => TooltipPopup,
9192 Portal: () => TooltipPortal,
9193 Positioner: () => TooltipPositioner,
9194 Provider: () => TooltipProvider,
9195 Root: () => TooltipRoot,
9196 Trigger: () => TooltipTrigger,
9197 Viewport: () => TooltipViewport,
9198 createHandle: () => createTooltipHandle
9199 });
9200
9201 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9202 var React47 = __toESM(require_react(), 1);
9203
9204 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
9205 var React45 = __toESM(require_react(), 1);
9206 var TooltipRootContext = /* @__PURE__ */ React45.createContext(void 0);
9207 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9208 function useTooltipRootContext(optional) {
9209 const context = React45.useContext(TooltipRootContext);
9210 if (context === void 0 && !optional) {
9211 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9212 }
9213 return context;
9214 }
9215
9216 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
9217 var React46 = __toESM(require_react(), 1);
9218 var selectors2 = {
9219 ...popupStoreSelectors,
9220 disabled: createSelector((state) => state.disabled),
9221 instantType: createSelector((state) => state.instantType),
9222 isInstantPhase: createSelector((state) => state.isInstantPhase),
9223 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9224 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9225 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9226 closeOnClick: createSelector((state) => state.closeOnClick),
9227 closeDelay: createSelector((state) => state.closeDelay),
9228 hasViewport: createSelector((state) => state.hasViewport)
9229 };
9230 var TooltipStore = class _TooltipStore extends ReactStore {
9231 constructor(initialState, floatingId, nested = false) {
9232 const triggerElements = new PopupTriggerMap();
9233 const state = {
9234 ...createInitialState(),
9235 ...initialState
9236 };
9237 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9238 super(state, {
9239 popupRef: /* @__PURE__ */ React46.createRef(),
9240 onOpenChange: void 0,
9241 onOpenChangeComplete: void 0,
9242 triggerElements
9243 }, selectors2);
9244 }
9245 setOpen = (nextOpen, eventDetails) => {
9246 applyPopupOpenChange(this, nextOpen, eventDetails, {
9247 extraState: {
9248 openChangeReason: eventDetails.reason
9249 }
9250 });
9251 };
9252 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9253 cancelPendingOpen(event) {
9254 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9255 }
9256 static useStore(externalStore, initialState) {
9257 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9258 return store;
9259 }
9260 };
9261 function createInitialState() {
9262 return {
9263 ...createInitialPopupStoreState(),
9264 disabled: false,
9265 instantType: void 0,
9266 isInstantPhase: false,
9267 trackCursorAxis: "none",
9268 disableHoverablePopup: false,
9269 openChangeReason: null,
9270 closeOnClick: true,
9271 closeDelay: 0,
9272 hasViewport: false
9273 };
9274 }
9275
9276 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9277 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
9278 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9279 const {
9280 disabled: disabled2 = false,
9281 defaultOpen = false,
9282 open: openProp,
9283 disableHoverablePopup = false,
9284 trackCursorAxis = "none",
9285 actionsRef,
9286 onOpenChange,
9287 onOpenChangeComplete,
9288 handle,
9289 triggerId: triggerIdProp,
9290 defaultTriggerId: defaultTriggerIdProp = null,
9291 children
9292 } = props;
9293 const store = TooltipStore.useStore(handle?.store, {
9294 open: defaultOpen,
9295 openProp,
9296 activeTriggerId: defaultTriggerIdProp,
9297 triggerIdProp
9298 });
9299 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
9300 store.useControlledProp("openProp", openProp);
9301 store.useControlledProp("triggerIdProp", triggerIdProp);
9302 store.useContextCallback("onOpenChange", onOpenChange);
9303 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9304 const openState = store.useState("open");
9305 const open = !disabled2 && openState;
9306 const activeTriggerId = store.useState("activeTriggerId");
9307 const mounted = store.useState("mounted");
9308 const payload = store.useState("payload");
9309 store.useSyncedValues({
9310 trackCursorAxis,
9311 disableHoverablePopup
9312 });
9313 store.useSyncedValue("disabled", disabled2);
9314 useImplicitActiveTrigger(store, {
9315 closeOnActiveTriggerUnmount: true
9316 });
9317 const {
9318 forceUnmount,
9319 transitionStatus
9320 } = useOpenStateTransitions(open, store);
9321 const isInstantPhase = store.useState("isInstantPhase");
9322 const instantType = store.useState("instantType");
9323 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9324 const previousInstantTypeRef = React47.useRef(null);
9325 useIsoLayoutEffect(() => {
9326 if (openState && disabled2) {
9327 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9328 }
9329 }, [openState, disabled2, store]);
9330 useIsoLayoutEffect(() => {
9331 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9332 if (instantType !== "delay") {
9333 previousInstantTypeRef.current = instantType;
9334 }
9335 store.set("instantType", "delay");
9336 } else if (previousInstantTypeRef.current !== null) {
9337 store.set("instantType", previousInstantTypeRef.current);
9338 previousInstantTypeRef.current = null;
9339 }
9340 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9341 useIsoLayoutEffect(() => {
9342 if (open) {
9343 if (activeTriggerId == null) {
9344 store.set("payload", void 0);
9345 }
9346 }
9347 }, [store, activeTriggerId, open]);
9348 const handleImperativeClose = React47.useCallback(() => {
9349 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9350 }, [store]);
9351 React47.useImperativeHandle(actionsRef, () => ({
9352 unmount: forceUnmount,
9353 close: handleImperativeClose
9354 }), [forceUnmount, handleImperativeClose]);
9355 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9356 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(TooltipRootContext.Provider, {
9357 value: store,
9358 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipInteractions, {
9359 store,
9360 disabled: disabled2,
9361 trackCursorAxis
9362 }), typeof children === "function" ? children({
9363 payload
9364 }) : children]
9365 });
9366 });
9367 if (true) TooltipRoot.displayName = "TooltipRoot";
9368 function TooltipInteractions({
9369 store,
9370 disabled: disabled2,
9371 trackCursorAxis
9372 }) {
9373 const floatingRootContext = store.useState("floatingRootContext");
9374 const dismiss = useDismiss(floatingRootContext, {
9375 enabled: !disabled2,
9376 referencePress: () => store.select("closeOnClick")
9377 });
9378 const clientPoint = useClientPoint(floatingRootContext, {
9379 enabled: !disabled2 && trackCursorAxis !== "none",
9380 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9381 });
9382 const activeTriggerProps = React47.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9383 const inactiveTriggerProps = React47.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9384 const popupProps = React47.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9385 usePopupInteractionProps(store, {
9386 activeTriggerProps,
9387 inactiveTriggerProps,
9388 popupProps
9389 });
9390 return null;
9391 }
9392
9393 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9394 var React49 = __toESM(require_react(), 1);
9395
9396 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
9397 var React48 = __toESM(require_react(), 1);
9398 var TooltipProviderContext = /* @__PURE__ */ React48.createContext(void 0);
9399 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9400 function useTooltipProviderContext() {
9401 return React48.useContext(TooltipProviderContext);
9402 }
9403
9404 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
9405 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9406 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9407 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9408 return TooltipTriggerDataAttributes2;
9409 })({});
9410
9411 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
9412 var OPEN_DELAY = 600;
9413
9414 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9415 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9416 function getTargetElement(event) {
9417 if ("composedPath" in event) {
9418 const path = event.composedPath();
9419 for (let i2 = 0; i2 < path.length; i2 += 1) {
9420 const element = path[i2];
9421 if (isElement(element)) {
9422 return element;
9423 }
9424 }
9425 }
9426 const target = event.target;
9427 if (isElement(target)) {
9428 return target;
9429 }
9430 return null;
9431 }
9432 function closestEnabledTooltipTrigger(element) {
9433 let current = element;
9434 while (current) {
9435 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9436 return current;
9437 }
9438 const parentElement = current.parentElement;
9439 if (parentElement) {
9440 current = parentElement;
9441 continue;
9442 }
9443 const root = current.getRootNode();
9444 current = "host" in root && isElement(root.host) ? root.host : null;
9445 }
9446 return null;
9447 }
9448 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9449 const {
9450 render: render4,
9451 className,
9452 style,
9453 handle,
9454 payload,
9455 disabled: disabledProp,
9456 delay,
9457 closeOnClick = true,
9458 closeDelay,
9459 id: idProp,
9460 ...elementProps
9461 } = componentProps;
9462 const rootContext = useTooltipRootContext(true);
9463 const store = handle?.store ?? rootContext;
9464 if (!store) {
9465 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));
9466 }
9467 const thisTriggerId = useBaseUiId(idProp);
9468 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9469 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9470 const floatingRootContext = store.useState("floatingRootContext");
9471 const triggerElementRef = React49.useRef(null);
9472 const delayWithDefault = delay ?? OPEN_DELAY;
9473 const closeDelayWithDefault = closeDelay ?? 0;
9474 const {
9475 registerTrigger,
9476 isMountedByThisTrigger
9477 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9478 payload,
9479 closeOnClick,
9480 closeDelay: closeDelayWithDefault
9481 });
9482 const providerContext = useTooltipProviderContext();
9483 const {
9484 delayRef,
9485 isInstantPhase,
9486 hasProvider
9487 } = useDelayGroup(floatingRootContext, {
9488 open: isOpenedByThisTrigger
9489 });
9490 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9491 store.useSyncedValue("isInstantPhase", isInstantPhase);
9492 const rootDisabled = store.useState("disabled");
9493 const disabled2 = disabledProp ?? rootDisabled;
9494 const disabledRef = useValueAsRef(disabled2);
9495 const trackCursorAxis = store.useState("trackCursorAxis");
9496 const disableHoverablePopup = store.useState("disableHoverablePopup");
9497 const isNestedTriggerHoveredRef = React49.useRef(false);
9498 const nestedTriggerOpenTimeout = useTimeout();
9499 const pointerTypeRef = React49.useRef(void 0);
9500 function getOpenDelay() {
9501 const providerDelay = providerContext?.delay;
9502 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9503 let computedOpenDelay = delayWithDefault;
9504 if (hasProvider) {
9505 if (groupOpenValue !== 0) {
9506 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9507 } else {
9508 computedOpenDelay = 0;
9509 }
9510 }
9511 return computedOpenDelay;
9512 }
9513 function isEnabledNestedTriggerTarget(target) {
9514 const triggerEl = triggerElementRef.current;
9515 if (!triggerEl || !target) {
9516 return false;
9517 }
9518 const nearestTrigger = closestEnabledTooltipTrigger(target);
9519 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9520 }
9521 function detectNestedTriggerHover(target) {
9522 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9523 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9524 if (nestedTriggerHovered) {
9525 hoverInteraction.openChangeTimeout.clear();
9526 hoverInteraction.restTimeout.clear();
9527 hoverInteraction.restTimeoutPending = false;
9528 nestedTriggerOpenTimeout.clear();
9529 }
9530 return nestedTriggerHovered;
9531 }
9532 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9533 enabled: !disabled2,
9534 mouseOnly: true,
9535 move: false,
9536 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9537 restMs: getOpenDelay,
9538 delay() {
9539 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9540 let computedCloseDelay = closeDelayWithDefault;
9541 if (closeDelay == null && hasProvider) {
9542 computedCloseDelay = closeValue;
9543 }
9544 return {
9545 close: computedCloseDelay
9546 };
9547 },
9548 triggerElementRef,
9549 isActiveTrigger: isTriggerActive,
9550 isClosing: () => store.select("transitionStatus") === "ending",
9551 shouldOpen() {
9552 return !isNestedTriggerHoveredRef.current;
9553 }
9554 });
9555 const focusProps = useFocus(floatingRootContext, {
9556 enabled: !disabled2
9557 }).reference;
9558 const handleNestedTriggerHover = (event) => {
9559 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9560 const target = getTargetElement(event);
9561 const nestedTriggerHovered = detectNestedTriggerHover(target);
9562 const triggerEl = triggerElementRef.current;
9563 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9564 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9565 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9566 return;
9567 }
9568 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9569 isMouseLikePointerType(pointerTypeRef.current)) {
9570 const open = () => {
9571 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9572 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9573 }
9574 };
9575 const openDelay = getOpenDelay();
9576 if (openDelay === 0) {
9577 nestedTriggerOpenTimeout.clear();
9578 open();
9579 } else {
9580 nestedTriggerOpenTimeout.start(openDelay, open);
9581 }
9582 }
9583 };
9584 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9585 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9586 const state = {
9587 open: isOpenedByThisTrigger
9588 };
9589 const element = useRenderElement("button", componentProps, {
9590 state,
9591 ref: [forwardedRef, registerTrigger, triggerElementRef],
9592 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9593 onMouseOver(event) {
9594 handleNestedTriggerHover(event.nativeEvent);
9595 },
9596 onFocus(event) {
9597 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9598 event.preventBaseUIHandler();
9599 }
9600 },
9601 onMouseLeave() {
9602 isNestedTriggerHoveredRef.current = false;
9603 nestedTriggerOpenTimeout.clear();
9604 pointerTypeRef.current = void 0;
9605 },
9606 onPointerEnter(event) {
9607 pointerTypeRef.current = event.pointerType;
9608 },
9609 onPointerDown(event) {
9610 pointerTypeRef.current = event.pointerType;
9611 store.set("closeOnClick", closeOnClick);
9612 if (closeOnClick && !store.select("open")) {
9613 store.cancelPendingOpen(event.nativeEvent);
9614 }
9615 },
9616 onClick(event) {
9617 if (closeOnClick && !store.select("open")) {
9618 store.cancelPendingOpen(event.nativeEvent);
9619 }
9620 },
9621 id: thisTriggerId,
9622 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9623 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9624 }, elementProps],
9625 stateAttributesMapping: triggerOpenStateMapping2
9626 });
9627 return element;
9628 });
9629 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9630
9631 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9632 var React51 = __toESM(require_react(), 1);
9633
9634 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
9635 var React50 = __toESM(require_react(), 1);
9636 var TooltipPortalContext = /* @__PURE__ */ React50.createContext(void 0);
9637 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9638 function useTooltipPortalContext() {
9639 const value = React50.useContext(TooltipPortalContext);
9640 if (value === void 0) {
9641 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9642 }
9643 return value;
9644 }
9645
9646 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9647 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9648 var TooltipPortal = /* @__PURE__ */ React51.forwardRef(function TooltipPortal2(props, forwardedRef) {
9649 const {
9650 keepMounted = false,
9651 ...portalProps
9652 } = props;
9653 const store = useTooltipRootContext();
9654 const mounted = store.useState("mounted");
9655 const shouldRender = mounted || keepMounted;
9656 if (!shouldRender) {
9657 return null;
9658 }
9659 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, {
9660 value: keepMounted,
9661 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, {
9662 ref: forwardedRef,
9663 ...portalProps
9664 })
9665 });
9666 });
9667 if (true) TooltipPortal.displayName = "TooltipPortal";
9668
9669 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9670 var React53 = __toESM(require_react(), 1);
9671
9672 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
9673 var React52 = __toESM(require_react(), 1);
9674 var TooltipPositionerContext = /* @__PURE__ */ React52.createContext(void 0);
9675 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9676 function useTooltipPositionerContext() {
9677 const context = React52.useContext(TooltipPositionerContext);
9678 if (context === void 0) {
9679 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9680 }
9681 return context;
9682 }
9683
9684 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9685 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9686 var TooltipPositioner = /* @__PURE__ */ React53.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9687 const {
9688 render: render4,
9689 className,
9690 anchor,
9691 positionMethod = "absolute",
9692 side = "top",
9693 align = "center",
9694 sideOffset = 0,
9695 alignOffset = 0,
9696 collisionBoundary = "clipping-ancestors",
9697 collisionPadding = 5,
9698 arrowPadding = 5,
9699 sticky = false,
9700 disableAnchorTracking = false,
9701 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9702 style,
9703 ...elementProps
9704 } = componentProps;
9705 const store = useTooltipRootContext();
9706 const keepMounted = useTooltipPortalContext();
9707 const open = store.useState("open");
9708 const mounted = store.useState("mounted");
9709 const trackCursorAxis = store.useState("trackCursorAxis");
9710 const disableHoverablePopup = store.useState("disableHoverablePopup");
9711 const floatingRootContext = store.useState("floatingRootContext");
9712 const instantType = store.useState("instantType");
9713 const transitionStatus = store.useState("transitionStatus");
9714 const hasViewport = store.useState("hasViewport");
9715 const positioning = useAnchorPositioning({
9716 anchor,
9717 positionMethod,
9718 floatingRootContext,
9719 mounted,
9720 side,
9721 sideOffset,
9722 align,
9723 alignOffset,
9724 collisionBoundary,
9725 collisionPadding,
9726 sticky,
9727 arrowPadding,
9728 disableAnchorTracking,
9729 keepMounted,
9730 collisionAvoidance,
9731 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9732 });
9733 const state = React53.useMemo(() => ({
9734 open,
9735 side: positioning.side,
9736 align: positioning.align,
9737 anchorHidden: positioning.anchorHidden,
9738 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9739 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9740 const element = usePositioner(componentProps, state, {
9741 styles: positioning.positionerStyles,
9742 transitionStatus,
9743 props: elementProps,
9744 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9745 hidden: !mounted,
9746 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9747 });
9748 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, {
9749 value: positioning,
9750 children: element
9751 });
9752 });
9753 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9754
9755 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9756 var React54 = __toESM(require_react(), 1);
9757 var stateAttributesMapping2 = {
9758 ...popupStateMapping,
9759 ...transitionStatusMapping
9760 };
9761 var TooltipPopup = /* @__PURE__ */ React54.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9762 const {
9763 render: render4,
9764 className,
9765 style,
9766 ...elementProps
9767 } = componentProps;
9768 const store = useTooltipRootContext();
9769 const {
9770 side,
9771 align
9772 } = useTooltipPositionerContext();
9773 const open = store.useState("open");
9774 const instantType = store.useState("instantType");
9775 const transitionStatus = store.useState("transitionStatus");
9776 const popupProps = store.useState("popupProps");
9777 const floatingContext = store.useState("floatingRootContext");
9778 const disabled2 = store.useState("disabled");
9779 const closeDelay = store.useState("closeDelay");
9780 useOpenChangeComplete({
9781 open,
9782 ref: store.context.popupRef,
9783 onComplete() {
9784 if (open) {
9785 store.context.onOpenChangeComplete?.(true);
9786 }
9787 }
9788 });
9789 useHoverFloatingInteraction(floatingContext, {
9790 enabled: !disabled2,
9791 closeDelay
9792 });
9793 const setPopupElement = store.useStateSetter("popupElement");
9794 const state = {
9795 open,
9796 side,
9797 align,
9798 instant: instantType,
9799 transitionStatus
9800 };
9801 const element = useRenderElement("div", componentProps, {
9802 state,
9803 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9804 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9805 stateAttributesMapping: stateAttributesMapping2
9806 });
9807 return element;
9808 });
9809 if (true) TooltipPopup.displayName = "TooltipPopup";
9810
9811 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9812 var React55 = __toESM(require_react(), 1);
9813 var TooltipArrow = /* @__PURE__ */ React55.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9814 const {
9815 render: render4,
9816 className,
9817 style,
9818 ...elementProps
9819 } = componentProps;
9820 const store = useTooltipRootContext();
9821 const {
9822 arrowRef,
9823 side,
9824 align,
9825 arrowUncentered,
9826 arrowStyles
9827 } = useTooltipPositionerContext();
9828 const open = store.useState("open");
9829 const instantType = store.useState("instantType");
9830 const state = {
9831 open,
9832 side,
9833 align,
9834 uncentered: arrowUncentered,
9835 instant: instantType
9836 };
9837 const element = useRenderElement("div", componentProps, {
9838 state,
9839 ref: [forwardedRef, arrowRef],
9840 props: [{
9841 style: arrowStyles,
9842 "aria-hidden": true
9843 }, elementProps],
9844 stateAttributesMapping: popupStateMapping
9845 });
9846 return element;
9847 });
9848 if (true) TooltipArrow.displayName = "TooltipArrow";
9849
9850 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9851 var React56 = __toESM(require_react(), 1);
9852 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9853 var TooltipProvider = function TooltipProvider2(props) {
9854 const {
9855 delay,
9856 closeDelay,
9857 timeout = 400
9858 } = props;
9859 const contextValue = React56.useMemo(() => ({
9860 delay,
9861 closeDelay
9862 }), [delay, closeDelay]);
9863 const delayValue = React56.useMemo(() => ({
9864 open: delay,
9865 close: closeDelay
9866 }), [delay, closeDelay]);
9867 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, {
9868 value: contextValue,
9869 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, {
9870 delay: delayValue,
9871 timeoutMs: timeout,
9872 children: props.children
9873 })
9874 });
9875 };
9876 if (true) TooltipProvider.displayName = "TooltipProvider";
9877
9878 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9879 var React57 = __toESM(require_react(), 1);
9880
9881 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9882 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9883 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9884 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9885 return TooltipViewportCssVars2;
9886 })({});
9887
9888 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9889 var stateAttributesMapping3 = {
9890 activationDirection: (value) => value ? {
9891 "data-activation-direction": value
9892 } : null
9893 };
9894 var TooltipViewport = /* @__PURE__ */ React57.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9895 const {
9896 render: render4,
9897 className,
9898 style,
9899 children,
9900 ...elementProps
9901 } = componentProps;
9902 const store = useTooltipRootContext();
9903 const positioner = useTooltipPositionerContext();
9904 const instantType = store.useState("instantType");
9905 const {
9906 children: childrenToRender,
9907 state: viewportState
9908 } = usePopupViewport({
9909 store,
9910 side: positioner.side,
9911 cssVars: TooltipViewportCssVars,
9912 children
9913 });
9914 const state = {
9915 activationDirection: viewportState.activationDirection,
9916 transitioning: viewportState.transitioning,
9917 instant: instantType
9918 };
9919 return useRenderElement("div", componentProps, {
9920 state,
9921 ref: forwardedRef,
9922 props: [elementProps, {
9923 children: childrenToRender
9924 }],
9925 stateAttributesMapping: stateAttributesMapping3
9926 });
9927 });
9928 if (true) TooltipViewport.displayName = "TooltipViewport";
9929
9930 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9931 var TooltipHandle = class {
9932 /**
9933 * Internal store holding the tooltip state.
9934 * @internal
9935 */
9936 constructor() {
9937 this.store = new TooltipStore();
9938 }
9939 /**
9940 * Opens the tooltip and associates it with the trigger with the given ID.
9941 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9942 *
9943 * This method should only be called in an event handler or an effect (not during rendering).
9944 *
9945 * @param triggerId ID of the trigger to associate with the tooltip.
9946 */
9947 open(triggerId) {
9948 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9949 if (triggerId && !triggerElement) {
9950 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9951 }
9952 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9953 }
9954 /**
9955 * Closes the tooltip.
9956 */
9957 close() {
9958 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9959 }
9960 /**
9961 * Indicates whether the tooltip is currently open.
9962 */
9963 get isOpen() {
9964 return this.store.select("open");
9965 }
9966 };
9967 function createTooltipHandle() {
9968 return new TooltipHandle();
9969 }
9970
9971 // node_modules/@base-ui/react/use-render/useRender.mjs
9972 function useRender(params) {
9973 return useRenderElement(params.defaultTagName ?? "div", params, params);
9974 }
9975
9976 // packages/ui/build-module/text/text.mjs
9977 var import_element10 = __toESM(require_element(), 1);
9978 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9979 function getRuntime() {
9980 const globalScope = globalThis;
9981 if (globalScope.__wpStyleRuntime) {
9982 return globalScope.__wpStyleRuntime;
9983 }
9984 globalScope.__wpStyleRuntime = {
9985 documents: /* @__PURE__ */ new Map(),
9986 styles: /* @__PURE__ */ new Map(),
9987 injectedStyles: /* @__PURE__ */ new WeakMap()
9988 };
9989 if (typeof document !== "undefined") {
9990 registerDocument(document);
9991 }
9992 return globalScope.__wpStyleRuntime;
9993 }
9994 function documentContainsStyleHash(targetDocument, hash) {
9995 if (!targetDocument.head) {
9996 return false;
9997 }
9998 for (const style of targetDocument.head.querySelectorAll(
9999 `style[${STYLE_HASH_ATTRIBUTE}]`
10000 )) {
10001 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
10002 return true;
10003 }
10004 }
10005 return false;
10006 }
10007 function injectStyle(targetDocument, hash, css) {
10008 if (!targetDocument.head) {
10009 return;
10010 }
10011 const runtime = getRuntime();
10012 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10013 if (!injectedStyles) {
10014 injectedStyles = /* @__PURE__ */ new Set();
10015 runtime.injectedStyles.set(targetDocument, injectedStyles);
10016 }
10017 if (injectedStyles.has(hash)) {
10018 return;
10019 }
10020 if (documentContainsStyleHash(targetDocument, hash)) {
10021 injectedStyles.add(hash);
10022 return;
10023 }
10024 const style = targetDocument.createElement("style");
10025 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
10026 style.appendChild(targetDocument.createTextNode(css));
10027 targetDocument.head.appendChild(style);
10028 injectedStyles.add(hash);
10029 }
10030 function registerDocument(targetDocument) {
10031 const runtime = getRuntime();
10032 runtime.documents.set(
10033 targetDocument,
10034 (runtime.documents.get(targetDocument) ?? 0) + 1
10035 );
10036 for (const [hash, css] of runtime.styles) {
10037 injectStyle(targetDocument, hash, css);
10038 }
10039 return () => {
10040 const count = runtime.documents.get(targetDocument);
10041 if (count === void 0) {
10042 return;
10043 }
10044 if (count <= 1) {
10045 runtime.documents.delete(targetDocument);
10046 return;
10047 }
10048 runtime.documents.set(targetDocument, count - 1);
10049 };
10050 }
10051 function registerStyle(hash, css) {
10052 const runtime = getRuntime();
10053 runtime.styles.set(hash, css);
10054 for (const targetDocument of runtime.documents.keys()) {
10055 injectStyle(targetDocument, hash, css);
10056 }
10057 }
10058 if (typeof process === "undefined" || true) {
10059 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
10060 }
10061 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
10062 if (typeof process === "undefined" || true) {
10063 registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10064 }
10065 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" };
10066 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
10067 const element = useRender({
10068 render: render4,
10069 defaultTagName: "span",
10070 ref,
10071 props: mergeProps(props, {
10072 className: clsx_default(
10073 style_default.text,
10074 global_css_defense_default.heading,
10075 global_css_defense_default.p,
10076 style_default[variant],
10077 className
10078 )
10079 })
10080 });
10081 return element;
10082 });
10083
10084 // packages/ui/build-module/badge/badge.mjs
10085 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10086 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10087 function getRuntime2() {
10088 const globalScope = globalThis;
10089 if (globalScope.__wpStyleRuntime) {
10090 return globalScope.__wpStyleRuntime;
10091 }
10092 globalScope.__wpStyleRuntime = {
10093 documents: /* @__PURE__ */ new Map(),
10094 styles: /* @__PURE__ */ new Map(),
10095 injectedStyles: /* @__PURE__ */ new WeakMap()
10096 };
10097 if (typeof document !== "undefined") {
10098 registerDocument2(document);
10099 }
10100 return globalScope.__wpStyleRuntime;
10101 }
10102 function documentContainsStyleHash2(targetDocument, hash) {
10103 if (!targetDocument.head) {
10104 return false;
10105 }
10106 for (const style of targetDocument.head.querySelectorAll(
10107 `style[${STYLE_HASH_ATTRIBUTE2}]`
10108 )) {
10109 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10110 return true;
10111 }
10112 }
10113 return false;
10114 }
10115 function injectStyle2(targetDocument, hash, css) {
10116 if (!targetDocument.head) {
10117 return;
10118 }
10119 const runtime = getRuntime2();
10120 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10121 if (!injectedStyles) {
10122 injectedStyles = /* @__PURE__ */ new Set();
10123 runtime.injectedStyles.set(targetDocument, injectedStyles);
10124 }
10125 if (injectedStyles.has(hash)) {
10126 return;
10127 }
10128 if (documentContainsStyleHash2(targetDocument, hash)) {
10129 injectedStyles.add(hash);
10130 return;
10131 }
10132 const style = targetDocument.createElement("style");
10133 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10134 style.appendChild(targetDocument.createTextNode(css));
10135 targetDocument.head.appendChild(style);
10136 injectedStyles.add(hash);
10137 }
10138 function registerDocument2(targetDocument) {
10139 const runtime = getRuntime2();
10140 runtime.documents.set(
10141 targetDocument,
10142 (runtime.documents.get(targetDocument) ?? 0) + 1
10143 );
10144 for (const [hash, css] of runtime.styles) {
10145 injectStyle2(targetDocument, hash, css);
10146 }
10147 return () => {
10148 const count = runtime.documents.get(targetDocument);
10149 if (count === void 0) {
10150 return;
10151 }
10152 if (count <= 1) {
10153 runtime.documents.delete(targetDocument);
10154 return;
10155 }
10156 runtime.documents.set(targetDocument, count - 1);
10157 };
10158 }
10159 function registerStyle2(hash, css) {
10160 const runtime = getRuntime2();
10161 runtime.styles.set(hash, css);
10162 for (const targetDocument of runtime.documents.keys()) {
10163 injectStyle2(targetDocument, hash, css);
10164 }
10165 }
10166 if (typeof process === "undefined" || true) {
10167 registerStyle2("9db2873e7f", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-background-surface-error,#f6e6e3);color:var(--wpds-color-foreground-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-background-surface-warning,#fde6be);color:var(--wpds-color-foreground-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-background-surface-caution,#fee995);color:var(--wpds-color-foreground-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-background-surface-success,#c6f7cd);color:var(--wpds-color-foreground-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-background-surface-info,#deebfa);color:var(--wpds-color-foreground-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}}");
10168 }
10169 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
10170 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
10171 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10172 Text,
10173 {
10174 ref,
10175 className: clsx_default(
10176 style_default2.badge,
10177 style_default2[`is-${intent}-intent`],
10178 className
10179 ),
10180 ...props,
10181 variant: "body-sm"
10182 }
10183 );
10184 });
10185
10186 // packages/ui/build-module/icon/icon.mjs
10187 var import_element12 = __toESM(require_element(), 1);
10188 var import_primitives = __toESM(require_primitives(), 1);
10189 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10190 var Icon = (0, import_element12.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
10191 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
10192 import_primitives.SVG,
10193 {
10194 ref,
10195 ...icon.props,
10196 ...restProps,
10197 width: size4,
10198 height: size4
10199 }
10200 );
10201 });
10202
10203 // packages/ui/build-module/card/index.mjs
10204 var card_exports = {};
10205 __export(card_exports, {
10206 Content: () => Content,
10207 FullBleed: () => FullBleed,
10208 Header: () => Header,
10209 Root: () => Root,
10210 Title: () => Title
10211 });
10212
10213 // packages/ui/build-module/card/root.mjs
10214 var import_element13 = __toESM(require_element(), 1);
10215 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10216 function getRuntime3() {
10217 const globalScope = globalThis;
10218 if (globalScope.__wpStyleRuntime) {
10219 return globalScope.__wpStyleRuntime;
10220 }
10221 globalScope.__wpStyleRuntime = {
10222 documents: /* @__PURE__ */ new Map(),
10223 styles: /* @__PURE__ */ new Map(),
10224 injectedStyles: /* @__PURE__ */ new WeakMap()
10225 };
10226 if (typeof document !== "undefined") {
10227 registerDocument3(document);
10228 }
10229 return globalScope.__wpStyleRuntime;
10230 }
10231 function documentContainsStyleHash3(targetDocument, hash) {
10232 if (!targetDocument.head) {
10233 return false;
10234 }
10235 for (const style of targetDocument.head.querySelectorAll(
10236 `style[${STYLE_HASH_ATTRIBUTE3}]`
10237 )) {
10238 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10239 return true;
10240 }
10241 }
10242 return false;
10243 }
10244 function injectStyle3(targetDocument, hash, css) {
10245 if (!targetDocument.head) {
10246 return;
10247 }
10248 const runtime = getRuntime3();
10249 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10250 if (!injectedStyles) {
10251 injectedStyles = /* @__PURE__ */ new Set();
10252 runtime.injectedStyles.set(targetDocument, injectedStyles);
10253 }
10254 if (injectedStyles.has(hash)) {
10255 return;
10256 }
10257 if (documentContainsStyleHash3(targetDocument, hash)) {
10258 injectedStyles.add(hash);
10259 return;
10260 }
10261 const style = targetDocument.createElement("style");
10262 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10263 style.appendChild(targetDocument.createTextNode(css));
10264 targetDocument.head.appendChild(style);
10265 injectedStyles.add(hash);
10266 }
10267 function registerDocument3(targetDocument) {
10268 const runtime = getRuntime3();
10269 runtime.documents.set(
10270 targetDocument,
10271 (runtime.documents.get(targetDocument) ?? 0) + 1
10272 );
10273 for (const [hash, css] of runtime.styles) {
10274 injectStyle3(targetDocument, hash, css);
10275 }
10276 return () => {
10277 const count = runtime.documents.get(targetDocument);
10278 if (count === void 0) {
10279 return;
10280 }
10281 if (count <= 1) {
10282 runtime.documents.delete(targetDocument);
10283 return;
10284 }
10285 runtime.documents.set(targetDocument, count - 1);
10286 };
10287 }
10288 function registerStyle3(hash, css) {
10289 const runtime = getRuntime3();
10290 runtime.styles.set(hash, css);
10291 for (const targetDocument of runtime.documents.keys()) {
10292 injectStyle3(targetDocument, hash, css);
10293 }
10294 }
10295 if (typeof process === "undefined" || true) {
10296 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10297 }
10298 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10299 if (typeof process === "undefined" || true) {
10300 registerStyle3("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10301 }
10302 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10303 var Root = (0, import_element13.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
10304 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]);
10305 const element = useRender({
10306 defaultTagName: "div",
10307 render: render4,
10308 ref,
10309 props: mergeProps({ className: mergedClassName }, restProps)
10310 });
10311 return element;
10312 });
10313
10314 // packages/ui/build-module/card/header.mjs
10315 var import_element14 = __toESM(require_element(), 1);
10316 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10317 function getRuntime4() {
10318 const globalScope = globalThis;
10319 if (globalScope.__wpStyleRuntime) {
10320 return globalScope.__wpStyleRuntime;
10321 }
10322 globalScope.__wpStyleRuntime = {
10323 documents: /* @__PURE__ */ new Map(),
10324 styles: /* @__PURE__ */ new Map(),
10325 injectedStyles: /* @__PURE__ */ new WeakMap()
10326 };
10327 if (typeof document !== "undefined") {
10328 registerDocument4(document);
10329 }
10330 return globalScope.__wpStyleRuntime;
10331 }
10332 function documentContainsStyleHash4(targetDocument, hash) {
10333 if (!targetDocument.head) {
10334 return false;
10335 }
10336 for (const style of targetDocument.head.querySelectorAll(
10337 `style[${STYLE_HASH_ATTRIBUTE4}]`
10338 )) {
10339 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10340 return true;
10341 }
10342 }
10343 return false;
10344 }
10345 function injectStyle4(targetDocument, hash, css) {
10346 if (!targetDocument.head) {
10347 return;
10348 }
10349 const runtime = getRuntime4();
10350 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10351 if (!injectedStyles) {
10352 injectedStyles = /* @__PURE__ */ new Set();
10353 runtime.injectedStyles.set(targetDocument, injectedStyles);
10354 }
10355 if (injectedStyles.has(hash)) {
10356 return;
10357 }
10358 if (documentContainsStyleHash4(targetDocument, hash)) {
10359 injectedStyles.add(hash);
10360 return;
10361 }
10362 const style = targetDocument.createElement("style");
10363 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10364 style.appendChild(targetDocument.createTextNode(css));
10365 targetDocument.head.appendChild(style);
10366 injectedStyles.add(hash);
10367 }
10368 function registerDocument4(targetDocument) {
10369 const runtime = getRuntime4();
10370 runtime.documents.set(
10371 targetDocument,
10372 (runtime.documents.get(targetDocument) ?? 0) + 1
10373 );
10374 for (const [hash, css] of runtime.styles) {
10375 injectStyle4(targetDocument, hash, css);
10376 }
10377 return () => {
10378 const count = runtime.documents.get(targetDocument);
10379 if (count === void 0) {
10380 return;
10381 }
10382 if (count <= 1) {
10383 runtime.documents.delete(targetDocument);
10384 return;
10385 }
10386 runtime.documents.set(targetDocument, count - 1);
10387 };
10388 }
10389 function registerStyle4(hash, css) {
10390 const runtime = getRuntime4();
10391 runtime.styles.set(hash, css);
10392 for (const targetDocument of runtime.documents.keys()) {
10393 injectStyle4(targetDocument, hash, css);
10394 }
10395 }
10396 if (typeof process === "undefined" || true) {
10397 registerStyle4("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10398 }
10399 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10400 var Header = (0, import_element14.forwardRef)(
10401 function CardHeader({ render: render4, ...props }, ref) {
10402 const element = useRender({
10403 defaultTagName: "div",
10404 render: render4,
10405 ref,
10406 props: mergeProps({ className: style_default4.header }, props)
10407 });
10408 return element;
10409 }
10410 );
10411
10412 // packages/ui/build-module/card/content.mjs
10413 var import_element15 = __toESM(require_element(), 1);
10414 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10415 function getRuntime5() {
10416 const globalScope = globalThis;
10417 if (globalScope.__wpStyleRuntime) {
10418 return globalScope.__wpStyleRuntime;
10419 }
10420 globalScope.__wpStyleRuntime = {
10421 documents: /* @__PURE__ */ new Map(),
10422 styles: /* @__PURE__ */ new Map(),
10423 injectedStyles: /* @__PURE__ */ new WeakMap()
10424 };
10425 if (typeof document !== "undefined") {
10426 registerDocument5(document);
10427 }
10428 return globalScope.__wpStyleRuntime;
10429 }
10430 function documentContainsStyleHash5(targetDocument, hash) {
10431 if (!targetDocument.head) {
10432 return false;
10433 }
10434 for (const style of targetDocument.head.querySelectorAll(
10435 `style[${STYLE_HASH_ATTRIBUTE5}]`
10436 )) {
10437 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10438 return true;
10439 }
10440 }
10441 return false;
10442 }
10443 function injectStyle5(targetDocument, hash, css) {
10444 if (!targetDocument.head) {
10445 return;
10446 }
10447 const runtime = getRuntime5();
10448 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10449 if (!injectedStyles) {
10450 injectedStyles = /* @__PURE__ */ new Set();
10451 runtime.injectedStyles.set(targetDocument, injectedStyles);
10452 }
10453 if (injectedStyles.has(hash)) {
10454 return;
10455 }
10456 if (documentContainsStyleHash5(targetDocument, hash)) {
10457 injectedStyles.add(hash);
10458 return;
10459 }
10460 const style = targetDocument.createElement("style");
10461 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10462 style.appendChild(targetDocument.createTextNode(css));
10463 targetDocument.head.appendChild(style);
10464 injectedStyles.add(hash);
10465 }
10466 function registerDocument5(targetDocument) {
10467 const runtime = getRuntime5();
10468 runtime.documents.set(
10469 targetDocument,
10470 (runtime.documents.get(targetDocument) ?? 0) + 1
10471 );
10472 for (const [hash, css] of runtime.styles) {
10473 injectStyle5(targetDocument, hash, css);
10474 }
10475 return () => {
10476 const count = runtime.documents.get(targetDocument);
10477 if (count === void 0) {
10478 return;
10479 }
10480 if (count <= 1) {
10481 runtime.documents.delete(targetDocument);
10482 return;
10483 }
10484 runtime.documents.set(targetDocument, count - 1);
10485 };
10486 }
10487 function registerStyle5(hash, css) {
10488 const runtime = getRuntime5();
10489 runtime.styles.set(hash, css);
10490 for (const targetDocument of runtime.documents.keys()) {
10491 injectStyle5(targetDocument, hash, css);
10492 }
10493 }
10494 if (typeof process === "undefined" || true) {
10495 registerStyle5("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10496 }
10497 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10498 var Content = (0, import_element15.forwardRef)(
10499 function CardContent({ render: render4, ...props }, ref) {
10500 const element = useRender({
10501 defaultTagName: "div",
10502 render: render4,
10503 ref,
10504 props: mergeProps({ className: style_default5.content }, props)
10505 });
10506 return element;
10507 }
10508 );
10509
10510 // packages/ui/build-module/card/full-bleed.mjs
10511 var import_element16 = __toESM(require_element(), 1);
10512 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10513 function getRuntime6() {
10514 const globalScope = globalThis;
10515 if (globalScope.__wpStyleRuntime) {
10516 return globalScope.__wpStyleRuntime;
10517 }
10518 globalScope.__wpStyleRuntime = {
10519 documents: /* @__PURE__ */ new Map(),
10520 styles: /* @__PURE__ */ new Map(),
10521 injectedStyles: /* @__PURE__ */ new WeakMap()
10522 };
10523 if (typeof document !== "undefined") {
10524 registerDocument6(document);
10525 }
10526 return globalScope.__wpStyleRuntime;
10527 }
10528 function documentContainsStyleHash6(targetDocument, hash) {
10529 if (!targetDocument.head) {
10530 return false;
10531 }
10532 for (const style of targetDocument.head.querySelectorAll(
10533 `style[${STYLE_HASH_ATTRIBUTE6}]`
10534 )) {
10535 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10536 return true;
10537 }
10538 }
10539 return false;
10540 }
10541 function injectStyle6(targetDocument, hash, css) {
10542 if (!targetDocument.head) {
10543 return;
10544 }
10545 const runtime = getRuntime6();
10546 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10547 if (!injectedStyles) {
10548 injectedStyles = /* @__PURE__ */ new Set();
10549 runtime.injectedStyles.set(targetDocument, injectedStyles);
10550 }
10551 if (injectedStyles.has(hash)) {
10552 return;
10553 }
10554 if (documentContainsStyleHash6(targetDocument, hash)) {
10555 injectedStyles.add(hash);
10556 return;
10557 }
10558 const style = targetDocument.createElement("style");
10559 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10560 style.appendChild(targetDocument.createTextNode(css));
10561 targetDocument.head.appendChild(style);
10562 injectedStyles.add(hash);
10563 }
10564 function registerDocument6(targetDocument) {
10565 const runtime = getRuntime6();
10566 runtime.documents.set(
10567 targetDocument,
10568 (runtime.documents.get(targetDocument) ?? 0) + 1
10569 );
10570 for (const [hash, css] of runtime.styles) {
10571 injectStyle6(targetDocument, hash, css);
10572 }
10573 return () => {
10574 const count = runtime.documents.get(targetDocument);
10575 if (count === void 0) {
10576 return;
10577 }
10578 if (count <= 1) {
10579 runtime.documents.delete(targetDocument);
10580 return;
10581 }
10582 runtime.documents.set(targetDocument, count - 1);
10583 };
10584 }
10585 function registerStyle6(hash, css) {
10586 const runtime = getRuntime6();
10587 runtime.styles.set(hash, css);
10588 for (const targetDocument of runtime.documents.keys()) {
10589 injectStyle6(targetDocument, hash, css);
10590 }
10591 }
10592 if (typeof process === "undefined" || true) {
10593 registerStyle6("5d38cbdd27", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}._02872bf298eadc43__root>:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):first-child>.c1fa192587e1b4a6__fullbleed:first-child{margin-block-start:calc(var(--wp-ui-card-padding)*-1)}:is(.bbccc92e6ba5662d__header,._5dffdaf2a6e669ac__content):last-child>.c1fa192587e1b4a6__fullbleed:last-child{margin-block-end:calc(var(--wp-ui-card-padding)*-1)}}}");
10594 }
10595 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10596 var FullBleed = (0, import_element16.forwardRef)(
10597 function CardFullBleed({ render: render4, ...props }, ref) {
10598 const element = useRender({
10599 defaultTagName: "div",
10600 render: render4,
10601 ref,
10602 props: mergeProps(
10603 { className: style_default6.fullbleed },
10604 props
10605 )
10606 });
10607 return element;
10608 }
10609 );
10610
10611 // packages/ui/build-module/card/title.mjs
10612 var import_element17 = __toESM(require_element(), 1);
10613 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10614 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {});
10615 var Title = (0, import_element17.forwardRef)(
10616 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
10617 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10618 Text,
10619 {
10620 ref,
10621 variant: "heading-lg",
10622 render: render4,
10623 ...props,
10624 children
10625 }
10626 );
10627 }
10628 );
10629
10630 // packages/ui/build-module/collapsible/panel.mjs
10631 var import_element18 = __toESM(require_element(), 1);
10632 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
10633 var Panel = (0, import_element18.forwardRef)(
10634 function CollapsiblePanel3(props, forwardedRef) {
10635 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
10636 }
10637 );
10638
10639 // packages/ui/build-module/collapsible/root.mjs
10640 var import_element19 = __toESM(require_element(), 1);
10641 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
10642 var Root2 = (0, import_element19.forwardRef)(
10643 function CollapsibleRoot3(props, forwardedRef) {
10644 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
10645 }
10646 );
10647
10648 // packages/ui/build-module/collapsible/trigger.mjs
10649 var import_element20 = __toESM(require_element(), 1);
10650 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
10651 var Trigger = (0, import_element20.forwardRef)(
10652 function CollapsibleTrigger3(props, forwardedRef) {
10653 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
10654 }
10655 );
10656
10657 // packages/ui/build-module/collapsible-card/index.mjs
10658 var collapsible_card_exports = {};
10659 __export(collapsible_card_exports, {
10660 Content: () => Content2,
10661 Header: () => Header2,
10662 HeaderDescription: () => HeaderDescription,
10663 Root: () => Root3
10664 });
10665
10666 // packages/ui/build-module/collapsible-card/root.mjs
10667 var import_element21 = __toESM(require_element(), 1);
10668 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
10669 var Root3 = (0, import_element21.forwardRef)(
10670 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
10671 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
10672 Root2,
10673 {
10674 ref,
10675 render: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Root, { render: render4 }),
10676 ...restProps
10677 }
10678 );
10679 }
10680 );
10681
10682 // packages/ui/build-module/collapsible-card/header.mjs
10683 var import_element23 = __toESM(require_element(), 1);
10684
10685 // packages/icons/build-module/library/arrow-down.mjs
10686 var import_primitives2 = __toESM(require_primitives(), 1);
10687 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
10688 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
10689
10690 // packages/icons/build-module/library/arrow-left.mjs
10691 var import_primitives3 = __toESM(require_primitives(), 1);
10692 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
10693 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
10694
10695 // packages/icons/build-module/library/arrow-right.mjs
10696 var import_primitives4 = __toESM(require_primitives(), 1);
10697 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
10698 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
10699
10700 // packages/icons/build-module/library/arrow-up.mjs
10701 var import_primitives5 = __toESM(require_primitives(), 1);
10702 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
10703 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
10704
10705 // packages/icons/build-module/library/block-default.mjs
10706 var import_primitives6 = __toESM(require_primitives(), 1);
10707 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
10708 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives6.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
10709
10710 // packages/icons/build-module/library/block-table.mjs
10711 var import_primitives7 = __toESM(require_primitives(), 1);
10712 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
10713 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives7.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" }) });
10714
10715 // packages/icons/build-module/library/category.mjs
10716 var import_primitives8 = __toESM(require_primitives(), 1);
10717 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
10718 var category_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives8.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" }) });
10719
10720 // packages/icons/build-module/library/check.mjs
10721 var import_primitives9 = __toESM(require_primitives(), 1);
10722 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
10723 var check_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
10724
10725 // packages/icons/build-module/library/chevron-down.mjs
10726 var import_primitives10 = __toESM(require_primitives(), 1);
10727 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
10728 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
10729
10730 // packages/icons/build-module/library/close-small.mjs
10731 var import_primitives11 = __toESM(require_primitives(), 1);
10732 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
10733 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives11.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" }) });
10734
10735 // packages/icons/build-module/library/cog.mjs
10736 var import_primitives12 = __toESM(require_primitives(), 1);
10737 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
10738 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives12.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" }) });
10739
10740 // packages/icons/build-module/library/envelope.mjs
10741 var import_primitives13 = __toESM(require_primitives(), 1);
10742 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
10743 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.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" }) });
10744
10745 // packages/icons/build-module/library/error.mjs
10746 var import_primitives14 = __toESM(require_primitives(), 1);
10747 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
10748 var error_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.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" }) });
10749
10750 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
10751 var import_primitives15 = __toESM(require_primitives(), 1);
10752 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
10753 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives15.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" }) });
10754
10755 // packages/icons/build-module/library/format-list-bullets.mjs
10756 var import_primitives16 = __toESM(require_primitives(), 1);
10757 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10758 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives16.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" }) });
10759
10760 // packages/icons/build-module/library/funnel.mjs
10761 var import_primitives17 = __toESM(require_primitives(), 1);
10762 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10763 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives17.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
10764
10765 // packages/icons/build-module/library/link.mjs
10766 var import_primitives18 = __toESM(require_primitives(), 1);
10767 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
10768 var link_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives18.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" }) });
10769
10770 // packages/icons/build-module/library/mobile.mjs
10771 var import_primitives19 = __toESM(require_primitives(), 1);
10772 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
10773 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives19.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" }) });
10774
10775 // packages/icons/build-module/library/more-vertical.mjs
10776 var import_primitives20 = __toESM(require_primitives(), 1);
10777 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10778 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives20.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
10779
10780 // packages/icons/build-module/library/next.mjs
10781 var import_primitives21 = __toESM(require_primitives(), 1);
10782 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10783 var next_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives21.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" }) });
10784
10785 // packages/icons/build-module/library/pencil.mjs
10786 var import_primitives22 = __toESM(require_primitives(), 1);
10787 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10788 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives22.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
10789
10790 // packages/icons/build-module/library/previous.mjs
10791 var import_primitives23 = __toESM(require_primitives(), 1);
10792 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10793 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives23.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" }) });
10794
10795 // packages/icons/build-module/library/scheduled.mjs
10796 var import_primitives24 = __toESM(require_primitives(), 1);
10797 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10798 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives24.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" }) });
10799
10800 // packages/icons/build-module/library/search.mjs
10801 var import_primitives25 = __toESM(require_primitives(), 1);
10802 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10803 var search_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives25.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" }) });
10804
10805 // packages/icons/build-module/library/seen.mjs
10806 var import_primitives26 = __toESM(require_primitives(), 1);
10807 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10808 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives26.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" }) });
10809
10810 // packages/icons/build-module/library/unseen.mjs
10811 var import_primitives27 = __toESM(require_primitives(), 1);
10812 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10813 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives27.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" }) });
10814
10815 // packages/ui/build-module/collapsible-card/context.mjs
10816 var import_element22 = __toESM(require_element(), 1);
10817 var HeaderDescriptionIdContext = (0, import_element22.createContext)({
10818 setDescriptionId: () => {
10819 }
10820 });
10821
10822 // packages/ui/build-module/collapsible-card/header.mjs
10823 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10824 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
10825 function getRuntime7() {
10826 const globalScope = globalThis;
10827 if (globalScope.__wpStyleRuntime) {
10828 return globalScope.__wpStyleRuntime;
10829 }
10830 globalScope.__wpStyleRuntime = {
10831 documents: /* @__PURE__ */ new Map(),
10832 styles: /* @__PURE__ */ new Map(),
10833 injectedStyles: /* @__PURE__ */ new WeakMap()
10834 };
10835 if (typeof document !== "undefined") {
10836 registerDocument7(document);
10837 }
10838 return globalScope.__wpStyleRuntime;
10839 }
10840 function documentContainsStyleHash7(targetDocument, hash) {
10841 if (!targetDocument.head) {
10842 return false;
10843 }
10844 for (const style of targetDocument.head.querySelectorAll(
10845 `style[${STYLE_HASH_ATTRIBUTE7}]`
10846 )) {
10847 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
10848 return true;
10849 }
10850 }
10851 return false;
10852 }
10853 function injectStyle7(targetDocument, hash, css) {
10854 if (!targetDocument.head) {
10855 return;
10856 }
10857 const runtime = getRuntime7();
10858 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10859 if (!injectedStyles) {
10860 injectedStyles = /* @__PURE__ */ new Set();
10861 runtime.injectedStyles.set(targetDocument, injectedStyles);
10862 }
10863 if (injectedStyles.has(hash)) {
10864 return;
10865 }
10866 if (documentContainsStyleHash7(targetDocument, hash)) {
10867 injectedStyles.add(hash);
10868 return;
10869 }
10870 const style = targetDocument.createElement("style");
10871 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
10872 style.appendChild(targetDocument.createTextNode(css));
10873 targetDocument.head.appendChild(style);
10874 injectedStyles.add(hash);
10875 }
10876 function registerDocument7(targetDocument) {
10877 const runtime = getRuntime7();
10878 runtime.documents.set(
10879 targetDocument,
10880 (runtime.documents.get(targetDocument) ?? 0) + 1
10881 );
10882 for (const [hash, css] of runtime.styles) {
10883 injectStyle7(targetDocument, hash, css);
10884 }
10885 return () => {
10886 const count = runtime.documents.get(targetDocument);
10887 if (count === void 0) {
10888 return;
10889 }
10890 if (count <= 1) {
10891 runtime.documents.delete(targetDocument);
10892 return;
10893 }
10894 runtime.documents.set(targetDocument, count - 1);
10895 };
10896 }
10897 function registerStyle7(hash, css) {
10898 const runtime = getRuntime7();
10899 runtime.styles.set(hash, css);
10900 for (const targetDocument of runtime.documents.keys()) {
10901 injectStyle7(targetDocument, hash, css);
10902 }
10903 }
10904 if (typeof process === "undefined" || true) {
10905 registerStyle7("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
10906 }
10907 var style_default7 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
10908 if (typeof process === "undefined" || true) {
10909 registerStyle7("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)}");
10910 }
10911 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
10912 if (typeof process === "undefined" || true) {
10913 registerStyle7("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))}}}");
10914 }
10915 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" };
10916 var Header2 = (0, import_element23.forwardRef)(
10917 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
10918 const [descriptionId, setDescriptionId] = (0, import_element23.useState)();
10919 const contextValue = (0, import_element23.useMemo)(
10920 () => ({ setDescriptionId }),
10921 [setDescriptionId]
10922 );
10923 return useRender({
10924 defaultTagName: "div",
10925 render: render4,
10926 ref,
10927 props: mergeProps(restProps, {
10928 className: clsx_default(
10929 global_css_defense_default2.heading,
10930 style_default7["heading-wrapper"],
10931 className
10932 ),
10933 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
10934 Trigger,
10935 {
10936 className: style_default7.header,
10937 render: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Header, {}),
10938 nativeButton: false,
10939 "aria-describedby": descriptionId,
10940 children: [
10941 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: style_default7["header-content"], children }),
10942 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10943 "div",
10944 {
10945 className: clsx_default(
10946 style_default7["header-trigger-positioner"]
10947 ),
10948 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10949 "div",
10950 {
10951 className: clsx_default(
10952 style_default7["header-trigger-wrapper"],
10953 global_css_defense_default2.div,
10954 // While the interactive trigger element is the whole header,
10955 // the focus ring will be displayed only on the icon to visually
10956 // emulate it being the button.
10957 focus_default["outset-ring--focus-parent-visible"]
10958 ),
10959 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10960 Icon,
10961 {
10962 icon: chevron_down_default,
10963 className: style_default7["header-trigger"]
10964 }
10965 )
10966 }
10967 )
10968 }
10969 )
10970 ]
10971 }
10972 ) })
10973 })
10974 });
10975 }
10976 );
10977
10978 // packages/ui/build-module/collapsible-card/header-description.mjs
10979 var import_element24 = __toESM(require_element(), 1);
10980 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10981 var HeaderDescription = (0, import_element24.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
10982 const descriptionId = (0, import_element24.useId)();
10983 const { setDescriptionId } = (0, import_element24.useContext)(HeaderDescriptionIdContext);
10984 (0, import_element24.useEffect)(() => {
10985 setDescriptionId(descriptionId);
10986 return () => setDescriptionId(void 0);
10987 }, [descriptionId, setDescriptionId]);
10988 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10989 "div",
10990 {
10991 ref,
10992 id: descriptionId,
10993 "aria-hidden": "true",
10994 className,
10995 ...restProps,
10996 children
10997 }
10998 );
10999 });
11000
11001 // packages/ui/build-module/collapsible-card/content.mjs
11002 var import_element25 = __toESM(require_element(), 1);
11003 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11004 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
11005 function getRuntime8() {
11006 const globalScope = globalThis;
11007 if (globalScope.__wpStyleRuntime) {
11008 return globalScope.__wpStyleRuntime;
11009 }
11010 globalScope.__wpStyleRuntime = {
11011 documents: /* @__PURE__ */ new Map(),
11012 styles: /* @__PURE__ */ new Map(),
11013 injectedStyles: /* @__PURE__ */ new WeakMap()
11014 };
11015 if (typeof document !== "undefined") {
11016 registerDocument8(document);
11017 }
11018 return globalScope.__wpStyleRuntime;
11019 }
11020 function documentContainsStyleHash8(targetDocument, hash) {
11021 if (!targetDocument.head) {
11022 return false;
11023 }
11024 for (const style of targetDocument.head.querySelectorAll(
11025 `style[${STYLE_HASH_ATTRIBUTE8}]`
11026 )) {
11027 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
11028 return true;
11029 }
11030 }
11031 return false;
11032 }
11033 function injectStyle8(targetDocument, hash, css) {
11034 if (!targetDocument.head) {
11035 return;
11036 }
11037 const runtime = getRuntime8();
11038 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11039 if (!injectedStyles) {
11040 injectedStyles = /* @__PURE__ */ new Set();
11041 runtime.injectedStyles.set(targetDocument, injectedStyles);
11042 }
11043 if (injectedStyles.has(hash)) {
11044 return;
11045 }
11046 if (documentContainsStyleHash8(targetDocument, hash)) {
11047 injectedStyles.add(hash);
11048 return;
11049 }
11050 const style = targetDocument.createElement("style");
11051 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
11052 style.appendChild(targetDocument.createTextNode(css));
11053 targetDocument.head.appendChild(style);
11054 injectedStyles.add(hash);
11055 }
11056 function registerDocument8(targetDocument) {
11057 const runtime = getRuntime8();
11058 runtime.documents.set(
11059 targetDocument,
11060 (runtime.documents.get(targetDocument) ?? 0) + 1
11061 );
11062 for (const [hash, css] of runtime.styles) {
11063 injectStyle8(targetDocument, hash, css);
11064 }
11065 return () => {
11066 const count = runtime.documents.get(targetDocument);
11067 if (count === void 0) {
11068 return;
11069 }
11070 if (count <= 1) {
11071 runtime.documents.delete(targetDocument);
11072 return;
11073 }
11074 runtime.documents.set(targetDocument, count - 1);
11075 };
11076 }
11077 function registerStyle8(hash, css) {
11078 const runtime = getRuntime8();
11079 runtime.styles.set(hash, css);
11080 for (const targetDocument of runtime.documents.keys()) {
11081 injectStyle8(targetDocument, hash, css);
11082 }
11083 }
11084 if (typeof process === "undefined" || true) {
11085 registerStyle8("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
11086 }
11087 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11088 var Content2 = (0, import_element25.forwardRef)(
11089 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
11090 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11091 Panel,
11092 {
11093 ref,
11094 className: (state) => clsx_default(
11095 style_default8.content,
11096 state.open && state.transitionStatus === "idle" && style_default8["overflow-visible"],
11097 className
11098 ),
11099 hiddenUntilFound,
11100 ...restProps,
11101 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11102 Content,
11103 {
11104 className: style_default8["content-inner"],
11105 render: render4,
11106 children
11107 }
11108 )
11109 }
11110 );
11111 }
11112 );
11113
11114 // packages/ui/build-module/utils/render-slot-with-children.mjs
11115 var import_element26 = __toESM(require_element(), 1);
11116 function renderSlotWithChildren(slot, defaultSlot, children) {
11117 return (0, import_element26.cloneElement)(slot ?? defaultSlot, { children });
11118 }
11119
11120 // packages/ui/build-module/utils/theme-provider.mjs
11121 var theme = __toESM(require_theme(), 1);
11122
11123 // packages/ui/build-module/lock-unlock.mjs
11124 var import_private_apis = __toESM(require_private_apis(), 1);
11125 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
11126 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
11127 "@wordpress/ui"
11128 );
11129
11130 // packages/ui/build-module/utils/theme-provider.mjs
11131 function getThemeProvider() {
11132 const themePackage = theme;
11133 if (themePackage.ThemeProvider) {
11134 return themePackage.ThemeProvider;
11135 }
11136 if (!themePackage.privateApis) {
11137 throw new Error(
11138 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
11139 );
11140 }
11141 return unlock(
11142 themePackage.privateApis
11143 ).ThemeProvider;
11144 }
11145 var ThemeProvider = getThemeProvider();
11146
11147 // packages/ui/build-module/stack/stack.mjs
11148 var import_element27 = __toESM(require_element(), 1);
11149 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
11150 function getRuntime9() {
11151 const globalScope = globalThis;
11152 if (globalScope.__wpStyleRuntime) {
11153 return globalScope.__wpStyleRuntime;
11154 }
11155 globalScope.__wpStyleRuntime = {
11156 documents: /* @__PURE__ */ new Map(),
11157 styles: /* @__PURE__ */ new Map(),
11158 injectedStyles: /* @__PURE__ */ new WeakMap()
11159 };
11160 if (typeof document !== "undefined") {
11161 registerDocument9(document);
11162 }
11163 return globalScope.__wpStyleRuntime;
11164 }
11165 function documentContainsStyleHash9(targetDocument, hash) {
11166 if (!targetDocument.head) {
11167 return false;
11168 }
11169 for (const style of targetDocument.head.querySelectorAll(
11170 `style[${STYLE_HASH_ATTRIBUTE9}]`
11171 )) {
11172 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
11173 return true;
11174 }
11175 }
11176 return false;
11177 }
11178 function injectStyle9(targetDocument, hash, css) {
11179 if (!targetDocument.head) {
11180 return;
11181 }
11182 const runtime = getRuntime9();
11183 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11184 if (!injectedStyles) {
11185 injectedStyles = /* @__PURE__ */ new Set();
11186 runtime.injectedStyles.set(targetDocument, injectedStyles);
11187 }
11188 if (injectedStyles.has(hash)) {
11189 return;
11190 }
11191 if (documentContainsStyleHash9(targetDocument, hash)) {
11192 injectedStyles.add(hash);
11193 return;
11194 }
11195 const style = targetDocument.createElement("style");
11196 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
11197 style.appendChild(targetDocument.createTextNode(css));
11198 targetDocument.head.appendChild(style);
11199 injectedStyles.add(hash);
11200 }
11201 function registerDocument9(targetDocument) {
11202 const runtime = getRuntime9();
11203 runtime.documents.set(
11204 targetDocument,
11205 (runtime.documents.get(targetDocument) ?? 0) + 1
11206 );
11207 for (const [hash, css] of runtime.styles) {
11208 injectStyle9(targetDocument, hash, css);
11209 }
11210 return () => {
11211 const count = runtime.documents.get(targetDocument);
11212 if (count === void 0) {
11213 return;
11214 }
11215 if (count <= 1) {
11216 runtime.documents.delete(targetDocument);
11217 return;
11218 }
11219 runtime.documents.set(targetDocument, count - 1);
11220 };
11221 }
11222 function registerStyle9(hash, css) {
11223 const runtime = getRuntime9();
11224 runtime.styles.set(hash, css);
11225 for (const targetDocument of runtime.documents.keys()) {
11226 injectStyle9(targetDocument, hash, css);
11227 }
11228 }
11229 if (typeof process === "undefined" || true) {
11230 registerStyle9("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
11231 }
11232 var style_default9 = { "stack": "_19ce0419607e1896__stack" };
11233 var gapTokens = {
11234 xs: "var(--wpds-dimension-gap-xs, 4px)",
11235 sm: "var(--wpds-dimension-gap-sm, 8px)",
11236 md: "var(--wpds-dimension-gap-md, 12px)",
11237 lg: "var(--wpds-dimension-gap-lg, 16px)",
11238 xl: "var(--wpds-dimension-gap-xl, 24px)",
11239 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
11240 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
11241 };
11242 var Stack = (0, import_element27.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
11243 const style = {
11244 gap: gap && gapTokens[gap],
11245 alignItems: align,
11246 justifyContent: justify,
11247 flexDirection: direction,
11248 flexWrap: wrap
11249 };
11250 const element = useRender({
11251 render: render4,
11252 ref,
11253 props: mergeProps(props, { style, className: style_default9.stack })
11254 });
11255 return element;
11256 });
11257
11258 // packages/ui/build-module/tooltip/index.mjs
11259 var tooltip_exports = {};
11260 __export(tooltip_exports, {
11261 Popup: () => Popup,
11262 Portal: () => Portal,
11263 Positioner: () => Positioner,
11264 Provider: () => Provider,
11265 Root: () => Root4,
11266 Trigger: () => Trigger2
11267 });
11268
11269 // packages/ui/build-module/tooltip/popup.mjs
11270 var import_element30 = __toESM(require_element(), 1);
11271
11272 // packages/ui/build-module/tooltip/portal.mjs
11273 var import_element28 = __toESM(require_element(), 1);
11274
11275 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
11276 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
11277 function getRuntime10() {
11278 const globalScope = globalThis;
11279 if (globalScope.__wpStyleRuntime) {
11280 return globalScope.__wpStyleRuntime;
11281 }
11282 globalScope.__wpStyleRuntime = {
11283 documents: /* @__PURE__ */ new Map(),
11284 styles: /* @__PURE__ */ new Map(),
11285 injectedStyles: /* @__PURE__ */ new WeakMap()
11286 };
11287 if (typeof document !== "undefined") {
11288 registerDocument10(document);
11289 }
11290 return globalScope.__wpStyleRuntime;
11291 }
11292 function documentContainsStyleHash10(targetDocument, hash) {
11293 if (!targetDocument.head) {
11294 return false;
11295 }
11296 for (const style of targetDocument.head.querySelectorAll(
11297 `style[${STYLE_HASH_ATTRIBUTE10}]`
11298 )) {
11299 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
11300 return true;
11301 }
11302 }
11303 return false;
11304 }
11305 function injectStyle10(targetDocument, hash, css) {
11306 if (!targetDocument.head) {
11307 return;
11308 }
11309 const runtime = getRuntime10();
11310 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11311 if (!injectedStyles) {
11312 injectedStyles = /* @__PURE__ */ new Set();
11313 runtime.injectedStyles.set(targetDocument, injectedStyles);
11314 }
11315 if (injectedStyles.has(hash)) {
11316 return;
11317 }
11318 if (documentContainsStyleHash10(targetDocument, hash)) {
11319 injectedStyles.add(hash);
11320 return;
11321 }
11322 const style = targetDocument.createElement("style");
11323 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
11324 style.appendChild(targetDocument.createTextNode(css));
11325 targetDocument.head.appendChild(style);
11326 injectedStyles.add(hash);
11327 }
11328 function registerDocument10(targetDocument) {
11329 const runtime = getRuntime10();
11330 runtime.documents.set(
11331 targetDocument,
11332 (runtime.documents.get(targetDocument) ?? 0) + 1
11333 );
11334 for (const [hash, css] of runtime.styles) {
11335 injectStyle10(targetDocument, hash, css);
11336 }
11337 return () => {
11338 const count = runtime.documents.get(targetDocument);
11339 if (count === void 0) {
11340 return;
11341 }
11342 if (count <= 1) {
11343 runtime.documents.delete(targetDocument);
11344 return;
11345 }
11346 runtime.documents.set(targetDocument, count - 1);
11347 };
11348 }
11349 function registerStyle10(hash, css) {
11350 const runtime = getRuntime10();
11351 runtime.styles.set(hash, css);
11352 for (const targetDocument of runtime.documents.keys()) {
11353 injectStyle10(targetDocument, hash, css);
11354 }
11355 }
11356 if (typeof process === "undefined" || true) {
11357 registerStyle10("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}}}");
11358 }
11359 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
11360 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
11361 function resolveOwnerDocument() {
11362 return typeof document === "undefined" ? null : document;
11363 }
11364 function isInWordPressEnvironment() {
11365 let topWp;
11366 try {
11367 topWp = window.top?.wp;
11368 } catch {
11369 }
11370 const wp = topWp ?? window.wp;
11371 return typeof wp?.components === "object" && wp.components !== null;
11372 }
11373 var cachedSlot = null;
11374 function ensureSlotIsAccessible(element) {
11375 element.setAttribute("aria-hidden", "false");
11376 return element;
11377 }
11378 function createSlot(ownerDocument2) {
11379 const element = ownerDocument2.createElement("div");
11380 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
11381 if (wp_compat_overlay_slot_default.slot) {
11382 element.classList.add(wp_compat_overlay_slot_default.slot);
11383 }
11384 ownerDocument2.body.appendChild(element);
11385 return element;
11386 }
11387 function getWpCompatOverlaySlot() {
11388 if (typeof window === "undefined") {
11389 return void 0;
11390 }
11391 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
11392 return void 0;
11393 }
11394 const ownerDocument2 = resolveOwnerDocument();
11395 if (!ownerDocument2 || !ownerDocument2.body) {
11396 return void 0;
11397 }
11398 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
11399 return ensureSlotIsAccessible(cachedSlot);
11400 }
11401 const existing = ownerDocument2.querySelector(
11402 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
11403 );
11404 if (existing instanceof HTMLDivElement) {
11405 cachedSlot = ensureSlotIsAccessible(existing);
11406 return cachedSlot;
11407 }
11408 if (cachedSlot?.isConnected) {
11409 cachedSlot.remove();
11410 }
11411 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
11412 return cachedSlot;
11413 }
11414
11415 // packages/ui/build-module/tooltip/portal.mjs
11416 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11417 var Portal = (0, import_element28.forwardRef)(
11418 function TooltipPortal3({ container, ...restProps }, ref) {
11419 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
11420 index_parts_exports2.Portal,
11421 {
11422 container: container ?? getWpCompatOverlaySlot(),
11423 ...restProps,
11424 ref
11425 }
11426 );
11427 }
11428 );
11429
11430 // packages/ui/build-module/tooltip/positioner.mjs
11431 var import_element29 = __toESM(require_element(), 1);
11432 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11433 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
11434 function getRuntime11() {
11435 const globalScope = globalThis;
11436 if (globalScope.__wpStyleRuntime) {
11437 return globalScope.__wpStyleRuntime;
11438 }
11439 globalScope.__wpStyleRuntime = {
11440 documents: /* @__PURE__ */ new Map(),
11441 styles: /* @__PURE__ */ new Map(),
11442 injectedStyles: /* @__PURE__ */ new WeakMap()
11443 };
11444 if (typeof document !== "undefined") {
11445 registerDocument11(document);
11446 }
11447 return globalScope.__wpStyleRuntime;
11448 }
11449 function documentContainsStyleHash11(targetDocument, hash) {
11450 if (!targetDocument.head) {
11451 return false;
11452 }
11453 for (const style of targetDocument.head.querySelectorAll(
11454 `style[${STYLE_HASH_ATTRIBUTE11}]`
11455 )) {
11456 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
11457 return true;
11458 }
11459 }
11460 return false;
11461 }
11462 function injectStyle11(targetDocument, hash, css) {
11463 if (!targetDocument.head) {
11464 return;
11465 }
11466 const runtime = getRuntime11();
11467 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11468 if (!injectedStyles) {
11469 injectedStyles = /* @__PURE__ */ new Set();
11470 runtime.injectedStyles.set(targetDocument, injectedStyles);
11471 }
11472 if (injectedStyles.has(hash)) {
11473 return;
11474 }
11475 if (documentContainsStyleHash11(targetDocument, hash)) {
11476 injectedStyles.add(hash);
11477 return;
11478 }
11479 const style = targetDocument.createElement("style");
11480 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
11481 style.appendChild(targetDocument.createTextNode(css));
11482 targetDocument.head.appendChild(style);
11483 injectedStyles.add(hash);
11484 }
11485 function registerDocument11(targetDocument) {
11486 const runtime = getRuntime11();
11487 runtime.documents.set(
11488 targetDocument,
11489 (runtime.documents.get(targetDocument) ?? 0) + 1
11490 );
11491 for (const [hash, css] of runtime.styles) {
11492 injectStyle11(targetDocument, hash, css);
11493 }
11494 return () => {
11495 const count = runtime.documents.get(targetDocument);
11496 if (count === void 0) {
11497 return;
11498 }
11499 if (count <= 1) {
11500 runtime.documents.delete(targetDocument);
11501 return;
11502 }
11503 runtime.documents.set(targetDocument, count - 1);
11504 };
11505 }
11506 function registerStyle11(hash, css) {
11507 const runtime = getRuntime11();
11508 runtime.styles.set(hash, css);
11509 for (const targetDocument of runtime.documents.keys()) {
11510 injectStyle11(targetDocument, hash, css);
11511 }
11512 }
11513 if (typeof process === "undefined" || true) {
11514 registerStyle11("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
11515 }
11516 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11517 if (typeof process === "undefined" || true) {
11518 registerStyle11("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}}}}');
11519 }
11520 var style_default10 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11521 var Positioner = (0, import_element29.forwardRef)(
11522 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
11523 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11524 index_parts_exports2.Positioner,
11525 {
11526 ref,
11527 align,
11528 side,
11529 sideOffset,
11530 ...props,
11531 className: clsx_default(
11532 resets_default2["box-sizing"],
11533 style_default10.positioner,
11534 className
11535 )
11536 }
11537 );
11538 }
11539 );
11540
11541 // packages/ui/build-module/tooltip/popup.mjs
11542 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11543 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
11544 function getRuntime12() {
11545 const globalScope = globalThis;
11546 if (globalScope.__wpStyleRuntime) {
11547 return globalScope.__wpStyleRuntime;
11548 }
11549 globalScope.__wpStyleRuntime = {
11550 documents: /* @__PURE__ */ new Map(),
11551 styles: /* @__PURE__ */ new Map(),
11552 injectedStyles: /* @__PURE__ */ new WeakMap()
11553 };
11554 if (typeof document !== "undefined") {
11555 registerDocument12(document);
11556 }
11557 return globalScope.__wpStyleRuntime;
11558 }
11559 function documentContainsStyleHash12(targetDocument, hash) {
11560 if (!targetDocument.head) {
11561 return false;
11562 }
11563 for (const style of targetDocument.head.querySelectorAll(
11564 `style[${STYLE_HASH_ATTRIBUTE12}]`
11565 )) {
11566 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
11567 return true;
11568 }
11569 }
11570 return false;
11571 }
11572 function injectStyle12(targetDocument, hash, css) {
11573 if (!targetDocument.head) {
11574 return;
11575 }
11576 const runtime = getRuntime12();
11577 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11578 if (!injectedStyles) {
11579 injectedStyles = /* @__PURE__ */ new Set();
11580 runtime.injectedStyles.set(targetDocument, injectedStyles);
11581 }
11582 if (injectedStyles.has(hash)) {
11583 return;
11584 }
11585 if (documentContainsStyleHash12(targetDocument, hash)) {
11586 injectedStyles.add(hash);
11587 return;
11588 }
11589 const style = targetDocument.createElement("style");
11590 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
11591 style.appendChild(targetDocument.createTextNode(css));
11592 targetDocument.head.appendChild(style);
11593 injectedStyles.add(hash);
11594 }
11595 function registerDocument12(targetDocument) {
11596 const runtime = getRuntime12();
11597 runtime.documents.set(
11598 targetDocument,
11599 (runtime.documents.get(targetDocument) ?? 0) + 1
11600 );
11601 for (const [hash, css] of runtime.styles) {
11602 injectStyle12(targetDocument, hash, css);
11603 }
11604 return () => {
11605 const count = runtime.documents.get(targetDocument);
11606 if (count === void 0) {
11607 return;
11608 }
11609 if (count <= 1) {
11610 runtime.documents.delete(targetDocument);
11611 return;
11612 }
11613 runtime.documents.set(targetDocument, count - 1);
11614 };
11615 }
11616 function registerStyle12(hash, css) {
11617 const runtime = getRuntime12();
11618 runtime.styles.set(hash, css);
11619 for (const targetDocument of runtime.documents.keys()) {
11620 injectStyle12(targetDocument, hash, css);
11621 }
11622 }
11623 if (typeof process === "undefined" || true) {
11624 registerStyle12("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}}}}');
11625 }
11626 var style_default11 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11627 var POPUP_COLOR = { background: "#1e1e1e" };
11628 var Popup = (0, import_element30.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
11629 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11630 index_parts_exports2.Popup,
11631 {
11632 ref,
11633 className: clsx_default(style_default11.popup, className),
11634 ...props,
11635 children
11636 }
11637 ) });
11638 const positionedPopup = renderSlotWithChildren(
11639 positioner,
11640 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Positioner, {}),
11641 popupContent
11642 );
11643 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Portal, {}), positionedPopup);
11644 });
11645
11646 // packages/ui/build-module/tooltip/trigger.mjs
11647 var import_element31 = __toESM(require_element(), 1);
11648 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11649 var Trigger2 = (0, import_element31.forwardRef)(
11650 function TooltipTrigger3(props, ref) {
11651 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(index_parts_exports2.Trigger, { ref, ...props });
11652 }
11653 );
11654
11655 // packages/ui/build-module/tooltip/root.mjs
11656 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11657 function Root4(props) {
11658 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(index_parts_exports2.Root, { ...props });
11659 }
11660
11661 // packages/ui/build-module/tooltip/provider.mjs
11662 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11663 function Provider({ ...props }) {
11664 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(index_parts_exports2.Provider, { ...props });
11665 }
11666
11667 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
11668 var import_element32 = __toESM(require_element(), 1);
11669 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
11670 function getRuntime13() {
11671 const globalScope = globalThis;
11672 if (globalScope.__wpStyleRuntime) {
11673 return globalScope.__wpStyleRuntime;
11674 }
11675 globalScope.__wpStyleRuntime = {
11676 documents: /* @__PURE__ */ new Map(),
11677 styles: /* @__PURE__ */ new Map(),
11678 injectedStyles: /* @__PURE__ */ new WeakMap()
11679 };
11680 if (typeof document !== "undefined") {
11681 registerDocument13(document);
11682 }
11683 return globalScope.__wpStyleRuntime;
11684 }
11685 function documentContainsStyleHash13(targetDocument, hash) {
11686 if (!targetDocument.head) {
11687 return false;
11688 }
11689 for (const style of targetDocument.head.querySelectorAll(
11690 `style[${STYLE_HASH_ATTRIBUTE13}]`
11691 )) {
11692 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
11693 return true;
11694 }
11695 }
11696 return false;
11697 }
11698 function injectStyle13(targetDocument, hash, css) {
11699 if (!targetDocument.head) {
11700 return;
11701 }
11702 const runtime = getRuntime13();
11703 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11704 if (!injectedStyles) {
11705 injectedStyles = /* @__PURE__ */ new Set();
11706 runtime.injectedStyles.set(targetDocument, injectedStyles);
11707 }
11708 if (injectedStyles.has(hash)) {
11709 return;
11710 }
11711 if (documentContainsStyleHash13(targetDocument, hash)) {
11712 injectedStyles.add(hash);
11713 return;
11714 }
11715 const style = targetDocument.createElement("style");
11716 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
11717 style.appendChild(targetDocument.createTextNode(css));
11718 targetDocument.head.appendChild(style);
11719 injectedStyles.add(hash);
11720 }
11721 function registerDocument13(targetDocument) {
11722 const runtime = getRuntime13();
11723 runtime.documents.set(
11724 targetDocument,
11725 (runtime.documents.get(targetDocument) ?? 0) + 1
11726 );
11727 for (const [hash, css] of runtime.styles) {
11728 injectStyle13(targetDocument, hash, css);
11729 }
11730 return () => {
11731 const count = runtime.documents.get(targetDocument);
11732 if (count === void 0) {
11733 return;
11734 }
11735 if (count <= 1) {
11736 runtime.documents.delete(targetDocument);
11737 return;
11738 }
11739 runtime.documents.set(targetDocument, count - 1);
11740 };
11741 }
11742 function registerStyle13(hash, css) {
11743 const runtime = getRuntime13();
11744 runtime.styles.set(hash, css);
11745 for (const targetDocument of runtime.documents.keys()) {
11746 injectStyle13(targetDocument, hash, css);
11747 }
11748 }
11749 if (typeof process === "undefined" || true) {
11750 registerStyle13("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}}}");
11751 }
11752 var style_default12 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
11753 var VisuallyHidden = (0, import_element32.forwardRef)(
11754 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
11755 const element = useRender({
11756 render: render4,
11757 ref,
11758 props: mergeProps(
11759 { className: style_default12["visually-hidden"] },
11760 restProps,
11761 {
11762 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
11763 "data-visually-hidden": ""
11764 }
11765 )
11766 });
11767 return element;
11768 }
11769 );
11770
11771 // packages/admin-ui/build-module/navigable-region/index.mjs
11772 var import_element33 = __toESM(require_element(), 1);
11773 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11774 var NavigableRegion = (0, import_element33.forwardRef)(
11775 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
11776 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11777 Tag,
11778 {
11779 ref,
11780 className: clsx_default("admin-ui-navigable-region", className),
11781 "aria-label": ariaLabel,
11782 role: "region",
11783 tabIndex: "-1",
11784 ...props,
11785 children
11786 }
11787 );
11788 }
11789 );
11790 NavigableRegion.displayName = "NavigableRegion";
11791 var navigable_region_default = NavigableRegion;
11792
11793 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
11794 var import_components = __toESM(require_components(), 1);
11795 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
11796
11797 // packages/admin-ui/build-module/page/header.mjs
11798 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11799 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
11800 function getRuntime14() {
11801 const globalScope = globalThis;
11802 if (globalScope.__wpStyleRuntime) {
11803 return globalScope.__wpStyleRuntime;
11804 }
11805 globalScope.__wpStyleRuntime = {
11806 documents: /* @__PURE__ */ new Map(),
11807 styles: /* @__PURE__ */ new Map(),
11808 injectedStyles: /* @__PURE__ */ new WeakMap()
11809 };
11810 if (typeof document !== "undefined") {
11811 registerDocument14(document);
11812 }
11813 return globalScope.__wpStyleRuntime;
11814 }
11815 function documentContainsStyleHash14(targetDocument, hash) {
11816 if (!targetDocument.head) {
11817 return false;
11818 }
11819 for (const style of targetDocument.head.querySelectorAll(
11820 `style[${STYLE_HASH_ATTRIBUTE14}]`
11821 )) {
11822 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
11823 return true;
11824 }
11825 }
11826 return false;
11827 }
11828 function injectStyle14(targetDocument, hash, css) {
11829 if (!targetDocument.head) {
11830 return;
11831 }
11832 const runtime = getRuntime14();
11833 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11834 if (!injectedStyles) {
11835 injectedStyles = /* @__PURE__ */ new Set();
11836 runtime.injectedStyles.set(targetDocument, injectedStyles);
11837 }
11838 if (injectedStyles.has(hash)) {
11839 return;
11840 }
11841 if (documentContainsStyleHash14(targetDocument, hash)) {
11842 injectedStyles.add(hash);
11843 return;
11844 }
11845 const style = targetDocument.createElement("style");
11846 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
11847 style.appendChild(targetDocument.createTextNode(css));
11848 targetDocument.head.appendChild(style);
11849 injectedStyles.add(hash);
11850 }
11851 function registerDocument14(targetDocument) {
11852 const runtime = getRuntime14();
11853 runtime.documents.set(
11854 targetDocument,
11855 (runtime.documents.get(targetDocument) ?? 0) + 1
11856 );
11857 for (const [hash, css] of runtime.styles) {
11858 injectStyle14(targetDocument, hash, css);
11859 }
11860 return () => {
11861 const count = runtime.documents.get(targetDocument);
11862 if (count === void 0) {
11863 return;
11864 }
11865 if (count <= 1) {
11866 runtime.documents.delete(targetDocument);
11867 return;
11868 }
11869 runtime.documents.set(targetDocument, count - 1);
11870 };
11871 }
11872 function registerStyle14(hash, css) {
11873 const runtime = getRuntime14();
11874 runtime.styles.set(hash, css);
11875 for (const targetDocument of runtime.documents.keys()) {
11876 injectStyle14(targetDocument, hash, css);
11877 }
11878 }
11879 if (typeof process === "undefined" || true) {
11880 registerStyle14("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
11881 }
11882 var style_default13 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
11883 function Header3({
11884 headingLevel = 1,
11885 breadcrumbs,
11886 badges,
11887 visual,
11888 title,
11889 subTitle,
11890 actions,
11891 showSidebarToggle = true
11892 }) {
11893 const HeadingTag = `h${headingLevel}`;
11894 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { direction: "column", className: style_default13.header, children: [
11895 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11896 Stack,
11897 {
11898 className: style_default13["header-content"],
11899 direction: "row",
11900 gap: "sm",
11901 justify: "space-between",
11902 children: [
11903 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
11904 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11905 SidebarToggleSlot,
11906 {
11907 bubblesVirtually: true,
11908 className: style_default13["sidebar-toggle-slot"]
11909 }
11910 ),
11911 visual && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11912 "div",
11913 {
11914 className: style_default13["header-visual"],
11915 "aria-hidden": "true",
11916 children: visual
11917 }
11918 ),
11919 title && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11920 Text,
11921 {
11922 className: style_default13["header-title"],
11923 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(HeadingTag, {}),
11924 variant: "heading-lg",
11925 children: title
11926 }
11927 ),
11928 breadcrumbs,
11929 badges
11930 ] }),
11931 actions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11932 Stack,
11933 {
11934 align: "center",
11935 className: style_default13["header-actions"],
11936 direction: "row",
11937 gap: "sm",
11938 children: actions
11939 }
11940 )
11941 ]
11942 }
11943 ),
11944 subTitle && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11945 Text,
11946 {
11947 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", {}),
11948 variant: "body-md",
11949 className: style_default13["header-subtitle"],
11950 children: subTitle
11951 }
11952 )
11953 ] });
11954 }
11955
11956 // packages/admin-ui/build-module/page/index.mjs
11957 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
11958 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
11959 function getRuntime15() {
11960 const globalScope = globalThis;
11961 if (globalScope.__wpStyleRuntime) {
11962 return globalScope.__wpStyleRuntime;
11963 }
11964 globalScope.__wpStyleRuntime = {
11965 documents: /* @__PURE__ */ new Map(),
11966 styles: /* @__PURE__ */ new Map(),
11967 injectedStyles: /* @__PURE__ */ new WeakMap()
11968 };
11969 if (typeof document !== "undefined") {
11970 registerDocument15(document);
11971 }
11972 return globalScope.__wpStyleRuntime;
11973 }
11974 function documentContainsStyleHash15(targetDocument, hash) {
11975 if (!targetDocument.head) {
11976 return false;
11977 }
11978 for (const style of targetDocument.head.querySelectorAll(
11979 `style[${STYLE_HASH_ATTRIBUTE15}]`
11980 )) {
11981 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
11982 return true;
11983 }
11984 }
11985 return false;
11986 }
11987 function injectStyle15(targetDocument, hash, css) {
11988 if (!targetDocument.head) {
11989 return;
11990 }
11991 const runtime = getRuntime15();
11992 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11993 if (!injectedStyles) {
11994 injectedStyles = /* @__PURE__ */ new Set();
11995 runtime.injectedStyles.set(targetDocument, injectedStyles);
11996 }
11997 if (injectedStyles.has(hash)) {
11998 return;
11999 }
12000 if (documentContainsStyleHash15(targetDocument, hash)) {
12001 injectedStyles.add(hash);
12002 return;
12003 }
12004 const style = targetDocument.createElement("style");
12005 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
12006 style.appendChild(targetDocument.createTextNode(css));
12007 targetDocument.head.appendChild(style);
12008 injectedStyles.add(hash);
12009 }
12010 function registerDocument15(targetDocument) {
12011 const runtime = getRuntime15();
12012 runtime.documents.set(
12013 targetDocument,
12014 (runtime.documents.get(targetDocument) ?? 0) + 1
12015 );
12016 for (const [hash, css] of runtime.styles) {
12017 injectStyle15(targetDocument, hash, css);
12018 }
12019 return () => {
12020 const count = runtime.documents.get(targetDocument);
12021 if (count === void 0) {
12022 return;
12023 }
12024 if (count <= 1) {
12025 runtime.documents.delete(targetDocument);
12026 return;
12027 }
12028 runtime.documents.set(targetDocument, count - 1);
12029 };
12030 }
12031 function registerStyle15(hash, css) {
12032 const runtime = getRuntime15();
12033 runtime.styles.set(hash, css);
12034 for (const targetDocument of runtime.documents.keys()) {
12035 injectStyle15(targetDocument, hash, css);
12036 }
12037 }
12038 if (typeof process === "undefined" || true) {
12039 registerStyle15("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
12040 }
12041 var style_default14 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
12042 function Page({
12043 headingLevel,
12044 breadcrumbs,
12045 badges,
12046 visual,
12047 title,
12048 subTitle,
12049 children,
12050 className,
12051 actions,
12052 ariaLabel,
12053 hasPadding = false,
12054 showSidebarToggle = true
12055 }) {
12056 const classes = clsx_default(style_default14.page, className);
12057 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
12058 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
12059 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12060 Header3,
12061 {
12062 headingLevel,
12063 breadcrumbs,
12064 badges,
12065 visual,
12066 title,
12067 subTitle,
12068 actions,
12069 showSidebarToggle
12070 }
12071 ),
12072 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12073 "div",
12074 {
12075 className: clsx_default(
12076 style_default14.content,
12077 style_default14["has-padding"]
12078 ),
12079 children
12080 }
12081 ) : children
12082 ] });
12083 }
12084 Page.SidebarToggleFill = SidebarToggleFill;
12085 var page_default = Page;
12086
12087 // routes/guidelines/stage.tsx
12088 var import_i18n55 = __toESM(require_i18n());
12089 var import_element111 = __toESM(require_element());
12090 var import_components60 = __toESM(require_components());
12091
12092 // routes/guidelines/style.scss
12093 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='67839b70f7']")) {
12094 const style = document.createElement("style");
12095 style.setAttribute("data-wp-hash", "67839b70f7");
12096 style.appendChild(document.createTextNode(".guidelines__content{border-radius:8px;margin-top:0;padding:24px}.guidelines__list{display:flex;flex-direction:column;gap:16px;list-style:none;margin:0;padding:0}.guidelines__list-item{margin:0 auto;width:min(680px,100%)}.guidelines__loading{align-items:center;display:flex;justify-content:center;margin-top:16px}.guidelines__revision-history{display:flex;flex-direction:column;gap:16px;padding:24px}.guidelines__revision-history .dataviews-wrapper{margin-inline:-24px}.guidelines__revision-history-back{align-self:flex-start;color:#1e1e1e;font-weight:var(--wpds-typography-font-weight-emphasis,600);margin-left:-16px}.guidelines__error-description{margin:8px 0 0}.guidelines__revision-description{padding-left:8px}.guidelines__restore-modal-actions{margin-top:24px}"));
12097 document.head.appendChild(style);
12098 }
12099
12100 // routes/guidelines/components/guideline-accordion.tsx
12101 var import_components2 = __toESM(require_components());
12102 function GuidelineAccordion({
12103 title,
12104 description,
12105 children
12106 }) {
12107 return /* @__PURE__ */ React.createElement(collapsible_card_exports.Root, null, /* @__PURE__ */ React.createElement(collapsible_card_exports.Header, { render: /* @__PURE__ */ React.createElement("h2", null) }, /* @__PURE__ */ React.createElement(import_components2.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(card_exports.Title, null, title), /* @__PURE__ */ React.createElement(collapsible_card_exports.HeaderDescription, null, /* @__PURE__ */ React.createElement(import_components2.__experimentalText, { variant: "muted" }, description)))), /* @__PURE__ */ React.createElement(collapsible_card_exports.Content, null, children));
12108 }
12109
12110 // routes/guidelines/components/guideline-accordion-form.tsx
12111 var import_components55 = __toESM(require_components());
12112
12113 // packages/dataviews/build-module/dataviews/index.mjs
12114 var import_element93 = __toESM(require_element(), 1);
12115 var import_compose14 = __toESM(require_compose(), 1);
12116
12117 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12118 var import_element34 = __toESM(require_element(), 1);
12119
12120 // packages/dataviews/build-module/constants.mjs
12121 var import_i18n = __toESM(require_i18n(), 1);
12122 var OPERATOR_IS_ANY = "isAny";
12123 var OPERATOR_IS_NONE = "isNone";
12124 var OPERATOR_IS_ALL = "isAll";
12125 var OPERATOR_IS_NOT_ALL = "isNotAll";
12126 var OPERATOR_BETWEEN = "between";
12127 var OPERATOR_IN_THE_PAST = "inThePast";
12128 var OPERATOR_OVER = "over";
12129 var OPERATOR_IS = "is";
12130 var OPERATOR_IS_NOT = "isNot";
12131 var OPERATOR_LESS_THAN = "lessThan";
12132 var OPERATOR_GREATER_THAN = "greaterThan";
12133 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
12134 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
12135 var OPERATOR_BEFORE = "before";
12136 var OPERATOR_AFTER = "after";
12137 var OPERATOR_BEFORE_INC = "beforeInc";
12138 var OPERATOR_AFTER_INC = "afterInc";
12139 var OPERATOR_CONTAINS = "contains";
12140 var OPERATOR_NOT_CONTAINS = "notContains";
12141 var OPERATOR_STARTS_WITH = "startsWith";
12142 var OPERATOR_ON = "on";
12143 var OPERATOR_NOT_ON = "notOn";
12144 var SORTING_DIRECTIONS = ["asc", "desc"];
12145 var sortArrows = { asc: "\u2191", desc: "\u2193" };
12146 var sortValues = { asc: "ascending", desc: "descending" };
12147 var sortLabels = {
12148 asc: (0, import_i18n.__)("Sort ascending"),
12149 desc: (0, import_i18n.__)("Sort descending")
12150 };
12151 var sortIcons = {
12152 asc: arrow_up_default,
12153 desc: arrow_down_default
12154 };
12155 var LAYOUT_TABLE = "table";
12156 var LAYOUT_GRID = "grid";
12157 var LAYOUT_LIST = "list";
12158 var LAYOUT_ACTIVITY = "activity";
12159 var LAYOUT_PICKER_GRID = "pickerGrid";
12160 var LAYOUT_PICKER_TABLE = "pickerTable";
12161 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
12162
12163 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12164 var DataViewsContext = (0, import_element34.createContext)({
12165 view: { type: LAYOUT_TABLE },
12166 onChangeView: () => {
12167 },
12168 fields: [],
12169 data: [],
12170 paginationInfo: {
12171 totalItems: 0,
12172 totalPages: 0
12173 },
12174 selection: [],
12175 onChangeSelection: () => {
12176 },
12177 setOpenedFilter: () => {
12178 },
12179 openedFilter: null,
12180 getItemId: (item) => item.id,
12181 isItemClickable: () => true,
12182 renderItemLink: void 0,
12183 containerWidth: 0,
12184 containerRef: (0, import_element34.createRef)(),
12185 resizeObserverRef: () => {
12186 },
12187 defaultLayouts: { list: {}, grid: {}, table: {} },
12188 filters: [],
12189 isShowingFilter: false,
12190 setIsShowingFilter: () => {
12191 },
12192 hasInitiallyLoaded: false,
12193 config: {
12194 perPageSizes: []
12195 },
12196 intersectionObserver: null
12197 });
12198 DataViewsContext.displayName = "DataViewsContext";
12199 var dataviews_context_default = DataViewsContext;
12200
12201 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
12202 var import_i18n22 = __toESM(require_i18n(), 1);
12203
12204 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
12205 var import_i18n9 = __toESM(require_i18n(), 1);
12206 var import_components8 = __toESM(require_components(), 1);
12207 var import_element43 = __toESM(require_element(), 1);
12208 var import_keycodes2 = __toESM(require_keycodes(), 1);
12209
12210 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
12211 var import_components3 = __toESM(require_components(), 1);
12212 var import_i18n2 = __toESM(require_i18n(), 1);
12213 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12214 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
12215 function DataViewsSelectionCheckbox({
12216 selection,
12217 onChangeSelection,
12218 item,
12219 getItemId,
12220 titleField,
12221 disabled: disabled2,
12222 ...extraProps
12223 }) {
12224 const id = getItemId(item);
12225 const isInSelectionArray = selection.includes(id);
12226 const checked = !disabled2 && isInSelectionArray;
12227 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
12228 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12229 import_components3.CheckboxControl,
12230 {
12231 className: SELECTION_CHECKBOX_CLASS,
12232 "aria-label": selectionLabel,
12233 "aria-disabled": disabled2,
12234 checked,
12235 onChange: () => {
12236 if (disabled2) {
12237 return;
12238 }
12239 onChangeSelection(
12240 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
12241 );
12242 },
12243 ...extraProps
12244 }
12245 );
12246 }
12247
12248 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
12249 var import_components4 = __toESM(require_components(), 1);
12250 var import_i18n3 = __toESM(require_i18n(), 1);
12251 var import_element35 = __toESM(require_element(), 1);
12252 var import_data = __toESM(require_data(), 1);
12253 var import_compose = __toESM(require_compose(), 1);
12254
12255 // packages/dataviews/build-module/lock-unlock.mjs
12256 var import_private_apis2 = __toESM(require_private_apis(), 1);
12257 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
12258 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
12259 "@wordpress/dataviews"
12260 );
12261
12262 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
12263 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12264 var { Menu, kebabCase } = unlock2(import_components4.privateApis);
12265 function ButtonTrigger({
12266 action,
12267 onClick,
12268 items,
12269 variant
12270 }) {
12271 const label = typeof action.label === "string" ? action.label : action.label(items);
12272 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12273 import_components4.Button,
12274 {
12275 disabled: !!action.disabled,
12276 accessibleWhenDisabled: true,
12277 size: "compact",
12278 variant,
12279 onClick,
12280 children: label
12281 }
12282 );
12283 }
12284 function MenuItemTrigger({
12285 action,
12286 onClick,
12287 items
12288 }) {
12289 const label = typeof action.label === "string" ? action.label : action.label(items);
12290 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Menu.ItemLabel, { children: label }) });
12291 }
12292 function ActionModal({
12293 action,
12294 items,
12295 closeModal
12296 }) {
12297 const label = typeof action.label === "string" ? action.label : action.label(items);
12298 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
12299 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12300 import_components4.Modal,
12301 {
12302 title: modalHeader || label,
12303 __experimentalHideHeader: !!action.hideModalHeader,
12304 onRequestClose: closeModal,
12305 focusOnMount: action.modalFocusOnMount ?? true,
12306 size: action.modalSize || "medium",
12307 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
12308 action.id
12309 )}`,
12310 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(action.RenderModal, { items, closeModal })
12311 }
12312 );
12313 }
12314 function ActionsMenuGroup({
12315 actions,
12316 item,
12317 registry,
12318 setActiveModalAction
12319 }) {
12320 const { primaryActions, regularActions } = (0, import_element35.useMemo)(() => {
12321 return actions.reduce(
12322 (acc, action) => {
12323 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
12324 return acc;
12325 },
12326 {
12327 primaryActions: [],
12328 regularActions: []
12329 }
12330 );
12331 }, [actions]);
12332 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12333 MenuItemTrigger,
12334 {
12335 action,
12336 onClick: () => {
12337 if ("RenderModal" in action) {
12338 setActiveModalAction(action);
12339 return;
12340 }
12341 action.callback([item], { registry });
12342 },
12343 items: [item]
12344 },
12345 action.id
12346 ));
12347 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Menu.Group, { children: [
12348 renderActionGroup(primaryActions),
12349 renderActionGroup(regularActions)
12350 ] });
12351 }
12352 function ItemActions({
12353 item,
12354 actions,
12355 isCompact
12356 }) {
12357 const registry = (0, import_data.useRegistry)();
12358 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
12359 const _eligibleActions = actions.filter(
12360 (action) => !action.isEligible || action.isEligible(item)
12361 );
12362 const _primaryActions = _eligibleActions.filter(
12363 (action) => action.isPrimary
12364 );
12365 return {
12366 primaryActions: _primaryActions,
12367 eligibleActions: _eligibleActions
12368 };
12369 }, [actions, item]);
12370 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
12371 if (isCompact) {
12372 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12373 CompactItemActions,
12374 {
12375 item,
12376 actions: eligibleActions,
12377 isSmall: true,
12378 registry
12379 }
12380 );
12381 }
12382 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12383 Stack,
12384 {
12385 direction: "row",
12386 justify: "flex-end",
12387 className: "dataviews-item-actions",
12388 style: {
12389 flexShrink: 0,
12390 width: "auto"
12391 },
12392 children: [
12393 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12394 PrimaryActions,
12395 {
12396 item,
12397 actions: primaryActions,
12398 registry
12399 }
12400 ),
12401 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
12402 // there if there are any actions at all.
12403 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12404 CompactItemActions,
12405 {
12406 item,
12407 actions: eligibleActions,
12408 registry
12409 }
12410 )
12411 ]
12412 }
12413 );
12414 }
12415 function CompactItemActions({
12416 item,
12417 actions,
12418 isSmall,
12419 registry
12420 }) {
12421 const [activeModalAction, setActiveModalAction] = (0, import_element35.useState)(
12422 null
12423 );
12424 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12425 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Menu, { placement: "bottom-end", children: [
12426 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12427 Menu.TriggerButton,
12428 {
12429 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12430 import_components4.Button,
12431 {
12432 size: isSmall ? "small" : "compact",
12433 icon: more_vertical_default,
12434 label: (0, import_i18n3.__)("Actions"),
12435 accessibleWhenDisabled: true,
12436 disabled: !actions.length,
12437 className: "dataviews-all-actions-button"
12438 }
12439 )
12440 }
12441 ),
12442 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12443 ActionsMenuGroup,
12444 {
12445 actions,
12446 item,
12447 registry,
12448 setActiveModalAction
12449 }
12450 ) })
12451 ] }),
12452 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12453 ActionModal,
12454 {
12455 action: activeModalAction,
12456 items: [item],
12457 closeModal: () => setActiveModalAction(null)
12458 }
12459 )
12460 ] });
12461 }
12462 function PrimaryActions({
12463 item,
12464 actions,
12465 registry,
12466 buttonVariant
12467 }) {
12468 const [activeModalAction, setActiveModalAction] = (0, import_element35.useState)(null);
12469 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
12470 if (isMobileViewport) {
12471 return null;
12472 }
12473 if (!Array.isArray(actions) || actions.length === 0) {
12474 return null;
12475 }
12476 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12477 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12478 ButtonTrigger,
12479 {
12480 action,
12481 onClick: () => {
12482 if ("RenderModal" in action) {
12483 setActiveModalAction(action);
12484 return;
12485 }
12486 action.callback([item], { registry });
12487 },
12488 items: [item],
12489 variant: buttonVariant
12490 },
12491 action.id
12492 )),
12493 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12494 ActionModal,
12495 {
12496 action: activeModalAction,
12497 items: [item],
12498 closeModal: () => setActiveModalAction(null)
12499 }
12500 )
12501 ] });
12502 }
12503
12504 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
12505 var import_components5 = __toESM(require_components(), 1);
12506 var import_i18n5 = __toESM(require_i18n(), 1);
12507 var import_element36 = __toESM(require_element(), 1);
12508 var import_data2 = __toESM(require_data(), 1);
12509 var import_compose2 = __toESM(require_compose(), 1);
12510
12511 // packages/dataviews/build-module/utils/get-footer-message.mjs
12512 var import_i18n4 = __toESM(require_i18n(), 1);
12513 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
12514 if (selectionCount > 0) {
12515 return (0, import_i18n4.sprintf)(
12516 /* translators: %d: number of items. */
12517 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
12518 selectionCount
12519 );
12520 }
12521 if (onlyTotalCount || totalItems <= itemsCount) {
12522 return (0, import_i18n4.sprintf)(
12523 /* translators: %d: number of items. */
12524 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
12525 totalItems
12526 );
12527 }
12528 return (0, import_i18n4.sprintf)(
12529 /* translators: %1$d: number of items. %2$d: total number of items. */
12530 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
12531 itemsCount,
12532 totalItems
12533 );
12534 }
12535
12536 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
12537 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12538 function ActionWithModal({
12539 action,
12540 items,
12541 ActionTriggerComponent
12542 }) {
12543 const [isModalOpen, setIsModalOpen] = (0, import_element36.useState)(false);
12544 const actionTriggerProps = {
12545 action,
12546 onClick: () => {
12547 setIsModalOpen(true);
12548 },
12549 items
12550 };
12551 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
12552 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
12553 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12554 ActionModal,
12555 {
12556 action,
12557 items,
12558 closeModal: () => setIsModalOpen(false)
12559 }
12560 )
12561 ] });
12562 }
12563 function hasAPossibleBulkAction(actions, item) {
12564 return actions.some(
12565 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
12566 );
12567 }
12568 function useHasAPossibleBulkAction(actions, item) {
12569 return (0, import_element36.useMemo)(
12570 () => hasAPossibleBulkAction(actions, item),
12571 [actions, item]
12572 );
12573 }
12574 function useSomeItemHasAPossibleBulkAction(actions, data) {
12575 return (0, import_element36.useMemo)(
12576 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
12577 [actions, data]
12578 );
12579 }
12580 function BulkSelectionCheckbox({
12581 selection,
12582 onChangeSelection,
12583 data,
12584 actions,
12585 getItemId,
12586 disableSelectAll = false
12587 }) {
12588 const selectableItems = (0, import_element36.useMemo)(() => {
12589 return data.filter((item) => {
12590 return actions.some(
12591 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
12592 );
12593 });
12594 }, [data, actions]);
12595 const selectedItems = data.filter(
12596 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
12597 );
12598 const hasSelection = selection.length > 0;
12599 const areAllSelected = selectedItems.length === selectableItems.length;
12600 if (disableSelectAll) {
12601 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12602 import_components5.CheckboxControl,
12603 {
12604 className: "dataviews-view-table-selection-checkbox",
12605 checked: hasSelection,
12606 disabled: !hasSelection,
12607 onChange: () => {
12608 onChangeSelection([]);
12609 },
12610 "aria-label": (0, import_i18n5.__)("Deselect all")
12611 }
12612 );
12613 }
12614 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12615 import_components5.CheckboxControl,
12616 {
12617 className: "dataviews-view-table-selection-checkbox",
12618 checked: areAllSelected,
12619 indeterminate: !areAllSelected && !!selectedItems.length,
12620 onChange: () => {
12621 if (areAllSelected) {
12622 onChangeSelection([]);
12623 } else {
12624 onChangeSelection(
12625 selectableItems.map((item) => getItemId(item))
12626 );
12627 }
12628 },
12629 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
12630 }
12631 );
12632 }
12633 function ActionTrigger({
12634 action,
12635 onClick,
12636 isBusy,
12637 items
12638 }) {
12639 const label = typeof action.label === "string" ? action.label : action.label(items);
12640 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
12641 if (isMobile) {
12642 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12643 import_components5.Button,
12644 {
12645 disabled: isBusy,
12646 accessibleWhenDisabled: true,
12647 label,
12648 icon: action.icon,
12649 size: "compact",
12650 onClick,
12651 isBusy
12652 }
12653 );
12654 }
12655 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12656 import_components5.Button,
12657 {
12658 disabled: isBusy,
12659 accessibleWhenDisabled: true,
12660 size: "compact",
12661 onClick,
12662 isBusy,
12663 children: label
12664 }
12665 );
12666 }
12667 var EMPTY_ARRAY2 = [];
12668 function ActionButton({
12669 action,
12670 selectedItems,
12671 actionInProgress,
12672 setActionInProgress
12673 }) {
12674 const registry = (0, import_data2.useRegistry)();
12675 const selectedEligibleItems = (0, import_element36.useMemo)(() => {
12676 return selectedItems.filter((item) => {
12677 return !action.isEligible || action.isEligible(item);
12678 });
12679 }, [action, selectedItems]);
12680 if ("RenderModal" in action) {
12681 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12682 ActionWithModal,
12683 {
12684 action,
12685 items: selectedEligibleItems,
12686 ActionTriggerComponent: ActionTrigger
12687 },
12688 action.id
12689 );
12690 }
12691 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12692 ActionTrigger,
12693 {
12694 action,
12695 onClick: async () => {
12696 setActionInProgress(action.id);
12697 await action.callback(selectedItems, {
12698 registry
12699 });
12700 setActionInProgress(null);
12701 },
12702 items: selectedEligibleItems,
12703 isBusy: actionInProgress === action.id
12704 },
12705 action.id
12706 );
12707 }
12708 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
12709 const message2 = getFooterMessage(
12710 selection.length,
12711 data.length,
12712 paginationInfo.totalItems,
12713 isInfiniteScroll
12714 );
12715 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12716 Stack,
12717 {
12718 direction: "row",
12719 className: "dataviews-bulk-actions-footer__container",
12720 gap: "md",
12721 align: "center",
12722 children: [
12723 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12724 BulkSelectionCheckbox,
12725 {
12726 selection,
12727 onChangeSelection,
12728 data,
12729 actions,
12730 getItemId,
12731 disableSelectAll: isInfiniteScroll
12732 }
12733 ),
12734 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
12735 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12736 Stack,
12737 {
12738 direction: "row",
12739 className: "dataviews-bulk-actions-footer__action-buttons",
12740 gap: "xs",
12741 children: [
12742 actionsToShow.map((action) => {
12743 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12744 ActionButton,
12745 {
12746 action,
12747 selectedItems,
12748 actionInProgress,
12749 setActionInProgress
12750 },
12751 action.id
12752 );
12753 }),
12754 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12755 import_components5.Button,
12756 {
12757 icon: close_small_default,
12758 showTooltip: true,
12759 tooltipPosition: "top",
12760 size: "compact",
12761 label: (0, import_i18n5.__)("Cancel"),
12762 disabled: !!actionInProgress,
12763 accessibleWhenDisabled: false,
12764 onClick: () => {
12765 onChangeSelection(EMPTY_ARRAY2);
12766 }
12767 }
12768 )
12769 ]
12770 }
12771 )
12772 ]
12773 }
12774 );
12775 }
12776 function FooterContent({
12777 selection,
12778 actions,
12779 onChangeSelection,
12780 data,
12781 getItemId,
12782 isInfiniteScroll,
12783 paginationInfo
12784 }) {
12785 const [actionInProgress, setActionInProgress] = (0, import_element36.useState)(
12786 null
12787 );
12788 const footerContentRef = (0, import_element36.useRef)(void 0);
12789 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
12790 const bulkActions = (0, import_element36.useMemo)(
12791 () => actions.filter((action) => action.supportsBulk),
12792 [actions]
12793 );
12794 const selectableItems = (0, import_element36.useMemo)(() => {
12795 return data.filter((item) => {
12796 return bulkActions.some(
12797 (action) => !action.isEligible || action.isEligible(item)
12798 );
12799 });
12800 }, [data, bulkActions]);
12801 const selectedItems = (0, import_element36.useMemo)(() => {
12802 return data.filter(
12803 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
12804 );
12805 }, [selection, data, getItemId, selectableItems]);
12806 const actionsToShow = (0, import_element36.useMemo)(
12807 () => actions.filter((action) => {
12808 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
12809 (item) => !action.isEligible || action.isEligible(item)
12810 );
12811 }),
12812 [actions, selectedItems, isMobile]
12813 );
12814 if (!actionInProgress) {
12815 if (footerContentRef.current) {
12816 footerContentRef.current = void 0;
12817 }
12818 return renderFooterContent(
12819 data,
12820 actions,
12821 getItemId,
12822 isInfiniteScroll,
12823 selection,
12824 actionsToShow,
12825 selectedItems,
12826 actionInProgress,
12827 setActionInProgress,
12828 onChangeSelection,
12829 paginationInfo
12830 );
12831 } else if (!footerContentRef.current) {
12832 footerContentRef.current = renderFooterContent(
12833 data,
12834 actions,
12835 getItemId,
12836 isInfiniteScroll,
12837 selection,
12838 actionsToShow,
12839 selectedItems,
12840 actionInProgress,
12841 setActionInProgress,
12842 onChangeSelection,
12843 paginationInfo
12844 );
12845 }
12846 return footerContentRef.current;
12847 }
12848 function BulkActionsFooter() {
12849 const {
12850 data,
12851 selection,
12852 actions = EMPTY_ARRAY2,
12853 onChangeSelection,
12854 getItemId,
12855 paginationInfo,
12856 view
12857 } = (0, import_element36.useContext)(dataviews_context_default);
12858 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12859 FooterContent,
12860 {
12861 selection,
12862 onChangeSelection,
12863 data,
12864 actions,
12865 getItemId,
12866 isInfiniteScroll: !!view.infiniteScrollEnabled,
12867 paginationInfo
12868 }
12869 );
12870 }
12871
12872 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
12873 var import_i18n6 = __toESM(require_i18n(), 1);
12874 var import_components6 = __toESM(require_components(), 1);
12875 var import_element37 = __toESM(require_element(), 1);
12876
12877 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
12878 function getHideableFields(view, fields2) {
12879 const togglableFields = [
12880 view?.titleField,
12881 view?.mediaField,
12882 view?.descriptionField
12883 ].filter(Boolean);
12884 return fields2.filter(
12885 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
12886 );
12887 }
12888
12889 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
12890 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
12891 var { Menu: Menu2 } = unlock2(import_components6.privateApis);
12892 function WithMenuSeparators({ children }) {
12893 return import_element37.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_element37.Fragment, { children: [
12894 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Separator, {}),
12895 child
12896 ] }, i2));
12897 }
12898 var _HeaderMenu = (0, import_element37.forwardRef)(function HeaderMenu({
12899 fieldId,
12900 view,
12901 fields: fields2,
12902 onChangeView,
12903 onHide,
12904 setOpenedFilter,
12905 canMove = true,
12906 canInsertLeft = true,
12907 canInsertRight = true
12908 }, ref) {
12909 const visibleFieldIds = view.fields ?? [];
12910 const index2 = visibleFieldIds?.indexOf(fieldId);
12911 const isSorted = view.sort?.field === fieldId;
12912 let isHidable = false;
12913 let isSortable = false;
12914 let canAddFilter = false;
12915 let operators = [];
12916 const field = fields2.find((f2) => f2.id === fieldId);
12917 const { setIsShowingFilter } = (0, import_element37.useContext)(dataviews_context_default);
12918 if (!field) {
12919 return null;
12920 }
12921 isHidable = field.enableHiding !== false;
12922 isSortable = field.enableSorting !== false;
12923 const header = field.header;
12924 operators = !!field.filterBy && field.filterBy?.operators || [];
12925 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
12926 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
12927 return header;
12928 }
12929 const hiddenFields = getHideableFields(view, fields2).filter(
12930 (f2) => !visibleFieldIds.includes(f2.id)
12931 );
12932 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
12933 const isRtl = (0, import_i18n6.isRTL)();
12934 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu2, { children: [
12935 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
12936 Menu2.TriggerButton,
12937 {
12938 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12939 import_components6.Button,
12940 {
12941 size: "compact",
12942 className: "dataviews-view-table-header-button",
12943 ref,
12944 variant: "tertiary"
12945 }
12946 ),
12947 children: [
12948 header,
12949 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
12950 ]
12951 }
12952 ),
12953 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(WithMenuSeparators, { children: [
12954 isSortable && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
12955 (direction) => {
12956 const isChecked = view.sort && isSorted && view.sort.direction === direction;
12957 const value = `${fieldId}-${direction}`;
12958 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12959 Menu2.RadioItem,
12960 {
12961 name: "view-table-sorting",
12962 value,
12963 checked: isChecked,
12964 onChange: () => {
12965 onChangeView({
12966 ...view,
12967 sort: {
12968 field: fieldId,
12969 direction
12970 },
12971 showLevels: false
12972 });
12973 },
12974 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
12975 },
12976 value
12977 );
12978 }
12979 ) }),
12980 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12981 Menu2.Item,
12982 {
12983 prefix: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components6.Icon, { icon: funnel_default }),
12984 onClick: () => {
12985 setOpenedFilter(fieldId);
12986 setIsShowingFilter(true);
12987 onChangeView({
12988 ...view,
12989 page: 1,
12990 filters: [
12991 ...view.filters || [],
12992 {
12993 field: fieldId,
12994 value: void 0,
12995 operator: operators[0]
12996 }
12997 ]
12998 });
12999 },
13000 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
13001 }
13002 ) }),
13003 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu2.Group, { children: [
13004 canMove && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13005 Menu2.Item,
13006 {
13007 prefix: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components6.Icon, { icon: arrow_left_default }),
13008 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
13009 onClick: () => {
13010 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
13011 const newFields = [
13012 ...visibleFieldIds
13013 ];
13014 newFields.splice(index2, 1);
13015 newFields.splice(
13016 targetIndex,
13017 0,
13018 fieldId
13019 );
13020 onChangeView({
13021 ...view,
13022 fields: newFields
13023 });
13024 },
13025 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
13026 }
13027 ),
13028 canMove && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13029 Menu2.Item,
13030 {
13031 prefix: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components6.Icon, { icon: arrow_right_default }),
13032 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
13033 onClick: () => {
13034 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
13035 const newFields = [
13036 ...visibleFieldIds
13037 ];
13038 newFields.splice(index2, 1);
13039 newFields.splice(
13040 targetIndex,
13041 0,
13042 fieldId
13043 );
13044 onChangeView({
13045 ...view,
13046 fields: newFields
13047 });
13048 },
13049 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
13050 }
13051 ),
13052 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu2, { children: [
13053 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
13054 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13055 const insertIndex = isRtl ? index2 + 1 : index2;
13056 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13057 Menu2.Item,
13058 {
13059 onClick: () => {
13060 onChangeView({
13061 ...view,
13062 fields: [
13063 ...visibleFieldIds.slice(
13064 0,
13065 insertIndex
13066 ),
13067 hiddenField.id,
13068 ...visibleFieldIds.slice(
13069 insertIndex
13070 )
13071 ]
13072 });
13073 },
13074 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13075 },
13076 hiddenField.id
13077 );
13078 }) })
13079 ] }),
13080 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu2, { children: [
13081 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
13082 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13083 const insertIndex = isRtl ? index2 : index2 + 1;
13084 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13085 Menu2.Item,
13086 {
13087 onClick: () => {
13088 onChangeView({
13089 ...view,
13090 fields: [
13091 ...visibleFieldIds.slice(
13092 0,
13093 insertIndex
13094 ),
13095 hiddenField.id,
13096 ...visibleFieldIds.slice(
13097 insertIndex
13098 )
13099 ]
13100 });
13101 },
13102 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13103 },
13104 hiddenField.id
13105 );
13106 }) })
13107 ] }),
13108 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13109 Menu2.Item,
13110 {
13111 prefix: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components6.Icon, { icon: unseen_default }),
13112 onClick: () => {
13113 onHide(field);
13114 onChangeView({
13115 ...view,
13116 fields: visibleFieldIds.filter(
13117 (id) => id !== fieldId
13118 )
13119 });
13120 },
13121 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
13122 }
13123 )
13124 ] })
13125 ] }) })
13126 ] });
13127 });
13128 var ColumnHeaderMenu = _HeaderMenu;
13129 var column_header_menu_default = ColumnHeaderMenu;
13130
13131 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
13132 var import_element38 = __toESM(require_element(), 1);
13133 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13134 function getClickableItemProps({
13135 item,
13136 isItemClickable,
13137 onClickItem,
13138 className
13139 }) {
13140 if (!isItemClickable(item) || !onClickItem) {
13141 return { className };
13142 }
13143 return {
13144 className: className ? `${className} ${className}--clickable` : void 0,
13145 role: "button",
13146 tabIndex: 0,
13147 onClick: (event) => {
13148 event.stopPropagation();
13149 onClickItem(item);
13150 },
13151 onKeyDown: (event) => {
13152 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13153 event.stopPropagation();
13154 onClickItem(item);
13155 }
13156 }
13157 };
13158 }
13159 function ItemClickWrapper({
13160 item,
13161 isItemClickable,
13162 onClickItem,
13163 renderItemLink,
13164 className,
13165 children,
13166 ...extraProps
13167 }) {
13168 if (!isItemClickable(item)) {
13169 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className, ...extraProps, children });
13170 }
13171 if (renderItemLink) {
13172 const renderedElement = renderItemLink({
13173 item,
13174 className: `${className} ${className}--clickable`,
13175 ...extraProps,
13176 children
13177 });
13178 return (0, import_element38.cloneElement)(renderedElement, {
13179 onClick: (event) => {
13180 event.stopPropagation();
13181 if (renderedElement.props.onClick) {
13182 renderedElement.props.onClick(event);
13183 }
13184 },
13185 onKeyDown: (event) => {
13186 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13187 event.stopPropagation();
13188 if (renderedElement.props.onKeyDown) {
13189 renderedElement.props.onKeyDown(event);
13190 }
13191 }
13192 }
13193 });
13194 }
13195 const clickProps = getClickableItemProps({
13196 item,
13197 isItemClickable,
13198 onClickItem,
13199 className
13200 });
13201 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { ...clickProps, ...extraProps, children });
13202 }
13203
13204 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
13205 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13206 function ColumnPrimary({
13207 item,
13208 level,
13209 titleField,
13210 mediaField,
13211 descriptionField,
13212 onClickItem,
13213 renderItemLink,
13214 isItemClickable
13215 }) {
13216 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
13217 mediaField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13218 ItemClickWrapper,
13219 {
13220 item,
13221 isItemClickable,
13222 onClickItem,
13223 renderItemLink,
13224 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
13225 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
13226 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13227 mediaField.render,
13228 {
13229 item,
13230 field: mediaField,
13231 config: { sizes: "32px" }
13232 }
13233 )
13234 }
13235 ),
13236 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13237 Stack,
13238 {
13239 direction: "column",
13240 align: "flex-start",
13241 className: "dataviews-view-table__primary-column-content",
13242 children: [
13243 titleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13244 ItemClickWrapper,
13245 {
13246 item,
13247 isItemClickable,
13248 onClickItem,
13249 renderItemLink,
13250 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
13251 children: [
13252 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "dataviews-view-table__level", children: [
13253 Array(level).fill("\u2014").join(" "),
13254 "\xA0"
13255 ] }),
13256 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField })
13257 ]
13258 }
13259 ),
13260 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13261 descriptionField.render,
13262 {
13263 item,
13264 field: descriptionField
13265 }
13266 )
13267 ]
13268 }
13269 )
13270 ] });
13271 }
13272 var column_primary_default = ColumnPrimary;
13273
13274 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
13275 var import_element39 = __toESM(require_element(), 1);
13276 var import_i18n7 = __toESM(require_i18n(), 1);
13277 var isScrolledToEnd = (element) => {
13278 if ((0, import_i18n7.isRTL)()) {
13279 const scrollLeft = Math.abs(element.scrollLeft);
13280 return scrollLeft <= 1;
13281 }
13282 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
13283 };
13284 function useScrollState({
13285 scrollContainerRef,
13286 enabledHorizontal = false
13287 }) {
13288 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element39.useState)(false);
13289 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element39.useState)(false);
13290 const handleScroll = (0, import_element39.useCallback)(() => {
13291 const scrollContainer = scrollContainerRef.current;
13292 if (!scrollContainer) {
13293 return;
13294 }
13295 if (enabledHorizontal) {
13296 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
13297 }
13298 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
13299 }, [scrollContainerRef, enabledHorizontal]);
13300 (0, import_element39.useEffect)(() => {
13301 if (typeof window === "undefined" || !scrollContainerRef.current) {
13302 return () => {
13303 };
13304 }
13305 const scrollContainer = scrollContainerRef.current;
13306 handleScroll();
13307 scrollContainer.addEventListener("scroll", handleScroll);
13308 window.addEventListener("resize", handleScroll);
13309 return () => {
13310 scrollContainer.removeEventListener("scroll", handleScroll);
13311 window.removeEventListener("resize", handleScroll);
13312 };
13313 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
13314 return { isHorizontalScrollEnd, isVerticallyScrolled };
13315 }
13316
13317 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
13318 function getDataByGroup(data, groupByField) {
13319 return data.reduce((groups, item) => {
13320 const groupName = groupByField.getValue({ item });
13321 if (!groups.has(groupName)) {
13322 groups.set(groupName, []);
13323 }
13324 groups.get(groupName)?.push(item);
13325 return groups;
13326 }, /* @__PURE__ */ new Map());
13327 }
13328
13329 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
13330 var import_element40 = __toESM(require_element(), 1);
13331 var import_keycodes = __toESM(require_keycodes(), 1);
13332 function getRange(orderedIds, fromIndex, toIndex) {
13333 return orderedIds.slice(
13334 Math.min(fromIndex, toIndex),
13335 Math.max(fromIndex, toIndex) + 1
13336 );
13337 }
13338 function getRangeSelection({
13339 anchorId,
13340 targetId,
13341 lastTargetId,
13342 orderedIds,
13343 selection
13344 }) {
13345 const targetIndex = orderedIds.indexOf(targetId);
13346 if (targetIndex === -1) {
13347 return selection;
13348 }
13349 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
13350 const hasAnchor = anchorIndex !== -1;
13351 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
13352 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
13353 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
13354 const base = selection.filter((id) => !lastRange.includes(id));
13355 return [
13356 .../* @__PURE__ */ new Set([
13357 ...base,
13358 ...getRange(orderedIds, rangeStart, targetIndex)
13359 ])
13360 ];
13361 }
13362 function getClosestSelectedId({
13363 targetId,
13364 orderedIds,
13365 selection
13366 }) {
13367 const targetIndex = orderedIds.indexOf(targetId);
13368 if (targetIndex === -1) {
13369 return null;
13370 }
13371 const selectedIds = new Set(selection);
13372 let closestId = null;
13373 let closestDistance = Infinity;
13374 orderedIds.forEach((id, index2) => {
13375 if (!selectedIds.has(id)) {
13376 return;
13377 }
13378 const distance = Math.abs(index2 - targetIndex);
13379 if (distance < closestDistance) {
13380 closestDistance = distance;
13381 closestId = id;
13382 }
13383 });
13384 return closestId;
13385 }
13386 function useSelectionProps({
13387 data,
13388 actions,
13389 getItemId,
13390 selection,
13391 onChangeSelection
13392 }) {
13393 const gestureRef = (0, import_element40.useRef)(null);
13394 const isTouchDeviceRef = (0, import_element40.useRef)(false);
13395 (0, import_element40.useEffect)(() => {
13396 const markTouchDevice = () => {
13397 isTouchDeviceRef.current = true;
13398 };
13399 document.addEventListener("touchstart", markTouchDevice, {
13400 once: true
13401 });
13402 return () => document.removeEventListener("touchstart", markTouchDevice);
13403 }, []);
13404 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
13405 const selectableIdSet = new Set(selectableIds);
13406 const hasSelectableItems = selectableIds.length > 0;
13407 const getSelectionProps = (id) => {
13408 const isSelectable = selectableIdSet.has(id);
13409 return {
13410 onMouseDown: (event) => {
13411 if (event.button === 0 && event.shiftKey && hasSelectableItems) {
13412 event.preventDefault();
13413 }
13414 },
13415 onClickCapture: (event) => {
13416 if (!hasSelectableItems) {
13417 return;
13418 }
13419 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
13420 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
13421 if (!isModifierKeyPressed && !event.shiftKey) {
13422 if (isSelectable && isSelectionCheckboxClick) {
13423 gestureRef.current = {
13424 anchorId: id,
13425 lastTargetId: null
13426 };
13427 }
13428 return;
13429 }
13430 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
13431 return;
13432 }
13433 event.stopPropagation();
13434 if (!isSelectionCheckboxClick) {
13435 event.preventDefault();
13436 }
13437 if (!isSelectable) {
13438 return;
13439 }
13440 if (event.shiftKey) {
13441 let gesture = gestureRef.current;
13442 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
13443 gesture = {
13444 anchorId: getClosestSelectedId({
13445 targetId: id,
13446 orderedIds: selectableIds,
13447 selection
13448 }) ?? id,
13449 lastTargetId: null
13450 };
13451 }
13452 onChangeSelection(
13453 getRangeSelection({
13454 anchorId: gesture.anchorId,
13455 targetId: id,
13456 lastTargetId: gesture.lastTargetId,
13457 orderedIds: selectableIds,
13458 selection
13459 })
13460 );
13461 gestureRef.current = {
13462 anchorId: gesture.anchorId,
13463 lastTargetId: id
13464 };
13465 } else {
13466 onChangeSelection(
13467 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
13468 );
13469 gestureRef.current = { anchorId: id, lastTargetId: null };
13470 }
13471 }
13472 };
13473 };
13474 return { getSelectionProps };
13475 }
13476
13477 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
13478 var import_components7 = __toESM(require_components(), 1);
13479 var import_i18n8 = __toESM(require_i18n(), 1);
13480 var import_element41 = __toESM(require_element(), 1);
13481 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13482 function FieldItem({
13483 field,
13484 isVisible: isVisible2,
13485 onToggleVisibility
13486 }) {
13487 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
13488 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components7.Icon, { icon: check_default }) }),
13489 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
13490 ] }) });
13491 }
13492 function isDefined(item) {
13493 return !!item;
13494 }
13495 function PropertiesSection({
13496 showLabel = true
13497 }) {
13498 const { view, fields: fields2, onChangeView } = (0, import_element41.useContext)(dataviews_context_default);
13499 const regularFields = getHideableFields(view, fields2);
13500 if (!regularFields?.length) {
13501 return null;
13502 }
13503 const titleField = fields2.find((f2) => f2.id === view.titleField);
13504 const previewField = fields2.find((f2) => f2.id === view.mediaField);
13505 const descriptionField = fields2.find(
13506 (f2) => f2.id === view.descriptionField
13507 );
13508 const lockedFields = [
13509 {
13510 field: titleField,
13511 isVisibleFlag: "showTitle"
13512 },
13513 {
13514 field: previewField,
13515 isVisibleFlag: "showMedia"
13516 },
13517 {
13518 field: descriptionField,
13519 isVisibleFlag: "showDescription"
13520 }
13521 ].filter(({ field }) => isDefined(field));
13522 const visibleFieldIds = view.fields ?? [];
13523 const visibleRegularFieldsCount = regularFields.filter(
13524 (f2) => visibleFieldIds.includes(f2.id)
13525 ).length;
13526 const visibleLockedFields = lockedFields.filter(
13527 ({ isVisibleFlag }) => (
13528 // @ts-expect-error
13529 view[isVisibleFlag] ?? true
13530 )
13531 );
13532 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
13533 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
13534 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
13535 showLabel && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
13536 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13537 Stack,
13538 {
13539 direction: "column",
13540 className: "dataviews-view-config__properties",
13541 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
13542 lockedFields.map(({ field, isVisibleFlag }) => {
13543 const isVisible2 = view[isVisibleFlag] ?? true;
13544 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
13545 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13546 FieldItem,
13547 {
13548 field: fieldToRender,
13549 isVisible: isVisible2,
13550 onToggleVisibility: () => {
13551 onChangeView({
13552 ...view,
13553 [isVisibleFlag]: !isVisible2
13554 });
13555 }
13556 },
13557 field.id
13558 );
13559 }),
13560 regularFields.map((field) => {
13561 const isVisible2 = visibleFieldIds.includes(field.id);
13562 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
13563 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13564 FieldItem,
13565 {
13566 field: fieldToRender,
13567 isVisible: isVisible2,
13568 onToggleVisibility: () => {
13569 onChangeView({
13570 ...view,
13571 fields: isVisible2 ? visibleFieldIds.filter(
13572 (fieldId) => fieldId !== field.id
13573 ) : [...visibleFieldIds, field.id]
13574 });
13575 }
13576 },
13577 field.id
13578 );
13579 })
13580 ] })
13581 }
13582 )
13583 ] });
13584 }
13585
13586 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
13587 var import_element42 = __toESM(require_element(), 1);
13588 function useDelayedLoading(isLoading, options = { delay: 400 }) {
13589 const [showLoader, setShowLoader] = (0, import_element42.useState)(false);
13590 (0, import_element42.useEffect)(() => {
13591 if (!isLoading) {
13592 return;
13593 }
13594 const timeout = setTimeout(() => {
13595 setShowLoader(true);
13596 }, options.delay);
13597 return () => {
13598 clearTimeout(timeout);
13599 setShowLoader(false);
13600 };
13601 }, [isLoading, options.delay]);
13602 return showLoader;
13603 }
13604
13605 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
13606 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13607 function getEffectiveAlign(explicitAlign, fieldType) {
13608 if (explicitAlign) {
13609 return explicitAlign;
13610 }
13611 if (fieldType === "integer" || fieldType === "number") {
13612 return "end";
13613 }
13614 return void 0;
13615 }
13616 function TableColumnField({
13617 item,
13618 fields: fields2,
13619 column,
13620 align
13621 }) {
13622 const field = fields2.find((f2) => f2.id === column);
13623 if (!field) {
13624 return null;
13625 }
13626 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
13627 "dataviews-view-table__cell-align-end": align === "end",
13628 "dataviews-view-table__cell-align-center": align === "center"
13629 });
13630 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(field.render, { item, field }) });
13631 }
13632 function TableRow({
13633 hasBulkActions,
13634 item,
13635 level,
13636 actions,
13637 fields: fields2,
13638 id,
13639 view,
13640 titleField,
13641 mediaField,
13642 descriptionField,
13643 selection,
13644 getItemId,
13645 isItemClickable,
13646 onClickItem,
13647 renderItemLink,
13648 onChangeSelection,
13649 onMouseDown,
13650 onClickCapture,
13651 isActionsColumnSticky,
13652 posinset
13653 }) {
13654 const { paginationInfo } = (0, import_element43.useContext)(dataviews_context_default);
13655 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
13656 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
13657 const {
13658 showTitle = true,
13659 showMedia = true,
13660 showDescription = true,
13661 infiniteScrollEnabled
13662 } = view;
13663 const columns = view.fields ?? [];
13664 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13665 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13666 "tr",
13667 {
13668 className: clsx_default("dataviews-view-table__row", {
13669 "is-selected": hasPossibleBulkAction && isSelected2,
13670 "has-bulk-actions": hasPossibleBulkAction
13671 }),
13672 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13673 "aria-posinset": posinset,
13674 role: infiniteScrollEnabled ? "article" : void 0,
13675 onClickCapture,
13676 onMouseDown: (event) => {
13677 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
13678 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
13679 event.preventDefault();
13680 }
13681 onMouseDown(event);
13682 },
13683 children: [
13684 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13685 DataViewsSelectionCheckbox,
13686 {
13687 item,
13688 selection,
13689 onChangeSelection,
13690 getItemId,
13691 titleField,
13692 disabled: !hasPossibleBulkAction
13693 }
13694 ) }) }),
13695 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13696 column_primary_default,
13697 {
13698 item,
13699 level,
13700 titleField: showTitle ? titleField : void 0,
13701 mediaField: showMedia ? mediaField : void 0,
13702 descriptionField: showDescription ? descriptionField : void 0,
13703 isItemClickable,
13704 onClickItem,
13705 renderItemLink
13706 }
13707 ) }),
13708 columns.map((column) => {
13709 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
13710 const field = fields2.find((f2) => f2.id === column);
13711 const effectiveAlign = getEffectiveAlign(align, field?.type);
13712 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13713 "td",
13714 {
13715 style: {
13716 width,
13717 maxWidth,
13718 minWidth
13719 },
13720 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13721 TableColumnField,
13722 {
13723 fields: fields2,
13724 item,
13725 column,
13726 align: effectiveAlign
13727 }
13728 )
13729 },
13730 column
13731 );
13732 }),
13733 !!actions?.length && // Disable reason: we are not making the element interactive,
13734 // but preventing any click events from bubbling up to the
13735 // table row. This allows us to add a click handler to the row
13736 // itself (to toggle row selection) without erroneously
13737 // intercepting click events from ItemActions.
13738 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13739 "td",
13740 {
13741 className: clsx_default("dataviews-view-table__actions-column", {
13742 "dataviews-view-table__actions-column--sticky": true,
13743 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
13744 }),
13745 onClick: (e2) => e2.stopPropagation(),
13746 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ItemActions, { item, actions })
13747 }
13748 )
13749 ]
13750 }
13751 );
13752 }
13753 function ViewTable({
13754 actions,
13755 data,
13756 fields: fields2,
13757 getItemId,
13758 getItemLevel,
13759 isLoading = false,
13760 onChangeView,
13761 onChangeSelection,
13762 selection,
13763 setOpenedFilter,
13764 onClickItem,
13765 isItemClickable,
13766 renderItemLink,
13767 view,
13768 className,
13769 empty
13770 }) {
13771 const { containerRef } = (0, import_element43.useContext)(dataviews_context_default);
13772 const isDelayedLoading = useDelayedLoading(isLoading);
13773 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
13774 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13775 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
13776 const { getSelectionProps } = useSelectionProps({
13777 data: orderedData,
13778 actions,
13779 getItemId,
13780 selection,
13781 onChangeSelection
13782 });
13783 const headerMenuRefs = (0, import_element43.useRef)(/* @__PURE__ */ new Map());
13784 const headerMenuToFocusRef = (0, import_element43.useRef)(void 0);
13785 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element43.useState)();
13786 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element43.useState)(null);
13787 (0, import_element43.useEffect)(() => {
13788 if (headerMenuToFocusRef.current) {
13789 headerMenuToFocusRef.current.focus();
13790 headerMenuToFocusRef.current = void 0;
13791 }
13792 });
13793 const tableNoticeId = (0, import_element43.useId)();
13794 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
13795 scrollContainerRef: containerRef,
13796 enabledHorizontal: !!actions?.length
13797 });
13798 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
13799 if (nextHeaderMenuToFocus) {
13800 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
13801 setNextHeaderMenuToFocus(void 0);
13802 return;
13803 }
13804 const onHide = (field) => {
13805 const hidden = headerMenuRefs.current.get(field.id);
13806 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
13807 setNextHeaderMenuToFocus(fallback?.node);
13808 };
13809 const handleHeaderContextMenu = (event) => {
13810 event.preventDefault();
13811 event.stopPropagation();
13812 const virtualAnchor = {
13813 getBoundingClientRect: () => ({
13814 x: event.clientX,
13815 y: event.clientY,
13816 top: event.clientY,
13817 left: event.clientX,
13818 right: event.clientX,
13819 bottom: event.clientY,
13820 width: 0,
13821 height: 0,
13822 toJSON: () => ({})
13823 })
13824 };
13825 window.requestAnimationFrame(() => {
13826 setContextMenuAnchor(virtualAnchor);
13827 });
13828 };
13829 const hasData = !!data?.length;
13830 const titleField = fields2.find((field) => field.id === view.titleField);
13831 const mediaField = fields2.find((field) => field.id === view.mediaField);
13832 const descriptionField = fields2.find(
13833 (field) => field.id === view.descriptionField
13834 );
13835 const { showTitle = true, showMedia = true, showDescription = true } = view;
13836 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13837 const columns = view.fields ?? [];
13838 const headerMenuRef = (column, index2) => (node) => {
13839 if (node) {
13840 headerMenuRefs.current.set(column, {
13841 node,
13842 fallback: columns[index2 > 0 ? index2 - 1 : 1]
13843 });
13844 } else {
13845 headerMenuRefs.current.delete(column);
13846 }
13847 };
13848 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13849 const isRtl = (0, import_i18n9.isRTL)();
13850 if (!hasData) {
13851 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13852 "div",
13853 {
13854 className: clsx_default("dataviews-no-results", {
13855 "is-refreshing": isDelayedLoading
13856 }),
13857 id: tableNoticeId,
13858 children: empty
13859 }
13860 );
13861 }
13862 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
13863 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13864 "table",
13865 {
13866 className: clsx_default("dataviews-view-table", className, {
13867 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13868 view.layout.density
13869 ),
13870 "has-bulk-actions": hasBulkActions,
13871 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13872 }),
13873 "aria-busy": isLoading,
13874 "aria-describedby": tableNoticeId,
13875 role: isInfiniteScroll ? "feed" : void 0,
13876 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
13877 children: [
13878 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("colgroup", { children: [
13879 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
13880 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
13881 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13882 "col",
13883 {
13884 className: clsx_default(
13885 `dataviews-view-table__col-${column}`,
13886 {
13887 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
13888 }
13889 )
13890 },
13891 `col-${column}`
13892 )),
13893 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("col", { className: "dataviews-view-table__col-actions" })
13894 ] }),
13895 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13896 import_components8.Popover,
13897 {
13898 anchor: contextMenuAnchor,
13899 onClose: () => setContextMenuAnchor(null),
13900 placement: "bottom-start",
13901 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(PropertiesSection, { showLabel: false })
13902 }
13903 ),
13904 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13905 "thead",
13906 {
13907 className: clsx_default({
13908 "dataviews-view-table__thead--stuck": isVerticallyScrolled
13909 }),
13910 onContextMenu: handleHeaderContextMenu,
13911 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("tr", { className: "dataviews-view-table__row", children: [
13912 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13913 "th",
13914 {
13915 className: "dataviews-view-table__checkbox-column",
13916 scope: "col",
13917 onContextMenu: handleHeaderContextMenu,
13918 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13919 BulkSelectionCheckbox,
13920 {
13921 selection,
13922 onChangeSelection,
13923 data,
13924 actions,
13925 getItemId
13926 }
13927 )
13928 }
13929 ),
13930 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13931 column_header_menu_default,
13932 {
13933 ref: headerMenuRef(
13934 titleField.id,
13935 0
13936 ),
13937 fieldId: titleField.id,
13938 view,
13939 fields: fields2,
13940 onChangeView,
13941 onHide,
13942 setOpenedFilter,
13943 canMove: false,
13944 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
13945 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
13946 }
13947 ) }),
13948 columns.map((column, index2) => {
13949 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
13950 const field = fields2.find(
13951 (f2) => f2.id === column
13952 );
13953 const effectiveAlign = getEffectiveAlign(
13954 align,
13955 field?.type
13956 );
13957 const canInsertOrMove = view.layout?.enableMoving ?? true;
13958 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13959 "th",
13960 {
13961 style: {
13962 width,
13963 maxWidth,
13964 minWidth,
13965 textAlign: effectiveAlign
13966 },
13967 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
13968 scope: "col",
13969 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13970 column_header_menu_default,
13971 {
13972 ref: headerMenuRef(column, index2),
13973 fieldId: column,
13974 view,
13975 fields: fields2,
13976 onChangeView,
13977 onHide,
13978 setOpenedFilter,
13979 canMove: canInsertOrMove,
13980 canInsertLeft: canInsertOrMove,
13981 canInsertRight: canInsertOrMove
13982 }
13983 )
13984 },
13985 column
13986 );
13987 }),
13988 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13989 "th",
13990 {
13991 className: clsx_default(
13992 "dataviews-view-table__actions-column",
13993 {
13994 "dataviews-view-table__actions-column--sticky": true,
13995 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
13996 }
13997 ),
13998 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
13999 }
14000 )
14001 ] })
14002 }
14003 ),
14004 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14005 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("tbody", { children: [
14006 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14007 "td",
14008 {
14009 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
14010 className: "dataviews-view-table__group-header-cell",
14011 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
14012 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14013 (0, import_i18n9.__)("%1$s: %2$s"),
14014 groupField.label,
14015 groupName
14016 )
14017 }
14018 ) }),
14019 groupItems.map((item, index2) => {
14020 const id = getItemId(item) || index2.toString();
14021 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14022 TableRow,
14023 {
14024 item,
14025 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14026 hasBulkActions,
14027 actions,
14028 fields: fields2,
14029 id,
14030 view,
14031 titleField,
14032 mediaField,
14033 descriptionField,
14034 selection,
14035 getItemId,
14036 onChangeSelection,
14037 ...getSelectionProps(id),
14038 onClickItem,
14039 renderItemLink,
14040 isItemClickable,
14041 isActionsColumnSticky: !isHorizontalScrollEnd
14042 },
14043 getItemId(item)
14044 );
14045 })
14046 ] }, `group-${groupName}`)
14047 ) : /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("tbody", { children: hasData && data.map((item, index2) => {
14048 const id = getItemId(item) || index2.toString();
14049 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14050 TableRow,
14051 {
14052 item,
14053 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14054 hasBulkActions,
14055 actions,
14056 fields: fields2,
14057 id,
14058 view,
14059 titleField,
14060 mediaField,
14061 descriptionField,
14062 selection,
14063 getItemId,
14064 onChangeSelection,
14065 ...getSelectionProps(id),
14066 onClickItem,
14067 renderItemLink,
14068 isItemClickable,
14069 isActionsColumnSticky: !isHorizontalScrollEnd,
14070 posinset: isInfiniteScroll ? index2 + 1 : void 0
14071 },
14072 getItemId(item)
14073 );
14074 }) })
14075 ]
14076 }
14077 ),
14078 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_components8.Spinner, {}) }) })
14079 ] });
14080 }
14081 var table_default = ViewTable;
14082
14083 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
14084 var import_components11 = __toESM(require_components(), 1);
14085 var import_i18n12 = __toESM(require_i18n(), 1);
14086
14087 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14088 var import_components10 = __toESM(require_components(), 1);
14089 var import_i18n11 = __toESM(require_i18n(), 1);
14090 var import_compose3 = __toESM(require_compose(), 1);
14091 var import_element47 = __toESM(require_element(), 1);
14092
14093 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
14094 var import_components9 = __toESM(require_components(), 1);
14095 var import_i18n10 = __toESM(require_i18n(), 1);
14096 var import_element44 = __toESM(require_element(), 1);
14097 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14098 var imageSizes = [
14099 {
14100 value: 120,
14101 breakpoint: 1
14102 },
14103 {
14104 value: 170,
14105 breakpoint: 1
14106 },
14107 {
14108 value: 230,
14109 breakpoint: 1
14110 },
14111 {
14112 value: 290,
14113 breakpoint: 1112
14114 // at minimum image width, 4 images display at this container size
14115 },
14116 {
14117 value: 350,
14118 breakpoint: 1636
14119 // at minimum image width, 6 images display at this container size
14120 },
14121 {
14122 value: 430,
14123 breakpoint: 588
14124 // at minimum image width, 2 images display at this container size
14125 }
14126 ];
14127 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
14128 function useGridColumns() {
14129 const context = (0, import_element44.useContext)(dataviews_context_default);
14130 const view = context.view;
14131 return (0, import_element44.useMemo)(() => {
14132 const containerWidth = context.containerWidth;
14133 const gap = 32;
14134 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
14135 const columns = Math.floor(
14136 (containerWidth + gap) / (previewSize + gap)
14137 );
14138 return Math.max(1, columns);
14139 }, [context.containerWidth, view.layout?.previewSize]);
14140 }
14141
14142 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
14143 var import_element45 = __toESM(require_element(), 1);
14144 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14145 var GridItems = (0, import_element45.forwardRef)(({ className, previewSize, ...props }, ref) => {
14146 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14147 "div",
14148 {
14149 ref,
14150 className: clsx_default("dataviews-view-grid-items", className),
14151 style: {
14152 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
14153 },
14154 ...props
14155 }
14156 );
14157 });
14158
14159 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
14160 var import_element46 = __toESM(require_element(), 1);
14161 function useIntersectionObserver(elementRef, posinset) {
14162 const { intersectionObserver } = (0, import_element46.useContext)(dataviews_context_default);
14163 (0, import_element46.useEffect)(() => {
14164 const element = elementRef.current;
14165 if (!element || posinset === void 0 || !intersectionObserver) {
14166 return;
14167 }
14168 intersectionObserver.observe(element);
14169 return () => {
14170 intersectionObserver.unobserve(element);
14171 };
14172 }, [elementRef, intersectionObserver, posinset]);
14173 }
14174 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
14175 const hasData = !!data?.length;
14176 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
14177 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
14178 }
14179
14180 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14181 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14182 var { Badge: WCBadge } = unlock2(import_components10.privateApis);
14183 function chunk(array, size4) {
14184 const chunks = [];
14185 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
14186 chunks.push(array.slice(i2, i2 + size4));
14187 }
14188 return chunks;
14189 }
14190 var GridItem = (0, import_element47.forwardRef)(
14191 function GridItem2({
14192 view,
14193 selection,
14194 onChangeSelection,
14195 onClickItem,
14196 isItemClickable,
14197 renderItemLink,
14198 getItemId,
14199 item,
14200 actions,
14201 mediaField,
14202 titleField,
14203 descriptionField,
14204 regularFields,
14205 badgeFields,
14206 hasBulkActions,
14207 config,
14208 posinset,
14209 setsize,
14210 ...props
14211 }, forwardedRef) {
14212 const {
14213 showTitle = true,
14214 showMedia = true,
14215 showDescription = true
14216 } = view;
14217 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
14218 const id = getItemId(item);
14219 const elementRef = (0, import_element47.useRef)(null);
14220 const setRefs = (0, import_element47.useCallback)(
14221 (node) => {
14222 elementRef.current = node;
14223 if (typeof forwardedRef === "function") {
14224 forwardedRef(node);
14225 } else if (forwardedRef) {
14226 forwardedRef.current = node;
14227 }
14228 },
14229 [forwardedRef]
14230 );
14231 useIntersectionObserver(elementRef, posinset);
14232 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
14233 const isSelected2 = selection.includes(id);
14234 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
14235 const rendersMediaField = showMedia && mediaField?.render;
14236 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14237 mediaField.render,
14238 {
14239 item,
14240 field: mediaField,
14241 config
14242 }
14243 ) : mediaPlaceholder;
14244 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(titleField.render, { item, field: titleField }) : null;
14245 let mediaA11yProps;
14246 let titleA11yProps;
14247 if (isItemClickable(item) && onClickItem) {
14248 if (renderedTitleField) {
14249 mediaA11yProps = {
14250 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
14251 };
14252 titleA11yProps = {
14253 id: `dataviews-view-grid__title-field-${instanceId}`
14254 };
14255 } else {
14256 mediaA11yProps = {
14257 "aria-label": (0, import_i18n11.__)("Navigate to item")
14258 };
14259 }
14260 }
14261 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14262 Stack,
14263 {
14264 direction: "column",
14265 ...props,
14266 ref: setRefs,
14267 "aria-setsize": setsize,
14268 "aria-posinset": posinset,
14269 className: clsx_default(
14270 props.className,
14271 "dataviews-view-grid__row__gridcell",
14272 "dataviews-view-grid__card",
14273 {
14274 "is-selected": hasBulkAction && isSelected2
14275 }
14276 ),
14277 children: [
14278 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14279 ItemClickWrapper,
14280 {
14281 item,
14282 isItemClickable,
14283 onClickItem,
14284 renderItemLink,
14285 className: clsx_default("dataviews-view-grid__media", {
14286 "dataviews-view-grid__media--placeholder": !rendersMediaField
14287 }),
14288 ...mediaA11yProps,
14289 children: renderedMediaField
14290 }
14291 ),
14292 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14293 DataViewsSelectionCheckbox,
14294 {
14295 item,
14296 selection,
14297 onChangeSelection,
14298 getItemId,
14299 titleField,
14300 disabled: !hasBulkAction
14301 }
14302 ),
14303 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14304 ItemActions,
14305 {
14306 item,
14307 actions,
14308 isCompact: true
14309 }
14310 ) }),
14311 showTitle && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14312 ItemClickWrapper,
14313 {
14314 item,
14315 isItemClickable,
14316 onClickItem,
14317 renderItemLink,
14318 className: "dataviews-view-grid__title-field dataviews-title-field",
14319 ...titleA11yProps,
14320 title: titleField?.getValueFormatted({
14321 item,
14322 field: titleField
14323 }) || void 0,
14324 children: renderedTitleField
14325 }
14326 ) }),
14327 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14328 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14329 descriptionField.render,
14330 {
14331 item,
14332 field: descriptionField
14333 }
14334 ),
14335 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14336 Stack,
14337 {
14338 direction: "row",
14339 className: "dataviews-view-grid__badge-fields",
14340 gap: "sm",
14341 wrap: "wrap",
14342 align: "top",
14343 justify: "flex-start",
14344 children: badgeFields.map((field) => {
14345 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14346 WCBadge,
14347 {
14348 className: "dataviews-view-grid__field-value",
14349 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14350 field.render,
14351 {
14352 item,
14353 field
14354 }
14355 )
14356 },
14357 field.id
14358 );
14359 })
14360 }
14361 ),
14362 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14363 Stack,
14364 {
14365 direction: "column",
14366 className: "dataviews-view-grid__fields",
14367 gap: "xs",
14368 children: regularFields.map((field) => {
14369 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14370 import_components10.Flex,
14371 {
14372 className: "dataviews-view-grid__field",
14373 gap: 1,
14374 justify: "flex-start",
14375 expanded: true,
14376 style: { height: "auto" },
14377 direction: "row",
14378 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14379 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(tooltip_exports.Root, { children: [
14380 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14381 tooltip_exports.Trigger,
14382 {
14383 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
14384 }
14385 ),
14386 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(tooltip_exports.Popup, { children: field.label })
14387 ] }),
14388 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14389 import_components10.FlexItem,
14390 {
14391 className: "dataviews-view-grid__field-value",
14392 style: { maxHeight: "none" },
14393 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14394 field.render,
14395 {
14396 item,
14397 field
14398 }
14399 )
14400 }
14401 )
14402 ] })
14403 },
14404 field.id
14405 );
14406 })
14407 }
14408 )
14409 ] })
14410 ]
14411 }
14412 );
14413 }
14414 );
14415 function CompositeGrid({
14416 data,
14417 isInfiniteScroll,
14418 className,
14419 inert,
14420 isLoading,
14421 view,
14422 fields: fields2,
14423 selection,
14424 onChangeSelection,
14425 onClickItem,
14426 isItemClickable,
14427 renderItemLink,
14428 getItemId,
14429 actions,
14430 getSelectionProps
14431 }) {
14432 const { paginationInfo, resizeObserverRef } = (0, import_element47.useContext)(dataviews_context_default);
14433 const gridColumns = useGridColumns();
14434 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
14435 const titleField = fields2.find(
14436 (field) => field.id === view?.titleField
14437 );
14438 const mediaField = fields2.find(
14439 (field) => field.id === view?.mediaField
14440 );
14441 const descriptionField = fields2.find(
14442 (field) => field.id === view?.descriptionField
14443 );
14444 const otherFields = view.fields ?? [];
14445 const { regularFields, badgeFields } = otherFields.reduce(
14446 (accumulator, fieldId) => {
14447 const field = fields2.find((f2) => f2.id === fieldId);
14448 if (!field) {
14449 return accumulator;
14450 }
14451 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14452 accumulator[key].push(field);
14453 return accumulator;
14454 },
14455 { regularFields: [], badgeFields: [] }
14456 );
14457 const size4 = "900px";
14458 const totalRows = Math.ceil(data.length / gridColumns);
14459 const placeholdersNeeded = usePlaceholdersNeeded(
14460 data,
14461 isInfiniteScroll,
14462 gridColumns
14463 );
14464 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, {
14465 // Render infinite scroll layout (no rows, feed semantics)
14466 children: [
14467 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14468 import_components10.Composite,
14469 {
14470 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14471 GridItems,
14472 {
14473 className: clsx_default(
14474 "dataviews-view-grid-infinite-scroll",
14475 className,
14476 {
14477 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14478 "compact",
14479 "comfortable"
14480 ].includes(view.layout.density)
14481 }
14482 ),
14483 previewSize: view.layout?.previewSize,
14484 "aria-busy": isLoading,
14485 ref: resizeObserverRef
14486 }
14487 ),
14488 role: "feed",
14489 focusWrap: true,
14490 inert,
14491 children: [
14492 Array.from({ length: placeholdersNeeded }).map(
14493 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14494 import_components10.Composite.Item,
14495 {
14496 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14497 Stack,
14498 {
14499 ...props,
14500 direction: "column",
14501 role: "article",
14502 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
14503 }
14504 ),
14505 "aria-hidden": true,
14506 tabIndex: -1
14507 },
14508 `placeholder-${index2}`
14509 )
14510 ),
14511 data.map((item) => {
14512 const itemId = getItemId(item);
14513 const selectionProps = getSelectionProps(itemId);
14514 const stablePosition = item.position;
14515 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14516 import_components10.Composite.Item,
14517 {
14518 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14519 GridItem,
14520 {
14521 ...props,
14522 id: itemId,
14523 role: "article",
14524 view,
14525 selection,
14526 onChangeSelection,
14527 onClickItem,
14528 isItemClickable,
14529 renderItemLink,
14530 getItemId,
14531 item,
14532 actions,
14533 onMouseDown: (event) => {
14534 props.onMouseDown?.(event);
14535 selectionProps.onMouseDown(
14536 event
14537 );
14538 },
14539 onClickCapture: (event) => {
14540 props.onClickCapture?.(event);
14541 selectionProps.onClickCapture(
14542 event
14543 );
14544 },
14545 mediaField,
14546 titleField,
14547 descriptionField,
14548 regularFields,
14549 badgeFields,
14550 hasBulkActions,
14551 posinset: stablePosition,
14552 setsize: paginationInfo.totalItems,
14553 config: {
14554 sizes: size4
14555 }
14556 }
14557 )
14558 },
14559 itemId
14560 );
14561 })
14562 ]
14563 }
14564 ),
14565 // Render standard grid layout (with rows, grid semantics)
14566 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14567 import_components10.Composite,
14568 {
14569 role: "grid",
14570 className: clsx_default("dataviews-view-grid", className, {
14571 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14572 view.layout.density
14573 )
14574 }),
14575 focusWrap: true,
14576 "aria-busy": isLoading,
14577 "aria-rowcount": totalRows,
14578 ref: resizeObserverRef,
14579 inert,
14580 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14581 import_components10.Composite.Row,
14582 {
14583 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14584 "div",
14585 {
14586 role: "row",
14587 "aria-rowindex": i2 + 1,
14588 "aria-label": (0, import_i18n11.sprintf)(
14589 /* translators: %d: The row number in the grid */
14590 (0, import_i18n11.__)("Row %d"),
14591 i2 + 1
14592 ),
14593 className: "dataviews-view-grid__row",
14594 style: {
14595 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
14596 }
14597 }
14598 ),
14599 children: row.map((item) => {
14600 const itemId = getItemId(item);
14601 const selectionProps = getSelectionProps(itemId);
14602 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14603 import_components10.Composite.Item,
14604 {
14605 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14606 GridItem,
14607 {
14608 ...props,
14609 id: itemId,
14610 role: "gridcell",
14611 view,
14612 selection,
14613 onChangeSelection,
14614 onClickItem,
14615 isItemClickable,
14616 renderItemLink,
14617 getItemId,
14618 item,
14619 actions,
14620 onMouseDown: (event) => {
14621 props.onMouseDown?.(
14622 event
14623 );
14624 selectionProps.onMouseDown(
14625 event
14626 );
14627 },
14628 onClickCapture: (event) => {
14629 props.onClickCapture?.(
14630 event
14631 );
14632 selectionProps.onClickCapture(
14633 event
14634 );
14635 },
14636 mediaField,
14637 titleField,
14638 descriptionField,
14639 regularFields,
14640 badgeFields,
14641 hasBulkActions,
14642 config: {
14643 sizes: size4
14644 }
14645 }
14646 )
14647 },
14648 itemId
14649 );
14650 })
14651 },
14652 i2
14653 ))
14654 }
14655 )
14656 ]
14657 });
14658 }
14659
14660 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
14661 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14662 function ViewGrid({
14663 actions,
14664 data,
14665 fields: fields2,
14666 getItemId,
14667 isLoading,
14668 onChangeSelection,
14669 onClickItem,
14670 isItemClickable,
14671 renderItemLink,
14672 selection,
14673 view,
14674 className,
14675 empty
14676 }) {
14677 const isDelayedLoading = useDelayedLoading(!!isLoading);
14678 const hasData = !!data?.length;
14679 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
14680 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14681 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14682 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14683 const { getSelectionProps } = useSelectionProps({
14684 data: orderedData,
14685 actions,
14686 getItemId,
14687 selection,
14688 onChangeSelection
14689 });
14690 if (!hasData) {
14691 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14692 "div",
14693 {
14694 className: clsx_default("dataviews-no-results", {
14695 "is-refreshing": isDelayedLoading
14696 }),
14697 children: empty
14698 }
14699 );
14700 }
14701 const gridProps = {
14702 className: clsx_default(className, {
14703 "is-refreshing": !isInfiniteScroll && isDelayedLoading
14704 }),
14705 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
14706 isLoading,
14707 view,
14708 fields: fields2,
14709 selection,
14710 onChangeSelection,
14711 onClickItem,
14712 isItemClickable,
14713 renderItemLink,
14714 getItemId,
14715 actions,
14716 getSelectionProps
14717 };
14718 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, {
14719 // Render multiple groups.
14720 children: [
14721 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
14722 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14723 Stack,
14724 {
14725 direction: "column",
14726 gap: "sm",
14727 children: [
14728 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
14729 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14730 (0, import_i18n12.__)("%1$s: %2$s"),
14731 groupField.label,
14732 groupName
14733 ) }),
14734 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14735 CompositeGrid,
14736 {
14737 ...gridProps,
14738 data: groupItems,
14739 isInfiniteScroll: false
14740 }
14741 )
14742 ]
14743 },
14744 groupName
14745 )
14746 ) }),
14747 // Render a single grid with all data.
14748 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14749 CompositeGrid,
14750 {
14751 ...gridProps,
14752 data,
14753 isInfiniteScroll: !!isInfiniteScroll
14754 }
14755 ),
14756 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components11.Spinner, {}) })
14757 ]
14758 });
14759 }
14760 var grid_default = ViewGrid;
14761
14762 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
14763 var import_compose4 = __toESM(require_compose(), 1);
14764 var import_components12 = __toESM(require_components(), 1);
14765 var import_element48 = __toESM(require_element(), 1);
14766 var import_i18n13 = __toESM(require_i18n(), 1);
14767 var import_data3 = __toESM(require_data(), 1);
14768 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14769 var { Menu: Menu3 } = unlock2(import_components12.privateApis);
14770 function generateItemWrapperCompositeId(idPrefix) {
14771 return `${idPrefix}-item-wrapper`;
14772 }
14773 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
14774 return `${idPrefix}-primary-action-${primaryActionId}`;
14775 }
14776 function generateDropdownTriggerCompositeId(idPrefix) {
14777 return `${idPrefix}-dropdown`;
14778 }
14779 function PrimaryActionGridCell({
14780 idPrefix,
14781 primaryAction,
14782 item
14783 }) {
14784 const registry = (0, import_data3.useRegistry)();
14785 const [isModalOpen, setIsModalOpen] = (0, import_element48.useState)(false);
14786 const compositeItemId = generatePrimaryActionCompositeId(
14787 idPrefix,
14788 primaryAction.id
14789 );
14790 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
14791 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14792 import_components12.Composite.Item,
14793 {
14794 id: compositeItemId,
14795 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14796 import_components12.Button,
14797 {
14798 disabled: !!primaryAction.disabled,
14799 accessibleWhenDisabled: true,
14800 text: label,
14801 size: "small",
14802 onClick: () => setIsModalOpen(true)
14803 }
14804 ),
14805 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14806 ActionModal,
14807 {
14808 action: primaryAction,
14809 items: [item],
14810 closeModal: () => setIsModalOpen(false)
14811 }
14812 )
14813 }
14814 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14815 import_components12.Composite.Item,
14816 {
14817 id: compositeItemId,
14818 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14819 import_components12.Button,
14820 {
14821 disabled: !!primaryAction.disabled,
14822 accessibleWhenDisabled: true,
14823 size: "small",
14824 onClick: () => {
14825 primaryAction.callback([item], { registry });
14826 },
14827 children: label
14828 }
14829 )
14830 }
14831 ) }, primaryAction.id);
14832 }
14833 function ListItem({
14834 view,
14835 actions,
14836 idPrefix,
14837 isSelected: isSelected2,
14838 item,
14839 titleField,
14840 mediaField,
14841 descriptionField,
14842 onSelect,
14843 otherFields,
14844 onDropdownTriggerKeyDown,
14845 posinset
14846 }) {
14847 const {
14848 showTitle = true,
14849 showMedia = true,
14850 showDescription = true,
14851 infiniteScrollEnabled
14852 } = view;
14853 const itemRef = (0, import_element48.useRef)(null);
14854 const labelId = `${idPrefix}-label`;
14855 const descriptionId = `${idPrefix}-description`;
14856 const registry = (0, import_data3.useRegistry)();
14857 const [isHovered, setIsHovered] = (0, import_element48.useState)(false);
14858 const [activeModalAction, setActiveModalAction] = (0, import_element48.useState)(
14859 null
14860 );
14861 const handleHover = ({ type }) => {
14862 const isHover = type === "mouseenter";
14863 setIsHovered(isHover);
14864 };
14865 const { paginationInfo } = (0, import_element48.useContext)(dataviews_context_default);
14866 (0, import_element48.useEffect)(() => {
14867 if (isSelected2) {
14868 itemRef.current?.scrollIntoView({
14869 behavior: "auto",
14870 block: "nearest",
14871 inline: "nearest"
14872 });
14873 }
14874 }, [isSelected2]);
14875 const { primaryAction, eligibleActions } = (0, import_element48.useMemo)(() => {
14876 const _eligibleActions = actions.filter(
14877 (action) => !action.isEligible || action.isEligible(item)
14878 );
14879 const _primaryActions = _eligibleActions.filter(
14880 (action) => action.isPrimary
14881 );
14882 return {
14883 primaryAction: _primaryActions[0],
14884 eligibleActions: _eligibleActions
14885 };
14886 }, [actions, item]);
14887 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
14888 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14889 mediaField.render,
14890 {
14891 item,
14892 field: mediaField,
14893 config: { sizes: "52px" }
14894 }
14895 ) }) : null;
14896 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(titleField.render, { item, field: titleField }) : null;
14897 const renderDescription = showDescription && descriptionField?.render;
14898 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
14899 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
14900 Stack,
14901 {
14902 direction: "row",
14903 gap: "md",
14904 className: "dataviews-view-list__item-actions",
14905 children: [
14906 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14907 PrimaryActionGridCell,
14908 {
14909 idPrefix,
14910 primaryAction,
14911 item
14912 }
14913 ),
14914 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { role: "gridcell", children: [
14915 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(Menu3, { placement: "bottom-end", children: [
14916 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14917 Menu3.TriggerButton,
14918 {
14919 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14920 import_components12.Composite.Item,
14921 {
14922 id: generateDropdownTriggerCompositeId(
14923 idPrefix
14924 ),
14925 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14926 import_components12.Button,
14927 {
14928 size: "small",
14929 icon: more_vertical_default,
14930 label: (0, import_i18n13.__)("Actions"),
14931 accessibleWhenDisabled: true,
14932 disabled: !actions.length,
14933 onKeyDown: onDropdownTriggerKeyDown
14934 }
14935 )
14936 }
14937 )
14938 }
14939 ),
14940 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14941 ActionsMenuGroup,
14942 {
14943 actions: eligibleActions,
14944 item,
14945 registry,
14946 setActiveModalAction
14947 }
14948 ) })
14949 ] }),
14950 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14951 ActionModal,
14952 {
14953 action: activeModalAction,
14954 items: [item],
14955 closeModal: () => setActiveModalAction(null)
14956 }
14957 )
14958 ] })
14959 ]
14960 }
14961 );
14962 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14963 import_components12.Composite.Row,
14964 {
14965 ref: itemRef,
14966 render: (
14967 /* aria-posinset breaks Composite.Row if passed to it directly. */
14968 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14969 "div",
14970 {
14971 "aria-posinset": posinset,
14972 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
14973 }
14974 )
14975 ),
14976 role: infiniteScrollEnabled ? "article" : "row",
14977 className: clsx_default({
14978 "is-selected": isSelected2,
14979 "is-hovered": isHovered
14980 }),
14981 onMouseEnter: handleHover,
14982 onMouseLeave: handleHover,
14983 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
14984 Stack,
14985 {
14986 direction: "row",
14987 className: "dataviews-view-list__item-wrapper",
14988 children: [
14989 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14990 import_components12.Composite.Item,
14991 {
14992 id: generateItemWrapperCompositeId(idPrefix),
14993 "aria-pressed": isSelected2,
14994 "aria-labelledby": labelId,
14995 "aria-describedby": descriptionId,
14996 className: "dataviews-view-list__item",
14997 onClick: () => onSelect(item)
14998 }
14999 ) }),
15000 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15001 Stack,
15002 {
15003 direction: "row",
15004 gap: "md",
15005 justify: "start",
15006 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
15007 style: { flex: 1, minWidth: 0 },
15008 children: [
15009 renderedMediaField,
15010 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15011 Stack,
15012 {
15013 direction: "column",
15014 gap: "xs",
15015 className: "dataviews-view-list__field-wrapper",
15016 children: [
15017 /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(Stack, { direction: "row", align: "center", children: [
15018 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15019 "div",
15020 {
15021 className: "dataviews-title-field dataviews-view-list__title-field",
15022 id: labelId,
15023 children: renderedTitleField
15024 }
15025 ),
15026 usedActions
15027 ] }),
15028 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15029 descriptionField.render,
15030 {
15031 item,
15032 field: descriptionField
15033 }
15034 ) }),
15035 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15036 "div",
15037 {
15038 className: "dataviews-view-list__fields",
15039 id: descriptionId,
15040 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15041 "div",
15042 {
15043 className: "dataviews-view-list__field",
15044 children: [
15045 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15046 VisuallyHidden,
15047 {
15048 className: "dataviews-view-list__field-label",
15049 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", {}),
15050 children: field.label
15051 }
15052 ),
15053 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15054 field.render,
15055 {
15056 item,
15057 field
15058 }
15059 ) })
15060 ]
15061 },
15062 field.id
15063 ))
15064 }
15065 )
15066 ]
15067 }
15068 )
15069 ]
15070 }
15071 )
15072 ]
15073 }
15074 )
15075 }
15076 );
15077 }
15078 function isDefined2(item) {
15079 return !!item;
15080 }
15081 function ViewList(props) {
15082 const {
15083 actions,
15084 data,
15085 fields: fields2,
15086 getItemId,
15087 isLoading,
15088 onChangeSelection,
15089 selection,
15090 view,
15091 className,
15092 empty
15093 } = props;
15094 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
15095 const isDelayedLoading = useDelayedLoading(!!isLoading);
15096 const { paginationInfo } = (0, import_element48.useContext)(dataviews_context_default);
15097 const selectedItem = data?.findLast(
15098 (item) => selection.includes(getItemId(item))
15099 );
15100 const titleField = fields2.find((field) => field.id === view.titleField);
15101 const mediaField = fields2.find((field) => field.id === view.mediaField);
15102 const descriptionField = fields2.find(
15103 (field) => field.id === view.descriptionField
15104 );
15105 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2);
15106 const onSelect = (item) => onChangeSelection([getItemId(item)]);
15107 const generateCompositeItemIdPrefix = (0, import_element48.useCallback)(
15108 (item) => `${baseId}-${getItemId(item)}`,
15109 [baseId, getItemId]
15110 );
15111 const isActiveCompositeItem = (0, import_element48.useCallback)(
15112 (item, idToCheck) => {
15113 return idToCheck.startsWith(
15114 generateCompositeItemIdPrefix(item)
15115 );
15116 },
15117 [generateCompositeItemIdPrefix]
15118 );
15119 const [activeCompositeId, setActiveCompositeId] = (0, import_element48.useState)(void 0);
15120 const compositeRef = (0, import_element48.useRef)(null);
15121 (0, import_element48.useEffect)(() => {
15122 if (selectedItem) {
15123 setActiveCompositeId(
15124 generateItemWrapperCompositeId(
15125 generateCompositeItemIdPrefix(selectedItem)
15126 )
15127 );
15128 }
15129 }, [selectedItem, generateCompositeItemIdPrefix]);
15130 const activeItemIndex = data.findIndex(
15131 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
15132 );
15133 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
15134 const isActiveIdInList = activeItemIndex !== -1;
15135 const selectCompositeItem = (0, import_element48.useCallback)(
15136 (targetIndex, generateCompositeId) => {
15137 const clampedIndex = Math.min(
15138 data.length - 1,
15139 Math.max(0, targetIndex)
15140 );
15141 if (!data[clampedIndex]) {
15142 return;
15143 }
15144 const itemIdPrefix = generateCompositeItemIdPrefix(
15145 data[clampedIndex]
15146 );
15147 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
15148 setActiveCompositeId(targetCompositeItemId);
15149 if (compositeRef.current?.contains(
15150 compositeRef.current.ownerDocument.activeElement
15151 )) {
15152 document.getElementById(targetCompositeItemId)?.focus();
15153 }
15154 },
15155 [data, generateCompositeItemIdPrefix]
15156 );
15157 (0, import_element48.useEffect)(() => {
15158 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
15159 if (!isActiveIdInList && wasActiveIdInList) {
15160 selectCompositeItem(
15161 previousActiveItemIndex,
15162 generateItemWrapperCompositeId
15163 );
15164 }
15165 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
15166 const onDropdownTriggerKeyDown = (0, import_element48.useCallback)(
15167 (event) => {
15168 if (event.key === "ArrowDown") {
15169 event.preventDefault();
15170 selectCompositeItem(
15171 activeItemIndex + 1,
15172 generateDropdownTriggerCompositeId
15173 );
15174 }
15175 if (event.key === "ArrowUp") {
15176 event.preventDefault();
15177 selectCompositeItem(
15178 activeItemIndex - 1,
15179 generateDropdownTriggerCompositeId
15180 );
15181 }
15182 },
15183 [selectCompositeItem, activeItemIndex]
15184 );
15185 const hasData = !!data?.length;
15186 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
15187 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
15188 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15189 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
15190 const listClassName = clsx_default("dataviews-view-list", className, {
15191 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
15192 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15193 });
15194 const compositeProps = {
15195 ref: compositeRef,
15196 id: baseId,
15197 render: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", {}),
15198 activeId: activeCompositeId,
15199 setActiveId: setActiveCompositeId,
15200 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
15201 };
15202 if (!hasData) {
15203 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15204 "div",
15205 {
15206 className: clsx_default("dataviews-no-results", {
15207 "is-refreshing": isDelayedLoading
15208 }),
15209 children: empty
15210 }
15211 );
15212 }
15213 if (hasData && groupField && dataByGroup) {
15214 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15215 import_components12.Composite,
15216 {
15217 ...compositeProps,
15218 className: "dataviews-view-list__group",
15219 role: "grid",
15220 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
15221 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(Stack, { direction: "column", children: [
15222 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
15223 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15224 (0, import_i18n13.__)("%1$s: %2$s"),
15225 groupField.label,
15226 groupName
15227 ) }),
15228 groupItems.map((item) => {
15229 const id = generateCompositeItemIdPrefix(item);
15230 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15231 ListItem,
15232 {
15233 view,
15234 idPrefix: id,
15235 actions,
15236 item,
15237 isSelected: item === selectedItem,
15238 onSelect,
15239 mediaField,
15240 titleField,
15241 descriptionField,
15242 otherFields,
15243 onDropdownTriggerKeyDown
15244 },
15245 id
15246 );
15247 })
15248 ] }, groupName)
15249 ) })
15250 }
15251 );
15252 }
15253 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
15254 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15255 import_components12.Composite,
15256 {
15257 ...compositeProps,
15258 className: listClassName,
15259 role: view.infiniteScrollEnabled ? "feed" : "grid",
15260 children: data.map((item, index2) => {
15261 const id = generateCompositeItemIdPrefix(item);
15262 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15263 ListItem,
15264 {
15265 view,
15266 idPrefix: id,
15267 actions,
15268 item,
15269 isSelected: item === selectedItem,
15270 onSelect,
15271 mediaField,
15272 titleField,
15273 descriptionField,
15274 otherFields,
15275 onDropdownTriggerKeyDown,
15276 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
15277 },
15278 id
15279 );
15280 })
15281 }
15282 ),
15283 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
15284 // scroll position doesn't bounce. Hidden, and silent to a11y,
15285 // while idle.
15286 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15287 "p",
15288 {
15289 className: "dataviews-loading-more",
15290 "aria-hidden": !isLoading,
15291 children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components12.Spinner, {})
15292 }
15293 )
15294 ] });
15295 }
15296
15297 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
15298 var import_components13 = __toESM(require_components(), 1);
15299
15300 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
15301 var import_i18n14 = __toESM(require_i18n(), 1);
15302 var import_element49 = __toESM(require_element(), 1);
15303 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15304 function ActivityGroup({
15305 groupName,
15306 groupData,
15307 groupField,
15308 showLabel = true,
15309 children
15310 }) {
15311 const groupHeader = showLabel ? (0, import_element49.createInterpolateElement)(
15312 // translators: %s: The label of the field e.g. "Status".
15313 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
15314 {
15315 groupName: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15316 groupField.render,
15317 {
15318 item: groupData[0],
15319 field: groupField
15320 }
15321 )
15322 }
15323 ) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(groupField.render, { item: groupData[0], field: groupField });
15324 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
15325 Stack,
15326 {
15327 direction: "column",
15328 className: "dataviews-view-activity__group",
15329 children: [
15330 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
15331 children
15332 ]
15333 },
15334 groupName
15335 );
15336 }
15337
15338 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
15339 var import_element50 = __toESM(require_element(), 1);
15340 var import_data4 = __toESM(require_data(), 1);
15341 var import_compose5 = __toESM(require_compose(), 1);
15342 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15343 function ActivityItem(props) {
15344 const {
15345 view,
15346 actions,
15347 item,
15348 titleField,
15349 mediaField,
15350 descriptionField,
15351 otherFields,
15352 posinset,
15353 onClickItem,
15354 renderItemLink,
15355 isItemClickable
15356 } = props;
15357 const {
15358 showTitle = true,
15359 showMedia = true,
15360 showDescription = true,
15361 infiniteScrollEnabled
15362 } = view;
15363 const itemRef = (0, import_element50.useRef)(null);
15364 const registry = (0, import_data4.useRegistry)();
15365 const { paginationInfo } = (0, import_element50.useContext)(dataviews_context_default);
15366 const { primaryActions, eligibleActions } = (0, import_element50.useMemo)(() => {
15367 const _eligibleActions = actions.filter(
15368 (action) => !action.isEligible || action.isEligible(item)
15369 );
15370 const _primaryActions = _eligibleActions.filter(
15371 (action) => action.isPrimary
15372 );
15373 return {
15374 primaryActions: _primaryActions,
15375 eligibleActions: _eligibleActions
15376 };
15377 }, [actions, item]);
15378 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
15379 const density = view.layout?.density ?? "balanced";
15380 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15381 mediaField.render,
15382 {
15383 item,
15384 field: mediaField,
15385 config: {
15386 sizes: density === "comfortable" ? "32px" : "24px"
15387 }
15388 }
15389 ) : null;
15390 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15391 "span",
15392 {
15393 className: "dataviews-view-activity__item-bullet",
15394 "aria-hidden": "true"
15395 }
15396 ) });
15397 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(titleField.render, { item, field: titleField }) : null;
15398 const verticalGap = (0, import_element50.useMemo)(() => {
15399 switch (density) {
15400 case "comfortable":
15401 return "md";
15402 default:
15403 return "sm";
15404 }
15405 }, [density]);
15406 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15407 "div",
15408 {
15409 ref: itemRef,
15410 role: infiniteScrollEnabled ? "article" : void 0,
15411 "aria-posinset": posinset,
15412 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
15413 className: clsx_default(
15414 "dataviews-view-activity__item",
15415 density === "compact" && "is-compact",
15416 density === "balanced" && "is-balanced",
15417 density === "comfortable" && "is-comfortable"
15418 ),
15419 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15420 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15421 Stack,
15422 {
15423 direction: "column",
15424 gap: "xs",
15425 align: "center",
15426 className: "dataviews-view-activity__item-type",
15427 children: renderedMediaField
15428 }
15429 ),
15430 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
15431 Stack,
15432 {
15433 direction: "column",
15434 gap: verticalGap,
15435 align: "flex-start",
15436 className: "dataviews-view-activity__item-content",
15437 children: [
15438 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15439 ItemClickWrapper,
15440 {
15441 item,
15442 isItemClickable,
15443 onClickItem,
15444 renderItemLink,
15445 className: "dataviews-view-activity__item-title",
15446 children: renderedTitleField
15447 }
15448 ),
15449 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15450 descriptionField.render,
15451 {
15452 item,
15453 field: descriptionField
15454 }
15455 ) }),
15456 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
15457 "div",
15458 {
15459 className: "dataviews-view-activity__item-field",
15460 children: [
15461 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15462 VisuallyHidden,
15463 {
15464 className: "dataviews-view-activity__item-field-label",
15465 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", {}),
15466 children: field.label
15467 }
15468 ),
15469 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15470 field.render,
15471 {
15472 item,
15473 field
15474 }
15475 ) })
15476 ]
15477 },
15478 field.id
15479 )) }),
15480 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15481 PrimaryActions,
15482 {
15483 item,
15484 actions: primaryActions,
15485 registry,
15486 buttonVariant: "secondary"
15487 }
15488 )
15489 ]
15490 }
15491 ),
15492 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
15493 // there if there are any actions at all.
15494 isMobileViewport && // At the same time, only show the menu if there are actions to show.
15495 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
15496 ItemActions,
15497 {
15498 item,
15499 actions: eligibleActions,
15500 isCompact: true
15501 }
15502 ) })
15503 ] })
15504 }
15505 );
15506 }
15507 var activity_item_default = ActivityItem;
15508
15509 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
15510 var import_react11 = __toESM(require_react(), 1);
15511 function isDefined3(item) {
15512 return !!item;
15513 }
15514 function ActivityItems(props) {
15515 const { data, fields: fields2, getItemId, view } = props;
15516 const titleField = fields2.find((field) => field.id === view.titleField);
15517 const mediaField = fields2.find((field) => field.id === view.mediaField);
15518 const descriptionField = fields2.find(
15519 (field) => field.id === view.descriptionField
15520 );
15521 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3);
15522 return data.map((item, index2) => {
15523 return /* @__PURE__ */ (0, import_react11.createElement)(
15524 activity_item_default,
15525 {
15526 ...props,
15527 key: getItemId(item),
15528 item,
15529 mediaField,
15530 titleField,
15531 descriptionField,
15532 otherFields,
15533 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
15534 }
15535 );
15536 });
15537 }
15538
15539 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
15540 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15541 function ViewActivity(props) {
15542 const { empty, data, fields: fields2, isLoading, view, className } = props;
15543 const isDelayedLoading = useDelayedLoading(!!isLoading);
15544 const hasData = !!data?.length;
15545 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
15546 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
15547 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15548 if (!hasData) {
15549 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15550 "div",
15551 {
15552 className: clsx_default("dataviews-no-results", {
15553 "is-refreshing": isDelayedLoading
15554 }),
15555 children: empty
15556 }
15557 );
15558 }
15559 const isInert = !isInfiniteScroll && !!isLoading;
15560 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
15561 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15562 });
15563 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
15564 if (hasData && groupField && dataByGroup) {
15565 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15566 Stack,
15567 {
15568 direction: "column",
15569 gap: "sm",
15570 className: wrapperClassName,
15571 inert: isInert ? "true" : void 0,
15572 children: groupedEntries.map(
15573 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15574 ActivityGroup,
15575 {
15576 groupName,
15577 groupData,
15578 groupField,
15579 showLabel: view.groupBy?.showLabel !== false,
15580 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15581 ActivityItems,
15582 {
15583 ...props,
15584 data: groupData
15585 }
15586 )
15587 },
15588 groupName
15589 )
15590 )
15591 }
15592 );
15593 }
15594 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
15595 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15596 "div",
15597 {
15598 className: wrapperClassName,
15599 role: view.infiniteScrollEnabled ? "feed" : void 0,
15600 inert: isInert ? "true" : void 0,
15601 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ActivityItems, { ...props })
15602 }
15603 ),
15604 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components13.Spinner, {}) })
15605 ] });
15606 }
15607
15608 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
15609 var import_components16 = __toESM(require_components(), 1);
15610 var import_i18n17 = __toESM(require_i18n(), 1);
15611 var import_compose6 = __toESM(require_compose(), 1);
15612 var import_element53 = __toESM(require_element(), 1);
15613
15614 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
15615 var import_components15 = __toESM(require_components(), 1);
15616 var import_data5 = __toESM(require_data(), 1);
15617 var import_element52 = __toESM(require_element(), 1);
15618 var import_i18n16 = __toESM(require_i18n(), 1);
15619
15620 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
15621 var import_components14 = __toESM(require_components(), 1);
15622 var import_element51 = __toESM(require_element(), 1);
15623 var import_i18n15 = __toESM(require_i18n(), 1);
15624 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
15625 function hasPaginationControls(view, paginationInfo) {
15626 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
15627 }
15628 function DataViewsPagination() {
15629 const { view, onChangeView, paginationInfo } = (0, import_element51.useContext)(dataviews_context_default);
15630 if (!hasPaginationControls(view, paginationInfo)) {
15631 return null;
15632 }
15633 const { totalPages } = paginationInfo;
15634 const currentPage = view.page ?? 1;
15635 const pageSelectOptions = Array.from(Array(totalPages)).map(
15636 (_, i2) => {
15637 const page = i2 + 1;
15638 return {
15639 value: page.toString(),
15640 label: page.toString(),
15641 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
15642 // translators: 1: current page number. 2: total number of pages.
15643 (0, import_i18n15.__)("Page %1$d of %2$d"),
15644 currentPage,
15645 totalPages
15646 ) : page.toString()
15647 };
15648 }
15649 );
15650 return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
15651 Stack,
15652 {
15653 direction: "row",
15654 className: "dataviews-pagination",
15655 justify: "end",
15656 align: "center",
15657 gap: "xl",
15658 children: [
15659 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15660 Stack,
15661 {
15662 direction: "row",
15663 justify: "flex-start",
15664 align: "center",
15665 gap: "xs",
15666 className: "dataviews-pagination__page-select",
15667 children: (0, import_element51.createInterpolateElement)(
15668 (0, import_i18n15.sprintf)(
15669 // translators: 1: Current page number, 2: Total number of pages.
15670 (0, import_i18n15._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
15671 "<CurrentPage />",
15672 totalPages
15673 ),
15674 {
15675 div: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { "aria-hidden": true }),
15676 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
15677 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15678 import_components14.SelectControl,
15679 {
15680 "aria-label": (0, import_i18n15.__)("Current page"),
15681 value: currentPage.toString(),
15682 options: pageSelectOptions,
15683 onChange: (newValue) => {
15684 onChangeView({
15685 ...view,
15686 page: +newValue
15687 });
15688 },
15689 size: "small",
15690 variant: "minimal"
15691 }
15692 )
15693 }
15694 )
15695 }
15696 ),
15697 /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
15698 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15699 import_components14.Button,
15700 {
15701 onClick: () => onChangeView({
15702 ...view,
15703 page: currentPage - 1
15704 }),
15705 disabled: currentPage === 1,
15706 accessibleWhenDisabled: true,
15707 label: (0, import_i18n15.__)("Previous page"),
15708 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
15709 showTooltip: true,
15710 size: "compact",
15711 tooltipPosition: "top"
15712 }
15713 ),
15714 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15715 import_components14.Button,
15716 {
15717 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
15718 disabled: currentPage >= totalPages,
15719 accessibleWhenDisabled: true,
15720 label: (0, import_i18n15.__)("Next page"),
15721 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
15722 showTooltip: true,
15723 size: "compact",
15724 tooltipPosition: "top"
15725 }
15726 )
15727 ] })
15728 ]
15729 }
15730 );
15731 }
15732 var dataviews_pagination_default = (0, import_element51.memo)(DataViewsPagination);
15733
15734 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
15735 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15736 function useIsMultiselectPicker(actions) {
15737 return (0, import_element52.useMemo)(() => {
15738 return !!actions?.length && actions?.every((action) => action.supportsBulk);
15739 }, [actions]);
15740 }
15741
15742 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
15743 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15744 var { Badge: WCBadge2 } = unlock2(import_components16.privateApis);
15745 function GridItem3({
15746 view,
15747 multiselect,
15748 selection,
15749 onChangeSelection,
15750 getItemId,
15751 item,
15752 mediaField,
15753 titleField,
15754 descriptionField,
15755 regularFields,
15756 badgeFields,
15757 config,
15758 posinset,
15759 setsize
15760 }) {
15761 const { showTitle = true, showMedia = true, showDescription = true } = view;
15762 const id = getItemId(item);
15763 const elementRef = (0, import_element53.useRef)(null);
15764 const isSelected2 = selection.includes(id);
15765 useIntersectionObserver(elementRef, posinset);
15766 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15767 mediaField.render,
15768 {
15769 item,
15770 field: mediaField,
15771 config
15772 }
15773 ) : null;
15774 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(titleField.render, { item, field: titleField }) : null;
15775 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15776 import_components16.Composite.Item,
15777 {
15778 ref: elementRef,
15779 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
15780 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Stack, { direction: "column", children, ...props }),
15781 role: "option",
15782 "aria-posinset": posinset,
15783 "aria-setsize": setsize,
15784 className: clsx_default("dataviews-view-picker-grid__card", {
15785 "is-selected": isSelected2
15786 }),
15787 "aria-selected": isSelected2,
15788 onClick: () => {
15789 if (isSelected2) {
15790 onChangeSelection(
15791 selection.filter((itemId) => id !== itemId)
15792 );
15793 } else {
15794 const newSelection = multiselect ? [...selection, id] : [id];
15795 onChangeSelection(newSelection);
15796 }
15797 },
15798 children: [
15799 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
15800 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15801 DataViewsSelectionCheckbox,
15802 {
15803 item,
15804 selection,
15805 onChangeSelection,
15806 getItemId,
15807 titleField,
15808 disabled: false,
15809 "aria-hidden": true,
15810 tabIndex: -1
15811 }
15812 ),
15813 showTitle && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15814 Stack,
15815 {
15816 direction: "row",
15817 justify: "space-between",
15818 className: "dataviews-view-picker-grid__title-actions",
15819 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
15820 }
15821 ),
15822 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", gap: "xs", children: [
15823 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15824 descriptionField.render,
15825 {
15826 item,
15827 field: descriptionField
15828 }
15829 ),
15830 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15831 Stack,
15832 {
15833 direction: "row",
15834 className: "dataviews-view-picker-grid__badge-fields",
15835 gap: "sm",
15836 wrap: "wrap",
15837 align: "top",
15838 justify: "flex-start",
15839 children: badgeFields.map((field) => {
15840 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15841 WCBadge2,
15842 {
15843 className: "dataviews-view-picker-grid__field-value",
15844 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15845 field.render,
15846 {
15847 item,
15848 field
15849 }
15850 )
15851 },
15852 field.id
15853 );
15854 })
15855 }
15856 ),
15857 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15858 Stack,
15859 {
15860 direction: "column",
15861 className: "dataviews-view-picker-grid__fields",
15862 gap: "xs",
15863 children: regularFields.map((field) => {
15864 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15865 import_components16.Flex,
15866 {
15867 className: "dataviews-view-picker-grid__field",
15868 gap: 1,
15869 justify: "flex-start",
15870 expanded: true,
15871 style: { height: "auto" },
15872 direction: "row",
15873 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
15874 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
15875 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15876 import_components16.FlexItem,
15877 {
15878 className: "dataviews-view-picker-grid__field-value",
15879 style: { maxHeight: "none" },
15880 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15881 field.render,
15882 {
15883 item,
15884 field
15885 }
15886 )
15887 }
15888 )
15889 ] })
15890 },
15891 field.id
15892 );
15893 })
15894 }
15895 )
15896 ] })
15897 ]
15898 },
15899 id
15900 );
15901 }
15902 function GridGroup({
15903 groupName,
15904 groupField,
15905 showLabel = true,
15906 children
15907 }) {
15908 const headerId = (0, import_compose6.useInstanceId)(
15909 GridGroup,
15910 "dataviews-view-picker-grid-group__header"
15911 );
15912 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15913 Stack,
15914 {
15915 direction: "column",
15916 gap: "sm",
15917 role: "group",
15918 "aria-labelledby": headerId,
15919 children: [
15920 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15921 "h3",
15922 {
15923 className: "dataviews-view-picker-grid-group__header",
15924 id: headerId,
15925 children: showLabel ? (0, import_i18n17.sprintf)(
15926 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15927 (0, import_i18n17.__)("%1$s: %2$s"),
15928 groupField.label,
15929 groupName
15930 ) : groupName
15931 }
15932 ),
15933 children
15934 ]
15935 },
15936 groupName
15937 );
15938 }
15939 function ViewPickerGrid({
15940 actions,
15941 data,
15942 fields: fields2,
15943 getItemId,
15944 isLoading,
15945 onChangeSelection,
15946 selection,
15947 view,
15948 className,
15949 empty
15950 }) {
15951 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element53.useContext)(dataviews_context_default);
15952 const titleField = fields2.find(
15953 (field) => field.id === view?.titleField
15954 );
15955 const mediaField = fields2.find(
15956 (field) => field.id === view?.mediaField
15957 );
15958 const descriptionField = fields2.find(
15959 (field) => field.id === view?.descriptionField
15960 );
15961 const otherFields = view.fields ?? [];
15962 const { regularFields, badgeFields } = otherFields.reduce(
15963 (accumulator, fieldId) => {
15964 const field = fields2.find((f2) => f2.id === fieldId);
15965 if (!field) {
15966 return accumulator;
15967 }
15968 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
15969 accumulator[key].push(field);
15970 return accumulator;
15971 },
15972 { regularFields: [], badgeFields: [] }
15973 );
15974 const hasData = !!data?.length;
15975 const usedPreviewSize = view.layout?.previewSize;
15976 const isMultiselect = useIsMultiselectPicker(actions);
15977 const size4 = "900px";
15978 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
15979 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15980 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15981 const currentPage = view?.page ?? 1;
15982 const perPage = view?.perPage ?? 0;
15983 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15984 const gridColumns = useGridColumns();
15985 const placeholdersNeeded = usePlaceholdersNeeded(
15986 data,
15987 isInfiniteScroll,
15988 gridColumns
15989 );
15990 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, {
15991 // Render multiple groups.
15992 children: [
15993 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15994 import_components16.Composite,
15995 {
15996 virtualFocus: true,
15997 orientation: "horizontal",
15998 role: "listbox",
15999 "aria-multiselectable": isMultiselect,
16000 className: clsx_default(
16001 "dataviews-view-picker-grid",
16002 className,
16003 {
16004 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16005 view.layout.density
16006 )
16007 }
16008 ),
16009 "aria-label": itemListLabel,
16010 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16011 Stack,
16012 {
16013 direction: "column",
16014 gap: "lg",
16015 children,
16016 ...props
16017 }
16018 ),
16019 children: Array.from(dataByGroup.entries()).map(
16020 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16021 GridGroup,
16022 {
16023 groupName,
16024 groupField,
16025 showLabel: view.groupBy?.showLabel !== false,
16026 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16027 GridItems,
16028 {
16029 previewSize: usedPreviewSize,
16030 style: {
16031 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
16032 },
16033 "aria-busy": isLoading,
16034 ref: resizeObserverRef,
16035 children: groupItems.map((item) => {
16036 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
16037 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16038 GridItem3,
16039 {
16040 view,
16041 multiselect: isMultiselect,
16042 selection,
16043 onChangeSelection,
16044 getItemId,
16045 item,
16046 mediaField,
16047 titleField,
16048 descriptionField,
16049 regularFields,
16050 badgeFields,
16051 config: {
16052 sizes: size4
16053 },
16054 posinset: posInSet,
16055 setsize: setSize
16056 },
16057 getItemId(item)
16058 );
16059 })
16060 }
16061 )
16062 },
16063 groupName
16064 )
16065 )
16066 }
16067 ),
16068 // Render a single grid with all data.
16069 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16070 import_components16.Composite,
16071 {
16072 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16073 GridItems,
16074 {
16075 className: clsx_default(
16076 "dataviews-view-picker-grid",
16077 className,
16078 {
16079 [`has-${view.layout?.density}-density`]: view.layout?.density && [
16080 "compact",
16081 "comfortable"
16082 ].includes(view.layout.density)
16083 }
16084 ),
16085 previewSize: usedPreviewSize,
16086 "aria-busy": isLoading,
16087 ref: resizeObserverRef
16088 }
16089 ),
16090 virtualFocus: true,
16091 orientation: "horizontal",
16092 role: "listbox",
16093 "aria-multiselectable": isMultiselect,
16094 "aria-label": itemListLabel,
16095 children: [
16096 Array.from({ length: placeholdersNeeded }).map(
16097 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16098 import_components16.Composite.Item,
16099 {
16100 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16101 Stack,
16102 {
16103 direction: "column",
16104 children,
16105 ...props
16106 }
16107 ),
16108 role: "option",
16109 "aria-hidden": true,
16110 tabIndex: -1,
16111 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
16112 },
16113 `placeholder-${index2}`
16114 )
16115 ),
16116 data.map((item) => {
16117 const posinset = item.position;
16118 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16119 GridItem3,
16120 {
16121 view,
16122 multiselect: isMultiselect,
16123 selection,
16124 onChangeSelection,
16125 getItemId,
16126 item,
16127 mediaField,
16128 titleField,
16129 descriptionField,
16130 regularFields,
16131 badgeFields,
16132 config: {
16133 sizes: size4
16134 },
16135 posinset,
16136 setsize: setSize
16137 },
16138 getItemId(item)
16139 );
16140 })
16141 ]
16142 }
16143 ),
16144 // Render empty state.
16145 !hasData && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16146 "div",
16147 {
16148 className: clsx_default({
16149 "dataviews-loading": isLoading,
16150 "dataviews-no-results": !isLoading
16151 }),
16152 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components16.Spinner, {}) }) : empty
16153 }
16154 ),
16155 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components16.Spinner, {}) })
16156 ]
16157 });
16158 }
16159 var picker_grid_default = ViewPickerGrid;
16160
16161 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
16162 var import_i18n18 = __toESM(require_i18n(), 1);
16163 var import_components17 = __toESM(require_components(), 1);
16164 var import_element54 = __toESM(require_element(), 1);
16165 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
16166 function TableColumnField2({
16167 item,
16168 fields: fields2,
16169 column,
16170 align
16171 }) {
16172 const field = fields2.find((f2) => f2.id === column);
16173 if (!field) {
16174 return null;
16175 }
16176 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
16177 "dataviews-view-table__cell-align-end": align === "end",
16178 "dataviews-view-table__cell-align-center": align === "center"
16179 });
16180 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(field.render, { item, field }) });
16181 }
16182 function TableRow2({
16183 item,
16184 fields: fields2,
16185 id,
16186 view,
16187 titleField,
16188 mediaField,
16189 descriptionField,
16190 selection,
16191 getItemId,
16192 onChangeSelection,
16193 multiselect,
16194 posinset
16195 }) {
16196 const { paginationInfo } = (0, import_element54.useContext)(dataviews_context_default);
16197 const isSelected2 = selection.includes(id);
16198 const [isHovered, setIsHovered] = (0, import_element54.useState)(false);
16199 const elementRef = (0, import_element54.useRef)(null);
16200 useIntersectionObserver(elementRef, posinset);
16201 const {
16202 showTitle = true,
16203 showMedia = true,
16204 showDescription = true,
16205 infiniteScrollEnabled
16206 } = view;
16207 const handleMouseEnter = () => {
16208 setIsHovered(true);
16209 };
16210 const handleMouseLeave = () => {
16211 setIsHovered(false);
16212 };
16213 const columns = view.fields ?? [];
16214 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16215 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
16216 import_components17.Composite.Item,
16217 {
16218 ref: elementRef,
16219 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16220 "tr",
16221 {
16222 className: clsx_default("dataviews-view-table__row", {
16223 "is-selected": isSelected2,
16224 "is-hovered": isHovered
16225 }),
16226 onMouseEnter: handleMouseEnter,
16227 onMouseLeave: handleMouseLeave,
16228 children,
16229 ...props
16230 }
16231 ),
16232 "aria-selected": isSelected2,
16233 "aria-setsize": paginationInfo.totalItems || void 0,
16234 "aria-posinset": posinset,
16235 role: infiniteScrollEnabled ? "article" : "option",
16236 onMouseDown: (event) => {
16237 if (event.button !== 0) {
16238 return;
16239 }
16240 event.currentTarget.parentElement?.focus({
16241 preventScroll: true
16242 });
16243 },
16244 onClick: () => {
16245 if (isSelected2) {
16246 onChangeSelection(
16247 selection.filter((itemId) => id !== itemId)
16248 );
16249 } else {
16250 const newSelection = multiselect ? [...selection, id] : [id];
16251 onChangeSelection(newSelection);
16252 }
16253 },
16254 children: [
16255 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16256 "td",
16257 {
16258 className: "dataviews-view-table__checkbox-column",
16259 role: "presentation",
16260 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16261 DataViewsSelectionCheckbox,
16262 {
16263 item,
16264 selection,
16265 onChangeSelection,
16266 getItemId,
16267 titleField,
16268 disabled: false,
16269 "aria-hidden": true,
16270 tabIndex: -1
16271 }
16272 ) })
16273 }
16274 ),
16275 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16276 "td",
16277 {
16278 role: "presentation",
16279 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16280 column_primary_default,
16281 {
16282 item,
16283 titleField: showTitle ? titleField : void 0,
16284 mediaField: showMedia ? mediaField : void 0,
16285 descriptionField: showDescription ? descriptionField : void 0,
16286 isItemClickable: () => false
16287 }
16288 )
16289 }
16290 ),
16291 columns.map((column) => {
16292 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
16293 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16294 "td",
16295 {
16296 style: {
16297 width,
16298 maxWidth,
16299 minWidth
16300 },
16301 role: "presentation",
16302 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16303 TableColumnField2,
16304 {
16305 fields: fields2,
16306 item,
16307 column,
16308 align
16309 }
16310 )
16311 },
16312 column
16313 );
16314 })
16315 ]
16316 },
16317 id
16318 );
16319 }
16320 function ViewPickerTable({
16321 actions,
16322 data,
16323 fields: fields2,
16324 getItemId,
16325 isLoading = false,
16326 onChangeView,
16327 onChangeSelection,
16328 selection,
16329 setOpenedFilter,
16330 view,
16331 className,
16332 empty
16333 }) {
16334 const headerMenuRefs = (0, import_element54.useRef)(/* @__PURE__ */ new Map());
16335 const headerMenuToFocusRef = (0, import_element54.useRef)(void 0);
16336 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element54.useState)();
16337 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
16338 (0, import_element54.useEffect)(() => {
16339 if (headerMenuToFocusRef.current) {
16340 headerMenuToFocusRef.current.focus();
16341 headerMenuToFocusRef.current = void 0;
16342 }
16343 });
16344 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
16345 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16346 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16347 const tableNoticeId = (0, import_element54.useId)();
16348 if (nextHeaderMenuToFocus) {
16349 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
16350 setNextHeaderMenuToFocus(void 0);
16351 return;
16352 }
16353 const onHide = (field) => {
16354 const hidden = headerMenuRefs.current.get(field.id);
16355 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
16356 setNextHeaderMenuToFocus(fallback?.node);
16357 };
16358 const hasData = !!data?.length;
16359 const titleField = fields2.find((field) => field.id === view.titleField);
16360 const mediaField = fields2.find((field) => field.id === view.mediaField);
16361 const descriptionField = fields2.find(
16362 (field) => field.id === view.descriptionField
16363 );
16364 const { showTitle = true, showMedia = true, showDescription = true } = view;
16365 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16366 const columns = view.fields ?? [];
16367 const headerMenuRef = (column, index2) => (node) => {
16368 if (node) {
16369 headerMenuRefs.current.set(column, {
16370 node,
16371 fallback: columns[index2 > 0 ? index2 - 1 : 1]
16372 });
16373 } else {
16374 headerMenuRefs.current.delete(column);
16375 }
16376 };
16377 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
16378 /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
16379 "table",
16380 {
16381 className: clsx_default(
16382 "dataviews-view-table",
16383 "dataviews-view-picker-table",
16384 className,
16385 {
16386 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16387 view.layout.density
16388 )
16389 }
16390 ),
16391 "aria-busy": isLoading,
16392 "aria-describedby": tableNoticeId,
16393 role: isInfiniteScroll ? "feed" : "listbox",
16394 children: [
16395 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
16396 "tr",
16397 {
16398 className: "dataviews-view-table__row",
16399 role: "presentation",
16400 children: [
16401 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16402 BulkSelectionCheckbox,
16403 {
16404 selection,
16405 onChangeSelection,
16406 data,
16407 actions,
16408 getItemId,
16409 disableSelectAll: isInfiniteScroll
16410 }
16411 ) }),
16412 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16413 column_header_menu_default,
16414 {
16415 ref: headerMenuRef(
16416 titleField.id,
16417 0
16418 ),
16419 fieldId: titleField.id,
16420 view,
16421 fields: fields2,
16422 onChangeView,
16423 onHide,
16424 setOpenedFilter,
16425 canMove: false
16426 }
16427 ) }),
16428 columns.map((column, index2) => {
16429 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
16430 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16431 "th",
16432 {
16433 style: {
16434 width,
16435 maxWidth,
16436 minWidth,
16437 textAlign: align
16438 },
16439 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
16440 scope: "col",
16441 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16442 column_header_menu_default,
16443 {
16444 ref: headerMenuRef(column, index2),
16445 fieldId: column,
16446 view,
16447 fields: fields2,
16448 onChangeView,
16449 onHide,
16450 setOpenedFilter,
16451 canMove: view.layout?.enableMoving ?? true
16452 }
16453 )
16454 },
16455 column
16456 );
16457 })
16458 ]
16459 }
16460 ) }),
16461 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
16462 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
16463 import_components17.Composite,
16464 {
16465 virtualFocus: true,
16466 orientation: "vertical",
16467 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("tbody", { role: "group" }),
16468 children: [
16469 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16470 "tr",
16471 {
16472 className: "dataviews-view-table__group-header-row",
16473 role: "presentation",
16474 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16475 "td",
16476 {
16477 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
16478 className: "dataviews-view-table__group-header-cell",
16479 role: "presentation",
16480 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
16481 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16482 (0, import_i18n18.__)("%1$s: %2$s"),
16483 groupField.label,
16484 groupName
16485 )
16486 }
16487 )
16488 }
16489 ),
16490 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16491 TableRow2,
16492 {
16493 item,
16494 fields: fields2,
16495 id: getItemId(item) || index2.toString(),
16496 view,
16497 titleField,
16498 mediaField,
16499 descriptionField,
16500 selection,
16501 getItemId,
16502 onChangeSelection,
16503 multiselect: isMultiselect
16504 },
16505 getItemId(item)
16506 ))
16507 ]
16508 },
16509 `group-${groupName}`
16510 )
16511 ) : /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16512 import_components17.Composite,
16513 {
16514 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("tbody", { role: "presentation" }),
16515 virtualFocus: true,
16516 orientation: "vertical",
16517 children: hasData && data.map((item, index2) => {
16518 const itemId = getItemId(item);
16519 const posinset = item.position;
16520 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
16521 TableRow2,
16522 {
16523 item,
16524 fields: fields2,
16525 id: itemId || index2.toString(),
16526 view,
16527 titleField,
16528 mediaField,
16529 descriptionField,
16530 selection,
16531 getItemId,
16532 onChangeSelection,
16533 multiselect: isMultiselect,
16534 posinset
16535 },
16536 itemId
16537 );
16538 })
16539 }
16540 )
16541 ]
16542 }
16543 ),
16544 /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
16545 "div",
16546 {
16547 className: clsx_default({
16548 "dataviews-loading": isLoading,
16549 "dataviews-no-results": !hasData && !isLoading
16550 }),
16551 id: tableNoticeId,
16552 children: [
16553 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components17.Spinner, {}) }) : empty),
16554 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components17.Spinner, {}) })
16555 ]
16556 }
16557 )
16558 ] });
16559 }
16560 var picker_table_default = ViewPickerTable;
16561
16562 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
16563 var import_components18 = __toESM(require_components(), 1);
16564 var import_element55 = __toESM(require_element(), 1);
16565 var import_compose7 = __toESM(require_compose(), 1);
16566 var import_i18n19 = __toESM(require_i18n(), 1);
16567 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
16568 function isDefined4(item) {
16569 return !!item;
16570 }
16571 function PickerActivityItem({
16572 view,
16573 multiselect,
16574 selection,
16575 onChangeSelection,
16576 getItemId,
16577 item,
16578 titleField,
16579 mediaField,
16580 descriptionField,
16581 otherFields,
16582 posinset,
16583 setsize
16584 }) {
16585 const elementRef = (0, import_element55.useRef)(null);
16586 useIntersectionObserver(elementRef, posinset);
16587 const { showTitle = true, showMedia = true, showDescription = true } = view;
16588 const id = getItemId(item);
16589 const isSelected2 = selection.includes(id);
16590 const density = view.layout?.density ?? "balanced";
16591 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16592 mediaField.render,
16593 {
16594 item,
16595 field: mediaField,
16596 config: {
16597 sizes: density === "comfortable" ? "32px" : "24px"
16598 }
16599 }
16600 ) : null;
16601 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16602 "span",
16603 {
16604 className: "dataviews-view-picker-activity__item-bullet",
16605 "aria-hidden": "true"
16606 }
16607 ) });
16608 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(titleField.render, { item, field: titleField }) : null;
16609 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
16610 const verticalGap = (0, import_element55.useMemo)(() => {
16611 switch (density) {
16612 case "comfortable":
16613 return "md";
16614 default:
16615 return "sm";
16616 }
16617 }, [density]);
16618 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16619 import_components18.Composite.Item,
16620 {
16621 ref: elementRef,
16622 role: "option",
16623 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
16624 "aria-posinset": posinset,
16625 "aria-setsize": setsize,
16626 "aria-selected": isSelected2,
16627 className: clsx_default(
16628 "dataviews-view-picker-activity__item",
16629 density === "compact" && "is-compact",
16630 density === "balanced" && "is-balanced",
16631 density === "comfortable" && "is-comfortable",
16632 isSelected2 && "is-selected"
16633 ),
16634 onClick: () => {
16635 if (isSelected2) {
16636 onChangeSelection(
16637 selection.filter((itemId) => id !== itemId)
16638 );
16639 } else {
16640 const newSelection = multiselect ? [...selection, id] : [id];
16641 onChangeSelection(newSelection);
16642 }
16643 },
16644 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
16645 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
16646 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16647 Stack,
16648 {
16649 direction: "column",
16650 gap: "xs",
16651 align: "center",
16652 className: "dataviews-view-picker-activity__item-type",
16653 children: renderedMediaField
16654 }
16655 ),
16656 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
16657 Stack,
16658 {
16659 direction: "column",
16660 gap: verticalGap,
16661 align: "flex-start",
16662 className: "dataviews-view-picker-activity__item-content",
16663 children: [
16664 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
16665 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
16666 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
16667 "div",
16668 {
16669 className: "dataviews-view-picker-activity__item-field",
16670 children: [
16671 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16672 VisuallyHidden,
16673 {
16674 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {}),
16675 className: "dataviews-view-picker-activity__item-field-label",
16676 children: field.label
16677 }
16678 ),
16679 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16680 field.render,
16681 {
16682 item,
16683 field
16684 }
16685 ) })
16686 ]
16687 },
16688 field.id
16689 )) })
16690 ]
16691 }
16692 )
16693 ] })
16694 }
16695 );
16696 }
16697 function PickerActivityGroup({
16698 groupName,
16699 groupField,
16700 showLabel = true,
16701 children
16702 }) {
16703 const headerId = (0, import_compose7.useInstanceId)(
16704 PickerActivityGroup,
16705 "dataviews-view-picker-activity-group__header"
16706 );
16707 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
16708 Stack,
16709 {
16710 direction: "column",
16711 role: "group",
16712 "aria-labelledby": headerId,
16713 className: "dataviews-view-picker-activity-group",
16714 children: [
16715 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16716 "h3",
16717 {
16718 className: "dataviews-view-picker-activity-group__header",
16719 id: headerId,
16720 children: showLabel ? (0, import_i18n19.sprintf)(
16721 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16722 (0, import_i18n19.__)("%1$s: %2$s"),
16723 groupField.label,
16724 groupName
16725 ) : groupName
16726 }
16727 ),
16728 children
16729 ]
16730 }
16731 );
16732 }
16733 function ViewPickerActivity({
16734 data,
16735 fields: fields2,
16736 getItemId,
16737 isLoading,
16738 onChangeSelection,
16739 selection,
16740 view,
16741 actions,
16742 className,
16743 empty
16744 }) {
16745 const { itemListLabel, paginationInfo } = (0, import_element55.useContext)(dataviews_context_default);
16746 const isMultiselect = useIsMultiselectPicker(actions);
16747 const titleField = fields2.find(
16748 (field) => field.id === view?.titleField
16749 );
16750 const mediaField = fields2.find(
16751 (field) => field.id === view?.mediaField
16752 );
16753 const descriptionField = fields2.find(
16754 (field) => field.id === view?.descriptionField
16755 );
16756 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined4);
16757 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
16758 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16759 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
16760 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
16761 const hasData = !!data?.length;
16762 const isGrouped = !!(groupField && dataByGroup);
16763 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16764 PickerActivityItem,
16765 {
16766 view,
16767 multiselect: isMultiselect,
16768 selection,
16769 onChangeSelection,
16770 getItemId,
16771 item,
16772 titleField,
16773 mediaField,
16774 descriptionField,
16775 otherFields,
16776 posinset: item.position,
16777 setsize
16778 },
16779 getItemId(item)
16780 );
16781 if (!hasData) {
16782 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16783 "div",
16784 {
16785 className: clsx_default({
16786 "dataviews-loading": isLoading,
16787 "dataviews-no-results": !isLoading
16788 }),
16789 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components18.Spinner, {}) }) : empty
16790 }
16791 );
16792 }
16793 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
16794 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16795 import_components18.Composite,
16796 {
16797 virtualFocus: true,
16798 orientation: "vertical",
16799 role: "listbox",
16800 "aria-multiselectable": isMultiselect,
16801 "aria-label": itemListLabel,
16802 "aria-busy": isLoading,
16803 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
16804 className: clsx_default(
16805 "dataviews-view-picker-activity",
16806 className
16807 ),
16808 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
16809 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16810 PickerActivityGroup,
16811 {
16812 groupName,
16813 groupField,
16814 showLabel: view.groupBy?.showLabel !== false,
16815 children: groupItems.map(renderItem)
16816 },
16817 groupName
16818 )
16819 ) : data.map(renderItem)
16820 }
16821 ),
16822 isLoading && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components18.Spinner, {}) })
16823 ] });
16824 }
16825
16826 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
16827 var import_components19 = __toESM(require_components(), 1);
16828 var import_i18n20 = __toESM(require_i18n(), 1);
16829 var import_element56 = __toESM(require_element(), 1);
16830 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
16831 function DensityPicker() {
16832 const context = (0, import_element56.useContext)(dataviews_context_default);
16833 const view = context.view;
16834 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
16835 import_components19.__experimentalToggleGroupControl,
16836 {
16837 label: (0, import_i18n20.__)("Density"),
16838 value: view.layout?.density || "balanced",
16839 onChange: (value) => {
16840 context.onChangeView({
16841 ...view,
16842 layout: {
16843 ...view.layout,
16844 density: value
16845 }
16846 });
16847 },
16848 isBlock: true,
16849 children: [
16850 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
16851 import_components19.__experimentalToggleGroupControlOption,
16852 {
16853 value: "comfortable",
16854 label: (0, import_i18n20._x)(
16855 "Comfortable",
16856 "Density option for DataView layout"
16857 )
16858 },
16859 "comfortable"
16860 ),
16861 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
16862 import_components19.__experimentalToggleGroupControlOption,
16863 {
16864 value: "balanced",
16865 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
16866 },
16867 "balanced"
16868 ),
16869 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
16870 import_components19.__experimentalToggleGroupControlOption,
16871 {
16872 value: "compact",
16873 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
16874 },
16875 "compact"
16876 )
16877 ]
16878 }
16879 );
16880 }
16881
16882 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
16883 var import_components20 = __toESM(require_components(), 1);
16884 var import_i18n21 = __toESM(require_i18n(), 1);
16885 var import_element57 = __toESM(require_element(), 1);
16886 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
16887 var imageSizes2 = [
16888 {
16889 value: 120,
16890 breakpoint: 1
16891 },
16892 {
16893 value: 170,
16894 breakpoint: 1
16895 },
16896 {
16897 value: 230,
16898 breakpoint: 1
16899 },
16900 {
16901 value: 290,
16902 breakpoint: 1112
16903 // at minimum image width, 4 images display at this container size
16904 },
16905 {
16906 value: 350,
16907 breakpoint: 1636
16908 // at minimum image width, 6 images display at this container size
16909 },
16910 {
16911 value: 430,
16912 breakpoint: 588
16913 // at minimum image width, 2 images display at this container size
16914 }
16915 ];
16916 function PreviewSizePicker() {
16917 const context = (0, import_element57.useContext)(dataviews_context_default);
16918 const view = context.view;
16919 const breakValues = imageSizes2.filter((size4) => {
16920 return context.containerWidth >= size4.breakpoint;
16921 });
16922 const layoutPreviewSize = view.layout?.previewSize ?? 230;
16923 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
16924 const marks = breakValues.map((size4, index2) => {
16925 return {
16926 value: index2
16927 };
16928 });
16929 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16930 import_components20.RangeControl,
16931 {
16932 showTooltip: false,
16933 label: (0, import_i18n21.__)("Preview size"),
16934 value: previewSizeToUse,
16935 min: 0,
16936 max: breakValues.length - 1,
16937 withInputField: false,
16938 onChange: (value = 0) => {
16939 context.onChangeView({
16940 ...view,
16941 layout: {
16942 ...view.layout,
16943 previewSize: breakValues[value].value
16944 }
16945 });
16946 },
16947 step: 1,
16948 marks
16949 }
16950 );
16951 }
16952
16953 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
16954 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
16955 function GridConfigOptions() {
16956 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
16957 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(DensityPicker, {}),
16958 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(PreviewSizePicker, {})
16959 ] });
16960 }
16961
16962 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
16963 var VIEW_LAYOUTS = [
16964 {
16965 type: LAYOUT_TABLE,
16966 label: (0, import_i18n22.__)("Table"),
16967 component: table_default,
16968 icon: block_table_default,
16969 viewConfigOptions: DensityPicker
16970 },
16971 {
16972 type: LAYOUT_GRID,
16973 label: (0, import_i18n22.__)("Grid"),
16974 component: grid_default,
16975 icon: category_default,
16976 viewConfigOptions: GridConfigOptions
16977 },
16978 {
16979 type: LAYOUT_LIST,
16980 label: (0, import_i18n22.__)("List"),
16981 component: ViewList,
16982 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
16983 viewConfigOptions: DensityPicker
16984 },
16985 {
16986 type: LAYOUT_ACTIVITY,
16987 label: (0, import_i18n22.__)("Activity"),
16988 component: ViewActivity,
16989 icon: scheduled_default,
16990 viewConfigOptions: DensityPicker
16991 },
16992 {
16993 type: LAYOUT_PICKER_GRID,
16994 label: (0, import_i18n22.__)("Grid"),
16995 component: picker_grid_default,
16996 icon: category_default,
16997 viewConfigOptions: GridConfigOptions,
16998 isPicker: true
16999 },
17000 {
17001 type: LAYOUT_PICKER_TABLE,
17002 label: (0, import_i18n22.__)("Table"),
17003 component: picker_table_default,
17004 icon: block_table_default,
17005 viewConfigOptions: DensityPicker,
17006 isPicker: true
17007 },
17008 {
17009 type: LAYOUT_PICKER_ACTIVITY,
17010 label: (0, import_i18n22.__)("Activity"),
17011 component: ViewPickerActivity,
17012 icon: scheduled_default,
17013 viewConfigOptions: DensityPicker,
17014 isPicker: true
17015 }
17016 ];
17017
17018 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
17019 var import_element65 = __toESM(require_element(), 1);
17020
17021 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
17022 var import_components23 = __toESM(require_components(), 1);
17023 var import_i18n25 = __toESM(require_i18n(), 1);
17024 var import_element62 = __toESM(require_element(), 1);
17025
17026 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
17027 var import_react12 = __toESM(require_react(), 1);
17028 var FocusableContext = (0, import_react12.createContext)(true);
17029
17030 // node_modules/@ariakit/utils/dist/index.js
17031 function toArray(arg) {
17032 if (Array.isArray(arg)) return arg;
17033 return typeof arg !== "undefined" ? [arg] : [];
17034 }
17035 function flatten2DArray(array) {
17036 const flattened = [];
17037 for (const row of array) flattened.push(...row);
17038 return flattened;
17039 }
17040 function reverseArray(array) {
17041 return array.slice().reverse();
17042 }
17043 function noop4(..._) {
17044 }
17045 function hasOwnProperty(object, prop) {
17046 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
17047 return Object.prototype.hasOwnProperty.call(object, prop);
17048 }
17049 function chain(...fns) {
17050 return (...args) => {
17051 for (const fn of fns) if (typeof fn === "function") fn(...args);
17052 };
17053 }
17054 function normalizeString(str) {
17055 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
17056 }
17057 function omit(object, keys) {
17058 const result = { ...object };
17059 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
17060 return result;
17061 }
17062 function pick(object, paths) {
17063 const result = {};
17064 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
17065 return result;
17066 }
17067 function identity(value) {
17068 return value;
17069 }
17070 function afterPaint(cb = noop4) {
17071 let raf = requestAnimationFrame(() => {
17072 raf = requestAnimationFrame(cb);
17073 });
17074 return () => cancelAnimationFrame(raf);
17075 }
17076 function invariant(condition, message2) {
17077 if (condition) return;
17078 if (typeof message2 !== "string") throw new Error("Invariant failed");
17079 throw new Error(message2);
17080 }
17081 function getKeys(obj) {
17082 return Object.keys(obj);
17083 }
17084 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
17085 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
17086 if (result == null) return false;
17087 return !result;
17088 }
17089 function disabledFromProps(props) {
17090 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
17091 }
17092 function removeUndefinedValues(obj) {
17093 const result = {};
17094 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
17095 return result;
17096 }
17097 function defaultValue(...values) {
17098 for (const value of values) if (value !== void 0) return value;
17099 }
17100 var canUseDOM = checkIsBrowser();
17101 function checkIsBrowser() {
17102 return typeof window !== "undefined" && !!window.document?.createElement;
17103 }
17104 function getDocument(node) {
17105 if (!node) return document;
17106 if ("self" in node) return node.document;
17107 return node.ownerDocument || document;
17108 }
17109 function getActiveElement(node, activeDescendant = false) {
17110 const { activeElement: activeElement2 } = getDocument(node);
17111 if (!activeElement2?.nodeName) return null;
17112 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
17113 if (activeDescendant) {
17114 const id = activeElement2.getAttribute("aria-activedescendant");
17115 if (id) {
17116 const element = getDocument(activeElement2).getElementById(id);
17117 if (element) return element;
17118 }
17119 }
17120 return activeElement2;
17121 }
17122 function contains2(parent, child) {
17123 return parent === child || parent.contains(child);
17124 }
17125 function isElement2(target) {
17126 return target?.nodeType === 1;
17127 }
17128 function isNode2(target) {
17129 return typeof target?.nodeType === "number";
17130 }
17131 function isFrame(element) {
17132 return element.tagName === "IFRAME";
17133 }
17134 function isButton(element) {
17135 const tagName = element.tagName.toLowerCase();
17136 if (tagName === "button") return true;
17137 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
17138 return false;
17139 }
17140 var buttonInputTypes = [
17141 "button",
17142 "color",
17143 "file",
17144 "image",
17145 "reset",
17146 "submit"
17147 ];
17148 function isVisible(element) {
17149 if (typeof element.checkVisibility === "function") return element.checkVisibility();
17150 const htmlElement = element;
17151 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
17152 }
17153 function isTextField(element) {
17154 try {
17155 if (element.tagName === "TEXTAREA") return true;
17156 if (element.tagName !== "INPUT") return false;
17157 return element.selectionStart !== null;
17158 } catch (_error) {
17159 return false;
17160 }
17161 }
17162 function isTextbox(element) {
17163 return element.isContentEditable || isTextField(element);
17164 }
17165 function getTextboxValue(element) {
17166 if (isTextField(element)) return element.value;
17167 if (element.isContentEditable) {
17168 const range = getDocument(element).createRange();
17169 range.selectNodeContents(element);
17170 return range.toString();
17171 }
17172 return "";
17173 }
17174 function getTextboxSelection(element) {
17175 let start = 0;
17176 let end = 0;
17177 if (isTextField(element)) {
17178 start = element.selectionStart || 0;
17179 end = element.selectionEnd || 0;
17180 } else if (element.isContentEditable) {
17181 const selection = getDocument(element).getSelection();
17182 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
17183 const range = selection.getRangeAt(0);
17184 const nextRange = range.cloneRange();
17185 nextRange.selectNodeContents(element);
17186 nextRange.setEnd(range.startContainer, range.startOffset);
17187 start = nextRange.toString().length;
17188 nextRange.setEnd(range.endContainer, range.endOffset);
17189 end = nextRange.toString().length;
17190 }
17191 }
17192 return {
17193 start,
17194 end
17195 };
17196 }
17197 var allowedPopupRoles = [
17198 "dialog",
17199 "menu",
17200 "listbox",
17201 "tree",
17202 "grid"
17203 ];
17204 var itemRoleByPopupRole = {
17205 menu: "menuitem",
17206 listbox: "option",
17207 tree: "treeitem"
17208 };
17209 function getPopupRole(element, fallback) {
17210 const role = element?.getAttribute("role");
17211 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
17212 return fallback;
17213 }
17214 function getItemRoleByPopupRole(popupRole) {
17215 if (popupRole == null) return;
17216 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
17217 return itemRoleByPopupRole[popupRole];
17218 }
17219 function getScrollingElement(element) {
17220 if (!element) return null;
17221 const isScrollableOverflow = (overflow) => {
17222 if (overflow === "auto") return true;
17223 if (overflow === "scroll") return true;
17224 return false;
17225 };
17226 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
17227 const { overflowY } = getComputedStyle(element);
17228 if (isScrollableOverflow(overflowY)) return element;
17229 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
17230 const { overflowX } = getComputedStyle(element);
17231 if (isScrollableOverflow(overflowX)) return element;
17232 }
17233 const doc = getDocument(element);
17234 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
17235 }
17236 function setSelectionRange(element, ...args) {
17237 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
17238 }
17239 function sortBasedOnDOMPosition(items, getElement) {
17240 const pairs = items.map((item, index2) => [index2, item]);
17241 let isOrderDifferent = false;
17242 pairs.sort(([indexA, a2], [indexB, b2]) => {
17243 const elementA = getElement(a2);
17244 const elementB = getElement(b2);
17245 if (elementA === elementB) return 0;
17246 if (!elementA || !elementB) return 0;
17247 if (isElementPreceding(elementA, elementB)) {
17248 if (indexA > indexB) isOrderDifferent = true;
17249 return -1;
17250 }
17251 if (indexA < indexB) isOrderDifferent = true;
17252 return 1;
17253 });
17254 if (isOrderDifferent) return pairs.map(([_, item]) => item);
17255 return items;
17256 }
17257 function isElementPreceding(a2, b2) {
17258 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
17259 }
17260 function isTouchDevice() {
17261 return canUseDOM && !!navigator.maxTouchPoints;
17262 }
17263 function isApple() {
17264 if (!canUseDOM) return false;
17265 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
17266 }
17267 function isSafari() {
17268 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
17269 }
17270 function isFirefox() {
17271 return canUseDOM && /firefox\//i.test(navigator.userAgent);
17272 }
17273 function isPortalEvent(event) {
17274 const { currentTarget, target } = event;
17275 if (!currentTarget) return false;
17276 if (!isNode2(target)) return true;
17277 return !contains2(currentTarget, target);
17278 }
17279 function isSelfTarget(event) {
17280 return event.target === event.currentTarget;
17281 }
17282 function isActivatableNavigationTarget(element) {
17283 if (!isElement2(element)) return false;
17284 const target = element;
17285 const tagName = target.tagName.toLowerCase();
17286 if (tagName === "a") return true;
17287 if (tagName === "button" && target.type === "submit") return true;
17288 if (tagName === "input" && target.type === "submit") return true;
17289 return false;
17290 }
17291 function isOpeningInNewTab(event) {
17292 const isAppleDevice = isApple();
17293 if (isAppleDevice && !event.metaKey) return false;
17294 if (!isAppleDevice && !event.ctrlKey) return false;
17295 return isActivatableNavigationTarget(event.currentTarget);
17296 }
17297 function isDownloading(event) {
17298 if (!event.altKey) return false;
17299 return isActivatableNavigationTarget(event.currentTarget);
17300 }
17301 function fireBlurEvent(element, eventInit) {
17302 const event = new FocusEvent("blur", eventInit);
17303 const defaultAllowed = element.dispatchEvent(event);
17304 const bubbleInit = {
17305 ...eventInit,
17306 bubbles: true
17307 };
17308 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
17309 return defaultAllowed;
17310 }
17311 function fireKeyboardEvent(element, type, eventInit) {
17312 const event = new KeyboardEvent(type, eventInit);
17313 return element.dispatchEvent(event);
17314 }
17315 function fireClickEvent(element, eventInit) {
17316 const event = new MouseEvent("click", eventInit);
17317 return element.dispatchEvent(event);
17318 }
17319 function isFocusEventOutside(event, container) {
17320 const containerElement = container || event.currentTarget;
17321 const relatedTarget = event.relatedTarget;
17322 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
17323 }
17324 function isInputEvent(event) {
17325 return event.type === "input";
17326 }
17327 function queueBeforeEvent(element, type, callback, timeout) {
17328 const createTimer = (callback2) => {
17329 if (timeout) {
17330 const timerId2 = setTimeout(callback2, timeout);
17331 return () => clearTimeout(timerId2);
17332 }
17333 const timerId = requestAnimationFrame(callback2);
17334 return () => cancelAnimationFrame(timerId);
17335 };
17336 const cancelTimer = createTimer(() => {
17337 element.removeEventListener(type, callSync, true);
17338 callback();
17339 });
17340 const callSync = () => {
17341 cancelTimer();
17342 callback();
17343 };
17344 element.addEventListener(type, callSync, {
17345 once: true,
17346 capture: true
17347 });
17348 return () => {
17349 cancelTimer();
17350 element.removeEventListener(type, callSync, true);
17351 };
17352 }
17353 function addGlobalEventListener(type, listener, options, scope = window) {
17354 const children = [];
17355 try {
17356 scope.document.addEventListener(type, listener, options);
17357 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
17358 } catch {
17359 }
17360 const removeEventListener = () => {
17361 try {
17362 scope.document.removeEventListener(type, listener, options);
17363 } catch {
17364 }
17365 for (const remove of children) remove();
17366 };
17367 return removeEventListener;
17368 }
17369 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'])";
17370 function isFocusable(element) {
17371 if (!element.matches(selector)) return false;
17372 if (!isVisible(element)) return false;
17373 if (element.closest("[inert]")) return false;
17374 return true;
17375 }
17376 function hasFocus(element) {
17377 const activeElement2 = getActiveElement(element);
17378 if (!activeElement2) return false;
17379 if (activeElement2 === element) return true;
17380 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
17381 if (!activeDescendant) return false;
17382 return activeDescendant === element.id;
17383 }
17384 function hasFocusWithin(element) {
17385 const activeElement2 = getActiveElement(element);
17386 if (!activeElement2) return false;
17387 if (contains2(element, activeElement2)) return true;
17388 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
17389 if (!activeDescendant) return false;
17390 if (!("id" in element)) return false;
17391 if (activeDescendant === element.id) return true;
17392 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
17393 }
17394 function focusIntoView(element, options) {
17395 if (!("scrollIntoView" in element)) element.focus();
17396 else {
17397 element.focus({ preventScroll: true });
17398 element.scrollIntoView({
17399 block: "nearest",
17400 inline: "nearest",
17401 ...options
17402 });
17403 }
17404 }
17405 function createUndoCallback(callback) {
17406 return async () => {
17407 const redo = await callback?.();
17408 return createUndoCallback(async () => {
17409 await redo?.();
17410 return callback;
17411 });
17412 };
17413 }
17414 var UndoManager = createUndoManager();
17415 function createUndoManager({ limit = 100 } = {}) {
17416 const undoStack = [];
17417 let redoStack = [];
17418 let currentGroup = null;
17419 const canUndo = () => undoStack.length > 0;
17420 const canRedo = () => redoStack.length > 0;
17421 const undo = async () => {
17422 if (!canUndo()) return;
17423 currentGroup = null;
17424 redoStack.push(await undoStack.pop()?.());
17425 };
17426 const redo = async () => {
17427 if (!canRedo()) return;
17428 currentGroup = null;
17429 undoStack.push(await redoStack.pop()?.());
17430 };
17431 const execute = async (callback, group) => {
17432 if (!callback) return;
17433 const sameGroup = group === currentGroup;
17434 currentGroup = group ?? null;
17435 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
17436 const undoCallback = await callback();
17437 if (!undoCallback) return;
17438 redoStack = [];
17439 const currentUndo = undoStack[nextIndex];
17440 undoStack[nextIndex] = createUndoCallback(async () => {
17441 await undoCallback?.();
17442 const currentRedo = await currentUndo?.();
17443 return async () => {
17444 await currentRedo?.();
17445 await callback?.();
17446 };
17447 });
17448 while (undoStack.length > limit) undoStack.shift();
17449 };
17450 return {
17451 canUndo,
17452 canRedo,
17453 undo,
17454 redo,
17455 execute
17456 };
17457 }
17458
17459 // node_modules/@ariakit/react-utils/dist/index.js
17460 var React58 = __toESM(require_react(), 1);
17461 var import_react13 = __toESM(require_react(), 1);
17462 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
17463 function setRef(ref, value) {
17464 if (typeof ref === "function") {
17465 const cleanup = ref(value);
17466 if (typeof cleanup === "function") return cleanup;
17467 } else if (ref) ref.current = value;
17468 }
17469 function isValidElementWithRef(element) {
17470 if (!element) return false;
17471 if (!(0, import_react13.isValidElement)(element)) return false;
17472 if ("ref" in element.props) return true;
17473 if ("ref" in element) return true;
17474 return false;
17475 }
17476 function getRefProperty(element) {
17477 if (!isValidElementWithRef(element)) return null;
17478 return { ...element.props }.ref || element.ref;
17479 }
17480 function mergeProps2(base, overrides) {
17481 const props = { ...base };
17482 for (const key in overrides) {
17483 if (!hasOwnProperty(overrides, key)) continue;
17484 if (key === "className") {
17485 const prop = "className";
17486 const baseClass = base[prop];
17487 const overrideClass = overrides[prop];
17488 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
17489 else props[prop] = overrideClass || baseClass;
17490 continue;
17491 }
17492 if (key === "style") {
17493 const prop = "style";
17494 props[prop] = base[prop] ? {
17495 ...base[prop],
17496 ...overrides[prop]
17497 } : overrides[prop];
17498 continue;
17499 }
17500 const overrideValue = overrides[key];
17501 if (key.startsWith("on")) {
17502 if (typeof overrideValue !== "function") continue;
17503 const baseValue = base[key];
17504 if (typeof baseValue === "function") {
17505 props[key] = (...args) => {
17506 overrideValue(...args);
17507 baseValue(...args);
17508 };
17509 continue;
17510 }
17511 }
17512 props[key] = overrideValue;
17513 }
17514 return props;
17515 }
17516 var _React = { ...React58 };
17517 var useReactId = _React.useId;
17518 var useReactDeferredValue = _React.useDeferredValue;
17519 var useReactInsertionEffect = _React.useInsertionEffect;
17520 var useSafeLayoutEffect = canUseDOM ? import_react13.useLayoutEffect : import_react13.useEffect;
17521 function useInitialValue(value) {
17522 const [initialValue] = (0, import_react13.useState)(value);
17523 return initialValue;
17524 }
17525 function useLiveRef(value) {
17526 const ref = (0, import_react13.useRef)(value);
17527 useSafeLayoutEffect(() => {
17528 ref.current = value;
17529 });
17530 return ref;
17531 }
17532 function useEvent(callback) {
17533 const ref = (0, import_react13.useRef)(() => {
17534 throw new Error("Cannot call an event handler while rendering.");
17535 });
17536 if (useReactInsertionEffect) useReactInsertionEffect(() => {
17537 ref.current = callback;
17538 });
17539 else ref.current = callback;
17540 return (0, import_react13.useCallback)((...args) => ref.current?.(...args), []);
17541 }
17542 function useTransactionState(callback) {
17543 const [state, setState] = (0, import_react13.useState)(null);
17544 useSafeLayoutEffect(() => {
17545 if (state == null) return;
17546 if (!callback) return;
17547 let prevState = null;
17548 callback((prev) => {
17549 prevState = prev;
17550 return state;
17551 });
17552 return () => {
17553 callback(prevState);
17554 };
17555 }, [state, callback]);
17556 return [state, setState];
17557 }
17558 function useMergeRefs(...refs) {
17559 return (0, import_react13.useMemo)(() => {
17560 if (!refs.some(Boolean)) return;
17561 return (value) => {
17562 const refEffects = [];
17563 for (const ref of refs) {
17564 if (!ref) continue;
17565 const cleanup = setRef(ref, value);
17566 refEffects.push({
17567 ref,
17568 cleanup: typeof cleanup === "function" ? cleanup : void 0
17569 });
17570 }
17571 if (!refEffects.some((effect) => effect.cleanup)) return;
17572 return () => {
17573 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
17574 else setRef(ref, null);
17575 };
17576 };
17577 }, refs);
17578 }
17579 function useId5(defaultId) {
17580 if (useReactId) {
17581 const reactId = useReactId();
17582 if (defaultId) return defaultId;
17583 return reactId;
17584 }
17585 const [id, setId] = (0, import_react13.useState)(defaultId);
17586 useSafeLayoutEffect(() => {
17587 if (defaultId || id) return;
17588 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
17589 }, [defaultId, id]);
17590 return defaultId || id;
17591 }
17592 function useTagName(refOrElement, type) {
17593 const stringOrUndefined = (type2) => {
17594 if (typeof type2 !== "string") return;
17595 return type2;
17596 };
17597 const [tagName, setTagName] = (0, import_react13.useState)(() => stringOrUndefined(type));
17598 useSafeLayoutEffect(() => {
17599 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
17600 }, [refOrElement, type]);
17601 return tagName;
17602 }
17603 function useAttribute(refOrElement, attributeName, defaultValue2) {
17604 const initialValue = useInitialValue(defaultValue2);
17605 const [attribute, setAttribute] = (0, import_react13.useState)(initialValue);
17606 (0, import_react13.useEffect)(() => {
17607 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
17608 if (!element) return;
17609 const callback = () => {
17610 const value = element.getAttribute(attributeName);
17611 setAttribute(value == null ? initialValue : value);
17612 };
17613 const observer = new MutationObserver(callback);
17614 observer.observe(element, { attributeFilter: [attributeName] });
17615 callback();
17616 return () => observer.disconnect();
17617 }, [
17618 refOrElement,
17619 attributeName,
17620 initialValue
17621 ]);
17622 return attribute;
17623 }
17624 function useUpdateEffect(effect, deps) {
17625 const mounted = (0, import_react13.useRef)(false);
17626 (0, import_react13.useEffect)(() => {
17627 if (mounted.current) return effect();
17628 mounted.current = true;
17629 }, deps);
17630 (0, import_react13.useEffect)(() => () => {
17631 mounted.current = false;
17632 }, []);
17633 }
17634 function useUpdateLayoutEffect(effect, deps) {
17635 const mounted = (0, import_react13.useRef)(false);
17636 useSafeLayoutEffect(() => {
17637 if (mounted.current) return effect();
17638 mounted.current = true;
17639 }, deps);
17640 useSafeLayoutEffect(() => () => {
17641 mounted.current = false;
17642 }, []);
17643 }
17644 function useForceUpdate() {
17645 return (0, import_react13.useReducer)(() => [], []);
17646 }
17647 function useBooleanEvent(booleanOrCallback) {
17648 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
17649 }
17650 function useWrapElement(props, callback, deps = []) {
17651 const wrapElement = (0, import_react13.useCallback)((element) => {
17652 if (props.wrapElement) element = props.wrapElement(element);
17653 return callback(element);
17654 }, [...deps, props.wrapElement]);
17655 return {
17656 ...props,
17657 wrapElement
17658 };
17659 }
17660 function useMetadataProps(props, key, value) {
17661 const parent = props.onLoadedMetadataCapture;
17662 const onLoadedMetadataCapture = (0, import_react13.useMemo)(() => {
17663 return Object.assign(() => {
17664 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
17665 }, [
17666 parent,
17667 key,
17668 value
17669 ]);
17670 return [parent?.[key], { onLoadedMetadataCapture }];
17671 }
17672 var hasInstalledGlobalEventListeners = false;
17673 function useIsMouseMoving() {
17674 (0, import_react13.useEffect)(() => {
17675 if (hasInstalledGlobalEventListeners) return;
17676 addGlobalEventListener("mousemove", setMouseMoving, true);
17677 addGlobalEventListener("mousedown", resetMouseMoving, true);
17678 addGlobalEventListener("mouseup", resetMouseMoving, true);
17679 addGlobalEventListener("keydown", resetMouseMoving, true);
17680 addGlobalEventListener("scroll", resetMouseMoving, true);
17681 hasInstalledGlobalEventListeners = true;
17682 }, []);
17683 return useEvent(() => mouseMoving);
17684 }
17685 var mouseMoving = false;
17686 var previousScreenX = 0;
17687 var previousScreenY = 0;
17688 function hasMouseMovement(event) {
17689 const movementX = event.movementX || event.screenX - previousScreenX;
17690 const movementY = event.movementY || event.screenY - previousScreenY;
17691 previousScreenX = event.screenX;
17692 previousScreenY = event.screenY;
17693 return movementX || movementY || false;
17694 }
17695 function setMouseMoving(event) {
17696 if (!hasMouseMovement(event)) return;
17697 mouseMoving = true;
17698 }
17699 function resetMouseMoving() {
17700 mouseMoving = false;
17701 }
17702 function forwardRef39(render4) {
17703 const Role = React58.forwardRef((props, ref) => render4({
17704 ...props,
17705 ref
17706 }));
17707 Role.displayName = render4.displayName || render4.name;
17708 return Role;
17709 }
17710 function memo3(Component, propsAreEqual) {
17711 return React58.memo(Component, propsAreEqual);
17712 }
17713 function createElement3(Type, props) {
17714 const { wrapElement, render: render4, ...rest } = props;
17715 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
17716 let element;
17717 if (React58.isValidElement(render4)) {
17718 const renderProps = {
17719 ...render4.props,
17720 ref: mergedRef
17721 };
17722 element = React58.cloneElement(render4, mergeProps2(rest, renderProps));
17723 } else if (render4) element = render4(rest);
17724 else element = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Type, { ...rest });
17725 if (wrapElement) return wrapElement(element);
17726 return element;
17727 }
17728 function createHook(useProps) {
17729 const useRole = (props = {}) => {
17730 return useProps(props);
17731 };
17732 useRole.displayName = useProps.name;
17733 return useRole;
17734 }
17735 function createStoreContext(providers = [], scopedProviders = []) {
17736 const context = React58.createContext(void 0);
17737 const scopedContext = React58.createContext(void 0);
17738 const useContext47 = () => React58.useContext(context);
17739 const useScopedContext = (onlyScoped = false) => {
17740 const scoped = React58.useContext(scopedContext);
17741 const store = useContext47();
17742 if (onlyScoped) return scoped;
17743 return scoped || store;
17744 };
17745 const useProviderContext = () => {
17746 const scoped = React58.useContext(scopedContext);
17747 const store = useContext47();
17748 if (scoped && scoped === store) return;
17749 return store;
17750 };
17751 const ContextProvider = (props) => {
17752 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Provider2, {
17753 ...props,
17754 children
17755 }), /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(context.Provider, { ...props }));
17756 };
17757 const ScopedContextProvider = (props) => {
17758 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ContextProvider, {
17759 ...props,
17760 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(Provider2, {
17761 ...props,
17762 children
17763 }), /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(scopedContext.Provider, { ...props }))
17764 });
17765 };
17766 return {
17767 context,
17768 scopedContext,
17769 useContext: useContext47,
17770 useScopedContext,
17771 useProviderContext,
17772 ContextProvider,
17773 ScopedContextProvider
17774 };
17775 }
17776
17777 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
17778 var import_react14 = __toESM(require_react(), 1);
17779 var TagName = "div";
17780 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
17781 var isSafariBrowser = isSafari();
17782 var alwaysFocusVisibleInputTypes = [
17783 "text",
17784 "search",
17785 "url",
17786 "tel",
17787 "email",
17788 "password",
17789 "number",
17790 "date",
17791 "month",
17792 "week",
17793 "time",
17794 "datetime",
17795 "datetime-local"
17796 ];
17797 function isAlwaysFocusVisible(element) {
17798 const { tagName, readOnly, type } = element;
17799 if (tagName === "TEXTAREA" && !readOnly) return true;
17800 if (tagName === "SELECT" && !readOnly) return true;
17801 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
17802 if (element.isContentEditable) return true;
17803 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
17804 return false;
17805 }
17806 function isNativeTabbable(tagName) {
17807 if (!tagName) return true;
17808 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
17809 }
17810 function supportsDisabledAttribute(tagName) {
17811 if (!tagName) return true;
17812 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
17813 }
17814 function isNativeSubmitControl(element) {
17815 if (element.tagName === "BUTTON") {
17816 const { type } = element;
17817 return type === "submit";
17818 }
17819 if (element.tagName === "INPUT") {
17820 const { type } = element;
17821 return type === "submit" || type === "image";
17822 }
17823 return false;
17824 }
17825 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
17826 if (!focusable2) return tabIndexProp;
17827 if (trulyDisabled) {
17828 if (nativeTabbable && !supportsDisabled) return -1;
17829 return;
17830 }
17831 if (nativeTabbable) {
17832 if (safariTabIndex && tabIndexProp == null) return 0;
17833 return tabIndexProp;
17834 }
17835 return tabIndexProp ?? 0;
17836 }
17837 function useDisableEvent(onEvent, disabled2) {
17838 return useEvent((event) => {
17839 onEvent?.(event);
17840 if (event.defaultPrevented) return;
17841 if (disabled2) {
17842 event.stopPropagation();
17843 event.preventDefault();
17844 }
17845 });
17846 }
17847 var hasInstalledGlobalEventListeners2 = false;
17848 var isKeyboardModality = true;
17849 function onGlobalMouseDown(event) {
17850 const target = event.target;
17851 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
17852 }
17853 function onGlobalKeyDown(event) {
17854 if (event.metaKey) return;
17855 if (event.ctrlKey) return;
17856 if (event.altKey) return;
17857 isKeyboardModality = true;
17858 }
17859 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
17860 const ref = (0, import_react14.useRef)(null);
17861 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
17862 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
17863 (0, import_react14.useEffect)(() => {
17864 if (!focusable2) return;
17865 if (hasInstalledGlobalEventListeners2) return;
17866 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
17867 addGlobalEventListener("keydown", onGlobalKeyDown, true);
17868 hasInstalledGlobalEventListeners2 = true;
17869 }, [focusable2]);
17870 const disabled2 = focusable2 && disabledFromProps(props);
17871 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
17872 const [focusVisible, setFocusVisible] = (0, import_react14.useState)(false);
17873 const focusVisibleRef = (0, import_react14.useRef)(false);
17874 const nativeSubmitObserverCleanupRef = (0, import_react14.useRef)(null);
17875 const cleanupFocusVisible = useEvent((element) => {
17876 nativeSubmitObserverCleanupRef.current?.();
17877 nativeSubmitObserverCleanupRef.current = null;
17878 focusVisibleRef.current = false;
17879 element?.removeAttribute("data-focus-visible");
17880 });
17881 (0, import_react14.useEffect)(() => {
17882 if (!focusable2) return;
17883 if (!trulyDisabled) return;
17884 cleanupFocusVisible(ref.current);
17885 if (focusVisible) setFocusVisible(false);
17886 }, [
17887 focusable2,
17888 trulyDisabled,
17889 focusVisible,
17890 cleanupFocusVisible
17891 ]);
17892 (0, import_react14.useEffect)(() => {
17893 if (!focusable2) return;
17894 if (!focusVisible) return;
17895 const element = ref.current;
17896 if (!element) return;
17897 if (typeof IntersectionObserver === "undefined") return;
17898 const observer = new IntersectionObserver(() => {
17899 if (!isFocusable(element)) {
17900 focusVisibleRef.current = false;
17901 setFocusVisible(false);
17902 }
17903 });
17904 observer.observe(element);
17905 return () => observer.disconnect();
17906 }, [focusable2, focusVisible]);
17907 (0, import_react14.useEffect)(() => {
17908 return () => nativeSubmitObserverCleanupRef.current?.();
17909 }, []);
17910 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
17911 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
17912 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
17913 const handleFocusVisible = (event, currentTarget) => {
17914 if (currentTarget) event.currentTarget = currentTarget;
17915 if (!focusable2) return;
17916 const element = event.currentTarget;
17917 if (!element) return;
17918 if (!hasFocus(element)) return;
17919 onFocusVisible?.(event);
17920 if (event.defaultPrevented) return;
17921 element.dataset.focusVisible = "true";
17922 focusVisibleRef.current = true;
17923 if (isNativeSubmitControl(element)) {
17924 nativeSubmitObserverCleanupRef.current?.();
17925 nativeSubmitObserverCleanupRef.current = null;
17926 if (typeof IntersectionObserver !== "undefined") {
17927 const observer = new IntersectionObserver(() => {
17928 if (isFocusable(element)) return;
17929 cleanupFocusVisible(element);
17930 });
17931 observer.observe(element);
17932 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
17933 }
17934 return;
17935 }
17936 setFocusVisible(true);
17937 };
17938 const onKeyDownCaptureProp = props.onKeyDownCapture;
17939 const onKeyDownCapture = useEvent((event) => {
17940 onKeyDownCaptureProp?.(event);
17941 if (event.defaultPrevented) return;
17942 if (!focusable2) return;
17943 if (focusVisible) return;
17944 if (focusVisibleRef.current) return;
17945 if (event.metaKey) return;
17946 if (event.altKey) return;
17947 if (event.ctrlKey) return;
17948 if (!isSelfTarget(event)) return;
17949 const element = event.currentTarget;
17950 const applyFocusVisible = () => handleFocusVisible(event, element);
17951 queueBeforeEvent(element, "focusout", applyFocusVisible);
17952 });
17953 const onFocusCaptureProp = props.onFocusCapture;
17954 const onFocusCapture = useEvent((event) => {
17955 onFocusCaptureProp?.(event);
17956 if (event.defaultPrevented) return;
17957 if (!focusable2) return;
17958 if (!isSelfTarget(event)) {
17959 setFocusVisible(false);
17960 return;
17961 }
17962 const element = event.currentTarget;
17963 const applyFocusVisible = () => handleFocusVisible(event, element);
17964 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
17965 else setFocusVisible(false);
17966 });
17967 const onBlurProp = props.onBlur;
17968 const onBlur = useEvent((event) => {
17969 onBlurProp?.(event);
17970 if (!focusable2) return;
17971 if (!isFocusEventOutside(event)) return;
17972 cleanupFocusVisible(event.currentTarget);
17973 setFocusVisible(false);
17974 });
17975 const autoFocusOnShow = (0, import_react14.useContext)(FocusableContext);
17976 const autoFocusRef = useEvent((element) => {
17977 if (!focusable2) return;
17978 if (!autoFocus) return;
17979 if (!element) return;
17980 if (!autoFocusOnShow) return;
17981 queueMicrotask(() => {
17982 if (hasFocus(element)) return;
17983 if (!isFocusable(element)) return;
17984 element.focus();
17985 });
17986 });
17987 const tagName = useTagName(ref);
17988 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
17989 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
17990 const [safariTabIndex, setSafariTabIndex] = (0, import_react14.useState)(false);
17991 if (isSafariBrowser) (0, import_react14.useEffect)(() => {
17992 if (!focusable2) return;
17993 const element = ref.current;
17994 if (!element) return;
17995 const { type } = element;
17996 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
17997 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
17998 }, [focusable2]);
17999 const styleProp = props.style;
18000 const style = (0, import_react14.useMemo)(() => {
18001 if (trulyDisabled) return {
18002 pointerEvents: "none",
18003 ...styleProp
18004 };
18005 return styleProp;
18006 }, [trulyDisabled, styleProp]);
18007 props = {
18008 "data-focus-visible": focusable2 && focusVisible || void 0,
18009 "data-autofocus": autoFocus || void 0,
18010 "aria-disabled": disabled2 || void 0,
18011 ...props,
18012 ...metadataProps,
18013 ref: useMergeRefs(ref, autoFocusRef, props.ref),
18014 style,
18015 tabIndex: getTabIndex2({
18016 focusable: focusable2,
18017 trulyDisabled,
18018 nativeTabbable,
18019 supportsDisabled,
18020 safariTabIndex,
18021 tabIndexProp: props.tabIndex
18022 }),
18023 disabled: supportsDisabled && trulyDisabled ? true : void 0,
18024 contentEditable: disabled2 ? void 0 : props.contentEditable,
18025 onKeyPressCapture,
18026 onClickCapture,
18027 onMouseDownCapture,
18028 onKeyDownCapture,
18029 onFocusCapture,
18030 onBlur
18031 };
18032 return removeUndefinedValues(props);
18033 });
18034 var Focusable = forwardRef39(function Focusable2(props) {
18035 return createElement3(TagName, useFocusable(props));
18036 });
18037
18038 // node_modules/@ariakit/react-components/dist/command/command.js
18039 var import_react15 = __toESM(require_react(), 1);
18040 var TagName2 = "button";
18041 function isNativeClick(event) {
18042 if (!event.isTrusted) return false;
18043 const element = event.currentTarget;
18044 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
18045 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
18046 return false;
18047 }
18048 var symbol = /* @__PURE__ */ Symbol("command");
18049 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
18050 const ref = (0, import_react15.useRef)(null);
18051 const [isNativeButton, setIsNativeButton] = (0, import_react15.useState)(false);
18052 (0, import_react15.useEffect)(() => {
18053 if (!ref.current) return;
18054 setIsNativeButton(isButton(ref.current));
18055 }, []);
18056 const [active, setActive] = (0, import_react15.useState)(false);
18057 const activeRef = (0, import_react15.useRef)(false);
18058 const disabled2 = disabledFromProps(props);
18059 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
18060 useSafeLayoutEffect(() => {
18061 if (!disabled2) return;
18062 activeRef.current = false;
18063 setActive(false);
18064 }, [disabled2]);
18065 const onKeyDownProp = props.onKeyDown;
18066 const onKeyDown = useEvent((event) => {
18067 onKeyDownProp?.(event);
18068 const element = event.currentTarget;
18069 if (event.defaultPrevented) return;
18070 if (isDuplicate) return;
18071 if (disabled2) return;
18072 if (!isSelfTarget(event)) return;
18073 if (isTextField(element)) return;
18074 if (element.isContentEditable) return;
18075 const isEnter = clickOnEnter && event.key === "Enter";
18076 const isSpace = clickOnSpace && event.key === " ";
18077 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
18078 const shouldPreventSpace = event.key === " " && !clickOnSpace;
18079 if (shouldPreventEnter || shouldPreventSpace) {
18080 event.preventDefault();
18081 return;
18082 }
18083 if (isEnter || isSpace) {
18084 const nativeClick = isNativeClick(event);
18085 if (isEnter) {
18086 if (!nativeClick) {
18087 event.preventDefault();
18088 const { view, ...eventInit } = event;
18089 const click = () => fireClickEvent(element, eventInit);
18090 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
18091 else queueMicrotask(click);
18092 }
18093 } else if (isSpace) {
18094 activeRef.current = true;
18095 if (!nativeClick) {
18096 event.preventDefault();
18097 setActive(true);
18098 }
18099 }
18100 }
18101 });
18102 const onKeyUpProp = props.onKeyUp;
18103 const onKeyUp = useEvent((event) => {
18104 onKeyUpProp?.(event);
18105 if (isDuplicate) return;
18106 const isSpace = clickOnSpace && event.key === " ";
18107 if (!activeRef.current || !isSpace) return;
18108 const nativeClick = isNativeClick(event);
18109 activeRef.current = false;
18110 if (!nativeClick) setActive(false);
18111 if (event.defaultPrevented) return;
18112 if (!isSelfTarget(event)) return;
18113 if (disabled2) return;
18114 if (event.metaKey) return;
18115 if (nativeClick) return;
18116 event.preventDefault();
18117 const element = event.currentTarget;
18118 const { view, ...eventInit } = event;
18119 queueMicrotask(() => fireClickEvent(element, eventInit));
18120 });
18121 const onBlurProp = props.onBlur;
18122 const onBlur = useEvent((event) => {
18123 onBlurProp?.(event);
18124 if (!activeRef.current) return;
18125 activeRef.current = false;
18126 setActive(false);
18127 });
18128 props = {
18129 "data-active": active || void 0,
18130 type: isNativeButton ? "button" : void 0,
18131 ...metadataProps,
18132 ...props,
18133 ref: useMergeRefs(ref, props.ref),
18134 onKeyDown,
18135 onKeyUp,
18136 onBlur
18137 };
18138 props = useFocusable(props);
18139 return props;
18140 });
18141 var Command = forwardRef39(function Command2(props) {
18142 return createElement3(TagName2, useCommand(props));
18143 });
18144
18145 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
18146 var ctx = createStoreContext();
18147 var useCollectionContext = ctx.useContext;
18148 var useCollectionScopedContext = ctx.useScopedContext;
18149 var useCollectionProviderContext = ctx.useProviderContext;
18150 var CollectionContextProvider = ctx.ContextProvider;
18151 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
18152
18153 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
18154 var import_react16 = __toESM(require_react(), 1);
18155 var TagName3 = "div";
18156 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
18157 const context = useCollectionContext();
18158 store = store || context;
18159 const id = useId5(props.id);
18160 const ref = (0, import_react16.useRef)(element);
18161 (0, import_react16.useEffect)(() => {
18162 const element2 = ref.current;
18163 if (!id) return;
18164 if (!element2) return;
18165 if (!shouldRegisterItem) return;
18166 const item = getItem({
18167 id,
18168 element: element2
18169 });
18170 return store?.renderItem(item);
18171 }, [
18172 id,
18173 shouldRegisterItem,
18174 getItem,
18175 store
18176 ]);
18177 props = {
18178 ...props,
18179 ref: useMergeRefs(ref, props.ref)
18180 };
18181 return removeUndefinedValues(props);
18182 });
18183 var CollectionItem = forwardRef39(function CollectionItem2(props) {
18184 return createElement3(TagName3, useCollectionItem(props));
18185 });
18186
18187 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
18188 var import_react17 = __toESM(require_react(), 1);
18189 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
18190 var useCompositeContext = ctx2.useContext;
18191 var useCompositeScopedContext = ctx2.useScopedContext;
18192 var useCompositeProviderContext = ctx2.useProviderContext;
18193 var CompositeContextProvider = ctx2.ContextProvider;
18194 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
18195 var CompositeItemContext = (0, import_react17.createContext)(void 0);
18196 var CompositeRowContext = (0, import_react17.createContext)(void 0);
18197
18198 // node_modules/@ariakit/store/dist/index.js
18199 function getInternal(store, key) {
18200 const internals = store.__unstableInternals;
18201 invariant(internals, "Invalid store");
18202 return internals[key];
18203 }
18204 function hasUpdatedKey(keys, updatedKey) {
18205 if (!keys) return true;
18206 for (const currentKey of keys) if (updatedKey instanceof Set) {
18207 if (updatedKey.has(currentKey)) return true;
18208 } else if (currentKey === updatedKey) return true;
18209 return false;
18210 }
18211 function isSameValue(value, other) {
18212 return value === other || value !== value && other !== other;
18213 }
18214 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
18215 let cleanupPrevState;
18216 for (const key of getKeys(state)) {
18217 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
18218 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
18219 cleanupPrevState ??= { ...prevState };
18220 cleanupPrevState[key] = state[key];
18221 }
18222 return cleanupPrevState;
18223 }
18224 var MAX_REPAIR_PASSES = 100;
18225 function addKeyedListener(map, keys, listener) {
18226 if (!keys) return;
18227 for (const key of keys) {
18228 let listeners = map.get(key);
18229 if (!listeners) {
18230 listeners = /* @__PURE__ */ new Set();
18231 map.set(key, listeners);
18232 }
18233 listeners.add(listener);
18234 }
18235 }
18236 function deleteKeyedListener(map, keys, listener) {
18237 if (!map) return;
18238 if (!keys) return;
18239 for (const key of keys) {
18240 const listeners = map.get(key);
18241 if (!listeners) continue;
18242 listeners.delete(listener);
18243 if (!listeners.size) map.delete(key);
18244 }
18245 }
18246 function getFastPathNotifiedListeners(frame) {
18247 const notifiedListeners = /* @__PURE__ */ new Set();
18248 const currentListener = frame.currentListener;
18249 if (!currentListener) return notifiedListeners;
18250 for (const listener of frame.keyedListeners) {
18251 notifiedListeners.add(listener);
18252 if (listener === currentListener) return notifiedListeners;
18253 }
18254 notifiedListeners.clear();
18255 notifiedListeners.add(currentListener);
18256 return notifiedListeners;
18257 }
18258 function preserveFastPathNotifiedListeners(frame) {
18259 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
18260 }
18261 function hasFastPathPassedListener(frame, listener) {
18262 if (!frame.currentListener) return false;
18263 let foundCurrentKeyedListener = false;
18264 for (const currentListener of frame.keyedListeners) {
18265 if (currentListener === frame.currentListener) {
18266 foundCurrentKeyedListener = true;
18267 continue;
18268 }
18269 if (!foundCurrentKeyedListener) continue;
18270 if (currentListener === listener) return false;
18271 }
18272 let foundListener = false;
18273 for (const currentListener of frame.group.listeners) {
18274 if (currentListener === frame.currentListener) return foundListener;
18275 if (currentListener === listener) foundListener = true;
18276 }
18277 return false;
18278 }
18279 function preserveFastPathFrames(fastPathFrames, group, listener) {
18280 for (const frame of fastPathFrames) {
18281 if (frame.group !== group) continue;
18282 if (frame.recovering) continue;
18283 if (listener && !frame.keyedListeners.has(listener)) continue;
18284 preserveFastPathNotifiedListeners(frame);
18285 for (const currentListener of frame.group.listeners) {
18286 if (currentListener === frame.currentListener) break;
18287 if (!hasFastPathPassedListener(frame, currentListener)) continue;
18288 frame.notifiedListeners?.add(currentListener);
18289 }
18290 }
18291 }
18292 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
18293 for (const frame of fastPathFrames) {
18294 if (frame.group !== group) continue;
18295 if (frame.recovering) continue;
18296 if (!hasFastPathPassedListener(frame, listener)) continue;
18297 preserveFastPathNotifiedListeners(frame);
18298 frame.notifiedListeners?.add(listener);
18299 }
18300 }
18301 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
18302 const wasRegistered = group.listeners.has(listener);
18303 for (const frame of fastPathFrames) {
18304 if (frame.group !== group) continue;
18305 if (frame.recovering) continue;
18306 if (!keys.includes(frame.updatedKey)) continue;
18307 if (hasFastPathPassedListener(frame, listener)) {
18308 preserveFastPathNotifiedListeners(frame);
18309 frame.notifiedListeners?.add(listener);
18310 } else if (wasRegistered) {
18311 preserveFastPathNotifiedListeners(frame);
18312 frame.recoverToLive = true;
18313 }
18314 }
18315 }
18316 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
18317 for (const frame of fastPathFrames) {
18318 if (frame.group !== group) continue;
18319 frame.notifiedListeners?.delete(listener);
18320 }
18321 }
18322 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
18323 for (const frame of fastPathFrames) {
18324 if (frame.group !== group) continue;
18325 if (frame.recovering) continue;
18326 if (!keys.includes(frame.updatedKey)) continue;
18327 frame.keyedListeners.add(listener);
18328 }
18329 }
18330 function runPendingCleanup(group, listener) {
18331 if (!group.disposables.size) return;
18332 const cleanup = group.disposables.get(listener);
18333 if (!cleanup) return;
18334 group.disposables.delete(listener);
18335 cleanup();
18336 }
18337 function setListenerCleanup(group, listener, cleanup) {
18338 const currentCleanup = group.disposables.get(listener);
18339 if (!currentCleanup) {
18340 group.disposables.set(listener, cleanup);
18341 return;
18342 }
18343 group.disposables.set(listener, () => {
18344 currentCleanup();
18345 cleanup();
18346 });
18347 }
18348 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
18349 if (group.suspendCounts?.has(listener)) return;
18350 const { disposables } = group;
18351 const cleanup = disposables.size ? disposables.get(listener) : void 0;
18352 if (cleanup) {
18353 disposables.delete(listener);
18354 const stateBeforeCleanup = state;
18355 cleanup();
18356 state = getState?.() ?? state;
18357 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
18358 }
18359 const result = listener(state, prevState);
18360 if (result) setListenerCleanup(group, listener, result);
18361 }
18362 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
18363 const allKeysListeners = group.allKeysListeners;
18364 for (const listener of group.listeners) {
18365 if (notifiedListeners?.has(listener)) continue;
18366 if (!allKeysListeners?.has(listener)) {
18367 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
18368 }
18369 notifiedListeners?.add(listener);
18370 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
18371 }
18372 }
18373 function createStore(initialState, ...stores) {
18374 let state = initialState;
18375 let prevStateBatch = state;
18376 let destroy = noop4;
18377 let batchPending = false;
18378 let inDispatch = false;
18379 let updatedKeys = /* @__PURE__ */ new Set();
18380 const instances = /* @__PURE__ */ new Set();
18381 const setups = /* @__PURE__ */ new Set();
18382 const syncListenerGroup = {
18383 listeners: /* @__PURE__ */ new Set(),
18384 disposables: /* @__PURE__ */ new Map(),
18385 listenerKeys: /* @__PURE__ */ new WeakMap()
18386 };
18387 const batchListenerGroup = {
18388 listeners: /* @__PURE__ */ new Set(),
18389 disposables: /* @__PURE__ */ new Map(),
18390 listenerKeys: /* @__PURE__ */ new WeakMap()
18391 };
18392 const storeSetup = (callback) => {
18393 setups.add(callback);
18394 return () => setups.delete(callback);
18395 };
18396 const storeInit = () => {
18397 const initializedInstances = instances.size;
18398 const instance = /* @__PURE__ */ Symbol();
18399 instances.add(instance);
18400 const maybeDestroy = () => {
18401 if (!instances.delete(instance)) return;
18402 if (instances.size) return;
18403 destroy();
18404 };
18405 if (initializedInstances) return maybeDestroy;
18406 const stateKeys = getKeys(state);
18407 const desyncs = [];
18408 for (const store of stores) {
18409 const storeState = store?.getState?.();
18410 if (!storeState) continue;
18411 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
18412 if (!keys.length) continue;
18413 if (stores.length === 1 || keys.length === stateKeys.length) {
18414 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
18415 setState(key, state2[key], true);
18416 }));
18417 continue;
18418 }
18419 desyncs.push(subscribe(store, keys, (state2, prevState) => {
18420 for (const key of keys) {
18421 if (state2[key] === prevState[key]) continue;
18422 setState(key, state2[key], true);
18423 }
18424 }));
18425 for (const key of keys) {
18426 const liveState = store?.getState?.();
18427 if (!liveState) continue;
18428 setState(key, liveState[key], true);
18429 }
18430 }
18431 const teardowns = [];
18432 for (const setup2 of setups) teardowns.push(setup2());
18433 const cleanups = stores.map(init);
18434 destroy = chain(...desyncs, ...teardowns, ...cleanups);
18435 return maybeDestroy;
18436 };
18437 const deleteListenerIndexes = (group, listener, keys) => {
18438 if (keys === void 0) return;
18439 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
18440 else group.allKeysListeners?.delete(listener);
18441 };
18442 const fastPathFrames = [];
18443 const registerListener = (keys, listener, group = syncListenerGroup) => {
18444 const listenerKeysValue = keys ? [...keys] : null;
18445 const wasRegistered = group.listeners.has(listener);
18446 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
18447 if (!listenerKeysValue) {
18448 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
18449 preserveFastPathPassedListeners(fastPathFrames, group, listener);
18450 } else preserveFastPathPassedKeyedListeners({
18451 fastPathFrames,
18452 group,
18453 keys: listenerKeysValue,
18454 listener
18455 });
18456 if (wasRegistered) {
18457 preserveFastPathFrames(fastPathFrames, group, listener);
18458 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
18459 }
18460 group.listeners.add(listener);
18461 if (listenerKeysValue) {
18462 group.listenersByKey ??= /* @__PURE__ */ new Map();
18463 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
18464 addFastPathKeyedListener({
18465 fastPathFrames,
18466 group,
18467 keys: listenerKeysValue,
18468 listener
18469 });
18470 } else {
18471 group.allKeysListeners ??= /* @__PURE__ */ new Set();
18472 group.allKeysListeners.add(listener);
18473 }
18474 group.listenerKeys.set(listener, listenerKeysValue);
18475 return () => {
18476 const cleanup = group.disposables.get(listener);
18477 group.disposables.delete(listener);
18478 preserveFastPathFrames(fastPathFrames, group, listener);
18479 const currentKeys = group.listenerKeys.get(listener);
18480 deleteListenerIndexes(group, listener, listenerKeysValue);
18481 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
18482 group.listenerKeys.delete(listener);
18483 group.listeners.delete(listener);
18484 cleanup?.();
18485 };
18486 };
18487 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
18488 const runInitialListener = (group, listener, prevState) => {
18489 const shouldSuspend = group.listeners.has(listener);
18490 if (shouldSuspend) {
18491 group.suspendCounts ??= /* @__PURE__ */ new Map();
18492 const count = group.suspendCounts.get(listener) ?? 0;
18493 group.suspendCounts.set(listener, count + 1);
18494 }
18495 let cleanupPrevState;
18496 try {
18497 const stateBeforeCleanups = state;
18498 runPendingCleanup(group, listener);
18499 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
18500 const cleanup = listener(state, cleanupPrevState ?? prevState);
18501 if (cleanup) setListenerCleanup(group, listener, cleanup);
18502 } finally {
18503 if (shouldSuspend) {
18504 const suspendCounts = group.suspendCounts;
18505 const count = suspendCounts?.get(listener);
18506 if (count && count > 1) suspendCounts?.set(listener, count - 1);
18507 else suspendCounts?.delete(listener);
18508 if (!suspendCounts?.size) delete group.suspendCounts;
18509 }
18510 }
18511 };
18512 const storeSync = (keys, listener) => {
18513 runInitialListener(syncListenerGroup, listener, state);
18514 return registerListener(keys, listener);
18515 };
18516 const storeBatch = (keys, listener) => {
18517 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
18518 runInitialListener(batchListenerGroup, listener, prevStateBatch);
18519 return registerListener(keys, listener, batchListenerGroup);
18520 };
18521 const storePick = (keys) => createStore(pick(state, keys), finalStore);
18522 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
18523 const getState = () => state;
18524 const runListeners = (group, prevState, updatedKey) => {
18525 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
18526 const keyedListeners = group.listenersByKey?.get(updatedKey);
18527 if (!keyedListeners) return;
18528 const frame = {
18529 group,
18530 keyedListeners,
18531 updatedKey,
18532 currentListener: null
18533 };
18534 fastPathFrames.push(frame);
18535 try {
18536 for (const listener of keyedListeners) {
18537 if (frame.notifiedListeners?.has(listener)) continue;
18538 frame.currentListener = listener;
18539 frame.notifiedListeners?.add(listener);
18540 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
18541 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
18542 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
18543 frame.notifiedListeners = notifiedListeners;
18544 frame.recovering = true;
18545 runLiveListeners({
18546 group,
18547 getState,
18548 prevState,
18549 updatedKey,
18550 notifiedListeners
18551 });
18552 return;
18553 }
18554 } finally {
18555 fastPathFrames.pop();
18556 }
18557 return;
18558 }
18559 runLiveListeners({
18560 group,
18561 getState,
18562 prevState,
18563 updatedKey
18564 });
18565 };
18566 const setState = (key, value, fromStores = false) => {
18567 if (!hasOwnProperty(state, key)) return;
18568 const currentValue = state[key];
18569 const nextValue = typeof value === "function" ? value(currentValue) : value;
18570 if (isSameValue(nextValue, currentValue)) return;
18571 const wasInDispatch = inDispatch;
18572 inDispatch = true;
18573 const prevState = state;
18574 const nextState = {
18575 ...state,
18576 [key]: nextValue
18577 };
18578 state = nextState;
18579 let superseded = false;
18580 try {
18581 if (!fromStores && stores.length) {
18582 for (const store of stores) {
18583 store?.setState?.(key, nextValue);
18584 if (isSameValue(state[key], nextValue)) continue;
18585 superseded = true;
18586 break;
18587 }
18588 if (superseded) {
18589 let pass = 0;
18590 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
18591 let changed = false;
18592 for (const store of stores) {
18593 const previousValue = state[key];
18594 store?.setState?.(key, previousValue);
18595 if (!isSameValue(state[key], previousValue)) changed = true;
18596 }
18597 if (!changed) break;
18598 }
18599 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.");
18600 }
18601 }
18602 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
18603 ...state,
18604 [key]: prevState[key]
18605 }, key);
18606 } finally {
18607 inDispatch = wasInDispatch;
18608 }
18609 if (!batchListenerGroup.listeners.size) {
18610 if (!inDispatch) prevStateBatch = state;
18611 return;
18612 }
18613 updatedKeys.add(key);
18614 if (batchPending) return;
18615 batchPending = true;
18616 queueMicrotask(() => {
18617 batchPending = false;
18618 const snapshot = state;
18619 const updatedKeysSnapshot = updatedKeys;
18620 updatedKeys = /* @__PURE__ */ new Set();
18621 const prevStateBatchBefore = prevStateBatch;
18622 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
18623 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
18624 });
18625 };
18626 const finalStore = {
18627 getState,
18628 setState,
18629 __unstableInternals: {
18630 setup: storeSetup,
18631 init: storeInit,
18632 subscribe: storeSubscribe,
18633 sync: storeSync,
18634 batch: storeBatch,
18635 pick: storePick,
18636 omit: storeOmit
18637 }
18638 };
18639 return finalStore;
18640 }
18641 function setup(store, ...args) {
18642 if (!store) return;
18643 return getInternal(store, "setup")(...args);
18644 }
18645 function init(store, ...args) {
18646 if (!store) return;
18647 return getInternal(store, "init")(...args);
18648 }
18649 function subscribe(store, ...args) {
18650 if (!store) return;
18651 return getInternal(store, "subscribe")(...args);
18652 }
18653 function sync(store, ...args) {
18654 if (!store) return;
18655 return getInternal(store, "sync")(...args);
18656 }
18657 function batch(store, ...args) {
18658 if (!store) return;
18659 return getInternal(store, "batch")(...args);
18660 }
18661 function omit2(store, ...args) {
18662 if (!store) return;
18663 return getInternal(store, "omit")(...args);
18664 }
18665 function pick2(store, ...args) {
18666 if (!store) return;
18667 return getInternal(store, "pick")(...args);
18668 }
18669 function mergeStore(...stores) {
18670 const initialState = {};
18671 for (const store2 of stores) {
18672 const nextState = store2?.getState?.();
18673 if (nextState) Object.assign(initialState, nextState);
18674 }
18675 const store = createStore(initialState, ...stores);
18676 return Object.assign({}, ...stores, store);
18677 }
18678 function throwOnConflictingProps(props, store) {
18679 if (false) return;
18680 if (!store) return;
18681 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
18682 const stateKey = key.replace("default", "");
18683 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
18684 });
18685 if (!defaultKeys.length) return;
18686 const storeState = store.getState();
18687 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
18688 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
18689
18690 const store = useSelectStore();
18691 <SelectProvider store={store} defaultValue="Apple" />
18692 ^ ^
18693
18694 Instead, pass the default state to the topmost store:
18695
18696 const store = useSelectStore({ defaultValue: "Apple" });
18697 <SelectProvider store={store} />
18698
18699 See https://github.com/ariakit/ariakit/pull/2745 for more details.
18700
18701 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
18702 `);
18703 }
18704
18705 // node_modules/@ariakit/components/dist/collection/collection-store.js
18706 function getCommonParent(items) {
18707 const firstItem = items.find((item) => !!item.element);
18708 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
18709 let parentElement = firstItem?.element?.parentElement;
18710 if (!lastElement) return getDocument(parentElement).body;
18711 while (parentElement) {
18712 if (parentElement.contains(lastElement)) return parentElement;
18713 parentElement = parentElement.parentElement;
18714 }
18715 return getDocument(parentElement).body;
18716 }
18717 function getPrivateStore(store) {
18718 return store?.__unstablePrivateStore;
18719 }
18720 function createCollectionStore(props = {}) {
18721 throwOnConflictingProps(props, props.store);
18722 const syncState = props.store?.getState();
18723 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
18724 const itemsMap = new Map(items.map((item) => [item.id, item]));
18725 const initialState = {
18726 items,
18727 renderedItems: defaultValue(syncState?.renderedItems, [])
18728 };
18729 const syncPrivateStore = getPrivateStore(props.store);
18730 const privateStore = createStore({
18731 items,
18732 renderedItems: initialState.renderedItems
18733 }, syncPrivateStore);
18734 const collection = createStore(initialState, props.store);
18735 const sortItems = (renderedItems) => {
18736 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
18737 privateStore.setState("renderedItems", sortedItems);
18738 collection.setState("renderedItems", sortedItems);
18739 };
18740 setup(collection, () => init(privateStore));
18741 setup(privateStore, () => {
18742 return batch(privateStore, ["items"], (state) => {
18743 collection.setState("items", state.items);
18744 });
18745 });
18746 setup(privateStore, () => {
18747 return batch(privateStore, ["renderedItems"], (state) => {
18748 let firstRun = true;
18749 let raf = requestAnimationFrame(() => {
18750 const { renderedItems } = collection.getState();
18751 if (state.renderedItems === renderedItems) return;
18752 sortItems(state.renderedItems);
18753 });
18754 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
18755 const ioCallback = () => {
18756 if (firstRun) {
18757 firstRun = false;
18758 return;
18759 }
18760 cancelAnimationFrame(raf);
18761 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
18762 };
18763 const root = getCommonParent(state.renderedItems);
18764 const observer = new IntersectionObserver(ioCallback, { root });
18765 for (const item of state.renderedItems) {
18766 if (!item.element) continue;
18767 observer.observe(item.element);
18768 }
18769 return () => {
18770 cancelAnimationFrame(raf);
18771 observer.disconnect();
18772 };
18773 });
18774 });
18775 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
18776 let prevItem;
18777 setItems((items2) => {
18778 const index2 = items2.findIndex(({ id }) => id === item.id);
18779 const nextItems = items2.slice();
18780 if (index2 !== -1) {
18781 prevItem = items2[index2];
18782 const nextItem = {
18783 ...prevItem,
18784 ...item
18785 };
18786 nextItems[index2] = nextItem;
18787 itemsMap.set(item.id, nextItem);
18788 } else {
18789 nextItems.push(item);
18790 itemsMap.set(item.id, item);
18791 }
18792 return nextItems;
18793 });
18794 const unmergeItem = () => {
18795 setItems((items2) => {
18796 if (!prevItem) {
18797 if (canDeleteFromMap) itemsMap.delete(item.id);
18798 return items2.filter(({ id }) => id !== item.id);
18799 }
18800 const index2 = items2.findIndex(({ id }) => id === item.id);
18801 if (index2 === -1) return items2;
18802 const nextItems = items2.slice();
18803 nextItems[index2] = prevItem;
18804 itemsMap.set(item.id, prevItem);
18805 return nextItems;
18806 });
18807 };
18808 return unmergeItem;
18809 };
18810 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
18811 return {
18812 ...collection,
18813 registerItem,
18814 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
18815 item: (id) => {
18816 if (!id) return null;
18817 let item = itemsMap.get(id);
18818 if (!item) {
18819 const { items: items2 } = privateStore.getState();
18820 item = items2.find((item2) => item2.id === id);
18821 if (item) itemsMap.set(id, item);
18822 }
18823 return item || null;
18824 },
18825 __unstablePrivateStore: privateStore
18826 };
18827 }
18828
18829 // node_modules/@ariakit/components/dist/composite/composite-store.js
18830 var NULL_ITEM = { id: null };
18831 function findFirstEnabledItem(items, excludeId) {
18832 return items.find((item) => {
18833 if (excludeId) return !item.disabled && item.id !== excludeId;
18834 return !item.disabled;
18835 });
18836 }
18837 function getEnabledItems(items, excludeId) {
18838 return items.filter((item) => {
18839 if (excludeId) return !item.disabled && item.id !== excludeId;
18840 return !item.disabled;
18841 });
18842 }
18843 function getItemsInRow(items, rowId) {
18844 return items.filter((item) => item.rowId === rowId);
18845 }
18846 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
18847 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
18848 const item = items[i2];
18849 if (!item) continue;
18850 if (item.rowId !== rowId) continue;
18851 if (item.disabled) continue;
18852 if (excludeId != null && item.id === excludeId) continue;
18853 return item.id;
18854 }
18855 }
18856 function flipItems(items, activeId, shouldInsertNullItem = false) {
18857 const index2 = items.findIndex((item) => item.id === activeId);
18858 return [
18859 ...items.slice(index2 + 1),
18860 ...shouldInsertNullItem ? [NULL_ITEM] : [],
18861 ...items.slice(0, index2)
18862 ];
18863 }
18864 function groupItemsByRows(items) {
18865 const rows = [];
18866 for (const item of items) {
18867 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
18868 if (row) row.push(item);
18869 else rows.push([item]);
18870 }
18871 return rows;
18872 }
18873 function getMaxRowLength(array) {
18874 let maxLength = 0;
18875 for (const { length } of array) if (length > maxLength) maxLength = length;
18876 return maxLength;
18877 }
18878 function createEmptyItem(rowId) {
18879 return {
18880 id: "__EMPTY_ITEM__",
18881 disabled: true,
18882 rowId
18883 };
18884 }
18885 function normalizeRows(rows, activeId, focusShift) {
18886 const maxLength = getMaxRowLength(rows);
18887 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
18888 const item = row[i2];
18889 if (!item || focusShift && item.disabled) {
18890 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
18891 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
18892 }
18893 }
18894 return rows;
18895 }
18896 function verticalizeItems(items) {
18897 const rows = groupItemsByRows(items);
18898 const maxLength = getMaxRowLength(rows);
18899 const verticalized = [];
18900 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
18901 const item = row[i2];
18902 if (item) verticalized.push({
18903 ...item,
18904 rowId: item.rowId ? `${i2}` : void 0
18905 });
18906 }
18907 return verticalized;
18908 }
18909 function createCompositeStore(props = {}) {
18910 const syncState = props.store?.getState();
18911 const collection = createCollectionStore(props);
18912 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
18913 const composite = createStore({
18914 ...collection.getState(),
18915 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
18916 activeId,
18917 baseElement: defaultValue(syncState?.baseElement, null),
18918 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
18919 moves: defaultValue(syncState?.moves, 0),
18920 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
18921 rtl: defaultValue(props.rtl, syncState?.rtl, false),
18922 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
18923 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
18924 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
18925 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
18926 }, collection, props.store);
18927 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
18928 composite.setState("activeId", (activeId2) => {
18929 if (activeId2 !== void 0) return activeId2;
18930 return findFirstEnabledItem(state.renderedItems)?.id;
18931 });
18932 }));
18933 const getNextId = (direction = "next", options = {}) => {
18934 const defaultState = composite.getState();
18935 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;
18936 const isVerticalDirection = direction === "up" || direction === "down";
18937 const isNextDirection = direction === "next" || direction === "down";
18938 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
18939 const canShift = focusShift && !skip;
18940 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
18941 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
18942 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
18943 const activeItem2 = renderedItems[activeIndex2];
18944 if (activeItem2) {
18945 const step = canReverse ? -1 : 1;
18946 const nextId = findEnabledItemId({
18947 items: renderedItems,
18948 fromIndex: activeIndex2 + step,
18949 step,
18950 rowId: activeItem2.rowId,
18951 excludeId: activeId2
18952 });
18953 if (nextId !== void 0) return nextId;
18954 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
18955 return findEnabledItemId({
18956 items: renderedItems,
18957 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
18958 step,
18959 rowId: activeItem2.rowId,
18960 excludeId: activeId2
18961 });
18962 }
18963 }
18964 }
18965 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
18966 items = canReverse ? reverseArray(items) : items;
18967 items = isVerticalDirection ? verticalizeItems(items) : items;
18968 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
18969 const activeItem = items.find((item) => item.id === activeId2);
18970 if (!activeItem) return findFirstEnabledItem(items)?.id;
18971 const isGrid2 = items.some((item) => item.rowId);
18972 const activeIndex = items.indexOf(activeItem);
18973 const nextItems = items.slice(activeIndex + 1);
18974 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
18975 if (skip) {
18976 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
18977 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
18978 }
18979 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
18980 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
18981 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
18982 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
18983 if (canWrap) {
18984 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
18985 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
18986 }
18987 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
18988 if (!nextItem && hasNullItem) return null;
18989 return nextItem?.id;
18990 };
18991 const getNextIdFromOptions = (direction, options) => {
18992 if (typeof options === "number") return getNextId(direction, { skip: options });
18993 return getNextId(direction, options);
18994 };
18995 return {
18996 ...collection,
18997 ...composite,
18998 setBaseElement: (element) => composite.setState("baseElement", element),
18999 setActiveId: (id) => composite.setState("activeId", id),
19000 move: (id) => {
19001 if (id === void 0) return;
19002 composite.setState("activeId", id);
19003 composite.setState("moves", (moves) => moves + 1);
19004 },
19005 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
19006 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
19007 next: (options) => getNextIdFromOptions("next", options),
19008 previous: (options) => getNextIdFromOptions("previous", options),
19009 down: (options) => getNextIdFromOptions("down", options),
19010 up: (options) => getNextIdFromOptions("up", options)
19011 };
19012 }
19013
19014 // node_modules/@ariakit/react-components/dist/composite/utils.js
19015 var findFirstEnabledItem2 = findFirstEnabledItem;
19016 var groupItemsByRows2 = groupItemsByRows;
19017 function getEnabledItem(store, id) {
19018 if (!id) return null;
19019 return store.item(id) || null;
19020 }
19021 function selectTextField(element, collapseToEnd = false) {
19022 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
19023 else if (element.isContentEditable) {
19024 const selection = getDocument(element).getSelection();
19025 selection?.selectAllChildren(element);
19026 if (collapseToEnd) selection?.collapseToEnd();
19027 }
19028 }
19029 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
19030 function focusSilently(element) {
19031 element[FOCUS_SILENTLY] = true;
19032 element.focus({ preventScroll: true });
19033 }
19034 function silentlyFocused(element) {
19035 const isSilentlyFocused = element[FOCUS_SILENTLY];
19036 delete element[FOCUS_SILENTLY];
19037 return isSilentlyFocused;
19038 }
19039 function isItem(store, element, exclude) {
19040 if (!element) return false;
19041 if (element === exclude) return false;
19042 const item = store.item(element.id);
19043 if (!item) return false;
19044 if (exclude && item.element === exclude) return false;
19045 return true;
19046 }
19047
19048 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
19049 var import_react18 = __toESM(require_react(), 1);
19050 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
19051
19052 // node_modules/@ariakit/react-store/dist/index.js
19053 var React59 = __toESM(require_react(), 1);
19054 var import_shim2 = __toESM(require_shim(), 1);
19055 var noopSubscribe = () => () => {
19056 };
19057 function useStoreState(store, keyOrSelector = identity) {
19058 const storeSubscribe = React59.useCallback((callback) => {
19059 if (!store) return noopSubscribe();
19060 return subscribe(store, null, callback);
19061 }, [store]);
19062 const getSnapshot = () => {
19063 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
19064 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
19065 const state = store?.getState();
19066 if (selector2) return selector2(state);
19067 if (!state) return;
19068 if (!key) return;
19069 if (!hasOwnProperty(state, key)) return;
19070 return state[key];
19071 };
19072 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19073 }
19074 function useStoreStateObject(store, object) {
19075 const objRef = React59.useRef({});
19076 const storeSubscribe = React59.useCallback((callback) => {
19077 if (!store) return noopSubscribe();
19078 return subscribe(store, null, callback);
19079 }, [store]);
19080 const getSnapshot = () => {
19081 const state = store?.getState();
19082 let updated = false;
19083 const obj = objRef.current;
19084 for (const prop in object) {
19085 const keyOrSelector = object[prop];
19086 if (typeof keyOrSelector === "function") {
19087 const value = keyOrSelector(state);
19088 if (!Object.is(value, obj[prop])) {
19089 obj[prop] = value;
19090 updated = true;
19091 }
19092 }
19093 if (typeof keyOrSelector === "string") {
19094 if (!state) continue;
19095 if (!hasOwnProperty(state, keyOrSelector)) continue;
19096 const value = state[keyOrSelector];
19097 if (!Object.is(value, obj[prop])) {
19098 obj[prop] = value;
19099 updated = true;
19100 }
19101 }
19102 }
19103 if (updated) objRef.current = { ...obj };
19104 return objRef.current;
19105 };
19106 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19107 }
19108 function useStoreProps(store, props, key, setKey) {
19109 const value = hasOwnProperty(props, key) ? props[key] : void 0;
19110 const propsRef = useLiveRef({
19111 value,
19112 setValue: setKey ? props[setKey] : void 0
19113 });
19114 useSafeLayoutEffect(() => {
19115 return sync(store, [key], (state, prev) => {
19116 const { value: value2, setValue } = propsRef.current;
19117 if (!setValue) return;
19118 if (state[key] === prev[key]) return;
19119 if (state[key] === value2) return;
19120 setValue(state[key]);
19121 });
19122 }, [store, key]);
19123 useSafeLayoutEffect(() => {
19124 if (value === void 0) return;
19125 store.setState(key, value);
19126 return batch(store, [key], () => {
19127 if (value === void 0) return;
19128 store.setState(key, value);
19129 });
19130 });
19131 }
19132 function useStore2(createStore2, props) {
19133 const [store, setStore] = React59.useState(() => createStore2(props));
19134 useSafeLayoutEffect(() => init(store), [store]);
19135 const useState50 = React59.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
19136 return [React59.useMemo(() => ({
19137 ...store,
19138 useState: useState50
19139 }), [store, useState50]), useEvent(() => {
19140 setStore((store2) => createStore2({
19141 ...props,
19142 ...store2.getState()
19143 }));
19144 })];
19145 }
19146
19147 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
19148 var TagName4 = "button";
19149 function isEditableElement(element) {
19150 if (isTextbox(element)) return true;
19151 return element.tagName === "INPUT" && !isButton(element);
19152 }
19153 function getNextPageOffset(scrollingElement, pageUp = false) {
19154 const height = scrollingElement.clientHeight;
19155 const { top } = scrollingElement.getBoundingClientRect();
19156 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
19157 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
19158 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
19159 return pageOffset;
19160 }
19161 function getItemOffset(itemElement, pageUp = false) {
19162 const { top } = itemElement.getBoundingClientRect();
19163 if (pageUp) return top + itemElement.clientHeight;
19164 return top;
19165 }
19166 function findNextPageItemId(element, store, next, pageUp = false) {
19167 if (!store) return;
19168 if (!next) return;
19169 const { renderedItems } = store.getState();
19170 const scrollingElement = getScrollingElement(element);
19171 if (!scrollingElement) return;
19172 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
19173 let id;
19174 let prevDifference;
19175 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
19176 const previousId = id;
19177 id = next(i2);
19178 if (!id) break;
19179 if (id === previousId) continue;
19180 const itemElement = getEnabledItem(store, id)?.element;
19181 if (!itemElement) continue;
19182 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
19183 const absDifference = Math.abs(difference);
19184 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
19185 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
19186 break;
19187 }
19188 prevDifference = absDifference;
19189 }
19190 return id;
19191 }
19192 function targetIsAnotherItem(event, store) {
19193 if (isSelfTarget(event)) return false;
19194 return isItem(store, event.target);
19195 }
19196 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
19197 const context = useCompositeScopedContext();
19198 store = store || context;
19199 const id = useId5(props.id);
19200 const ref = (0, import_react18.useRef)(null);
19201 const row = (0, import_react18.useContext)(CompositeRowContext);
19202 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
19203 const shouldRegisterItem = props.shouldRegisterItem;
19204 const getRowId = (state) => {
19205 if (rowIdProp) return rowIdProp;
19206 if (!state) return;
19207 if (!row?.baseElement) return;
19208 if (row.baseElement !== state.baseElement) return;
19209 return row.id;
19210 };
19211 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
19212 rowId: getRowId,
19213 baseElement(state) {
19214 return state?.baseElement || void 0;
19215 },
19216 isActiveItem(state) {
19217 return !!state && state.activeId === id;
19218 },
19219 ariaSetSize(state) {
19220 if (ariaSetSizeProp != null) return ariaSetSizeProp;
19221 if (!state) return;
19222 if (!row?.ariaSetSize) return;
19223 if (row.baseElement !== state.baseElement) return;
19224 return row.ariaSetSize;
19225 },
19226 ariaPosInSet(state) {
19227 if (ariaPosInSetProp != null) return ariaPosInSetProp;
19228 if (!state) return;
19229 if (!row?.ariaPosInSet) return;
19230 if (row.baseElement !== state.baseElement) return;
19231 const rowId2 = getRowId(state);
19232 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
19233 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
19234 },
19235 isTabbable(state) {
19236 if (!state?.renderedItems.length) return true;
19237 if (state.virtualFocus) return false;
19238 if (tabbable2) return true;
19239 if (state.activeId === null) return false;
19240 const item = store?.item(state.activeId);
19241 if (item?.disabled) return true;
19242 if (!item?.element) return true;
19243 return state.activeId === id;
19244 }
19245 });
19246 const getItem = (0, import_react18.useCallback)((item) => {
19247 const nextItem = {
19248 ...item,
19249 id: id || item.id,
19250 rowId,
19251 disabled: trulyDisabled,
19252 children: item.element?.textContent
19253 };
19254 if (getItemProp) return getItemProp(nextItem);
19255 return nextItem;
19256 }, [
19257 id,
19258 rowId,
19259 trulyDisabled,
19260 getItemProp
19261 ]);
19262 const onFocusProp = props.onFocus;
19263 const hasFocusedComposite = (0, import_react18.useRef)(false);
19264 const cancelScheduledFocusRedirectRef = (0, import_react18.useRef)(null);
19265 const onFocus = useEvent((event) => {
19266 onFocusProp?.(event);
19267 if (event.defaultPrevented) return;
19268 if (isPortalEvent(event)) return;
19269 if (!id) return;
19270 if (!store) return;
19271 if (targetIsAnotherItem(event, store)) return;
19272 const { virtualFocus, baseElement: baseElement2 } = store.getState();
19273 store.setActiveId(id);
19274 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
19275 if (!virtualFocus) return;
19276 if (!isSelfTarget(event)) return;
19277 if (isEditableElement(event.currentTarget)) return;
19278 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
19279 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
19280 block: "nearest",
19281 inline: "nearest"
19282 });
19283 hasFocusedComposite.current = true;
19284 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
19285 else baseElement3.focus();
19286 };
19287 if (baseElement2?.isConnected) {
19288 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
19289 return;
19290 }
19291 if (shouldRegisterItem === false) return;
19292 const { currentTarget, relatedTarget } = event;
19293 const cancelScheduledFocusRedirect = () => {
19294 cancelScheduledFocusRedirectRef.current?.();
19295 cancelScheduledFocusRedirectRef.current = null;
19296 };
19297 cancelScheduledFocusRedirect();
19298 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
19299 if (getActiveElement(currentTarget) !== currentTarget) {
19300 cancelScheduledFocusRedirect();
19301 return;
19302 }
19303 const state = store.getState();
19304 const nextBaseElement = state.baseElement;
19305 if (!nextBaseElement?.isConnected) return;
19306 cancelScheduledFocusRedirect();
19307 if (!state.virtualFocus) return;
19308 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
19309 });
19310 });
19311 const onBlurCaptureProp = props.onBlurCapture;
19312 const onBlurCapture = useEvent((event) => {
19313 onBlurCaptureProp?.(event);
19314 if (event.defaultPrevented) return;
19315 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
19316 hasFocusedComposite.current = false;
19317 event.preventDefault();
19318 event.stopPropagation();
19319 }
19320 });
19321 const onKeyDownProp = props.onKeyDown;
19322 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
19323 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19324 const onKeyDown = useEvent((event) => {
19325 onKeyDownProp?.(event);
19326 if (event.defaultPrevented) return;
19327 if (!isSelfTarget(event)) return;
19328 if (!store) return;
19329 const { currentTarget } = event;
19330 const state = store.getState();
19331 const isGrid2 = !!store.item(id)?.rowId;
19332 const isVertical = state.orientation !== "horizontal";
19333 const isHorizontal = state.orientation !== "vertical";
19334 const canHomeEnd = () => {
19335 if (isGrid2) return true;
19336 if (isHorizontal) return true;
19337 if (!state.baseElement) return true;
19338 if (!isTextField(state.baseElement)) return true;
19339 return false;
19340 };
19341 const action = {
19342 ArrowUp: (isGrid2 || isVertical) && store.up,
19343 ArrowRight: (isGrid2 || isHorizontal) && store.next,
19344 ArrowDown: (isGrid2 || isVertical) && store.down,
19345 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
19346 Home: () => {
19347 if (!canHomeEnd()) return;
19348 if (!isGrid2 || event.ctrlKey) return store?.first();
19349 return store?.previous(-1);
19350 },
19351 End: () => {
19352 if (!canHomeEnd()) return;
19353 if (!isGrid2 || event.ctrlKey) return store?.last();
19354 return store?.next(-1);
19355 },
19356 PageUp: () => {
19357 return findNextPageItemId(currentTarget, store, store?.up, true);
19358 },
19359 PageDown: () => {
19360 return findNextPageItemId(currentTarget, store, store?.down);
19361 }
19362 }[event.key];
19363 if (action) {
19364 if (isTextbox(currentTarget)) {
19365 const selection = getTextboxSelection(currentTarget);
19366 const isLeft = isHorizontal && event.key === "ArrowLeft";
19367 const isRight = isHorizontal && event.key === "ArrowRight";
19368 const isUp = isVertical && event.key === "ArrowUp";
19369 const isDown = isVertical && event.key === "ArrowDown";
19370 if (isRight || isDown) {
19371 const { length: valueLength } = getTextboxValue(currentTarget);
19372 if (selection.end !== valueLength) return;
19373 } else if ((isLeft || isUp) && selection.start !== 0) return;
19374 }
19375 const nextId = action();
19376 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
19377 if (!moveOnKeyPressProp(event)) return;
19378 event.preventDefault();
19379 store.move(nextId);
19380 }
19381 }
19382 });
19383 const providerValue = (0, import_react18.useMemo)(() => ({
19384 id,
19385 baseElement
19386 }), [id, baseElement]);
19387 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CompositeItemContext.Provider, {
19388 value: providerValue,
19389 children: element
19390 }), [providerValue]);
19391 props = {
19392 "data-active-item": isActiveItem || void 0,
19393 ...props,
19394 id,
19395 ref: useMergeRefs(ref, props.ref),
19396 tabIndex: isTabbable ? props.tabIndex : -1,
19397 onFocus,
19398 onBlurCapture,
19399 onKeyDown
19400 };
19401 props = useCommand(props);
19402 props = useCollectionItem({
19403 store,
19404 ...props,
19405 getItem,
19406 shouldRegisterItem: id ? shouldRegisterItem : false
19407 });
19408 return removeUndefinedValues({
19409 ...props,
19410 "aria-setsize": ariaSetSize,
19411 "aria-posinset": ariaPosInSet
19412 });
19413 });
19414 var CompositeItem = memo3(forwardRef39(function CompositeItem2(props) {
19415 return createElement3(TagName4, useCompositeItem(props));
19416 }));
19417
19418 // node_modules/@ariakit/react-components/dist/composite/composite.js
19419 var import_react19 = __toESM(require_react(), 1);
19420 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
19421 var TagName5 = "div";
19422 function isGrid(items) {
19423 return items.some((item) => !!item.rowId);
19424 }
19425 function isPrintableKey(event) {
19426 const target = event.target;
19427 if (target && !isTextField(target)) return false;
19428 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19429 }
19430 function isModifierKey(event) {
19431 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
19432 }
19433 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
19434 return useEvent((event) => {
19435 onKeyboardEvent?.(event);
19436 if (event.defaultPrevented) return;
19437 if (event.isPropagationStopped()) return;
19438 if (!isSelfTarget(event)) return;
19439 if (isModifierKey(event)) return;
19440 if (isPrintableKey(event)) return;
19441 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
19442 if (!activeElement2) return;
19443 const { view, ...eventInit } = event;
19444 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
19445 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
19446 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
19447 });
19448 }
19449 function findFirstEnabledItemInTheLastRow(items) {
19450 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
19451 }
19452 function withBaseScrollPreserved(store, callback) {
19453 const { virtualFocus, baseElement } = store.getState();
19454 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
19455 callback();
19456 return;
19457 }
19458 const savedScrollLeft = baseElement.scrollLeft;
19459 const savedScrollTop = baseElement.scrollTop;
19460 callback();
19461 baseElement.scrollLeft = savedScrollLeft;
19462 baseElement.scrollTop = savedScrollTop;
19463 }
19464 function useScheduleFocus(store) {
19465 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
19466 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
19467 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
19468 (0, import_react19.useEffect)(() => {
19469 const activeElement2 = activeItem?.element;
19470 if (!scheduled) return;
19471 if (!activeElement2) return;
19472 setScheduled(false);
19473 withBaseScrollPreserved(store, () => {
19474 activeElement2.focus({ preventScroll: true });
19475 });
19476 }, [
19477 store,
19478 activeItem,
19479 scheduled
19480 ]);
19481 return schedule;
19482 }
19483 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
19484 const moves = useStoreState(store, "moves");
19485 const baseElement = useStoreState(store, "baseElement");
19486 (0, import_react19.useEffect)(() => {
19487 if (!moves) return;
19488 if (!focusOnMove) return;
19489 const { activeId } = store.getState();
19490 const itemElement = getEnabledItem(store, activeId)?.element;
19491 if (!itemElement) return;
19492 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
19493 }, [
19494 store,
19495 moves,
19496 focusOnMove
19497 ]);
19498 useSafeLayoutEffect(() => {
19499 if (!moves) return;
19500 if (!baseElement) return;
19501 const { activeId } = store.getState();
19502 if (!(activeId === null)) return;
19503 const previousElement = previousElementRef.current;
19504 previousElementRef.current = null;
19505 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
19506 if (!hasFocus(baseElement)) baseElement.focus();
19507 }, [
19508 store,
19509 moves,
19510 baseElement
19511 ]);
19512 return null;
19513 });
19514 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
19515 const context = useCompositeProviderContext();
19516 store = store || context;
19517 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
19518 const ref = (0, import_react19.useRef)(null);
19519 const previousElementRef = (0, import_react19.useRef)(null);
19520 const scheduleFocus = useScheduleFocus(store);
19521 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
19522 const virtualFocus = useStoreState(store, "virtualFocus");
19523 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
19524 useSafeLayoutEffect(() => {
19525 if (!store) return;
19526 if (!composite) return;
19527 if (!virtualFocus) return;
19528 const previousElement = previousElementRef.current;
19529 previousElementRef.current = null;
19530 if (!previousElement) return;
19531 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
19532 if (relatedTarget === previousElement) return;
19533 fireBlurEvent(previousElement, { relatedTarget });
19534 }, [
19535 store,
19536 activeId,
19537 virtualFocus,
19538 composite
19539 ]);
19540 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
19541 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
19542 const onFocusCaptureProp = props.onFocusCapture;
19543 const onFocusCapture = useEvent((event) => {
19544 onFocusCaptureProp?.(event);
19545 if (event.defaultPrevented) return;
19546 if (!store) return;
19547 const { virtualFocus: virtualFocus2 } = store.getState();
19548 if (!virtualFocus2) return;
19549 const previousActiveElement = event.relatedTarget;
19550 const isSilentlyFocused = silentlyFocused(event.currentTarget);
19551 if (isSelfTarget(event) && isSilentlyFocused) {
19552 event.stopPropagation();
19553 previousElementRef.current = previousActiveElement;
19554 }
19555 });
19556 const onFocusProp = props.onFocus;
19557 const onFocus = useEvent((event) => {
19558 onFocusProp?.(event);
19559 if (event.defaultPrevented) return;
19560 if (!composite) return;
19561 if (!store) return;
19562 const { relatedTarget } = event;
19563 const { virtualFocus: virtualFocus2 } = store.getState();
19564 if (virtualFocus2) {
19565 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
19566 } else if (isSelfTarget(event)) store.setActiveId(null);
19567 });
19568 const onBlurCaptureProp = props.onBlurCapture;
19569 const onBlurCapture = useEvent((event) => {
19570 onBlurCaptureProp?.(event);
19571 if (event.defaultPrevented) return;
19572 if (!store) return;
19573 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
19574 if (!virtualFocus2) return;
19575 const activeElement2 = getEnabledItem(store, activeId2)?.element;
19576 const nextActiveElement = event.relatedTarget;
19577 const nextActiveElementIsItem = isItem(store, nextActiveElement);
19578 const previousElement = previousElementRef.current;
19579 previousElementRef.current = null;
19580 if (isSelfTarget(event) && nextActiveElementIsItem) {
19581 if (nextActiveElement === activeElement2) {
19582 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
19583 } else if (activeElement2) fireBlurEvent(activeElement2, event);
19584 else if (previousElement) fireBlurEvent(previousElement, event);
19585 event.stopPropagation();
19586 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
19587 });
19588 const onKeyDownProp = props.onKeyDown;
19589 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19590 const onKeyDown = useEvent((event) => {
19591 onKeyDownProp?.(event);
19592 if (event.nativeEvent.isComposing) return;
19593 if (event.defaultPrevented) return;
19594 if (!store) return;
19595 if (!isSelfTarget(event)) return;
19596 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
19597 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
19598 const isVertical = orientation !== "horizontal";
19599 const isHorizontal = orientation !== "vertical";
19600 const grid = isGrid(renderedItems);
19601 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
19602 const up = () => {
19603 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
19604 return store?.last();
19605 };
19606 const action = {
19607 ArrowUp: (grid || isVertical) && up,
19608 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
19609 ArrowDown: (grid || isVertical) && store.first,
19610 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
19611 Home: store.first,
19612 End: store.last,
19613 PageUp: store.first,
19614 PageDown: store.last
19615 }[event.key];
19616 if (action) {
19617 const id = action();
19618 if (id !== void 0) {
19619 if (!moveOnKeyPressProp(event)) return;
19620 event.preventDefault();
19621 store.move(id);
19622 }
19623 }
19624 });
19625 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(CompositeScopedContextProvider, {
19626 value: store,
19627 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(CompositeFocusOnMove, {
19628 store,
19629 focusOnMove,
19630 previousElementRef
19631 })]
19632 }), [
19633 store,
19634 composite,
19635 focusOnMove
19636 ]);
19637 props = {
19638 "aria-activedescendant": useStoreState(store, (state) => {
19639 if (!store) return;
19640 if (!composite) return;
19641 if (!state.virtualFocus) return;
19642 return getEnabledItem(store, state.activeId)?.id;
19643 }),
19644 ...props,
19645 ref: useMergeRefs(ref, setBaseElement, props.ref),
19646 onKeyDownCapture,
19647 onKeyUpCapture,
19648 onFocusCapture,
19649 onFocus,
19650 onBlurCapture,
19651 onKeyDown
19652 };
19653 props = useFocusable({
19654 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
19655 ...props
19656 });
19657 return props;
19658 });
19659 var Composite6 = forwardRef39(function Composite7(props) {
19660 return createElement3(TagName5, useComposite(props));
19661 });
19662
19663 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
19664 var ctx3 = createStoreContext();
19665 var useDisclosureContext = ctx3.useContext;
19666 var useDisclosureScopedContext = ctx3.useScopedContext;
19667 var useDisclosureProviderContext = ctx3.useProviderContext;
19668 var DisclosureContextProvider = ctx3.ContextProvider;
19669 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
19670
19671 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
19672 var import_react20 = __toESM(require_react(), 1);
19673 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
19674 var useDialogContext = ctx4.useContext;
19675 var useDialogScopedContext = ctx4.useScopedContext;
19676 var useDialogProviderContext = ctx4.useProviderContext;
19677 var DialogContextProvider = ctx4.ContextProvider;
19678 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
19679 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
19680 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
19681
19682 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
19683 var import_react21 = __toESM(require_react(), 1);
19684 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
19685 var import_react_dom4 = __toESM(require_react_dom(), 1);
19686 var TagName6 = "div";
19687 function afterTimeout(timeoutMs, cb) {
19688 const timeoutId = setTimeout(cb, timeoutMs);
19689 return () => clearTimeout(timeoutId);
19690 }
19691 function parseCSSTime(time) {
19692 const value = time?.trim() || "0s";
19693 const multiplier = value.endsWith("ms") ? 1 : 1e3;
19694 const parsed = Number.parseFloat(value) * multiplier;
19695 return Number.isNaN(parsed) ? 0 : parsed;
19696 }
19697 function getEndTime(names, delays, durations) {
19698 const nameList = names.split(",");
19699 const delayList = delays.split(",");
19700 const durationList = durations.split(",");
19701 let endTime = 0;
19702 for (const [index2, name] of nameList.entries()) {
19703 if (name.trim() === "none") continue;
19704 const delay = parseCSSTime(delayList[index2 % delayList.length]);
19705 const duration = parseCSSTime(durationList[index2 % durationList.length]);
19706 endTime = Math.max(endTime, delay + duration);
19707 }
19708 return endTime;
19709 }
19710 function getElementEndTime(element) {
19711 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
19712 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
19713 }
19714 function isHidden(mounted, hidden, alwaysVisible) {
19715 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
19716 }
19717 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
19718 const context = useDisclosureProviderContext();
19719 store = store || context;
19720 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
19721 const ref = (0, import_react21.useRef)(null);
19722 const id = useId5(props.id);
19723 const [transition, setTransition] = (0, import_react21.useState)(null);
19724 const open = useStoreState(store, "open");
19725 const mounted = useStoreState(store, "mounted");
19726 const animated = useStoreState(store, "animated");
19727 const contentElement = useStoreState(store, "contentElement");
19728 const otherElement = useStoreState(store.disclosure, "contentElement");
19729 const hasClosedRef = (0, import_react21.useRef)(false);
19730 useSafeLayoutEffect(() => {
19731 if (!ref.current) return;
19732 store?.setContentElement(ref.current);
19733 }, [store]);
19734 useSafeLayoutEffect(() => {
19735 let previousAnimated;
19736 store?.setState("animated", (animated2) => {
19737 previousAnimated = animated2;
19738 return true;
19739 });
19740 return () => {
19741 if (previousAnimated === void 0) return;
19742 store?.setState("animated", previousAnimated);
19743 };
19744 }, [store]);
19745 useSafeLayoutEffect(() => {
19746 if (!animated) {
19747 if (!open) {
19748 hasClosedRef.current = true;
19749 setTransition(null);
19750 } else if (hasClosedRef.current) {
19751 hasClosedRef.current = false;
19752 setTransition("enter");
19753 }
19754 return;
19755 }
19756 if (!contentElement?.isConnected) {
19757 setTransition(null);
19758 return;
19759 }
19760 return afterPaint(() => {
19761 setTransition(open ? "enter" : mounted ? "leave" : null);
19762 });
19763 }, [
19764 animated,
19765 contentElement,
19766 open,
19767 mounted
19768 ]);
19769 useSafeLayoutEffect(() => {
19770 if (!store) return;
19771 if (!animated) return;
19772 if (!transition) return;
19773 if (!contentElement) return;
19774 const stopAnimation = () => store?.setState("animating", false);
19775 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
19776 if (transition === "leave" && open) return;
19777 if (transition === "enter" && !open) return;
19778 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
19779 const elements = [contentElement];
19780 if (otherElement) elements.push(otherElement);
19781 const relatedElement = otherElementRef?.current;
19782 if (relatedElement) elements.push(relatedElement);
19783 const timeout = Math.max(...elements.map(getElementEndTime));
19784 if (!timeout) {
19785 if (transition === "enter") store.setState("animated", false);
19786 stopAnimation();
19787 return;
19788 }
19789 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
19790 }, [
19791 store,
19792 animated,
19793 contentElement,
19794 otherElement,
19795 otherElementRef,
19796 open,
19797 transition
19798 ]);
19799 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DialogScopedContextProvider, {
19800 value: store,
19801 children: element
19802 }), [store]);
19803 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19804 const styleProp = props.style;
19805 const style = (0, import_react21.useMemo)(() => {
19806 if (hidden) return {
19807 ...styleProp,
19808 display: "none"
19809 };
19810 return styleProp;
19811 }, [hidden, styleProp]);
19812 props = {
19813 "data-open": open || void 0,
19814 "data-enter": transition === "enter" || void 0,
19815 "data-leave": transition === "leave" || void 0,
19816 hidden,
19817 ...props,
19818 id,
19819 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
19820 style
19821 };
19822 return removeUndefinedValues(props);
19823 });
19824 var DisclosureContentImpl = forwardRef39(function DisclosureContentImpl2(props) {
19825 return createElement3(TagName6, useDisclosureContent(props));
19826 });
19827 var DisclosureContent = forwardRef39(function DisclosureContent2({ unmountOnHide, ...props }) {
19828 const context = useDisclosureProviderContext();
19829 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
19830 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DisclosureContentImpl, { ...props });
19831 });
19832
19833 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
19834 function createDisclosureStore(props = {}) {
19835 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
19836 throwOnConflictingProps(props, store);
19837 const syncState = store?.getState();
19838 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
19839 const animated = defaultValue(props.animated, syncState?.animated, false);
19840 const disclosure = createStore({
19841 open,
19842 animated,
19843 animating: !!animated && open,
19844 mounted: open,
19845 contentElement: defaultValue(syncState?.contentElement, null),
19846 disclosureElement: defaultValue(syncState?.disclosureElement, null)
19847 }, store);
19848 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
19849 if (state.animated) return;
19850 disclosure.setState("animating", false);
19851 }));
19852 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
19853 if (!disclosure.getState().animated) return;
19854 disclosure.setState("animating", true);
19855 }));
19856 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
19857 disclosure.setState("mounted", state.open || state.animating);
19858 }));
19859 return {
19860 ...disclosure,
19861 disclosure: props.disclosure,
19862 setOpen: (value) => disclosure.setState("open", value),
19863 show: () => disclosure.setState("open", true),
19864 hide: () => disclosure.setState("open", false),
19865 toggle: () => disclosure.setState("open", (open2) => !open2),
19866 stopAnimation: () => disclosure.setState("animating", false),
19867 setContentElement: (value) => disclosure.setState("contentElement", value),
19868 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
19869 };
19870 }
19871
19872 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
19873 function useDisclosureStoreProps(store, update2, props) {
19874 useUpdateEffect(update2, [props.store, props.disclosure]);
19875 useStoreProps(store, props, "open", "setOpen");
19876 useStoreProps(store, props, "mounted", "setMounted");
19877 useStoreProps(store, props, "animated");
19878 return Object.assign(store, { disclosure: props.disclosure });
19879 }
19880
19881 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
19882 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
19883 var usePopoverContext = ctx5.useContext;
19884 var usePopoverScopedContext = ctx5.useScopedContext;
19885 var usePopoverProviderContext = ctx5.useProviderContext;
19886 var PopoverContextProvider = ctx5.ContextProvider;
19887 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
19888
19889 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
19890 var import_react22 = __toESM(require_react(), 1);
19891 var ComboboxListRoleContext = (0, import_react22.createContext)(void 0);
19892 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
19893 var useComboboxContext = ctx6.useContext;
19894 var useComboboxScopedContext = ctx6.useScopedContext;
19895 var useComboboxProviderContext = ctx6.useProviderContext;
19896 var ComboboxContextProvider = ctx6.ContextProvider;
19897 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
19898 var ComboboxItemValueContext = (0, import_react22.createContext)(void 0);
19899 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
19900
19901 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
19902 function useCollectionStoreProps(store, update2, props) {
19903 useUpdateEffect(update2, [props.store]);
19904 useStoreProps(store, props, "items", "setItems");
19905 return store;
19906 }
19907
19908 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
19909 function useCompositeStoreOptions(props) {
19910 return {
19911 id: useId5(props.id),
19912 ...props
19913 };
19914 }
19915 function useCompositeStoreProps(store, update2, props) {
19916 store = useCollectionStoreProps(store, update2, props);
19917 useStoreProps(store, props, "activeId", "setActiveId");
19918 useStoreProps(store, props, "includesBaseElement");
19919 useStoreProps(store, props, "virtualFocus");
19920 useStoreProps(store, props, "orientation");
19921 useStoreProps(store, props, "rtl");
19922 useStoreProps(store, props, "focusLoop");
19923 useStoreProps(store, props, "focusWrap");
19924 useStoreProps(store, props, "focusShift");
19925 return store;
19926 }
19927
19928 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
19929 function createDialogStore(props = {}) {
19930 return createDisclosureStore(props);
19931 }
19932
19933 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
19934 function useDialogStoreProps(store, update2, props) {
19935 return useDisclosureStoreProps(store, update2, props);
19936 }
19937
19938 // node_modules/@ariakit/components/dist/popover/popover-store.js
19939 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
19940 const store = mergeStore(props.store, omit2(otherPopover, [
19941 "arrowElement",
19942 "anchorElement",
19943 "contentElement",
19944 "popoverElement",
19945 "disclosureElement"
19946 ]));
19947 throwOnConflictingProps(props, store);
19948 const syncState = store?.getState();
19949 const dialog = createDialogStore({
19950 ...props,
19951 store
19952 });
19953 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
19954 const popover = createStore({
19955 ...dialog.getState(),
19956 placement,
19957 currentPlacement: placement,
19958 anchorElement: defaultValue(syncState?.anchorElement, null),
19959 popoverElement: defaultValue(syncState?.popoverElement, null),
19960 arrowElement: defaultValue(syncState?.arrowElement, null),
19961 rendered: /* @__PURE__ */ Symbol("rendered")
19962 }, dialog, store);
19963 return {
19964 ...dialog,
19965 ...popover,
19966 setAnchorElement: (element) => popover.setState("anchorElement", element),
19967 setPopoverElement: (element) => popover.setState("popoverElement", element),
19968 setArrowElement: (element) => popover.setState("arrowElement", element),
19969 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
19970 };
19971 }
19972
19973 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
19974 function usePopoverStoreProps(store, update2, props) {
19975 useUpdateEffect(update2, [props.popover]);
19976 useStoreProps(store, props, "placement");
19977 return useDialogStoreProps(store, update2, props);
19978 }
19979
19980 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
19981 var TagName7 = "div";
19982 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
19983 const context = usePopoverProviderContext();
19984 store = store || context;
19985 props = {
19986 ...props,
19987 ref: useMergeRefs(store?.setAnchorElement, props.ref)
19988 };
19989 return props;
19990 });
19991 var PopoverAnchor = forwardRef39(function PopoverAnchor2(props) {
19992 return createElement3(TagName7, usePopoverAnchor(props));
19993 });
19994
19995 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
19996 var import_react23 = __toESM(require_react(), 1);
19997 var TagName8 = "div";
19998 function hoveringInside(event) {
19999 const nextElement = event.relatedTarget;
20000 if (!isElement2(nextElement)) return false;
20001 return contains2(event.currentTarget, nextElement);
20002 }
20003 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
20004 function movingToAnotherItem(event) {
20005 const { relatedTarget } = event;
20006 if (!isElement2(relatedTarget)) return false;
20007 let dest = relatedTarget;
20008 do {
20009 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
20010 dest = dest.parentElement;
20011 } while (dest);
20012 return false;
20013 }
20014 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
20015 const context = useCompositeScopedContext();
20016 store = store || context;
20017 invariant(store, "CompositeHover must be wrapped in a Composite component.");
20018 const isMouseMoving = useIsMouseMoving();
20019 const onMouseMoveProp = props.onMouseMove;
20020 const focusOnHoverProp = useBooleanEvent(focusOnHover);
20021 const onMouseMove = useEvent((event) => {
20022 onMouseMoveProp?.(event);
20023 if (event.defaultPrevented) return;
20024 if (!isMouseMoving()) return;
20025 if (!focusOnHoverProp(event)) return;
20026 if (!hasFocusWithin(event.currentTarget)) {
20027 const baseElement = store?.getState().baseElement;
20028 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
20029 }
20030 store?.setActiveId(event.currentTarget.id);
20031 });
20032 const onMouseLeaveProp = props.onMouseLeave;
20033 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
20034 const onMouseLeave = useEvent((event) => {
20035 onMouseLeaveProp?.(event);
20036 if (event.defaultPrevented) return;
20037 if (!isMouseMoving()) return;
20038 if (hoveringInside(event)) return;
20039 if (movingToAnotherItem(event)) return;
20040 if (!focusOnHoverProp(event)) return;
20041 if (!blurOnHoverEndProp(event)) return;
20042 store?.setActiveId(null);
20043 store?.getState().baseElement?.focus();
20044 });
20045 const ref = (0, import_react23.useCallback)((element) => {
20046 if (!element) return;
20047 element[symbol2] = true;
20048 }, []);
20049 props = {
20050 ...props,
20051 ref: useMergeRefs(ref, props.ref),
20052 onMouseMove,
20053 onMouseLeave
20054 };
20055 return removeUndefinedValues(props);
20056 });
20057 var CompositeHover = memo3(forwardRef39(function CompositeHover2(props) {
20058 return createElement3(TagName8, useCompositeHover(props));
20059 }));
20060
20061 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
20062 var import_react24 = __toESM(require_react(), 1);
20063 var TagName9 = "input";
20064 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
20065 if (!autoSelect) return false;
20066 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
20067 }
20068 function hasCompletionString(value, activeValue) {
20069 if (!activeValue) return false;
20070 if (value == null) return false;
20071 const normalizedValue = normalizeString(value);
20072 const normalizedActiveValue = normalizeString(activeValue);
20073 if (normalizedValue.length !== value.length) return false;
20074 if (normalizedActiveValue.length !== activeValue.length) return false;
20075 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
20076 }
20077 function isAriaAutoCompleteValue(value) {
20078 return value === "inline" || value === "list" || value === "both" || value === "none";
20079 }
20080 function getDefaultAutoSelectId(items) {
20081 return items.find((item) => {
20082 if (item.disabled) return false;
20083 return item.element?.getAttribute("role") !== "tab";
20084 })?.id;
20085 }
20086 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 }) {
20087 const context = useComboboxProviderContext();
20088 store = store || context;
20089 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20090 const ref = (0, import_react24.useRef)(null);
20091 const [valueUpdated, forceValueUpdate] = useForceUpdate();
20092 const canAutoSelectRef = (0, import_react24.useRef)(false);
20093 const composingRef = (0, import_react24.useRef)(false);
20094 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
20095 const inline4 = autoComplete === "inline" || autoComplete === "both";
20096 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
20097 useUpdateLayoutEffect(() => {
20098 if (!inline4) return;
20099 setCanInline(true);
20100 }, [inline4]);
20101 const storeValue = useStoreState(store, "value");
20102 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
20103 (0, import_react24.useEffect)(() => {
20104 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
20105 prevSelectedValueRef.current = prev.selectedValue;
20106 });
20107 }, [store]);
20108 const inlineActiveValue = useStoreState(store, (state) => {
20109 if (!inline4) return;
20110 if (!canInline) return;
20111 if (state.activeValue && Array.isArray(state.selectedValue)) {
20112 if (state.selectedValue.includes(state.activeValue)) return;
20113 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
20114 }
20115 return state.activeValue;
20116 });
20117 const items = useStoreState(store, "renderedItems");
20118 const open = useStoreState(store, "open");
20119 const contentElement = useStoreState(store, "contentElement");
20120 const value = (0, import_react24.useMemo)(() => {
20121 if (!inline4) return storeValue;
20122 if (!canInline) return storeValue;
20123 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
20124 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
20125 return storeValue;
20126 }
20127 return inlineActiveValue || storeValue;
20128 }, [
20129 inline4,
20130 canInline,
20131 items,
20132 inlineActiveValue,
20133 autoSelect,
20134 storeValue
20135 ]);
20136 (0, import_react24.useEffect)(() => {
20137 const element = ref.current;
20138 if (!element) return;
20139 const onCompositeItemMove = () => setCanInline(true);
20140 element.addEventListener("combobox-item-move", onCompositeItemMove);
20141 return () => {
20142 element.removeEventListener("combobox-item-move", onCompositeItemMove);
20143 };
20144 }, []);
20145 (0, import_react24.useEffect)(() => {
20146 if (!inline4) return;
20147 if (!canInline) return;
20148 if (!inlineActiveValue) return;
20149 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
20150 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
20151 let cleanup = noop4;
20152 queueMicrotask(() => {
20153 const element = ref.current;
20154 if (!element) return;
20155 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
20156 const nextStart = storeValue.length;
20157 const nextEnd = inlineActiveValue.length;
20158 setSelectionRange(element, nextStart, nextEnd);
20159 cleanup = () => {
20160 if (!hasFocus(element)) return;
20161 const { start, end } = getTextboxSelection(element);
20162 if (start !== nextStart) return;
20163 if (end !== nextEnd) return;
20164 setSelectionRange(element, prevStart, prevEnd);
20165 };
20166 });
20167 return () => cleanup();
20168 }, [
20169 valueUpdated,
20170 inline4,
20171 canInline,
20172 inlineActiveValue,
20173 items,
20174 autoSelect,
20175 storeValue
20176 ]);
20177 const getAutoSelectIdProp = useEvent(getAutoSelectId);
20178 const autoSelectIdRef = (0, import_react24.useRef)(null);
20179 const autoSelectMovedRef = (0, import_react24.useRef)(void 0);
20180 const userScrolledRef = (0, import_react24.useRef)(false);
20181 const isAutoScrollingRef = (0, import_react24.useRef)(false);
20182 (0, import_react24.useEffect)(() => {
20183 if (!open) return;
20184 if (!contentElement) return;
20185 const scrollingElement = getScrollingElement(contentElement);
20186 if (!scrollingElement) return;
20187 const onUserScroll = () => {
20188 canAutoSelectRef.current = false;
20189 userScrolledRef.current = true;
20190 };
20191 const onScroll = () => {
20192 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
20193 if (!store) return;
20194 if (!canAutoSelectRef.current) return;
20195 const { activeId } = store.getState();
20196 if (activeId === null) return;
20197 if (activeId === autoSelectIdRef.current) return;
20198 canAutoSelectRef.current = false;
20199 };
20200 const options = {
20201 passive: true,
20202 capture: true
20203 };
20204 scrollingElement.addEventListener("wheel", onUserScroll, options);
20205 scrollingElement.addEventListener("touchmove", onUserScroll, options);
20206 scrollingElement.addEventListener("scroll", onScroll, options);
20207 return () => {
20208 scrollingElement.removeEventListener("wheel", onUserScroll, true);
20209 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
20210 scrollingElement.removeEventListener("scroll", onScroll, true);
20211 };
20212 }, [
20213 open,
20214 contentElement,
20215 store
20216 ]);
20217 useSafeLayoutEffect(() => {
20218 userScrolledRef.current = false;
20219 if (!storeValue) return;
20220 if (composingRef.current) return;
20221 canAutoSelectRef.current = true;
20222 }, [storeValue]);
20223 useSafeLayoutEffect(() => {
20224 if (autoSelect !== "always" && open) return;
20225 canAutoSelectRef.current = open;
20226 }, [autoSelect, open]);
20227 useSafeLayoutEffect(() => {
20228 if (open) return;
20229 autoSelectMovedRef.current = void 0;
20230 }, [open]);
20231 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
20232 useUpdateEffect(() => {
20233 const canAutoSelect = canAutoSelectRef.current;
20234 if (!store) return;
20235 if (!open) return;
20236 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
20237 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
20238 if (baseElement && !hasFocus(baseElement)) return;
20239 if (contentElement2?.hasAttribute("data-placing")) {
20240 const observer = new MutationObserver(forceValueUpdate);
20241 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
20242 return () => observer.disconnect();
20243 }
20244 if (autoSelect && canAutoSelect) {
20245 const userAutoSelectId = getAutoSelectIdProp(items);
20246 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
20247 autoSelectIdRef.current = autoSelectId;
20248 const nextActiveId = autoSelectId ?? null;
20249 const nextActiveValue = store.item(nextActiveId)?.value;
20250 const moved = autoSelectMovedRef.current;
20251 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
20252 autoSelectMovedRef.current = {
20253 id: nextActiveId,
20254 value: nextActiveValue
20255 };
20256 store.move(nextActiveId);
20257 } else store.setState("activeValue", nextActiveValue);
20258 } else {
20259 const element = store.item(activeId || store.first())?.element;
20260 if (element && "scrollIntoView" in element) {
20261 isAutoScrollingRef.current = true;
20262 element.scrollIntoView({
20263 block: "nearest",
20264 inline: "nearest"
20265 });
20266 requestAnimationFrame(() => {
20267 isAutoScrollingRef.current = false;
20268 });
20269 }
20270 }
20271 }, [
20272 store,
20273 open,
20274 valueUpdated,
20275 storeValue,
20276 autoSelect,
20277 resetValueOnSelect,
20278 getAutoSelectIdProp,
20279 items
20280 ]);
20281 (0, import_react24.useEffect)(() => {
20282 if (!inline4) return;
20283 const combobox = ref.current;
20284 if (!combobox) return;
20285 const elements = [combobox, contentElement].filter((value2) => !!value2);
20286 const onBlur2 = (event) => {
20287 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
20288 };
20289 for (const element of elements) element.addEventListener("focusout", onBlur2);
20290 return () => {
20291 for (const element of elements) element.removeEventListener("focusout", onBlur2);
20292 };
20293 }, [
20294 inline4,
20295 contentElement,
20296 store,
20297 value
20298 ]);
20299 const canShow = (event) => {
20300 return event.currentTarget.value.length >= showMinLength;
20301 };
20302 const onChangeProp = props.onChange;
20303 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
20304 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
20305 const onChange = useEvent((event) => {
20306 onChangeProp?.(event);
20307 if (event.defaultPrevented) return;
20308 if (!store) return;
20309 const currentTarget = event.currentTarget;
20310 const { value: value2, selectionStart, selectionEnd } = currentTarget;
20311 const nativeEvent = event.nativeEvent;
20312 canAutoSelectRef.current = true;
20313 if (isInputEvent(nativeEvent)) {
20314 if (nativeEvent.isComposing) {
20315 canAutoSelectRef.current = false;
20316 composingRef.current = true;
20317 }
20318 if (inline4) {
20319 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
20320 const caretAtEnd = selectionStart === value2.length;
20321 setCanInline(textInserted && caretAtEnd);
20322 }
20323 }
20324 if (setValueOnChangeProp(event)) {
20325 const isSameValue2 = value2 === store.getState().value;
20326 store.setValue(value2);
20327 queueMicrotask(() => {
20328 setSelectionRange(currentTarget, selectionStart, selectionEnd);
20329 });
20330 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
20331 }
20332 if (showOnChangeProp(event)) store.show();
20333 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
20334 });
20335 const onCompositionEndProp = props.onCompositionEnd;
20336 const onCompositionEnd = useEvent((event) => {
20337 canAutoSelectRef.current = true;
20338 composingRef.current = false;
20339 onCompositionEndProp?.(event);
20340 if (event.defaultPrevented) return;
20341 if (!autoSelect) return;
20342 forceValueUpdate();
20343 });
20344 const onMouseDownProp = props.onMouseDown;
20345 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
20346 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
20347 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
20348 const onMouseDown = useEvent((event) => {
20349 onMouseDownProp?.(event);
20350 if (event.defaultPrevented) return;
20351 if (event.button) return;
20352 if (event.ctrlKey) return;
20353 if (!store) return;
20354 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
20355 if (setValueOnClickProp(event)) store.setValue(value);
20356 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
20357 });
20358 const onKeyDownProp = props.onKeyDown;
20359 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
20360 const onKeyDown = useEvent((event) => {
20361 onKeyDownProp?.(event);
20362 if (!event.repeat) canAutoSelectRef.current = false;
20363 if (event.defaultPrevented) return;
20364 if (!store) return;
20365 const { open: open2 } = store.getState();
20366 if (open2 && event.key === "Enter") {
20367 event.preventDefault();
20368 return;
20369 }
20370 if (event.ctrlKey) return;
20371 if (event.altKey) return;
20372 if (event.shiftKey) return;
20373 if (event.metaKey) return;
20374 if (open2) return;
20375 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
20376 if (showOnKeyPressProp(event)) {
20377 event.preventDefault();
20378 store.show();
20379 }
20380 }
20381 });
20382 const onBlurProp = props.onBlur;
20383 const onBlur = useEvent((event) => {
20384 canAutoSelectRef.current = false;
20385 onBlurProp?.(event);
20386 });
20387 const id = useId5(props.id);
20388 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
20389 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
20390 props = {
20391 role: "combobox",
20392 "aria-autocomplete": ariaAutoComplete,
20393 "aria-haspopup": getPopupRole(contentElement, "listbox"),
20394 "aria-expanded": open,
20395 "aria-controls": contentElement?.id,
20396 "data-active-item": isActiveItem || void 0,
20397 value,
20398 ...props,
20399 id,
20400 ref: useMergeRefs(ref, props.ref),
20401 onChange,
20402 onCompositionEnd,
20403 onMouseDown,
20404 onKeyDown,
20405 onBlur
20406 };
20407 props = useComposite({
20408 store,
20409 focusable: focusable2,
20410 ...props,
20411 moveOnKeyPress: (event) => {
20412 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
20413 if (inline4) setCanInline(true);
20414 return true;
20415 }
20416 });
20417 props = usePopoverAnchor({
20418 store,
20419 ...props
20420 });
20421 return {
20422 autoComplete: "off",
20423 ...props
20424 };
20425 });
20426 var Combobox = forwardRef39(function Combobox2(props) {
20427 return createElement3(TagName9, useCombobox(props));
20428 });
20429
20430 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
20431 var import_react25 = __toESM(require_react(), 1);
20432 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
20433 var TagName10 = "div";
20434 function isSelected(storeValue, itemValue) {
20435 if (itemValue == null) return;
20436 if (storeValue == null) return false;
20437 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
20438 return storeValue === itemValue;
20439 }
20440 function getItemRole(popupRole) {
20441 return getItemRoleByPopupRole(popupRole) ?? "option";
20442 }
20443 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
20444 const context = useComboboxScopedContext();
20445 store = store || context;
20446 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
20447 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
20448 resetValueOnSelectState: "resetValueOnSelect",
20449 multiSelectable(state) {
20450 return Array.isArray(state.selectedValue);
20451 },
20452 selected(state) {
20453 return isSelected(state.selectedValue, value);
20454 }
20455 });
20456 const getItem = (0, import_react25.useCallback)((item) => {
20457 const nextItem = {
20458 ...item,
20459 value
20460 };
20461 if (getItemProp) return getItemProp(nextItem);
20462 return nextItem;
20463 }, [value, getItemProp]);
20464 setValueOnClick = setValueOnClick ?? !multiSelectable;
20465 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
20466 const onClickProp = props.onClick;
20467 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
20468 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
20469 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
20470 const hideOnClickProp = useBooleanEvent(hideOnClick);
20471 const onClick = useEvent((event) => {
20472 onClickProp?.(event);
20473 if (event.defaultPrevented) return;
20474 if (isDownloading(event)) return;
20475 if (isOpeningInNewTab(event)) return;
20476 if (value != null) {
20477 if (selectValueOnClickProp(event)) {
20478 if (resetValueOnSelectProp(event)) store?.resetValue();
20479 store?.setSelectedValue((prevValue) => {
20480 if (!Array.isArray(prevValue)) return value;
20481 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
20482 return [...prevValue, value];
20483 });
20484 }
20485 if (setValueOnClickProp(event)) store?.setValue(value);
20486 }
20487 if (hideOnClickProp(event)) store?.hide();
20488 });
20489 const onKeyDownProp = props.onKeyDown;
20490 const onKeyDown = useEvent((event) => {
20491 onKeyDownProp?.(event);
20492 if (event.defaultPrevented) return;
20493 const baseElement = store?.getState().baseElement;
20494 if (!baseElement) return;
20495 if (hasFocus(baseElement)) return;
20496 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
20497 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
20498 const deleteKey = event.key === "Backspace" || event.key === "Delete";
20499 if (printable || paste || deleteKey) {
20500 queueMicrotask(() => baseElement.focus());
20501 if (isTextField(baseElement)) store?.setValue(baseElement.value);
20502 }
20503 });
20504 if (multiSelectable && selected != null) props = {
20505 "aria-selected": selected,
20506 ...props
20507 };
20508 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ComboboxItemValueContext.Provider, {
20509 value,
20510 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ComboboxItemCheckedContext.Provider, {
20511 value: selected ?? false,
20512 children: element
20513 })
20514 }), [value, selected]);
20515 props = {
20516 role: getItemRole((0, import_react25.useContext)(ComboboxListRoleContext)),
20517 children: value,
20518 ...props,
20519 onClick,
20520 onKeyDown
20521 };
20522 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
20523 props = useCompositeItem({
20524 store,
20525 ...props,
20526 getItem,
20527 moveOnKeyPress: (event) => {
20528 if (!moveOnKeyPressProp(event)) return false;
20529 const moveEvent = new Event("combobox-item-move");
20530 store?.getState().baseElement?.dispatchEvent(moveEvent);
20531 return true;
20532 }
20533 });
20534 props = useCompositeHover({
20535 store,
20536 focusOnHover,
20537 ...props
20538 });
20539 return props;
20540 });
20541 var ComboboxItem = memo3(forwardRef39(function ComboboxItem2(props) {
20542 return createElement3(TagName10, useComboboxItem(props));
20543 }));
20544
20545 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
20546 var import_react26 = __toESM(require_react(), 1);
20547 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
20548 var TagName11 = "span";
20549 function normalizeValue(value) {
20550 return normalizeString(value).toLowerCase();
20551 }
20552 function getOffsets(string, values) {
20553 const offsets = [];
20554 for (const value of values) {
20555 if (!value) continue;
20556 let pos = 0;
20557 const length = value.length;
20558 let index2 = string.indexOf(value, pos);
20559 while (index2 !== -1) {
20560 offsets.push([index2, length]);
20561 pos = index2 + 1;
20562 index2 = string.indexOf(value, pos);
20563 }
20564 }
20565 return offsets;
20566 }
20567 function mergeOverlappingOffsets(offsets) {
20568 offsets.sort(([a2], [b2]) => a2 - b2);
20569 const merged = [];
20570 for (const [offset4, length] of offsets) {
20571 const last = merged[merged.length - 1];
20572 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
20573 else merged.push([offset4, length]);
20574 }
20575 return merged;
20576 }
20577 function getNormalizedIndexes(itemValue) {
20578 const starts = [];
20579 const ends = [];
20580 let index2 = 0;
20581 for (const char of itemValue) {
20582 const normalizedLength = normalizeValue(char).length;
20583 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
20584 starts.push(i2 === 0 ? index2 : -1);
20585 ends.push(index2);
20586 }
20587 index2 += char.length;
20588 }
20589 starts.push(itemValue.length);
20590 ends.push(itemValue.length);
20591 let nextBoundary = itemValue.length;
20592 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
20593 const start = starts[i2];
20594 if (start == null) continue;
20595 if (start === -1) starts[i2] = nextBoundary;
20596 else nextBoundary = start;
20597 }
20598 return {
20599 starts,
20600 ends
20601 };
20602 }
20603 function toOriginalOffsets(itemValue, normalizedOffsets) {
20604 if (!normalizedOffsets.length) return normalizedOffsets;
20605 const { starts, ends } = getNormalizedIndexes(itemValue);
20606 const offsets = [];
20607 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
20608 const start = starts[normalizedOffset];
20609 const end = ends[normalizedOffset + normalizedLength];
20610 if (start == null || end == null) continue;
20611 if (end <= start) continue;
20612 offsets.push([start, end - start]);
20613 }
20614 return offsets;
20615 }
20616 function splitValue(itemValue, userValue) {
20617 if (!itemValue) return itemValue;
20618 if (!userValue) return itemValue;
20619 const userValues = toArray(userValue).map(normalizeValue);
20620 const parts = [];
20621 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", {
20622 "data-autocomplete-value": autocomplete ? "" : void 0,
20623 "data-user-value": autocomplete ? void 0 : "",
20624 children: value
20625 }, parts.length);
20626 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
20627 const firstEntry = offsets[0];
20628 if (!firstEntry) {
20629 parts.push(span(itemValue, true));
20630 return parts;
20631 }
20632 const [firstOffset] = firstEntry;
20633 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
20634 const value = itemValue.slice(offset4, offset4 + length);
20635 const nextOffset = offsets[i2 + 1]?.[0];
20636 return [value, itemValue.slice(offset4 + length, nextOffset)];
20637 })].forEach((value, i2) => {
20638 if (!value) return;
20639 parts.push(span(value, i2 % 2 === 0));
20640 });
20641 return parts;
20642 }
20643 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
20644 const context = useComboboxScopedContext();
20645 store = store || context;
20646 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
20647 const itemValue = value ?? itemContext;
20648 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
20649 props = {
20650 children: (0, import_react26.useMemo)(() => {
20651 if (!itemValue) return;
20652 if (!inputValue) return itemValue;
20653 return splitValue(itemValue, inputValue);
20654 }, [itemValue, inputValue]),
20655 ...props
20656 };
20657 return removeUndefinedValues(props);
20658 });
20659 var ComboboxItemValue = forwardRef39(function ComboboxItemValue2(props) {
20660 return createElement3(TagName11, useComboboxItemValue(props));
20661 });
20662
20663 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
20664 var TagName12 = "label";
20665 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
20666 const context = useComboboxProviderContext();
20667 store = store || context;
20668 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20669 props = {
20670 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
20671 ...props
20672 };
20673 return removeUndefinedValues(props);
20674 });
20675 var ComboboxLabel = memo3(forwardRef39(function ComboboxLabel2(props) {
20676 return createElement3(TagName12, useComboboxLabel(props));
20677 }));
20678
20679 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
20680 var import_react27 = __toESM(require_react(), 1);
20681 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
20682 var TagName13 = "div";
20683 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
20684 const scopedContext = useComboboxScopedContext(true);
20685 const context = useComboboxContext();
20686 store = store || context;
20687 const scopedContextSameStore = !!store && store === scopedContext;
20688 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20689 const ref = (0, import_react27.useRef)(null);
20690 const id = useId5(props.id);
20691 const mounted = useStoreState(store, "mounted");
20692 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
20693 const style = hidden ? {
20694 ...props.style,
20695 display: "none"
20696 } : props.style;
20697 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
20698 const role = useAttribute(ref, "role", props.role);
20699 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
20700 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
20701 const contentElement = useStoreState(store, "contentElement");
20702 useSafeLayoutEffect(() => {
20703 if (!mounted) return;
20704 const element = ref.current;
20705 if (!element) return;
20706 if (contentElement !== element) return;
20707 const callback = () => {
20708 setHasListboxInside(!!element.querySelector("[role='listbox']"));
20709 };
20710 const observer = new MutationObserver(callback);
20711 observer.observe(element, {
20712 subtree: true,
20713 childList: true,
20714 attributeFilter: ["role"]
20715 });
20716 callback();
20717 return () => observer.disconnect();
20718 }, [mounted, contentElement]);
20719 if (!hasListboxInside) props = {
20720 role: "listbox",
20721 "aria-multiselectable": ariaMultiSelectable,
20722 ...props
20723 };
20724 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(ComboboxScopedContextProvider, {
20725 value: store,
20726 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(ComboboxListRoleContext.Provider, {
20727 value: role,
20728 children: element
20729 })
20730 }), [store, role]);
20731 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
20732 props = {
20733 hidden,
20734 ...props,
20735 id,
20736 ref: useMergeRefs(setContentElement, ref, props.ref),
20737 style
20738 };
20739 return removeUndefinedValues(props);
20740 });
20741 var ComboboxList = forwardRef39(function ComboboxList2(props) {
20742 return createElement3(TagName13, useComboboxList(props));
20743 });
20744
20745 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
20746 var import_react28 = __toESM(require_react(), 1);
20747 var TagValueContext = (0, import_react28.createContext)(null);
20748 var TagRemoveIdContext = (0, import_react28.createContext)(null);
20749 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
20750 var useTagContext = ctx7.useContext;
20751 var useTagScopedContext = ctx7.useScopedContext;
20752 var useTagProviderContext = ctx7.useProviderContext;
20753 var TagContextProvider = ctx7.ContextProvider;
20754 var TagScopedContextProvider = ctx7.ScopedContextProvider;
20755
20756 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
20757 var isTouchSafari = isSafari() && isTouchDevice();
20758 function createComboboxStore({ tag, ...props } = {}) {
20759 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
20760 throwOnConflictingProps(props, store);
20761 const tagState = tag?.getState();
20762 const syncState = store?.getState();
20763 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
20764 const composite = createCompositeStore({
20765 ...props,
20766 activeId,
20767 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
20768 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
20769 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
20770 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
20771 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
20772 });
20773 const popover = createPopoverStore({
20774 ...props,
20775 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
20776 });
20777 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
20778 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
20779 const multiSelectable = Array.isArray(selectedValue);
20780 const initialState = {
20781 ...composite.getState(),
20782 ...popover.getState(),
20783 value,
20784 selectedValue,
20785 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
20786 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
20787 activeValue: syncState?.activeValue
20788 };
20789 const combobox = createStore(initialState, composite, popover, store);
20790 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
20791 combobox.setState("virtualFocus", false);
20792 }));
20793 setup(combobox, () => {
20794 if (!tag) return;
20795 return chain(sync(combobox, ["selectedValue"], (state) => {
20796 if (!Array.isArray(state.selectedValue)) return;
20797 tag.setValues(state.selectedValue);
20798 }), sync(tag, ["values"], (state) => {
20799 combobox.setState("selectedValue", state.values);
20800 }));
20801 });
20802 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
20803 if (!state.resetValueOnHide) return;
20804 if (state.mounted) return;
20805 combobox.setState("value", value);
20806 }));
20807 setup(combobox, () => sync(combobox, ["open"], (state) => {
20808 if (state.open) return;
20809 combobox.setState("activeId", activeId);
20810 combobox.setState("moves", 0);
20811 }));
20812 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
20813 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
20814 }));
20815 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
20816 if (state.moves === prev.moves) return;
20817 const { activeId: activeId2 } = combobox.getState();
20818 const activeItem = composite.item(activeId2);
20819 combobox.setState("activeValue", activeItem?.value);
20820 }));
20821 return {
20822 ...popover,
20823 ...composite,
20824 ...combobox,
20825 tag,
20826 setValue: (value2) => combobox.setState("value", value2),
20827 resetValue: () => combobox.setState("value", initialState.value),
20828 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
20829 };
20830 }
20831
20832 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
20833 function useComboboxStoreOptions(props) {
20834 const tag = useTagContext();
20835 props = {
20836 ...props,
20837 tag: props.tag !== void 0 ? props.tag : tag
20838 };
20839 return useCompositeStoreOptions(props);
20840 }
20841 function useComboboxStoreProps(store, update2, props) {
20842 useUpdateEffect(update2, [props.tag]);
20843 useStoreProps(store, props, "value", "setValue");
20844 useStoreProps(store, props, "selectedValue", "setSelectedValue");
20845 useStoreProps(store, props, "resetValueOnHide");
20846 useStoreProps(store, props, "resetValueOnSelect");
20847 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
20848 }
20849 function useComboboxStore(props = {}) {
20850 props = useComboboxStoreOptions(props);
20851 const [store, update2] = useStore2(createComboboxStore, props);
20852 return useComboboxStoreProps(store, update2, props);
20853 }
20854
20855 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
20856 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
20857 function ComboboxProvider(props = {}) {
20858 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ComboboxContextProvider, {
20859 value: useComboboxStore(props),
20860 children: props.children
20861 });
20862 }
20863
20864 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
20865 var import_remove_accents = __toESM(require_remove_accents(), 1);
20866 var import_compose8 = __toESM(require_compose(), 1);
20867 var import_i18n23 = __toESM(require_i18n(), 1);
20868 var import_element59 = __toESM(require_element(), 1);
20869 var import_components21 = __toESM(require_components(), 1);
20870
20871 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
20872 var EMPTY_ARRAY3 = [];
20873 var getCurrentValue = (filterDefinition, currentFilter) => {
20874 if (filterDefinition.singleSelection) {
20875 return currentFilter?.value;
20876 }
20877 if (Array.isArray(currentFilter?.value)) {
20878 return currentFilter.value;
20879 }
20880 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
20881 return [currentFilter.value];
20882 }
20883 return EMPTY_ARRAY3;
20884 };
20885
20886 // packages/dataviews/build-module/hooks/use-elements.mjs
20887 var import_element58 = __toESM(require_element(), 1);
20888 var EMPTY_ARRAY4 = [];
20889 function useElements({
20890 elements,
20891 getElements
20892 }) {
20893 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
20894 const [records, setRecords] = (0, import_element58.useState)(staticElements);
20895 const [isLoading, setIsLoading] = (0, import_element58.useState)(false);
20896 (0, import_element58.useEffect)(() => {
20897 if (!getElements) {
20898 setRecords(staticElements);
20899 return;
20900 }
20901 let cancelled = false;
20902 setIsLoading(true);
20903 getElements().then((fetchedElements) => {
20904 if (!cancelled) {
20905 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
20906 setRecords(dynamicElements);
20907 }
20908 }).catch(() => {
20909 if (!cancelled) {
20910 setRecords(staticElements);
20911 }
20912 }).finally(() => {
20913 if (!cancelled) {
20914 setIsLoading(false);
20915 }
20916 });
20917 return () => {
20918 cancelled = true;
20919 };
20920 }, [getElements, staticElements]);
20921 return {
20922 elements: records,
20923 isLoading
20924 };
20925 }
20926
20927 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
20928 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
20929 function normalizeSearchInput(input = "") {
20930 return (0, import_remove_accents.default)(input.trim().toLowerCase());
20931 }
20932 var getNewValue = (filterDefinition, currentFilter, value) => {
20933 if (filterDefinition.singleSelection) {
20934 return value;
20935 }
20936 if (Array.isArray(currentFilter?.value)) {
20937 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
20938 }
20939 return [value];
20940 };
20941 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
20942 return `${prefix}-${filterElementValue}`;
20943 }
20944 var MultiSelectionOption = ({ selected }) => {
20945 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
20946 "span",
20947 {
20948 className: clsx_default(
20949 "dataviews-filters__search-widget-listitem-multi-selection",
20950 { "is-selected": selected }
20951 ),
20952 children: selected && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components21.Icon, { icon: check_default })
20953 }
20954 );
20955 };
20956 var SingleSelectionOption = ({ selected }) => {
20957 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
20958 "span",
20959 {
20960 className: clsx_default(
20961 "dataviews-filters__search-widget-listitem-single-selection",
20962 { "is-selected": selected }
20963 )
20964 }
20965 );
20966 };
20967 function ListBox({ view, filter, onChangeView }) {
20968 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
20969 const [activeCompositeId, setActiveCompositeId] = (0, import_element59.useState)(
20970 // When there are one or less operators, the first item is set as active
20971 // (by setting the initial `activeId` to `undefined`).
20972 // With 2 or more operators, the focus is moved on the operators control
20973 // (by setting the initial `activeId` to `null`), meaning that there won't
20974 // be an active item initially. Focus is then managed via the
20975 // `onFocusVisible` callback.
20976 filter.operators?.length === 1 ? void 0 : null
20977 );
20978 const currentFilter = view.filters?.find(
20979 (f2) => f2.field === filter.field
20980 );
20981 const currentValue = getCurrentValue(filter, currentFilter);
20982 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
20983 import_components21.Composite,
20984 {
20985 virtualFocus: true,
20986 focusLoop: true,
20987 activeId: activeCompositeId,
20988 setActiveId: setActiveCompositeId,
20989 role: "listbox",
20990 className: "dataviews-filters__search-widget-listbox",
20991 "aria-label": (0, import_i18n23.sprintf)(
20992 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
20993 (0, import_i18n23.__)("List of: %1$s"),
20994 filter.name
20995 ),
20996 onFocusVisible: () => {
20997 if (!activeCompositeId && filter.elements.length) {
20998 setActiveCompositeId(
20999 generateFilterElementCompositeItemId(
21000 baseId,
21001 filter.elements[0].value
21002 )
21003 );
21004 }
21005 },
21006 render: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components21.Composite.Typeahead, {}),
21007 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
21008 import_components21.Composite.Hover,
21009 {
21010 render: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21011 import_components21.Composite.Item,
21012 {
21013 id: generateFilterElementCompositeItemId(
21014 baseId,
21015 element.value
21016 ),
21017 render: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21018 "div",
21019 {
21020 "aria-label": element.label,
21021 role: "option",
21022 className: "dataviews-filters__search-widget-listitem"
21023 }
21024 ),
21025 onClick: () => {
21026 const newFilters = currentFilter ? [
21027 ...(view.filters ?? []).map(
21028 (_filter) => {
21029 if (_filter.field === filter.field) {
21030 return {
21031 ..._filter,
21032 operator: currentFilter.operator || filter.operators[0],
21033 value: getNewValue(
21034 filter,
21035 currentFilter,
21036 element.value
21037 )
21038 };
21039 }
21040 return _filter;
21041 }
21042 )
21043 ] : [
21044 ...view.filters ?? [],
21045 {
21046 field: filter.field,
21047 operator: filter.operators[0],
21048 value: getNewValue(
21049 filter,
21050 currentFilter,
21051 element.value
21052 )
21053 }
21054 ];
21055 onChangeView({
21056 ...view,
21057 page: 1,
21058 filters: newFilters
21059 });
21060 }
21061 }
21062 ),
21063 children: [
21064 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21065 SingleSelectionOption,
21066 {
21067 selected: currentValue === element.value
21068 }
21069 ),
21070 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21071 MultiSelectionOption,
21072 {
21073 selected: currentValue.includes(element.value)
21074 }
21075 ),
21076 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21077 "span",
21078 {
21079 className: "dataviews-filters__search-widget-listitem-value",
21080 title: element.label,
21081 children: element.label
21082 }
21083 )
21084 ]
21085 },
21086 element.value
21087 ))
21088 }
21089 );
21090 }
21091 function ComboboxList22({ view, filter, onChangeView }) {
21092 const [searchValue, setSearchValue] = (0, import_element59.useState)("");
21093 const deferredSearchValue = (0, import_element59.useDeferredValue)(searchValue);
21094 const currentFilter = view.filters?.find(
21095 (_filter) => _filter.field === filter.field
21096 );
21097 const currentValue = getCurrentValue(filter, currentFilter);
21098 const matches = (0, import_element59.useMemo)(() => {
21099 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
21100 return filter.elements.filter(
21101 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
21102 );
21103 }, [filter.elements, deferredSearchValue]);
21104 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
21105 ComboboxProvider,
21106 {
21107 selectedValue: currentValue,
21108 setSelectedValue: (value) => {
21109 const newFilters = currentFilter ? [
21110 ...(view.filters ?? []).map((_filter) => {
21111 if (_filter.field === filter.field) {
21112 return {
21113 ..._filter,
21114 operator: currentFilter.operator || filter.operators[0],
21115 value
21116 };
21117 }
21118 return _filter;
21119 })
21120 ] : [
21121 ...view.filters ?? [],
21122 {
21123 field: filter.field,
21124 operator: filter.operators[0],
21125 value
21126 }
21127 ];
21128 onChangeView({
21129 ...view,
21130 page: 1,
21131 filters: newFilters
21132 });
21133 },
21134 setValue: setSearchValue,
21135 children: [
21136 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
21137 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
21138 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21139 Combobox,
21140 {
21141 autoSelect: "always",
21142 placeholder: (0, import_i18n23.__)("Search"),
21143 className: "dataviews-filters__search-widget-filter-combobox__input"
21144 }
21145 ),
21146 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components21.Icon, { icon: search_default }) })
21147 ] }),
21148 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
21149 ComboboxList,
21150 {
21151 className: "dataviews-filters__search-widget-filter-combobox-list",
21152 alwaysVisible: true,
21153 children: [
21154 matches.map((element) => {
21155 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
21156 ComboboxItem,
21157 {
21158 resetValueOnSelect: false,
21159 value: element.value,
21160 className: "dataviews-filters__search-widget-listitem",
21161 hideOnClick: false,
21162 setValueOnClick: false,
21163 focusOnHover: true,
21164 children: [
21165 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21166 SingleSelectionOption,
21167 {
21168 selected: currentValue === element.value
21169 }
21170 ),
21171 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21172 MultiSelectionOption,
21173 {
21174 selected: currentValue.includes(
21175 element.value
21176 )
21177 }
21178 ),
21179 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
21180 "span",
21181 {
21182 className: "dataviews-filters__search-widget-listitem-value",
21183 title: element.label,
21184 children: [
21185 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21186 ComboboxItemValue,
21187 {
21188 className: "dataviews-filters__search-widget-filter-combobox-item-value",
21189 value: element.label
21190 }
21191 ),
21192 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
21193 ]
21194 }
21195 )
21196 ]
21197 },
21198 element.value
21199 );
21200 }),
21201 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
21202 ]
21203 }
21204 )
21205 ]
21206 }
21207 );
21208 }
21209 function SearchWidget(props) {
21210 const { elements, isLoading } = useElements({
21211 elements: props.filter.elements,
21212 getElements: props.filter.getElements
21213 });
21214 if (isLoading) {
21215 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components21.Spinner, {}) });
21216 }
21217 if (elements.length === 0) {
21218 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
21219 }
21220 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
21221 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
21222 }
21223
21224 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
21225 var import_es6 = __toESM(require_es6(), 1);
21226 var import_compose9 = __toESM(require_compose(), 1);
21227 var import_element60 = __toESM(require_element(), 1);
21228 var import_components22 = __toESM(require_components(), 1);
21229 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
21230 function InputWidget({
21231 filter,
21232 view,
21233 onChangeView,
21234 fields: fields2
21235 }) {
21236 const currentFilter = view.filters?.find(
21237 (f2) => f2.field === filter.field
21238 );
21239 const currentValue = getCurrentValue(filter, currentFilter);
21240 const field = (0, import_element60.useMemo)(() => {
21241 const currentField = fields2.find((f2) => f2.id === filter.field);
21242 if (currentField) {
21243 return {
21244 ...currentField,
21245 // Deactivate validation for filters.
21246 isValid: {},
21247 // Filter controls are always enabled.
21248 isDisabled: () => false,
21249 // Filter controls are always visible.
21250 isVisible: () => true,
21251 // Configure getValue/setValue as if Item was a plain object.
21252 getValue: ({ item }) => item[currentField.id],
21253 setValue: ({ value }) => ({
21254 [currentField.id]: value
21255 })
21256 };
21257 }
21258 return currentField;
21259 }, [fields2, filter.field]);
21260 const data = (0, import_element60.useMemo)(() => {
21261 return (view.filters ?? []).reduce(
21262 (acc, activeFilter) => {
21263 acc[activeFilter.field] = activeFilter.value;
21264 return acc;
21265 },
21266 {}
21267 );
21268 }, [view.filters]);
21269 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
21270 if (!field || !currentFilter) {
21271 return;
21272 }
21273 const nextValue = field.getValue({ item: updatedData });
21274 if ((0, import_es6.default)(nextValue, currentValue)) {
21275 return;
21276 }
21277 onChangeView({
21278 ...view,
21279 filters: (view.filters ?? []).map(
21280 (_filter) => _filter.field === filter.field ? {
21281 ..._filter,
21282 operator: currentFilter.operator || filter.operators[0],
21283 // Consider empty strings as undefined:
21284 //
21285 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
21286 // - empty string as value means "search empty string": returns only the records that have an empty string as value
21287 //
21288 // In practice, this means the filter will not be able to find an empty string as the value.
21289 value: nextValue === "" ? void 0 : nextValue
21290 } : _filter
21291 )
21292 });
21293 });
21294 if (!field || !field.Edit || !currentFilter) {
21295 return null;
21296 }
21297 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
21298 import_components22.Flex,
21299 {
21300 className: "dataviews-filters__user-input-widget",
21301 gap: 2.5,
21302 direction: "column",
21303 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
21304 field.Edit,
21305 {
21306 hideLabelFromVision: true,
21307 data,
21308 field,
21309 operator: currentFilter.operator,
21310 onChange: handleChange
21311 }
21312 )
21313 }
21314 );
21315 }
21316
21317 // node_modules/date-fns/constants.js
21318 var daysInYear = 365.2425;
21319 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
21320 var minTime = -maxTime;
21321 var millisecondsInWeek = 6048e5;
21322 var millisecondsInDay = 864e5;
21323 var secondsInHour = 3600;
21324 var secondsInDay = secondsInHour * 24;
21325 var secondsInWeek = secondsInDay * 7;
21326 var secondsInYear = secondsInDay * daysInYear;
21327 var secondsInMonth = secondsInYear / 12;
21328 var secondsInQuarter = secondsInMonth * 3;
21329 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
21330
21331 // node_modules/date-fns/constructFrom.js
21332 function constructFrom(date, value) {
21333 if (typeof date === "function") return date(value);
21334 if (date && typeof date === "object" && constructFromSymbol in date)
21335 return date[constructFromSymbol](value);
21336 if (date instanceof Date) return new date.constructor(value);
21337 return new Date(value);
21338 }
21339
21340 // node_modules/date-fns/toDate.js
21341 function toDate(argument, context) {
21342 return constructFrom(context || argument, argument);
21343 }
21344
21345 // node_modules/date-fns/addDays.js
21346 function addDays(date, amount, options) {
21347 const _date = toDate(date, options?.in);
21348 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
21349 if (!amount) return _date;
21350 _date.setDate(_date.getDate() + amount);
21351 return _date;
21352 }
21353
21354 // node_modules/date-fns/addMonths.js
21355 function addMonths(date, amount, options) {
21356 const _date = toDate(date, options?.in);
21357 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
21358 if (!amount) {
21359 return _date;
21360 }
21361 const dayOfMonth = _date.getDate();
21362 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
21363 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
21364 const daysInMonth = endOfDesiredMonth.getDate();
21365 if (dayOfMonth >= daysInMonth) {
21366 return endOfDesiredMonth;
21367 } else {
21368 _date.setFullYear(
21369 endOfDesiredMonth.getFullYear(),
21370 endOfDesiredMonth.getMonth(),
21371 dayOfMonth
21372 );
21373 return _date;
21374 }
21375 }
21376
21377 // node_modules/date-fns/_lib/defaultOptions.js
21378 var defaultOptions = {};
21379 function getDefaultOptions() {
21380 return defaultOptions;
21381 }
21382
21383 // node_modules/date-fns/startOfWeek.js
21384 function startOfWeek(date, options) {
21385 const defaultOptions2 = getDefaultOptions();
21386 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21387 const _date = toDate(date, options?.in);
21388 const day = _date.getDay();
21389 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
21390 _date.setDate(_date.getDate() - diff);
21391 _date.setHours(0, 0, 0, 0);
21392 return _date;
21393 }
21394
21395 // node_modules/date-fns/startOfISOWeek.js
21396 function startOfISOWeek(date, options) {
21397 return startOfWeek(date, { ...options, weekStartsOn: 1 });
21398 }
21399
21400 // node_modules/date-fns/getISOWeekYear.js
21401 function getISOWeekYear(date, options) {
21402 const _date = toDate(date, options?.in);
21403 const year = _date.getFullYear();
21404 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
21405 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
21406 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
21407 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
21408 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
21409 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
21410 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
21411 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
21412 if (_date.getTime() >= startOfNextYear.getTime()) {
21413 return year + 1;
21414 } else if (_date.getTime() >= startOfThisYear.getTime()) {
21415 return year;
21416 } else {
21417 return year - 1;
21418 }
21419 }
21420
21421 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
21422 function getTimezoneOffsetInMilliseconds(date) {
21423 const _date = toDate(date);
21424 const utcDate = new Date(
21425 Date.UTC(
21426 _date.getFullYear(),
21427 _date.getMonth(),
21428 _date.getDate(),
21429 _date.getHours(),
21430 _date.getMinutes(),
21431 _date.getSeconds(),
21432 _date.getMilliseconds()
21433 )
21434 );
21435 utcDate.setUTCFullYear(_date.getFullYear());
21436 return +date - +utcDate;
21437 }
21438
21439 // node_modules/date-fns/_lib/normalizeDates.js
21440 function normalizeDates(context, ...dates) {
21441 const normalize = constructFrom.bind(
21442 null,
21443 context || dates.find((date) => typeof date === "object")
21444 );
21445 return dates.map(normalize);
21446 }
21447
21448 // node_modules/date-fns/startOfDay.js
21449 function startOfDay(date, options) {
21450 const _date = toDate(date, options?.in);
21451 _date.setHours(0, 0, 0, 0);
21452 return _date;
21453 }
21454
21455 // node_modules/date-fns/differenceInCalendarDays.js
21456 function differenceInCalendarDays(laterDate, earlierDate, options) {
21457 const [laterDate_, earlierDate_] = normalizeDates(
21458 options?.in,
21459 laterDate,
21460 earlierDate
21461 );
21462 const laterStartOfDay = startOfDay(laterDate_);
21463 const earlierStartOfDay = startOfDay(earlierDate_);
21464 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
21465 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
21466 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
21467 }
21468
21469 // node_modules/date-fns/startOfISOWeekYear.js
21470 function startOfISOWeekYear(date, options) {
21471 const year = getISOWeekYear(date, options);
21472 const fourthOfJanuary = constructFrom(options?.in || date, 0);
21473 fourthOfJanuary.setFullYear(year, 0, 4);
21474 fourthOfJanuary.setHours(0, 0, 0, 0);
21475 return startOfISOWeek(fourthOfJanuary);
21476 }
21477
21478 // node_modules/date-fns/addWeeks.js
21479 function addWeeks(date, amount, options) {
21480 return addDays(date, amount * 7, options);
21481 }
21482
21483 // node_modules/date-fns/addYears.js
21484 function addYears(date, amount, options) {
21485 return addMonths(date, amount * 12, options);
21486 }
21487
21488 // node_modules/date-fns/isDate.js
21489 function isDate(value) {
21490 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
21491 }
21492
21493 // node_modules/date-fns/isValid.js
21494 function isValid(date) {
21495 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
21496 }
21497
21498 // node_modules/date-fns/startOfMonth.js
21499 function startOfMonth(date, options) {
21500 const _date = toDate(date, options?.in);
21501 _date.setDate(1);
21502 _date.setHours(0, 0, 0, 0);
21503 return _date;
21504 }
21505
21506 // node_modules/date-fns/startOfYear.js
21507 function startOfYear(date, options) {
21508 const date_ = toDate(date, options?.in);
21509 date_.setFullYear(date_.getFullYear(), 0, 1);
21510 date_.setHours(0, 0, 0, 0);
21511 return date_;
21512 }
21513
21514 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
21515 var formatDistanceLocale = {
21516 lessThanXSeconds: {
21517 one: "less than a second",
21518 other: "less than {{count}} seconds"
21519 },
21520 xSeconds: {
21521 one: "1 second",
21522 other: "{{count}} seconds"
21523 },
21524 halfAMinute: "half a minute",
21525 lessThanXMinutes: {
21526 one: "less than a minute",
21527 other: "less than {{count}} minutes"
21528 },
21529 xMinutes: {
21530 one: "1 minute",
21531 other: "{{count}} minutes"
21532 },
21533 aboutXHours: {
21534 one: "about 1 hour",
21535 other: "about {{count}} hours"
21536 },
21537 xHours: {
21538 one: "1 hour",
21539 other: "{{count}} hours"
21540 },
21541 xDays: {
21542 one: "1 day",
21543 other: "{{count}} days"
21544 },
21545 aboutXWeeks: {
21546 one: "about 1 week",
21547 other: "about {{count}} weeks"
21548 },
21549 xWeeks: {
21550 one: "1 week",
21551 other: "{{count}} weeks"
21552 },
21553 aboutXMonths: {
21554 one: "about 1 month",
21555 other: "about {{count}} months"
21556 },
21557 xMonths: {
21558 one: "1 month",
21559 other: "{{count}} months"
21560 },
21561 aboutXYears: {
21562 one: "about 1 year",
21563 other: "about {{count}} years"
21564 },
21565 xYears: {
21566 one: "1 year",
21567 other: "{{count}} years"
21568 },
21569 overXYears: {
21570 one: "over 1 year",
21571 other: "over {{count}} years"
21572 },
21573 almostXYears: {
21574 one: "almost 1 year",
21575 other: "almost {{count}} years"
21576 }
21577 };
21578 var formatDistance = (token, count, options) => {
21579 let result;
21580 const tokenValue = formatDistanceLocale[token];
21581 if (typeof tokenValue === "string") {
21582 result = tokenValue;
21583 } else if (count === 1) {
21584 result = tokenValue.one;
21585 } else {
21586 result = tokenValue.other.replace("{{count}}", count.toString());
21587 }
21588 if (options?.addSuffix) {
21589 if (options.comparison && options.comparison > 0) {
21590 return "in " + result;
21591 } else {
21592 return result + " ago";
21593 }
21594 }
21595 return result;
21596 };
21597
21598 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
21599 function buildFormatLongFn(args) {
21600 return (options = {}) => {
21601 const width = options.width ? String(options.width) : args.defaultWidth;
21602 const format6 = args.formats[width] || args.formats[args.defaultWidth];
21603 return format6;
21604 };
21605 }
21606
21607 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
21608 var dateFormats = {
21609 full: "EEEE, MMMM do, y",
21610 long: "MMMM do, y",
21611 medium: "MMM d, y",
21612 short: "MM/dd/yyyy"
21613 };
21614 var timeFormats = {
21615 full: "h:mm:ss a zzzz",
21616 long: "h:mm:ss a z",
21617 medium: "h:mm:ss a",
21618 short: "h:mm a"
21619 };
21620 var dateTimeFormats = {
21621 full: "{{date}} 'at' {{time}}",
21622 long: "{{date}} 'at' {{time}}",
21623 medium: "{{date}}, {{time}}",
21624 short: "{{date}}, {{time}}"
21625 };
21626 var formatLong = {
21627 date: buildFormatLongFn({
21628 formats: dateFormats,
21629 defaultWidth: "full"
21630 }),
21631 time: buildFormatLongFn({
21632 formats: timeFormats,
21633 defaultWidth: "full"
21634 }),
21635 dateTime: buildFormatLongFn({
21636 formats: dateTimeFormats,
21637 defaultWidth: "full"
21638 })
21639 };
21640
21641 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
21642 var formatRelativeLocale = {
21643 lastWeek: "'last' eeee 'at' p",
21644 yesterday: "'yesterday at' p",
21645 today: "'today at' p",
21646 tomorrow: "'tomorrow at' p",
21647 nextWeek: "eeee 'at' p",
21648 other: "P"
21649 };
21650 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
21651
21652 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
21653 function buildLocalizeFn(args) {
21654 return (value, options) => {
21655 const context = options?.context ? String(options.context) : "standalone";
21656 let valuesArray;
21657 if (context === "formatting" && args.formattingValues) {
21658 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
21659 const width = options?.width ? String(options.width) : defaultWidth;
21660 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
21661 } else {
21662 const defaultWidth = args.defaultWidth;
21663 const width = options?.width ? String(options.width) : args.defaultWidth;
21664 valuesArray = args.values[width] || args.values[defaultWidth];
21665 }
21666 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
21667 return valuesArray[index2];
21668 };
21669 }
21670
21671 // node_modules/date-fns/locale/en-US/_lib/localize.js
21672 var eraValues = {
21673 narrow: ["B", "A"],
21674 abbreviated: ["BC", "AD"],
21675 wide: ["Before Christ", "Anno Domini"]
21676 };
21677 var quarterValues = {
21678 narrow: ["1", "2", "3", "4"],
21679 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
21680 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
21681 };
21682 var monthValues = {
21683 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
21684 abbreviated: [
21685 "Jan",
21686 "Feb",
21687 "Mar",
21688 "Apr",
21689 "May",
21690 "Jun",
21691 "Jul",
21692 "Aug",
21693 "Sep",
21694 "Oct",
21695 "Nov",
21696 "Dec"
21697 ],
21698 wide: [
21699 "January",
21700 "February",
21701 "March",
21702 "April",
21703 "May",
21704 "June",
21705 "July",
21706 "August",
21707 "September",
21708 "October",
21709 "November",
21710 "December"
21711 ]
21712 };
21713 var dayValues = {
21714 narrow: ["S", "M", "T", "W", "T", "F", "S"],
21715 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
21716 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
21717 wide: [
21718 "Sunday",
21719 "Monday",
21720 "Tuesday",
21721 "Wednesday",
21722 "Thursday",
21723 "Friday",
21724 "Saturday"
21725 ]
21726 };
21727 var dayPeriodValues = {
21728 narrow: {
21729 am: "a",
21730 pm: "p",
21731 midnight: "mi",
21732 noon: "n",
21733 morning: "morning",
21734 afternoon: "afternoon",
21735 evening: "evening",
21736 night: "night"
21737 },
21738 abbreviated: {
21739 am: "AM",
21740 pm: "PM",
21741 midnight: "midnight",
21742 noon: "noon",
21743 morning: "morning",
21744 afternoon: "afternoon",
21745 evening: "evening",
21746 night: "night"
21747 },
21748 wide: {
21749 am: "a.m.",
21750 pm: "p.m.",
21751 midnight: "midnight",
21752 noon: "noon",
21753 morning: "morning",
21754 afternoon: "afternoon",
21755 evening: "evening",
21756 night: "night"
21757 }
21758 };
21759 var formattingDayPeriodValues = {
21760 narrow: {
21761 am: "a",
21762 pm: "p",
21763 midnight: "mi",
21764 noon: "n",
21765 morning: "in the morning",
21766 afternoon: "in the afternoon",
21767 evening: "in the evening",
21768 night: "at night"
21769 },
21770 abbreviated: {
21771 am: "AM",
21772 pm: "PM",
21773 midnight: "midnight",
21774 noon: "noon",
21775 morning: "in the morning",
21776 afternoon: "in the afternoon",
21777 evening: "in the evening",
21778 night: "at night"
21779 },
21780 wide: {
21781 am: "a.m.",
21782 pm: "p.m.",
21783 midnight: "midnight",
21784 noon: "noon",
21785 morning: "in the morning",
21786 afternoon: "in the afternoon",
21787 evening: "in the evening",
21788 night: "at night"
21789 }
21790 };
21791 var ordinalNumber = (dirtyNumber, _options) => {
21792 const number = Number(dirtyNumber);
21793 const rem100 = number % 100;
21794 if (rem100 > 20 || rem100 < 10) {
21795 switch (rem100 % 10) {
21796 case 1:
21797 return number + "st";
21798 case 2:
21799 return number + "nd";
21800 case 3:
21801 return number + "rd";
21802 }
21803 }
21804 return number + "th";
21805 };
21806 var localize = {
21807 ordinalNumber,
21808 era: buildLocalizeFn({
21809 values: eraValues,
21810 defaultWidth: "wide"
21811 }),
21812 quarter: buildLocalizeFn({
21813 values: quarterValues,
21814 defaultWidth: "wide",
21815 argumentCallback: (quarter) => quarter - 1
21816 }),
21817 month: buildLocalizeFn({
21818 values: monthValues,
21819 defaultWidth: "wide"
21820 }),
21821 day: buildLocalizeFn({
21822 values: dayValues,
21823 defaultWidth: "wide"
21824 }),
21825 dayPeriod: buildLocalizeFn({
21826 values: dayPeriodValues,
21827 defaultWidth: "wide",
21828 formattingValues: formattingDayPeriodValues,
21829 defaultFormattingWidth: "wide"
21830 })
21831 };
21832
21833 // node_modules/date-fns/locale/_lib/buildMatchFn.js
21834 function buildMatchFn(args) {
21835 return (string, options = {}) => {
21836 const width = options.width;
21837 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
21838 const matchResult = string.match(matchPattern);
21839 if (!matchResult) {
21840 return null;
21841 }
21842 const matchedString = matchResult[0];
21843 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
21844 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
21845 // [TODO] -- I challenge you to fix the type
21846 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
21847 );
21848 let value;
21849 value = args.valueCallback ? args.valueCallback(key) : key;
21850 value = options.valueCallback ? (
21851 // [TODO] -- I challenge you to fix the type
21852 options.valueCallback(value)
21853 ) : value;
21854 const rest = string.slice(matchedString.length);
21855 return { value, rest };
21856 };
21857 }
21858 function findKey(object, predicate) {
21859 for (const key in object) {
21860 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
21861 return key;
21862 }
21863 }
21864 return void 0;
21865 }
21866 function findIndex(array, predicate) {
21867 for (let key = 0; key < array.length; key++) {
21868 if (predicate(array[key])) {
21869 return key;
21870 }
21871 }
21872 return void 0;
21873 }
21874
21875 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
21876 function buildMatchPatternFn(args) {
21877 return (string, options = {}) => {
21878 const matchResult = string.match(args.matchPattern);
21879 if (!matchResult) return null;
21880 const matchedString = matchResult[0];
21881 const parseResult = string.match(args.parsePattern);
21882 if (!parseResult) return null;
21883 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
21884 value = options.valueCallback ? options.valueCallback(value) : value;
21885 const rest = string.slice(matchedString.length);
21886 return { value, rest };
21887 };
21888 }
21889
21890 // node_modules/date-fns/locale/en-US/_lib/match.js
21891 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
21892 var parseOrdinalNumberPattern = /\d+/i;
21893 var matchEraPatterns = {
21894 narrow: /^(b|a)/i,
21895 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
21896 wide: /^(before christ|before common era|anno domini|common era)/i
21897 };
21898 var parseEraPatterns = {
21899 any: [/^b/i, /^(a|c)/i]
21900 };
21901 var matchQuarterPatterns = {
21902 narrow: /^[1234]/i,
21903 abbreviated: /^q[1234]/i,
21904 wide: /^[1234](th|st|nd|rd)? quarter/i
21905 };
21906 var parseQuarterPatterns = {
21907 any: [/1/i, /2/i, /3/i, /4/i]
21908 };
21909 var matchMonthPatterns = {
21910 narrow: /^[jfmasond]/i,
21911 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
21912 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
21913 };
21914 var parseMonthPatterns = {
21915 narrow: [
21916 /^j/i,
21917 /^f/i,
21918 /^m/i,
21919 /^a/i,
21920 /^m/i,
21921 /^j/i,
21922 /^j/i,
21923 /^a/i,
21924 /^s/i,
21925 /^o/i,
21926 /^n/i,
21927 /^d/i
21928 ],
21929 any: [
21930 /^ja/i,
21931 /^f/i,
21932 /^mar/i,
21933 /^ap/i,
21934 /^may/i,
21935 /^jun/i,
21936 /^jul/i,
21937 /^au/i,
21938 /^s/i,
21939 /^o/i,
21940 /^n/i,
21941 /^d/i
21942 ]
21943 };
21944 var matchDayPatterns = {
21945 narrow: /^[smtwf]/i,
21946 short: /^(su|mo|tu|we|th|fr|sa)/i,
21947 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
21948 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
21949 };
21950 var parseDayPatterns = {
21951 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
21952 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
21953 };
21954 var matchDayPeriodPatterns = {
21955 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
21956 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
21957 };
21958 var parseDayPeriodPatterns = {
21959 any: {
21960 am: /^a/i,
21961 pm: /^p/i,
21962 midnight: /^mi/i,
21963 noon: /^no/i,
21964 morning: /morning/i,
21965 afternoon: /afternoon/i,
21966 evening: /evening/i,
21967 night: /night/i
21968 }
21969 };
21970 var match = {
21971 ordinalNumber: buildMatchPatternFn({
21972 matchPattern: matchOrdinalNumberPattern,
21973 parsePattern: parseOrdinalNumberPattern,
21974 valueCallback: (value) => parseInt(value, 10)
21975 }),
21976 era: buildMatchFn({
21977 matchPatterns: matchEraPatterns,
21978 defaultMatchWidth: "wide",
21979 parsePatterns: parseEraPatterns,
21980 defaultParseWidth: "any"
21981 }),
21982 quarter: buildMatchFn({
21983 matchPatterns: matchQuarterPatterns,
21984 defaultMatchWidth: "wide",
21985 parsePatterns: parseQuarterPatterns,
21986 defaultParseWidth: "any",
21987 valueCallback: (index2) => index2 + 1
21988 }),
21989 month: buildMatchFn({
21990 matchPatterns: matchMonthPatterns,
21991 defaultMatchWidth: "wide",
21992 parsePatterns: parseMonthPatterns,
21993 defaultParseWidth: "any"
21994 }),
21995 day: buildMatchFn({
21996 matchPatterns: matchDayPatterns,
21997 defaultMatchWidth: "wide",
21998 parsePatterns: parseDayPatterns,
21999 defaultParseWidth: "any"
22000 }),
22001 dayPeriod: buildMatchFn({
22002 matchPatterns: matchDayPeriodPatterns,
22003 defaultMatchWidth: "any",
22004 parsePatterns: parseDayPeriodPatterns,
22005 defaultParseWidth: "any"
22006 })
22007 };
22008
22009 // node_modules/date-fns/locale/en-US.js
22010 var enUS = {
22011 code: "en-US",
22012 formatDistance,
22013 formatLong,
22014 formatRelative,
22015 localize,
22016 match,
22017 options: {
22018 weekStartsOn: 0,
22019 firstWeekContainsDate: 1
22020 }
22021 };
22022
22023 // node_modules/date-fns/getDayOfYear.js
22024 function getDayOfYear(date, options) {
22025 const _date = toDate(date, options?.in);
22026 const diff = differenceInCalendarDays(_date, startOfYear(_date));
22027 const dayOfYear = diff + 1;
22028 return dayOfYear;
22029 }
22030
22031 // node_modules/date-fns/getISOWeek.js
22032 function getISOWeek(date, options) {
22033 const _date = toDate(date, options?.in);
22034 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
22035 return Math.round(diff / millisecondsInWeek) + 1;
22036 }
22037
22038 // node_modules/date-fns/getWeekYear.js
22039 function getWeekYear(date, options) {
22040 const _date = toDate(date, options?.in);
22041 const year = _date.getFullYear();
22042 const defaultOptions2 = getDefaultOptions();
22043 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22044 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
22045 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
22046 firstWeekOfNextYear.setHours(0, 0, 0, 0);
22047 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
22048 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
22049 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
22050 firstWeekOfThisYear.setHours(0, 0, 0, 0);
22051 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
22052 if (+_date >= +startOfNextYear) {
22053 return year + 1;
22054 } else if (+_date >= +startOfThisYear) {
22055 return year;
22056 } else {
22057 return year - 1;
22058 }
22059 }
22060
22061 // node_modules/date-fns/startOfWeekYear.js
22062 function startOfWeekYear(date, options) {
22063 const defaultOptions2 = getDefaultOptions();
22064 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22065 const year = getWeekYear(date, options);
22066 const firstWeek = constructFrom(options?.in || date, 0);
22067 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
22068 firstWeek.setHours(0, 0, 0, 0);
22069 const _date = startOfWeek(firstWeek, options);
22070 return _date;
22071 }
22072
22073 // node_modules/date-fns/getWeek.js
22074 function getWeek(date, options) {
22075 const _date = toDate(date, options?.in);
22076 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
22077 return Math.round(diff / millisecondsInWeek) + 1;
22078 }
22079
22080 // node_modules/date-fns/_lib/addLeadingZeros.js
22081 function addLeadingZeros(number, targetLength) {
22082 const sign = number < 0 ? "-" : "";
22083 const output = Math.abs(number).toString().padStart(targetLength, "0");
22084 return sign + output;
22085 }
22086
22087 // node_modules/date-fns/_lib/format/lightFormatters.js
22088 var lightFormatters = {
22089 // Year
22090 y(date, token) {
22091 const signedYear = date.getFullYear();
22092 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22093 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
22094 },
22095 // Month
22096 M(date, token) {
22097 const month = date.getMonth();
22098 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
22099 },
22100 // Day of the month
22101 d(date, token) {
22102 return addLeadingZeros(date.getDate(), token.length);
22103 },
22104 // AM or PM
22105 a(date, token) {
22106 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
22107 switch (token) {
22108 case "a":
22109 case "aa":
22110 return dayPeriodEnumValue.toUpperCase();
22111 case "aaa":
22112 return dayPeriodEnumValue;
22113 case "aaaaa":
22114 return dayPeriodEnumValue[0];
22115 case "aaaa":
22116 default:
22117 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
22118 }
22119 },
22120 // Hour [1-12]
22121 h(date, token) {
22122 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
22123 },
22124 // Hour [0-23]
22125 H(date, token) {
22126 return addLeadingZeros(date.getHours(), token.length);
22127 },
22128 // Minute
22129 m(date, token) {
22130 return addLeadingZeros(date.getMinutes(), token.length);
22131 },
22132 // Second
22133 s(date, token) {
22134 return addLeadingZeros(date.getSeconds(), token.length);
22135 },
22136 // Fraction of second
22137 S(date, token) {
22138 const numberOfDigits = token.length;
22139 const milliseconds = date.getMilliseconds();
22140 const fractionalSeconds = Math.trunc(
22141 milliseconds * Math.pow(10, numberOfDigits - 3)
22142 );
22143 return addLeadingZeros(fractionalSeconds, token.length);
22144 }
22145 };
22146
22147 // node_modules/date-fns/_lib/format/formatters.js
22148 var dayPeriodEnum = {
22149 am: "am",
22150 pm: "pm",
22151 midnight: "midnight",
22152 noon: "noon",
22153 morning: "morning",
22154 afternoon: "afternoon",
22155 evening: "evening",
22156 night: "night"
22157 };
22158 var formatters = {
22159 // Era
22160 G: function(date, token, localize2) {
22161 const era = date.getFullYear() > 0 ? 1 : 0;
22162 switch (token) {
22163 // AD, BC
22164 case "G":
22165 case "GG":
22166 case "GGG":
22167 return localize2.era(era, { width: "abbreviated" });
22168 // A, B
22169 case "GGGGG":
22170 return localize2.era(era, { width: "narrow" });
22171 // Anno Domini, Before Christ
22172 case "GGGG":
22173 default:
22174 return localize2.era(era, { width: "wide" });
22175 }
22176 },
22177 // Year
22178 y: function(date, token, localize2) {
22179 if (token === "yo") {
22180 const signedYear = date.getFullYear();
22181 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22182 return localize2.ordinalNumber(year, { unit: "year" });
22183 }
22184 return lightFormatters.y(date, token);
22185 },
22186 // Local week-numbering year
22187 Y: function(date, token, localize2, options) {
22188 const signedWeekYear = getWeekYear(date, options);
22189 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
22190 if (token === "YY") {
22191 const twoDigitYear = weekYear % 100;
22192 return addLeadingZeros(twoDigitYear, 2);
22193 }
22194 if (token === "Yo") {
22195 return localize2.ordinalNumber(weekYear, { unit: "year" });
22196 }
22197 return addLeadingZeros(weekYear, token.length);
22198 },
22199 // ISO week-numbering year
22200 R: function(date, token) {
22201 const isoWeekYear = getISOWeekYear(date);
22202 return addLeadingZeros(isoWeekYear, token.length);
22203 },
22204 // Extended year. This is a single number designating the year of this calendar system.
22205 // The main difference between `y` and `u` localizers are B.C. years:
22206 // | Year | `y` | `u` |
22207 // |------|-----|-----|
22208 // | AC 1 | 1 | 1 |
22209 // | BC 1 | 1 | 0 |
22210 // | BC 2 | 2 | -1 |
22211 // Also `yy` always returns the last two digits of a year,
22212 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
22213 u: function(date, token) {
22214 const year = date.getFullYear();
22215 return addLeadingZeros(year, token.length);
22216 },
22217 // Quarter
22218 Q: function(date, token, localize2) {
22219 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22220 switch (token) {
22221 // 1, 2, 3, 4
22222 case "Q":
22223 return String(quarter);
22224 // 01, 02, 03, 04
22225 case "QQ":
22226 return addLeadingZeros(quarter, 2);
22227 // 1st, 2nd, 3rd, 4th
22228 case "Qo":
22229 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22230 // Q1, Q2, Q3, Q4
22231 case "QQQ":
22232 return localize2.quarter(quarter, {
22233 width: "abbreviated",
22234 context: "formatting"
22235 });
22236 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22237 case "QQQQQ":
22238 return localize2.quarter(quarter, {
22239 width: "narrow",
22240 context: "formatting"
22241 });
22242 // 1st quarter, 2nd quarter, ...
22243 case "QQQQ":
22244 default:
22245 return localize2.quarter(quarter, {
22246 width: "wide",
22247 context: "formatting"
22248 });
22249 }
22250 },
22251 // Stand-alone quarter
22252 q: function(date, token, localize2) {
22253 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22254 switch (token) {
22255 // 1, 2, 3, 4
22256 case "q":
22257 return String(quarter);
22258 // 01, 02, 03, 04
22259 case "qq":
22260 return addLeadingZeros(quarter, 2);
22261 // 1st, 2nd, 3rd, 4th
22262 case "qo":
22263 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22264 // Q1, Q2, Q3, Q4
22265 case "qqq":
22266 return localize2.quarter(quarter, {
22267 width: "abbreviated",
22268 context: "standalone"
22269 });
22270 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22271 case "qqqqq":
22272 return localize2.quarter(quarter, {
22273 width: "narrow",
22274 context: "standalone"
22275 });
22276 // 1st quarter, 2nd quarter, ...
22277 case "qqqq":
22278 default:
22279 return localize2.quarter(quarter, {
22280 width: "wide",
22281 context: "standalone"
22282 });
22283 }
22284 },
22285 // Month
22286 M: function(date, token, localize2) {
22287 const month = date.getMonth();
22288 switch (token) {
22289 case "M":
22290 case "MM":
22291 return lightFormatters.M(date, token);
22292 // 1st, 2nd, ..., 12th
22293 case "Mo":
22294 return localize2.ordinalNumber(month + 1, { unit: "month" });
22295 // Jan, Feb, ..., Dec
22296 case "MMM":
22297 return localize2.month(month, {
22298 width: "abbreviated",
22299 context: "formatting"
22300 });
22301 // J, F, ..., D
22302 case "MMMMM":
22303 return localize2.month(month, {
22304 width: "narrow",
22305 context: "formatting"
22306 });
22307 // January, February, ..., December
22308 case "MMMM":
22309 default:
22310 return localize2.month(month, { width: "wide", context: "formatting" });
22311 }
22312 },
22313 // Stand-alone month
22314 L: function(date, token, localize2) {
22315 const month = date.getMonth();
22316 switch (token) {
22317 // 1, 2, ..., 12
22318 case "L":
22319 return String(month + 1);
22320 // 01, 02, ..., 12
22321 case "LL":
22322 return addLeadingZeros(month + 1, 2);
22323 // 1st, 2nd, ..., 12th
22324 case "Lo":
22325 return localize2.ordinalNumber(month + 1, { unit: "month" });
22326 // Jan, Feb, ..., Dec
22327 case "LLL":
22328 return localize2.month(month, {
22329 width: "abbreviated",
22330 context: "standalone"
22331 });
22332 // J, F, ..., D
22333 case "LLLLL":
22334 return localize2.month(month, {
22335 width: "narrow",
22336 context: "standalone"
22337 });
22338 // January, February, ..., December
22339 case "LLLL":
22340 default:
22341 return localize2.month(month, { width: "wide", context: "standalone" });
22342 }
22343 },
22344 // Local week of year
22345 w: function(date, token, localize2, options) {
22346 const week = getWeek(date, options);
22347 if (token === "wo") {
22348 return localize2.ordinalNumber(week, { unit: "week" });
22349 }
22350 return addLeadingZeros(week, token.length);
22351 },
22352 // ISO week of year
22353 I: function(date, token, localize2) {
22354 const isoWeek = getISOWeek(date);
22355 if (token === "Io") {
22356 return localize2.ordinalNumber(isoWeek, { unit: "week" });
22357 }
22358 return addLeadingZeros(isoWeek, token.length);
22359 },
22360 // Day of the month
22361 d: function(date, token, localize2) {
22362 if (token === "do") {
22363 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
22364 }
22365 return lightFormatters.d(date, token);
22366 },
22367 // Day of year
22368 D: function(date, token, localize2) {
22369 const dayOfYear = getDayOfYear(date);
22370 if (token === "Do") {
22371 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
22372 }
22373 return addLeadingZeros(dayOfYear, token.length);
22374 },
22375 // Day of week
22376 E: function(date, token, localize2) {
22377 const dayOfWeek = date.getDay();
22378 switch (token) {
22379 // Tue
22380 case "E":
22381 case "EE":
22382 case "EEE":
22383 return localize2.day(dayOfWeek, {
22384 width: "abbreviated",
22385 context: "formatting"
22386 });
22387 // T
22388 case "EEEEE":
22389 return localize2.day(dayOfWeek, {
22390 width: "narrow",
22391 context: "formatting"
22392 });
22393 // Tu
22394 case "EEEEEE":
22395 return localize2.day(dayOfWeek, {
22396 width: "short",
22397 context: "formatting"
22398 });
22399 // Tuesday
22400 case "EEEE":
22401 default:
22402 return localize2.day(dayOfWeek, {
22403 width: "wide",
22404 context: "formatting"
22405 });
22406 }
22407 },
22408 // Local day of week
22409 e: function(date, token, localize2, options) {
22410 const dayOfWeek = date.getDay();
22411 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
22412 switch (token) {
22413 // Numerical value (Nth day of week with current locale or weekStartsOn)
22414 case "e":
22415 return String(localDayOfWeek);
22416 // Padded numerical value
22417 case "ee":
22418 return addLeadingZeros(localDayOfWeek, 2);
22419 // 1st, 2nd, ..., 7th
22420 case "eo":
22421 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
22422 case "eee":
22423 return localize2.day(dayOfWeek, {
22424 width: "abbreviated",
22425 context: "formatting"
22426 });
22427 // T
22428 case "eeeee":
22429 return localize2.day(dayOfWeek, {
22430 width: "narrow",
22431 context: "formatting"
22432 });
22433 // Tu
22434 case "eeeeee":
22435 return localize2.day(dayOfWeek, {
22436 width: "short",
22437 context: "formatting"
22438 });
22439 // Tuesday
22440 case "eeee":
22441 default:
22442 return localize2.day(dayOfWeek, {
22443 width: "wide",
22444 context: "formatting"
22445 });
22446 }
22447 },
22448 // Stand-alone local day of week
22449 c: function(date, token, localize2, options) {
22450 const dayOfWeek = date.getDay();
22451 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
22452 switch (token) {
22453 // Numerical value (same as in `e`)
22454 case "c":
22455 return String(localDayOfWeek);
22456 // Padded numerical value
22457 case "cc":
22458 return addLeadingZeros(localDayOfWeek, token.length);
22459 // 1st, 2nd, ..., 7th
22460 case "co":
22461 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
22462 case "ccc":
22463 return localize2.day(dayOfWeek, {
22464 width: "abbreviated",
22465 context: "standalone"
22466 });
22467 // T
22468 case "ccccc":
22469 return localize2.day(dayOfWeek, {
22470 width: "narrow",
22471 context: "standalone"
22472 });
22473 // Tu
22474 case "cccccc":
22475 return localize2.day(dayOfWeek, {
22476 width: "short",
22477 context: "standalone"
22478 });
22479 // Tuesday
22480 case "cccc":
22481 default:
22482 return localize2.day(dayOfWeek, {
22483 width: "wide",
22484 context: "standalone"
22485 });
22486 }
22487 },
22488 // ISO day of week
22489 i: function(date, token, localize2) {
22490 const dayOfWeek = date.getDay();
22491 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
22492 switch (token) {
22493 // 2
22494 case "i":
22495 return String(isoDayOfWeek);
22496 // 02
22497 case "ii":
22498 return addLeadingZeros(isoDayOfWeek, token.length);
22499 // 2nd
22500 case "io":
22501 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
22502 // Tue
22503 case "iii":
22504 return localize2.day(dayOfWeek, {
22505 width: "abbreviated",
22506 context: "formatting"
22507 });
22508 // T
22509 case "iiiii":
22510 return localize2.day(dayOfWeek, {
22511 width: "narrow",
22512 context: "formatting"
22513 });
22514 // Tu
22515 case "iiiiii":
22516 return localize2.day(dayOfWeek, {
22517 width: "short",
22518 context: "formatting"
22519 });
22520 // Tuesday
22521 case "iiii":
22522 default:
22523 return localize2.day(dayOfWeek, {
22524 width: "wide",
22525 context: "formatting"
22526 });
22527 }
22528 },
22529 // AM or PM
22530 a: function(date, token, localize2) {
22531 const hours = date.getHours();
22532 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
22533 switch (token) {
22534 case "a":
22535 case "aa":
22536 return localize2.dayPeriod(dayPeriodEnumValue, {
22537 width: "abbreviated",
22538 context: "formatting"
22539 });
22540 case "aaa":
22541 return localize2.dayPeriod(dayPeriodEnumValue, {
22542 width: "abbreviated",
22543 context: "formatting"
22544 }).toLowerCase();
22545 case "aaaaa":
22546 return localize2.dayPeriod(dayPeriodEnumValue, {
22547 width: "narrow",
22548 context: "formatting"
22549 });
22550 case "aaaa":
22551 default:
22552 return localize2.dayPeriod(dayPeriodEnumValue, {
22553 width: "wide",
22554 context: "formatting"
22555 });
22556 }
22557 },
22558 // AM, PM, midnight, noon
22559 b: function(date, token, localize2) {
22560 const hours = date.getHours();
22561 let dayPeriodEnumValue;
22562 if (hours === 12) {
22563 dayPeriodEnumValue = dayPeriodEnum.noon;
22564 } else if (hours === 0) {
22565 dayPeriodEnumValue = dayPeriodEnum.midnight;
22566 } else {
22567 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
22568 }
22569 switch (token) {
22570 case "b":
22571 case "bb":
22572 return localize2.dayPeriod(dayPeriodEnumValue, {
22573 width: "abbreviated",
22574 context: "formatting"
22575 });
22576 case "bbb":
22577 return localize2.dayPeriod(dayPeriodEnumValue, {
22578 width: "abbreviated",
22579 context: "formatting"
22580 }).toLowerCase();
22581 case "bbbbb":
22582 return localize2.dayPeriod(dayPeriodEnumValue, {
22583 width: "narrow",
22584 context: "formatting"
22585 });
22586 case "bbbb":
22587 default:
22588 return localize2.dayPeriod(dayPeriodEnumValue, {
22589 width: "wide",
22590 context: "formatting"
22591 });
22592 }
22593 },
22594 // in the morning, in the afternoon, in the evening, at night
22595 B: function(date, token, localize2) {
22596 const hours = date.getHours();
22597 let dayPeriodEnumValue;
22598 if (hours >= 17) {
22599 dayPeriodEnumValue = dayPeriodEnum.evening;
22600 } else if (hours >= 12) {
22601 dayPeriodEnumValue = dayPeriodEnum.afternoon;
22602 } else if (hours >= 4) {
22603 dayPeriodEnumValue = dayPeriodEnum.morning;
22604 } else {
22605 dayPeriodEnumValue = dayPeriodEnum.night;
22606 }
22607 switch (token) {
22608 case "B":
22609 case "BB":
22610 case "BBB":
22611 return localize2.dayPeriod(dayPeriodEnumValue, {
22612 width: "abbreviated",
22613 context: "formatting"
22614 });
22615 case "BBBBB":
22616 return localize2.dayPeriod(dayPeriodEnumValue, {
22617 width: "narrow",
22618 context: "formatting"
22619 });
22620 case "BBBB":
22621 default:
22622 return localize2.dayPeriod(dayPeriodEnumValue, {
22623 width: "wide",
22624 context: "formatting"
22625 });
22626 }
22627 },
22628 // Hour [1-12]
22629 h: function(date, token, localize2) {
22630 if (token === "ho") {
22631 let hours = date.getHours() % 12;
22632 if (hours === 0) hours = 12;
22633 return localize2.ordinalNumber(hours, { unit: "hour" });
22634 }
22635 return lightFormatters.h(date, token);
22636 },
22637 // Hour [0-23]
22638 H: function(date, token, localize2) {
22639 if (token === "Ho") {
22640 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
22641 }
22642 return lightFormatters.H(date, token);
22643 },
22644 // Hour [0-11]
22645 K: function(date, token, localize2) {
22646 const hours = date.getHours() % 12;
22647 if (token === "Ko") {
22648 return localize2.ordinalNumber(hours, { unit: "hour" });
22649 }
22650 return addLeadingZeros(hours, token.length);
22651 },
22652 // Hour [1-24]
22653 k: function(date, token, localize2) {
22654 let hours = date.getHours();
22655 if (hours === 0) hours = 24;
22656 if (token === "ko") {
22657 return localize2.ordinalNumber(hours, { unit: "hour" });
22658 }
22659 return addLeadingZeros(hours, token.length);
22660 },
22661 // Minute
22662 m: function(date, token, localize2) {
22663 if (token === "mo") {
22664 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
22665 }
22666 return lightFormatters.m(date, token);
22667 },
22668 // Second
22669 s: function(date, token, localize2) {
22670 if (token === "so") {
22671 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
22672 }
22673 return lightFormatters.s(date, token);
22674 },
22675 // Fraction of second
22676 S: function(date, token) {
22677 return lightFormatters.S(date, token);
22678 },
22679 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
22680 X: function(date, token, _localize) {
22681 const timezoneOffset = date.getTimezoneOffset();
22682 if (timezoneOffset === 0) {
22683 return "Z";
22684 }
22685 switch (token) {
22686 // Hours and optional minutes
22687 case "X":
22688 return formatTimezoneWithOptionalMinutes(timezoneOffset);
22689 // Hours, minutes and optional seconds without `:` delimiter
22690 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22691 // so this token always has the same output as `XX`
22692 case "XXXX":
22693 case "XX":
22694 return formatTimezone(timezoneOffset);
22695 // Hours, minutes and optional seconds with `:` delimiter
22696 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22697 // so this token always has the same output as `XXX`
22698 case "XXXXX":
22699 case "XXX":
22700 // Hours and minutes with `:` delimiter
22701 default:
22702 return formatTimezone(timezoneOffset, ":");
22703 }
22704 },
22705 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
22706 x: function(date, token, _localize) {
22707 const timezoneOffset = date.getTimezoneOffset();
22708 switch (token) {
22709 // Hours and optional minutes
22710 case "x":
22711 return formatTimezoneWithOptionalMinutes(timezoneOffset);
22712 // Hours, minutes and optional seconds without `:` delimiter
22713 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22714 // so this token always has the same output as `xx`
22715 case "xxxx":
22716 case "xx":
22717 return formatTimezone(timezoneOffset);
22718 // Hours, minutes and optional seconds with `:` delimiter
22719 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22720 // so this token always has the same output as `xxx`
22721 case "xxxxx":
22722 case "xxx":
22723 // Hours and minutes with `:` delimiter
22724 default:
22725 return formatTimezone(timezoneOffset, ":");
22726 }
22727 },
22728 // Timezone (GMT)
22729 O: function(date, token, _localize) {
22730 const timezoneOffset = date.getTimezoneOffset();
22731 switch (token) {
22732 // Short
22733 case "O":
22734 case "OO":
22735 case "OOO":
22736 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
22737 // Long
22738 case "OOOO":
22739 default:
22740 return "GMT" + formatTimezone(timezoneOffset, ":");
22741 }
22742 },
22743 // Timezone (specific non-location)
22744 z: function(date, token, _localize) {
22745 const timezoneOffset = date.getTimezoneOffset();
22746 switch (token) {
22747 // Short
22748 case "z":
22749 case "zz":
22750 case "zzz":
22751 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
22752 // Long
22753 case "zzzz":
22754 default:
22755 return "GMT" + formatTimezone(timezoneOffset, ":");
22756 }
22757 },
22758 // Seconds timestamp
22759 t: function(date, token, _localize) {
22760 const timestamp = Math.trunc(+date / 1e3);
22761 return addLeadingZeros(timestamp, token.length);
22762 },
22763 // Milliseconds timestamp
22764 T: function(date, token, _localize) {
22765 return addLeadingZeros(+date, token.length);
22766 }
22767 };
22768 function formatTimezoneShort(offset4, delimiter = "") {
22769 const sign = offset4 > 0 ? "-" : "+";
22770 const absOffset = Math.abs(offset4);
22771 const hours = Math.trunc(absOffset / 60);
22772 const minutes = absOffset % 60;
22773 if (minutes === 0) {
22774 return sign + String(hours);
22775 }
22776 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
22777 }
22778 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
22779 if (offset4 % 60 === 0) {
22780 const sign = offset4 > 0 ? "-" : "+";
22781 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
22782 }
22783 return formatTimezone(offset4, delimiter);
22784 }
22785 function formatTimezone(offset4, delimiter = "") {
22786 const sign = offset4 > 0 ? "-" : "+";
22787 const absOffset = Math.abs(offset4);
22788 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
22789 const minutes = addLeadingZeros(absOffset % 60, 2);
22790 return sign + hours + delimiter + minutes;
22791 }
22792
22793 // node_modules/date-fns/_lib/format/longFormatters.js
22794 var dateLongFormatter = (pattern, formatLong2) => {
22795 switch (pattern) {
22796 case "P":
22797 return formatLong2.date({ width: "short" });
22798 case "PP":
22799 return formatLong2.date({ width: "medium" });
22800 case "PPP":
22801 return formatLong2.date({ width: "long" });
22802 case "PPPP":
22803 default:
22804 return formatLong2.date({ width: "full" });
22805 }
22806 };
22807 var timeLongFormatter = (pattern, formatLong2) => {
22808 switch (pattern) {
22809 case "p":
22810 return formatLong2.time({ width: "short" });
22811 case "pp":
22812 return formatLong2.time({ width: "medium" });
22813 case "ppp":
22814 return formatLong2.time({ width: "long" });
22815 case "pppp":
22816 default:
22817 return formatLong2.time({ width: "full" });
22818 }
22819 };
22820 var dateTimeLongFormatter = (pattern, formatLong2) => {
22821 const matchResult = pattern.match(/(P+)(p+)?/) || [];
22822 const datePattern = matchResult[1];
22823 const timePattern = matchResult[2];
22824 if (!timePattern) {
22825 return dateLongFormatter(pattern, formatLong2);
22826 }
22827 let dateTimeFormat;
22828 switch (datePattern) {
22829 case "P":
22830 dateTimeFormat = formatLong2.dateTime({ width: "short" });
22831 break;
22832 case "PP":
22833 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
22834 break;
22835 case "PPP":
22836 dateTimeFormat = formatLong2.dateTime({ width: "long" });
22837 break;
22838 case "PPPP":
22839 default:
22840 dateTimeFormat = formatLong2.dateTime({ width: "full" });
22841 break;
22842 }
22843 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
22844 };
22845 var longFormatters = {
22846 p: timeLongFormatter,
22847 P: dateTimeLongFormatter
22848 };
22849
22850 // node_modules/date-fns/_lib/protectedTokens.js
22851 var dayOfYearTokenRE = /^D+$/;
22852 var weekYearTokenRE = /^Y+$/;
22853 var throwTokens = ["D", "DD", "YY", "YYYY"];
22854 function isProtectedDayOfYearToken(token) {
22855 return dayOfYearTokenRE.test(token);
22856 }
22857 function isProtectedWeekYearToken(token) {
22858 return weekYearTokenRE.test(token);
22859 }
22860 function warnOrThrowProtectedError(token, format6, input) {
22861 const _message = message(token, format6, input);
22862 console.warn(_message);
22863 if (throwTokens.includes(token)) throw new RangeError(_message);
22864 }
22865 function message(token, format6, input) {
22866 const subject = token[0] === "Y" ? "years" : "days of the month";
22867 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`;
22868 }
22869
22870 // node_modules/date-fns/format.js
22871 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
22872 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
22873 var escapedStringRegExp = /^'([^]*?)'?$/;
22874 var doubleQuoteRegExp = /''/g;
22875 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
22876 function format(date, formatStr, options) {
22877 const defaultOptions2 = getDefaultOptions();
22878 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
22879 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22880 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
22881 const originalDate = toDate(date, options?.in);
22882 if (!isValid(originalDate)) {
22883 throw new RangeError("Invalid time value");
22884 }
22885 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
22886 const firstCharacter = substring[0];
22887 if (firstCharacter === "p" || firstCharacter === "P") {
22888 const longFormatter = longFormatters[firstCharacter];
22889 return longFormatter(substring, locale.formatLong);
22890 }
22891 return substring;
22892 }).join("").match(formattingTokensRegExp).map((substring) => {
22893 if (substring === "''") {
22894 return { isToken: false, value: "'" };
22895 }
22896 const firstCharacter = substring[0];
22897 if (firstCharacter === "'") {
22898 return { isToken: false, value: cleanEscapedString(substring) };
22899 }
22900 if (formatters[firstCharacter]) {
22901 return { isToken: true, value: substring };
22902 }
22903 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
22904 throw new RangeError(
22905 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
22906 );
22907 }
22908 return { isToken: false, value: substring };
22909 });
22910 if (locale.localize.preprocessor) {
22911 parts = locale.localize.preprocessor(originalDate, parts);
22912 }
22913 const formatterOptions = {
22914 firstWeekContainsDate,
22915 weekStartsOn,
22916 locale
22917 };
22918 return parts.map((part) => {
22919 if (!part.isToken) return part.value;
22920 const token = part.value;
22921 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
22922 warnOrThrowProtectedError(token, formatStr, String(date));
22923 }
22924 const formatter = formatters[token[0]];
22925 return formatter(originalDate, token, locale.localize, formatterOptions);
22926 }).join("");
22927 }
22928 function cleanEscapedString(input) {
22929 const matched = input.match(escapedStringRegExp);
22930 if (!matched) {
22931 return input;
22932 }
22933 return matched[1].replace(doubleQuoteRegExp, "'");
22934 }
22935
22936 // node_modules/date-fns/subDays.js
22937 function subDays(date, amount, options) {
22938 return addDays(date, -amount, options);
22939 }
22940
22941 // node_modules/date-fns/subMonths.js
22942 function subMonths(date, amount, options) {
22943 return addMonths(date, -amount, options);
22944 }
22945
22946 // node_modules/date-fns/subWeeks.js
22947 function subWeeks(date, amount, options) {
22948 return addWeeks(date, -amount, options);
22949 }
22950
22951 // node_modules/date-fns/subYears.js
22952 function subYears(date, amount, options) {
22953 return addYears(date, -amount, options);
22954 }
22955
22956 // packages/dataviews/build-module/utils/operators.mjs
22957 var import_i18n24 = __toESM(require_i18n(), 1);
22958 var import_element61 = __toESM(require_element(), 1);
22959 var import_date = __toESM(require_date(), 1);
22960 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22961 var filterTextWrappers = {
22962 Name: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
22963 Value: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
22964 };
22965 function getRelativeDate(value, unit) {
22966 switch (unit) {
22967 case "days":
22968 return subDays(/* @__PURE__ */ new Date(), value);
22969 case "weeks":
22970 return subWeeks(/* @__PURE__ */ new Date(), value);
22971 case "months":
22972 return subMonths(/* @__PURE__ */ new Date(), value);
22973 case "years":
22974 return subYears(/* @__PURE__ */ new Date(), value);
22975 default:
22976 return /* @__PURE__ */ new Date();
22977 }
22978 }
22979 var isNoneOperatorDefinition = {
22980 /* translators: DataViews operator name */
22981 label: (0, import_i18n24.__)("Is none of"),
22982 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
22983 (0, import_i18n24.sprintf)(
22984 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
22985 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
22986 filter.name,
22987 activeElements.map((element) => element.label).join(", ")
22988 ),
22989 filterTextWrappers
22990 ),
22991 filter: ((item, field, filterValue) => {
22992 if (!filterValue?.length) {
22993 return true;
22994 }
22995 const fieldValue = field.getValue({ item });
22996 if (Array.isArray(fieldValue)) {
22997 return !filterValue.some(
22998 (fv) => fieldValue.includes(fv)
22999 );
23000 } else if (typeof fieldValue === "string") {
23001 return !filterValue.includes(fieldValue);
23002 }
23003 return false;
23004 }),
23005 selection: "multi"
23006 };
23007 var OPERATORS = [
23008 {
23009 name: OPERATOR_IS_ANY,
23010 /* translators: DataViews operator name */
23011 label: (0, import_i18n24.__)("Includes"),
23012 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23013 (0, import_i18n24.sprintf)(
23014 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
23015 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
23016 filter.name,
23017 activeElements.map((element) => element.label).join(", ")
23018 ),
23019 filterTextWrappers
23020 ),
23021 filter(item, field, filterValue) {
23022 if (!filterValue?.length) {
23023 return true;
23024 }
23025 const fieldValue = field.getValue({ item });
23026 if (Array.isArray(fieldValue)) {
23027 return filterValue.some(
23028 (fv) => fieldValue.includes(fv)
23029 );
23030 } else if (typeof fieldValue === "string") {
23031 return filterValue.includes(fieldValue);
23032 }
23033 return false;
23034 },
23035 selection: "multi"
23036 },
23037 {
23038 name: OPERATOR_IS_NONE,
23039 ...isNoneOperatorDefinition
23040 },
23041 {
23042 name: OPERATOR_IS_ALL,
23043 /* translators: DataViews operator name */
23044 label: (0, import_i18n24.__)("Includes all"),
23045 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23046 (0, import_i18n24.sprintf)(
23047 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
23048 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
23049 filter.name,
23050 activeElements.map((element) => element.label).join(", ")
23051 ),
23052 filterTextWrappers
23053 ),
23054 filter(item, field, filterValue) {
23055 if (!filterValue?.length) {
23056 return true;
23057 }
23058 return filterValue.every((value) => {
23059 return field.getValue({ item })?.includes(value);
23060 });
23061 },
23062 selection: "multi"
23063 },
23064 {
23065 name: OPERATOR_IS_NOT_ALL,
23066 ...isNoneOperatorDefinition
23067 },
23068 {
23069 name: OPERATOR_BETWEEN,
23070 /* translators: DataViews operator name */
23071 label: (0, import_i18n24.__)("Between (inc)"),
23072 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23073 (0, import_i18n24.sprintf)(
23074 /* 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". */
23075 (0, import_i18n24.__)(
23076 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
23077 ),
23078 filter.name,
23079 activeElements[0].label[0],
23080 activeElements[0].label[1]
23081 ),
23082 filterTextWrappers
23083 ),
23084 filter(item, field, filterValue) {
23085 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
23086 return true;
23087 }
23088 const fieldValue = field.getValue({ item });
23089 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
23090 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
23091 }
23092 return false;
23093 },
23094 selection: "custom"
23095 },
23096 {
23097 name: OPERATOR_IN_THE_PAST,
23098 /* translators: DataViews operator name */
23099 label: (0, import_i18n24.__)("In the past"),
23100 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23101 (0, import_i18n24.sprintf)(
23102 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
23103 (0, import_i18n24.__)(
23104 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
23105 ),
23106 filter.name,
23107 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23108 ),
23109 filterTextWrappers
23110 ),
23111 filter(item, field, filterValue) {
23112 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23113 return true;
23114 }
23115 const targetDate = getRelativeDate(
23116 filterValue.value,
23117 filterValue.unit
23118 );
23119 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23120 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
23121 },
23122 selection: "custom"
23123 },
23124 {
23125 name: OPERATOR_OVER,
23126 /* translators: DataViews operator name */
23127 label: (0, import_i18n24.__)("Over"),
23128 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23129 (0, import_i18n24.sprintf)(
23130 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
23131 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
23132 filter.name,
23133 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23134 ),
23135 filterTextWrappers
23136 ),
23137 filter(item, field, filterValue) {
23138 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23139 return true;
23140 }
23141 const targetDate = getRelativeDate(
23142 filterValue.value,
23143 filterValue.unit
23144 );
23145 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23146 return fieldValue < targetDate;
23147 },
23148 selection: "custom"
23149 },
23150 {
23151 name: OPERATOR_IS,
23152 /* translators: DataViews operator name */
23153 label: (0, import_i18n24.__)("Is"),
23154 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23155 (0, import_i18n24.sprintf)(
23156 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
23157 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
23158 filter.name,
23159 activeElements[0].label
23160 ),
23161 filterTextWrappers
23162 ),
23163 filter(item, field, filterValue) {
23164 return filterValue === field.getValue({ item }) || filterValue === void 0;
23165 },
23166 selection: "single"
23167 },
23168 {
23169 name: OPERATOR_IS_NOT,
23170 /* translators: DataViews operator name */
23171 label: (0, import_i18n24.__)("Is not"),
23172 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23173 (0, import_i18n24.sprintf)(
23174 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
23175 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
23176 filter.name,
23177 activeElements[0].label
23178 ),
23179 filterTextWrappers
23180 ),
23181 filter(item, field, filterValue) {
23182 return filterValue !== field.getValue({ item });
23183 },
23184 selection: "single"
23185 },
23186 {
23187 name: OPERATOR_LESS_THAN,
23188 /* translators: DataViews operator name */
23189 label: (0, import_i18n24.__)("Less than"),
23190 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23191 (0, import_i18n24.sprintf)(
23192 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
23193 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
23194 filter.name,
23195 activeElements[0].label
23196 ),
23197 filterTextWrappers
23198 ),
23199 filter(item, field, filterValue) {
23200 if (filterValue === void 0) {
23201 return true;
23202 }
23203 const fieldValue = field.getValue({ item });
23204 return fieldValue < filterValue;
23205 },
23206 selection: "single"
23207 },
23208 {
23209 name: OPERATOR_GREATER_THAN,
23210 /* translators: DataViews operator name */
23211 label: (0, import_i18n24.__)("Greater than"),
23212 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23213 (0, import_i18n24.sprintf)(
23214 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
23215 (0, import_i18n24.__)(
23216 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
23217 ),
23218 filter.name,
23219 activeElements[0].label
23220 ),
23221 filterTextWrappers
23222 ),
23223 filter(item, field, filterValue) {
23224 if (filterValue === void 0) {
23225 return true;
23226 }
23227 const fieldValue = field.getValue({ item });
23228 return fieldValue > filterValue;
23229 },
23230 selection: "single"
23231 },
23232 {
23233 name: OPERATOR_LESS_THAN_OR_EQUAL,
23234 /* translators: DataViews operator name */
23235 label: (0, import_i18n24.__)("Less than or equal"),
23236 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23237 (0, import_i18n24.sprintf)(
23238 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
23239 (0, import_i18n24.__)(
23240 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
23241 ),
23242 filter.name,
23243 activeElements[0].label
23244 ),
23245 filterTextWrappers
23246 ),
23247 filter(item, field, filterValue) {
23248 if (filterValue === void 0) {
23249 return true;
23250 }
23251 const fieldValue = field.getValue({ item });
23252 return fieldValue <= filterValue;
23253 },
23254 selection: "single"
23255 },
23256 {
23257 name: OPERATOR_GREATER_THAN_OR_EQUAL,
23258 /* translators: DataViews operator name */
23259 label: (0, import_i18n24.__)("Greater than or equal"),
23260 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23261 (0, import_i18n24.sprintf)(
23262 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
23263 (0, import_i18n24.__)(
23264 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
23265 ),
23266 filter.name,
23267 activeElements[0].label
23268 ),
23269 filterTextWrappers
23270 ),
23271 filter(item, field, filterValue) {
23272 if (filterValue === void 0) {
23273 return true;
23274 }
23275 const fieldValue = field.getValue({ item });
23276 return fieldValue >= filterValue;
23277 },
23278 selection: "single"
23279 },
23280 {
23281 name: OPERATOR_BEFORE,
23282 /* translators: DataViews operator name */
23283 label: (0, import_i18n24.__)("Before"),
23284 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23285 (0, import_i18n24.sprintf)(
23286 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
23287 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
23288 filter.name,
23289 activeElements[0].label
23290 ),
23291 filterTextWrappers
23292 ),
23293 filter(item, field, filterValue) {
23294 if (filterValue === void 0) {
23295 return true;
23296 }
23297 const filterDate = (0, import_date.getDate)(filterValue);
23298 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23299 return fieldDate < filterDate;
23300 },
23301 selection: "single"
23302 },
23303 {
23304 name: OPERATOR_AFTER,
23305 /* translators: DataViews operator name */
23306 label: (0, import_i18n24.__)("After"),
23307 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23308 (0, import_i18n24.sprintf)(
23309 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
23310 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
23311 filter.name,
23312 activeElements[0].label
23313 ),
23314 filterTextWrappers
23315 ),
23316 filter(item, field, filterValue) {
23317 if (filterValue === void 0) {
23318 return true;
23319 }
23320 const filterDate = (0, import_date.getDate)(filterValue);
23321 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23322 return fieldDate > filterDate;
23323 },
23324 selection: "single"
23325 },
23326 {
23327 name: OPERATOR_BEFORE_INC,
23328 /* translators: DataViews operator name */
23329 label: (0, import_i18n24.__)("Before (inc)"),
23330 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23331 (0, import_i18n24.sprintf)(
23332 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
23333 (0, import_i18n24.__)(
23334 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
23335 ),
23336 filter.name,
23337 activeElements[0].label
23338 ),
23339 filterTextWrappers
23340 ),
23341 filter(item, field, filterValue) {
23342 if (filterValue === void 0) {
23343 return true;
23344 }
23345 const filterDate = (0, import_date.getDate)(filterValue);
23346 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23347 return fieldDate <= filterDate;
23348 },
23349 selection: "single"
23350 },
23351 {
23352 name: OPERATOR_AFTER_INC,
23353 /* translators: DataViews operator name */
23354 label: (0, import_i18n24.__)("After (inc)"),
23355 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23356 (0, import_i18n24.sprintf)(
23357 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
23358 (0, import_i18n24.__)(
23359 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
23360 ),
23361 filter.name,
23362 activeElements[0].label
23363 ),
23364 filterTextWrappers
23365 ),
23366 filter(item, field, filterValue) {
23367 if (filterValue === void 0) {
23368 return true;
23369 }
23370 const filterDate = (0, import_date.getDate)(filterValue);
23371 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23372 return fieldDate >= filterDate;
23373 },
23374 selection: "single"
23375 },
23376 {
23377 name: OPERATOR_CONTAINS,
23378 /* translators: DataViews operator name */
23379 label: (0, import_i18n24.__)("Contains"),
23380 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23381 (0, import_i18n24.sprintf)(
23382 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
23383 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
23384 filter.name,
23385 activeElements[0].label
23386 ),
23387 filterTextWrappers
23388 ),
23389 filter(item, field, filterValue) {
23390 if (filterValue === void 0) {
23391 return true;
23392 }
23393 const fieldValue = field.getValue({ item });
23394 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
23395 },
23396 selection: "single"
23397 },
23398 {
23399 name: OPERATOR_NOT_CONTAINS,
23400 /* translators: DataViews operator name */
23401 label: (0, import_i18n24.__)("Doesn't contain"),
23402 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23403 (0, import_i18n24.sprintf)(
23404 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
23405 (0, import_i18n24.__)(
23406 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
23407 ),
23408 filter.name,
23409 activeElements[0].label
23410 ),
23411 filterTextWrappers
23412 ),
23413 filter(item, field, filterValue) {
23414 if (filterValue === void 0) {
23415 return true;
23416 }
23417 const fieldValue = field.getValue({ item });
23418 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
23419 },
23420 selection: "single"
23421 },
23422 {
23423 name: OPERATOR_STARTS_WITH,
23424 /* translators: DataViews operator name */
23425 label: (0, import_i18n24.__)("Starts with"),
23426 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23427 (0, import_i18n24.sprintf)(
23428 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
23429 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
23430 filter.name,
23431 activeElements[0].label
23432 ),
23433 filterTextWrappers
23434 ),
23435 filter(item, field, filterValue) {
23436 if (filterValue === void 0) {
23437 return true;
23438 }
23439 const fieldValue = field.getValue({ item });
23440 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
23441 },
23442 selection: "single"
23443 },
23444 {
23445 name: OPERATOR_ON,
23446 /* translators: DataViews operator name */
23447 label: (0, import_i18n24.__)("On"),
23448 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23449 (0, import_i18n24.sprintf)(
23450 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
23451 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
23452 filter.name,
23453 activeElements[0].label
23454 ),
23455 filterTextWrappers
23456 ),
23457 filter(item, field, filterValue) {
23458 if (filterValue === void 0) {
23459 return true;
23460 }
23461 const filterDate = (0, import_date.getDate)(filterValue);
23462 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23463 return filterDate.getTime() === fieldDate.getTime();
23464 },
23465 selection: "single"
23466 },
23467 {
23468 name: OPERATOR_NOT_ON,
23469 /* translators: DataViews operator name */
23470 label: (0, import_i18n24.__)("Not on"),
23471 filterText: (filter, activeElements) => (0, import_element61.createInterpolateElement)(
23472 (0, import_i18n24.sprintf)(
23473 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
23474 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
23475 filter.name,
23476 activeElements[0].label
23477 ),
23478 filterTextWrappers
23479 ),
23480 filter(item, field, filterValue) {
23481 if (filterValue === void 0) {
23482 return true;
23483 }
23484 const filterDate = (0, import_date.getDate)(filterValue);
23485 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23486 return filterDate.getTime() !== fieldDate.getTime();
23487 },
23488 selection: "single"
23489 }
23490 ];
23491 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
23492 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
23493 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
23494 (op) => op.name === name
23495 );
23496 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
23497
23498 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
23499 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23500 var ENTER = "Enter";
23501 var SPACE = " ";
23502 var FilterText = ({
23503 activeElements,
23504 filterInView,
23505 filter
23506 }) => {
23507 if (activeElements === void 0 || activeElements.length === 0) {
23508 return filter.name;
23509 }
23510 const operator = getOperatorByName(filterInView?.operator);
23511 if (operator !== void 0) {
23512 return operator.filterText(filter, activeElements);
23513 }
23514 return (0, import_i18n25.sprintf)(
23515 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
23516 (0, import_i18n25.__)("Unknown status for %1$s"),
23517 filter.name
23518 );
23519 };
23520 function OperatorSelector({
23521 filter,
23522 view,
23523 onChangeView
23524 }) {
23525 const operatorOptions = filter.operators?.map((operator) => ({
23526 value: operator,
23527 label: getOperatorByName(operator)?.label || operator
23528 }));
23529 const currentFilter = view.filters?.find(
23530 (_filter) => _filter.field === filter.field
23531 );
23532 const value = currentFilter?.operator || filter.operators[0];
23533 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
23534 Stack,
23535 {
23536 direction: "row",
23537 gap: "sm",
23538 justify: "flex-start",
23539 className: "dataviews-filters__summary-operators-container",
23540 align: "center",
23541 children: [
23542 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
23543 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23544 import_components23.SelectControl,
23545 {
23546 className: "dataviews-filters__summary-operators-filter-select",
23547 label: (0, import_i18n25.__)("Conditions"),
23548 value,
23549 options: operatorOptions,
23550 onChange: (newValue) => {
23551 const newOperator = newValue;
23552 const currentOperator = currentFilter?.operator;
23553 const newFilters = currentFilter ? [
23554 ...(view.filters ?? []).map(
23555 (_filter) => {
23556 if (_filter.field === filter.field) {
23557 const currentOpSelectionModel = getOperatorByName(
23558 currentOperator
23559 )?.selection;
23560 const newOpSelectionModel = getOperatorByName(
23561 newOperator
23562 )?.selection;
23563 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
23564 currentOpSelectionModel,
23565 newOpSelectionModel
23566 ].includes("custom");
23567 return {
23568 ..._filter,
23569 value: shouldResetValue ? void 0 : _filter.value,
23570 operator: newOperator
23571 };
23572 }
23573 return _filter;
23574 }
23575 )
23576 ] : [
23577 ...view.filters ?? [],
23578 {
23579 field: filter.field,
23580 operator: newOperator,
23581 value: void 0
23582 }
23583 ];
23584 onChangeView({
23585 ...view,
23586 page: 1,
23587 filters: newFilters
23588 });
23589 },
23590 size: "small",
23591 variant: "minimal",
23592 hideLabelFromVision: true
23593 }
23594 )
23595 ]
23596 }
23597 );
23598 }
23599 function Filter({
23600 addFilterRef,
23601 openedFilter,
23602 fields: fields2,
23603 ...commonProps
23604 }) {
23605 const toggleRef = (0, import_element62.useRef)(null);
23606 const { filter, view, onChangeView } = commonProps;
23607 const filterInView = view.filters?.find(
23608 (f2) => f2.field === filter.field
23609 );
23610 let activeElements = [];
23611 const field = (0, import_element62.useMemo)(() => {
23612 const currentField = fields2.find((f2) => f2.id === filter.field);
23613 if (currentField) {
23614 return {
23615 ...currentField,
23616 // Configure getValue as if Item was a plain object.
23617 // See related input-widget.tsx
23618 getValue: ({ item }) => item[currentField.id]
23619 };
23620 }
23621 return currentField;
23622 }, [fields2, filter.field]);
23623 const { elements } = useElements({
23624 elements: filter.elements,
23625 getElements: filter.getElements
23626 });
23627 if (elements.length > 0) {
23628 activeElements = elements.filter((element) => {
23629 if (filter.singleSelection) {
23630 return element.value === filterInView?.value;
23631 }
23632 return filterInView?.value?.includes(element.value);
23633 });
23634 } else if (Array.isArray(filterInView?.value)) {
23635 const label = filterInView.value.map((v2) => {
23636 const formattedValue = field?.getValueFormatted({
23637 item: { [field.id]: v2 },
23638 field
23639 });
23640 return formattedValue || String(v2);
23641 });
23642 activeElements = [
23643 {
23644 value: filterInView.value,
23645 // @ts-ignore
23646 label
23647 }
23648 ];
23649 } else if (typeof filterInView?.value === "object") {
23650 activeElements = [
23651 { value: filterInView.value, label: filterInView.value }
23652 ];
23653 } else if (filterInView?.value !== void 0) {
23654 const label = field !== void 0 ? field.getValueFormatted({
23655 item: { [field.id]: filterInView.value },
23656 field
23657 }) : String(filterInView.value);
23658 activeElements = [
23659 {
23660 value: filterInView.value,
23661 label
23662 }
23663 ];
23664 }
23665 const isPrimary = filter.isPrimary;
23666 const isLocked = filterInView?.isLocked;
23667 const hasValues = !isLocked && filterInView?.value !== void 0;
23668 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
23669 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
23670 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23671 import_components23.Dropdown,
23672 {
23673 defaultOpen: openedFilter === filter.field,
23674 contentClassName: "dataviews-filters__summary-popover",
23675 popoverProps: { placement: "bottom-start", role: "dialog" },
23676 onClose: () => {
23677 toggleRef.current?.focus();
23678 },
23679 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
23680 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(tooltip_exports.Root, { children: [
23681 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23682 tooltip_exports.Trigger,
23683 {
23684 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23685 "div",
23686 {
23687 className: clsx_default(
23688 "dataviews-filters__summary-chip",
23689 {
23690 "has-reset": canResetOrRemove,
23691 "has-values": hasValues,
23692 "is-not-clickable": isLocked
23693 }
23694 ),
23695 role: "button",
23696 tabIndex: isLocked ? -1 : 0,
23697 onClick: () => {
23698 if (!isLocked) {
23699 onToggle();
23700 }
23701 },
23702 onKeyDown: (event) => {
23703 if (!isLocked && [ENTER, SPACE].includes(
23704 event.key
23705 )) {
23706 onToggle();
23707 event.preventDefault();
23708 }
23709 },
23710 "aria-disabled": isLocked,
23711 "aria-pressed": isOpen,
23712 "aria-expanded": isOpen,
23713 ref: toggleRef,
23714 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23715 FilterText,
23716 {
23717 activeElements,
23718 filterInView,
23719 filter
23720 }
23721 )
23722 }
23723 )
23724 }
23725 ),
23726 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
23727 /* translators: 1: Filter name. */
23728 (0, import_i18n25.__)("Filter by: %1$s"),
23729 filter.name.toLowerCase()
23730 ) })
23731 ] }),
23732 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(tooltip_exports.Root, { children: [
23733 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23734 tooltip_exports.Trigger,
23735 {
23736 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23737 "button",
23738 {
23739 className: clsx_default(
23740 "dataviews-filters__summary-chip-remove",
23741 { "has-values": hasValues }
23742 ),
23743 "aria-label": resetOrRemoveLabel,
23744 onClick: () => {
23745 onChangeView({
23746 ...view,
23747 page: 1,
23748 filters: view.filters?.filter(
23749 (_filter) => _filter.field !== filter.field
23750 )
23751 });
23752 if (!isPrimary) {
23753 addFilterRef.current?.focus();
23754 } else {
23755 toggleRef.current?.focus();
23756 }
23757 },
23758 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components23.Icon, { icon: close_small_default })
23759 }
23760 )
23761 }
23762 ),
23763 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
23764 ] })
23765 ] }),
23766 renderContent: () => {
23767 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
23768 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(OperatorSelector, { ...commonProps }),
23769 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23770 SearchWidget,
23771 {
23772 ...commonProps,
23773 filter: {
23774 ...commonProps.filter,
23775 elements
23776 }
23777 }
23778 ) : /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(InputWidget, { ...commonProps, fields: fields2 })
23779 ] });
23780 }
23781 }
23782 );
23783 }
23784
23785 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
23786 var import_components24 = __toESM(require_components(), 1);
23787 var import_i18n26 = __toESM(require_i18n(), 1);
23788 var import_element63 = __toESM(require_element(), 1);
23789 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23790 var { Menu: Menu4 } = unlock2(import_components24.privateApis);
23791 function AddFilterMenu({
23792 filters,
23793 view,
23794 onChangeView,
23795 setOpenedFilter,
23796 triggerProps
23797 }) {
23798 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
23799 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Menu4, { children: [
23800 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Menu4.TriggerButton, { ...triggerProps }),
23801 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
23802 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23803 Menu4.Item,
23804 {
23805 onClick: () => {
23806 setOpenedFilter(filter.field);
23807 onChangeView({
23808 ...view,
23809 page: 1,
23810 filters: [
23811 ...view.filters || [],
23812 {
23813 field: filter.field,
23814 value: void 0,
23815 operator: filter.operators[0]
23816 }
23817 ]
23818 });
23819 },
23820 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Menu4.ItemLabel, { children: filter.name })
23821 },
23822 filter.field
23823 );
23824 }) })
23825 ] });
23826 }
23827 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
23828 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
23829 return null;
23830 }
23831 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
23832 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23833 AddFilterMenu,
23834 {
23835 triggerProps: {
23836 render: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23837 import_components24.Button,
23838 {
23839 accessibleWhenDisabled: true,
23840 size: "compact",
23841 className: "dataviews-filters-button",
23842 variant: "tertiary",
23843 disabled: !inactiveFilters.length,
23844 ref
23845 }
23846 ),
23847 children: (0, import_i18n26.__)("Add filter")
23848 },
23849 ...{ filters, view, onChangeView, setOpenedFilter }
23850 }
23851 );
23852 }
23853 var add_filter_default = (0, import_element63.forwardRef)(AddFilter);
23854
23855 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
23856 var import_components25 = __toESM(require_components(), 1);
23857 var import_i18n27 = __toESM(require_i18n(), 1);
23858 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23859 function ResetFilter({
23860 filters,
23861 view,
23862 onChangeView
23863 }) {
23864 const isPrimary = (field) => filters.some(
23865 (_filter) => _filter.field === field && _filter.isPrimary
23866 );
23867 const isDisabled = !view.search && !view.filters?.some(
23868 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
23869 );
23870 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23871 import_components25.Button,
23872 {
23873 disabled: isDisabled,
23874 accessibleWhenDisabled: true,
23875 size: "compact",
23876 variant: "tertiary",
23877 className: "dataviews-filters__reset-button",
23878 onClick: () => {
23879 onChangeView({
23880 ...view,
23881 page: 1,
23882 search: "",
23883 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
23884 });
23885 },
23886 children: (0, import_i18n27.__)("Reset")
23887 }
23888 );
23889 }
23890
23891 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
23892 var import_element64 = __toESM(require_element(), 1);
23893 function useFilters(fields2, view) {
23894 return (0, import_element64.useMemo)(() => {
23895 const filters = [];
23896 fields2.forEach((field) => {
23897 if (field.filterBy === false || !field.hasElements && !field.Edit) {
23898 return;
23899 }
23900 const operators = field.filterBy.operators;
23901 const isPrimary = !!field.filterBy?.isPrimary;
23902 const isLocked = view.filters?.some(
23903 (f2) => f2.field === field.id && !!f2.isLocked
23904 ) ?? false;
23905 filters.push({
23906 field: field.id,
23907 name: field.label,
23908 elements: field.elements,
23909 getElements: field.getElements,
23910 hasElements: field.hasElements,
23911 singleSelection: operators.some(
23912 (op) => isSingleSelectionOperator(op)
23913 ),
23914 operators,
23915 isVisible: isLocked || isPrimary || !!view.filters?.some(
23916 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
23917 ),
23918 isPrimary,
23919 isLocked
23920 });
23921 });
23922 filters.sort((a2, b2) => {
23923 if (a2.isLocked && !b2.isLocked) {
23924 return -1;
23925 }
23926 if (!a2.isLocked && b2.isLocked) {
23927 return 1;
23928 }
23929 if (a2.isPrimary && !b2.isPrimary) {
23930 return -1;
23931 }
23932 if (!a2.isPrimary && b2.isPrimary) {
23933 return 1;
23934 }
23935 return a2.name.localeCompare(b2.name);
23936 });
23937 return filters;
23938 }, [fields2, view]);
23939 }
23940 var use_filters_default = useFilters;
23941
23942 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
23943 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23944 function Filters({ className }) {
23945 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element65.useContext)(dataviews_context_default);
23946 const addFilterRef = (0, import_element65.useRef)(null);
23947 const filters = use_filters_default(fields2, view);
23948 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23949 add_filter_default,
23950 {
23951 filters,
23952 view,
23953 onChangeView,
23954 ref: addFilterRef,
23955 setOpenedFilter
23956 },
23957 "add-filter"
23958 );
23959 const visibleFilters = filters.filter((filter) => filter.isVisible);
23960 if (visibleFilters.length === 0) {
23961 return null;
23962 }
23963 const filterComponents = [
23964 ...visibleFilters.map((filter) => {
23965 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23966 Filter,
23967 {
23968 filter,
23969 view,
23970 fields: fields2,
23971 onChangeView,
23972 addFilterRef,
23973 openedFilter
23974 },
23975 filter.field
23976 );
23977 }),
23978 addFilter
23979 ];
23980 filterComponents.push(
23981 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23982 ResetFilter,
23983 {
23984 filters,
23985 view,
23986 onChangeView
23987 },
23988 "reset-filters"
23989 )
23990 );
23991 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23992 Stack,
23993 {
23994 direction: "row",
23995 justify: "flex-start",
23996 gap: "sm",
23997 style: { width: "fit-content" },
23998 wrap: "wrap",
23999 className,
24000 children: filterComponents
24001 }
24002 );
24003 }
24004 var filters_default = (0, import_element65.memo)(Filters);
24005
24006 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
24007 var import_element66 = __toESM(require_element(), 1);
24008 var import_components26 = __toESM(require_components(), 1);
24009 var import_i18n28 = __toESM(require_i18n(), 1);
24010 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
24011 function FiltersToggle() {
24012 const {
24013 filters,
24014 view,
24015 onChangeView,
24016 setOpenedFilter,
24017 isShowingFilter,
24018 setIsShowingFilter
24019 } = (0, import_element66.useContext)(dataviews_context_default);
24020 const buttonRef = (0, import_element66.useRef)(null);
24021 const onChangeViewWithFilterVisibility = (0, import_element66.useCallback)(
24022 (_view) => {
24023 onChangeView(_view);
24024 setIsShowingFilter(true);
24025 },
24026 [onChangeView, setIsShowingFilter]
24027 );
24028 if (filters.length === 0) {
24029 return null;
24030 }
24031 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
24032 const addFilterButtonProps = {
24033 label: (0, import_i18n28.__)("Add filter"),
24034 "aria-expanded": false,
24035 isPressed: false
24036 };
24037 const toggleFiltersButtonProps = {
24038 label: (0, import_i18n28._x)("Filter", "verb"),
24039 "aria-expanded": isShowingFilter,
24040 isPressed: isShowingFilter,
24041 onClick: () => {
24042 if (!isShowingFilter) {
24043 setOpenedFilter(null);
24044 }
24045 setIsShowingFilter(!isShowingFilter);
24046 }
24047 };
24048 const hasPrimaryOrLockedFilters = filters.some(
24049 (filter) => filter.isPrimary || filter.isLocked
24050 );
24051 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24052 import_components26.Button,
24053 {
24054 ref: buttonRef,
24055 className: "dataviews-filters__visibility-toggle",
24056 size: "compact",
24057 icon: funnel_default,
24058 disabled: hasPrimaryOrLockedFilters,
24059 accessibleWhenDisabled: true,
24060 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
24061 }
24062 );
24063 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24064 AddFilterMenu,
24065 {
24066 filters,
24067 view,
24068 onChangeView: onChangeViewWithFilterVisibility,
24069 setOpenedFilter,
24070 triggerProps: { render: buttonComponent }
24071 }
24072 ) : /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24073 FilterVisibilityToggle,
24074 {
24075 buttonRef,
24076 filtersCount: view.filters?.length,
24077 children: buttonComponent
24078 }
24079 ) });
24080 }
24081 function FilterVisibilityToggle({
24082 buttonRef,
24083 filtersCount,
24084 children
24085 }) {
24086 (0, import_element66.useEffect)(
24087 () => () => {
24088 buttonRef.current?.focus();
24089 },
24090 [buttonRef]
24091 );
24092 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_jsx_runtime96.Fragment, { children: [
24093 children,
24094 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
24095 ] });
24096 }
24097 var toggle_default = FiltersToggle;
24098
24099 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
24100 var import_element67 = __toESM(require_element(), 1);
24101 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24102 function FiltersToggled(props) {
24103 const { isShowingFilter } = (0, import_element67.useContext)(dataviews_context_default);
24104 if (!isShowingFilter) {
24105 return null;
24106 }
24107 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(filters_default, { ...props });
24108 }
24109 var filters_toggled_default = FiltersToggled;
24110
24111 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
24112 var import_element68 = __toESM(require_element(), 1);
24113 var import_components27 = __toESM(require_components(), 1);
24114 var import_i18n29 = __toESM(require_i18n(), 1);
24115 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24116 function DataViewsLayout({ className }) {
24117 const {
24118 actions = [],
24119 data,
24120 fields: fields2,
24121 getItemId,
24122 getItemLevel,
24123 hasInitiallyLoaded,
24124 isLoading,
24125 view,
24126 onChangeView,
24127 selection,
24128 onChangeSelection,
24129 setOpenedFilter,
24130 onClickItem,
24131 isItemClickable,
24132 renderItemLink,
24133 defaultLayouts,
24134 containerRef,
24135 empty = /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { children: (0, import_i18n29.__)("No results") })
24136 } = (0, import_element68.useContext)(dataviews_context_default);
24137 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
24138 delay: 200
24139 });
24140 if (!hasInitiallyLoaded) {
24141 if (!isDelayedInitialLoading) {
24142 return null;
24143 }
24144 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components27.Spinner, {}) }) });
24145 }
24146 const ViewComponent = VIEW_LAYOUTS.find(
24147 (v2) => v2.type === view.type && defaultLayouts[v2.type]
24148 )?.component;
24149 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
24150 ViewComponent,
24151 {
24152 className,
24153 actions,
24154 data,
24155 fields: fields2,
24156 getItemId,
24157 getItemLevel,
24158 isLoading,
24159 onChangeView,
24160 onChangeSelection,
24161 selection,
24162 setOpenedFilter,
24163 onClickItem,
24164 renderItemLink,
24165 isItemClickable,
24166 view,
24167 empty
24168 }
24169 ) });
24170 }
24171
24172 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
24173 var import_element69 = __toESM(require_element(), 1);
24174 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24175 var EMPTY_ARRAY5 = [];
24176 function DataViewsFooter() {
24177 const {
24178 view,
24179 paginationInfo: { totalItems = 0, totalPages },
24180 data,
24181 actions = EMPTY_ARRAY5,
24182 isLoading,
24183 hasInitiallyLoaded
24184 } = (0, import_element69.useContext)(dataviews_context_default);
24185 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
24186 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
24187 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
24188 const hasPagination = hasPaginationControls(view, {
24189 totalItems,
24190 totalPages
24191 });
24192 if (!totalItems || !hasBulkActions && !hasPagination) {
24193 return null;
24194 }
24195 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24196 "div",
24197 {
24198 className: "dataviews-footer",
24199 inert: isRefreshing ? "true" : void 0,
24200 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
24201 Stack,
24202 {
24203 direction: "row",
24204 justify: "end",
24205 align: "center",
24206 className: clsx_default("dataviews-footer__content", {
24207 "is-refreshing": isDelayedRefreshing
24208 }),
24209 gap: "sm",
24210 children: [
24211 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(BulkActionsFooter, {}),
24212 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(dataviews_pagination_default, {})
24213 ]
24214 }
24215 )
24216 }
24217 );
24218 }
24219
24220 // packages/dataviews/build-module/components/dataviews-search/index.mjs
24221 var import_i18n30 = __toESM(require_i18n(), 1);
24222 var import_element70 = __toESM(require_element(), 1);
24223 var import_components28 = __toESM(require_components(), 1);
24224 var import_compose10 = __toESM(require_compose(), 1);
24225 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24226 var DataViewsSearch = (0, import_element70.memo)(function Search({ label }) {
24227 const { view, onChangeView } = (0, import_element70.useContext)(dataviews_context_default);
24228 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
24229 view.search
24230 );
24231 (0, import_element70.useEffect)(() => {
24232 if (view.search !== debouncedSearch) {
24233 setSearch(view.search ?? "");
24234 }
24235 }, [view.search, setSearch]);
24236 const onChangeViewRef = (0, import_element70.useRef)(onChangeView);
24237 const viewRef = (0, import_element70.useRef)(view);
24238 (0, import_element70.useEffect)(() => {
24239 onChangeViewRef.current = onChangeView;
24240 viewRef.current = view;
24241 }, [onChangeView, view]);
24242 (0, import_element70.useEffect)(() => {
24243 if (debouncedSearch !== viewRef.current?.search) {
24244 onChangeViewRef.current({
24245 ...viewRef.current,
24246 page: view.page ? 1 : void 0,
24247 startPosition: view.startPosition ? 1 : void 0,
24248 search: debouncedSearch
24249 });
24250 }
24251 }, [debouncedSearch]);
24252 const searchLabel = label || (0, import_i18n30.__)("Search");
24253 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24254 import_components28.SearchControl,
24255 {
24256 className: "dataviews-search",
24257 onChange: setSearch,
24258 value: search,
24259 label: searchLabel,
24260 placeholder: searchLabel,
24261 size: "compact"
24262 }
24263 );
24264 });
24265 var dataviews_search_default = DataViewsSearch;
24266
24267 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
24268 var import_components29 = __toESM(require_components(), 1);
24269 var import_i18n31 = __toESM(require_i18n(), 1);
24270 var import_element71 = __toESM(require_element(), 1);
24271 var import_warning = __toESM(require_warning(), 1);
24272 var import_compose11 = __toESM(require_compose(), 1);
24273 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24274 var { Menu: Menu5 } = unlock2(import_components29.privateApis);
24275 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
24276 className: "dataviews-config__popover",
24277 placement: "bottom-end",
24278 offset: 9
24279 };
24280 function ViewTypeMenu() {
24281 const { view, onChangeView, defaultLayouts } = (0, import_element71.useContext)(dataviews_context_default);
24282 const availableLayouts = Object.keys(defaultLayouts);
24283 if (availableLayouts.length <= 1) {
24284 return null;
24285 }
24286 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
24287 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Menu5, { children: [
24288 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24289 Menu5.TriggerButton,
24290 {
24291 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24292 import_components29.Button,
24293 {
24294 size: "compact",
24295 icon: activeView?.icon,
24296 label: (0, import_i18n31.__)("Layout")
24297 }
24298 )
24299 }
24300 ),
24301 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
24302 const config = VIEW_LAYOUTS.find(
24303 (v2) => v2.type === layout
24304 );
24305 if (!config) {
24306 return null;
24307 }
24308 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24309 Menu5.RadioItem,
24310 {
24311 value: layout,
24312 name: "view-actions-available-view",
24313 checked: layout === view.type,
24314 hideOnClick: true,
24315 onChange: (e2) => {
24316 switch (e2.target.value) {
24317 case "list":
24318 case "grid":
24319 case "table":
24320 case "pickerGrid":
24321 case "pickerTable":
24322 case "pickerActivity":
24323 case "activity":
24324 const viewWithoutLayout = { ...view };
24325 if ("layout" in viewWithoutLayout) {
24326 delete viewWithoutLayout.layout;
24327 }
24328 return onChangeView({
24329 ...viewWithoutLayout,
24330 type: e2.target.value,
24331 ...defaultLayouts[e2.target.value]
24332 });
24333 }
24334 (0, import_warning.default)("Invalid dataview");
24335 },
24336 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu5.ItemLabel, { children: config.label })
24337 },
24338 layout
24339 );
24340 }) })
24341 ] });
24342 }
24343 function SortFieldControl() {
24344 const { view, fields: fields2, onChangeView } = (0, import_element71.useContext)(dataviews_context_default);
24345 const orderOptions = (0, import_element71.useMemo)(() => {
24346 const sortableFields = fields2.filter(
24347 (field) => field.enableSorting !== false
24348 );
24349 return sortableFields.map((field) => {
24350 return {
24351 label: field.label,
24352 value: field.id
24353 };
24354 });
24355 }, [fields2]);
24356 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24357 import_components29.SelectControl,
24358 {
24359 label: (0, import_i18n31.__)("Sort by"),
24360 value: view.sort?.field,
24361 options: orderOptions,
24362 onChange: (value) => {
24363 onChangeView({
24364 ...view,
24365 sort: {
24366 direction: view?.sort?.direction || "desc",
24367 field: value
24368 },
24369 showLevels: false
24370 });
24371 }
24372 }
24373 );
24374 }
24375 function SortDirectionControl() {
24376 const { view, fields: fields2, onChangeView } = (0, import_element71.useContext)(dataviews_context_default);
24377 const sortableFields = fields2.filter(
24378 (field) => field.enableSorting !== false
24379 );
24380 if (sortableFields.length === 0) {
24381 return null;
24382 }
24383 let value = view.sort?.direction;
24384 if (!value && view.sort?.field) {
24385 value = "desc";
24386 }
24387 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24388 import_components29.__experimentalToggleGroupControl,
24389 {
24390 className: "dataviews-view-config__sort-direction",
24391 isBlock: true,
24392 label: (0, import_i18n31.__)("Order"),
24393 value,
24394 onChange: (newDirection) => {
24395 if (newDirection === "asc" || newDirection === "desc") {
24396 onChangeView({
24397 ...view,
24398 sort: {
24399 direction: newDirection,
24400 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
24401 fields2.find(
24402 (field) => field.enableSorting !== false
24403 )?.id || ""
24404 },
24405 showLevels: false
24406 });
24407 return;
24408 }
24409 (0, import_warning.default)("Invalid direction");
24410 },
24411 children: SORTING_DIRECTIONS.map((direction) => {
24412 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24413 import_components29.__experimentalToggleGroupControlOptionIcon,
24414 {
24415 value: direction,
24416 icon: sortIcons[direction],
24417 label: sortLabels[direction]
24418 },
24419 direction
24420 );
24421 })
24422 }
24423 );
24424 }
24425 function ItemsPerPageControl() {
24426 const { view, config, onChangeView } = (0, import_element71.useContext)(dataviews_context_default);
24427 const { infiniteScrollEnabled } = view;
24428 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
24429 return null;
24430 }
24431 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24432 import_components29.__experimentalToggleGroupControl,
24433 {
24434 isBlock: true,
24435 label: (0, import_i18n31.__)("Items per page"),
24436 value: view.perPage || 10,
24437 disabled: !view?.sort?.field,
24438 onChange: (newItemsPerPage) => {
24439 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
24440 onChangeView({
24441 ...view,
24442 perPage: newItemsPerPageNumber,
24443 page: 1
24444 });
24445 },
24446 children: config.perPageSizes.map((value) => {
24447 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24448 import_components29.__experimentalToggleGroupControlOption,
24449 {
24450 value,
24451 label: value.toString()
24452 },
24453 value
24454 );
24455 })
24456 }
24457 );
24458 }
24459 function ResetViewButton() {
24460 const { onReset } = (0, import_element71.useContext)(dataviews_context_default);
24461 if (onReset === void 0) {
24462 return null;
24463 }
24464 const isDisabled = onReset === false;
24465 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24466 import_components29.Button,
24467 {
24468 variant: "tertiary",
24469 size: "compact",
24470 disabled: isDisabled,
24471 accessibleWhenDisabled: true,
24472 className: "dataviews-view-config__reset-button",
24473 onClick: () => {
24474 if (typeof onReset === "function") {
24475 onReset();
24476 }
24477 },
24478 children: (0, import_i18n31.__)("Reset view")
24479 }
24480 );
24481 }
24482 function DataviewsViewConfigDropdown() {
24483 const { view, onReset } = (0, import_element71.useContext)(dataviews_context_default);
24484 const popoverId = (0, import_compose11.useInstanceId)(
24485 _DataViewsViewConfig,
24486 "dataviews-view-config-dropdown"
24487 );
24488 const activeLayout = VIEW_LAYOUTS.find(
24489 (layout) => layout.type === view.type
24490 );
24491 const isModified = typeof onReset === "function";
24492 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24493 import_components29.Dropdown,
24494 {
24495 expandOnMobile: true,
24496 popoverProps: {
24497 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
24498 id: popoverId
24499 },
24500 renderToggle: ({ onToggle, isOpen }) => {
24501 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
24502 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24503 import_components29.Button,
24504 {
24505 size: "compact",
24506 icon: cog_default,
24507 label: (0, import_i18n31._x)(
24508 "View options",
24509 "View is used as a noun"
24510 ),
24511 onClick: onToggle,
24512 "aria-expanded": isOpen ? "true" : "false",
24513 "aria-controls": popoverId
24514 }
24515 ),
24516 isModified && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
24517 ] });
24518 },
24519 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24520 import_components29.__experimentalDropdownContentWrapper,
24521 {
24522 paddingSize: "medium",
24523 className: "dataviews-config__popover-content-wrapper",
24524 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
24525 Stack,
24526 {
24527 direction: "column",
24528 className: "dataviews-view-config",
24529 gap: "xl",
24530 children: [
24531 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
24532 Stack,
24533 {
24534 direction: "row",
24535 justify: "space-between",
24536 align: "center",
24537 className: "dataviews-view-config__header",
24538 children: [
24539 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24540 import_components29.__experimentalHeading,
24541 {
24542 level: 2,
24543 className: "dataviews-settings-section__title",
24544 children: (0, import_i18n31.__)("Appearance")
24545 }
24546 ),
24547 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ResetViewButton, {})
24548 ]
24549 }
24550 ),
24551 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Stack, { direction: "column", gap: "lg", children: [
24552 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
24553 Stack,
24554 {
24555 direction: "row",
24556 gap: "sm",
24557 className: "dataviews-view-config__sort-controls",
24558 children: [
24559 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(SortFieldControl, {}),
24560 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(SortDirectionControl, {})
24561 ]
24562 }
24563 ),
24564 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(activeLayout.viewConfigOptions, {}),
24565 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ItemsPerPageControl, {}),
24566 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(PropertiesSection, {})
24567 ] })
24568 ]
24569 }
24570 )
24571 }
24572 )
24573 }
24574 );
24575 }
24576 function _DataViewsViewConfig() {
24577 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
24578 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ViewTypeMenu, {}),
24579 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(DataviewsViewConfigDropdown, {})
24580 ] });
24581 }
24582 var DataViewsViewConfig = (0, import_element71.memo)(_DataViewsViewConfig);
24583 var dataviews_view_config_default = DataViewsViewConfig;
24584
24585 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
24586 var import_components30 = __toESM(require_components(), 1);
24587 var import_element72 = __toESM(require_element(), 1);
24588
24589 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
24590 function getCustomValidity(isValid2, validity) {
24591 let customValidity;
24592 if (isValid2?.required && validity?.required) {
24593 customValidity = validity?.required?.message ? validity.required : void 0;
24594 } else if (isValid2?.pattern && validity?.pattern) {
24595 customValidity = validity.pattern;
24596 } else if (isValid2?.min && validity?.min) {
24597 customValidity = validity.min;
24598 } else if (isValid2?.max && validity?.max) {
24599 customValidity = validity.max;
24600 } else if (isValid2?.minLength && validity?.minLength) {
24601 customValidity = validity.minLength;
24602 } else if (isValid2?.maxLength && validity?.maxLength) {
24603 customValidity = validity.maxLength;
24604 } else if (isValid2?.elements && validity?.elements) {
24605 customValidity = validity.elements;
24606 } else if (validity?.custom) {
24607 customValidity = validity.custom;
24608 }
24609 return customValidity;
24610 }
24611
24612 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
24613 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24614 var { ValidatedCheckboxControl } = unlock2(import_components30.privateApis);
24615 function Checkbox({
24616 field,
24617 onChange,
24618 data,
24619 hideLabelFromVision,
24620 markWhenOptional,
24621 validity
24622 }) {
24623 const { getValue, setValue, label, description, isValid: isValid2 } = field;
24624 const disabled2 = field.isDisabled({ item: data, field });
24625 const onChangeControl = (0, import_element72.useCallback)(() => {
24626 onChange(
24627 setValue({ item: data, value: !getValue({ item: data }) })
24628 );
24629 }, [data, getValue, onChange, setValue]);
24630 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24631 ValidatedCheckboxControl,
24632 {
24633 required: !!field.isValid?.required,
24634 markWhenOptional,
24635 customValidity: getCustomValidity(isValid2, validity),
24636 hidden: hideLabelFromVision,
24637 label,
24638 help: description,
24639 checked: getValue({ item: data }),
24640 onChange: onChangeControl,
24641 disabled: disabled2
24642 }
24643 );
24644 }
24645
24646 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
24647 var import_components31 = __toESM(require_components(), 1);
24648 var import_element73 = __toESM(require_element(), 1);
24649 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24650 var { ValidatedComboboxControl } = unlock2(import_components31.privateApis);
24651 function Combobox3({
24652 data,
24653 field,
24654 onChange,
24655 hideLabelFromVision,
24656 validity
24657 }) {
24658 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
24659 const value = getValue({ item: data }) ?? "";
24660 const onChangeControl = (0, import_element73.useCallback)(
24661 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
24662 [data, onChange, setValue]
24663 );
24664 const { elements, isLoading } = useElements({
24665 elements: field.elements,
24666 getElements: field.getElements
24667 });
24668 if (isLoading) {
24669 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components31.Spinner, {});
24670 }
24671 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24672 ValidatedComboboxControl,
24673 {
24674 required: !!field.isValid?.required,
24675 customValidity: getCustomValidity(isValid2, validity),
24676 label,
24677 value,
24678 help: description,
24679 placeholder,
24680 options: elements,
24681 onChange: onChangeControl,
24682 hideLabelFromVision,
24683 allowReset: true,
24684 expandOnFocus: true
24685 }
24686 );
24687 }
24688
24689 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
24690 var import_components33 = __toESM(require_components(), 1);
24691 var import_element76 = __toESM(require_element(), 1);
24692 var import_i18n33 = __toESM(require_i18n(), 1);
24693 var import_date3 = __toESM(require_date(), 1);
24694
24695 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
24696 var import_components32 = __toESM(require_components(), 1);
24697 var import_element74 = __toESM(require_element(), 1);
24698 var import_i18n32 = __toESM(require_i18n(), 1);
24699 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24700 var TIME_UNITS_OPTIONS = {
24701 [OPERATOR_IN_THE_PAST]: [
24702 { value: "days", label: (0, import_i18n32.__)("Days") },
24703 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
24704 { value: "months", label: (0, import_i18n32.__)("Months") },
24705 { value: "years", label: (0, import_i18n32.__)("Years") }
24706 ],
24707 [OPERATOR_OVER]: [
24708 { value: "days", label: (0, import_i18n32.__)("Days ago") },
24709 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
24710 { value: "months", label: (0, import_i18n32.__)("Months ago") },
24711 { value: "years", label: (0, import_i18n32.__)("Years ago") }
24712 ]
24713 };
24714 function RelativeDateControl({
24715 className,
24716 data,
24717 field,
24718 onChange,
24719 hideLabelFromVision,
24720 operator
24721 }) {
24722 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
24723 const { id, label, description, getValue, setValue } = field;
24724 const disabled2 = field.isDisabled({ item: data, field });
24725 const fieldValue = getValue({ item: data });
24726 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
24727 const onChangeValue = (0, import_element74.useCallback)(
24728 (newValue) => onChange(
24729 setValue({
24730 item: data,
24731 value: { value: Number(newValue), unit }
24732 })
24733 ),
24734 [onChange, setValue, data, unit]
24735 );
24736 const onChangeUnit = (0, import_element74.useCallback)(
24737 (newUnit) => onChange(
24738 setValue({
24739 item: data,
24740 value: { value: relValue, unit: newUnit }
24741 })
24742 ),
24743 [onChange, setValue, data, relValue]
24744 );
24745 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24746 import_components32.BaseControl,
24747 {
24748 id,
24749 className: clsx_default(className, "dataviews-controls__relative-date"),
24750 label,
24751 hideLabelFromVision,
24752 help: description,
24753 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(Stack, { direction: "row", gap: "sm", children: [
24754 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24755 import_components32.__experimentalNumberControl,
24756 {
24757 className: "dataviews-controls__relative-date-number",
24758 spinControls: "none",
24759 min: 1,
24760 step: 1,
24761 value: relValue,
24762 onChange: onChangeValue,
24763 disabled: disabled2
24764 }
24765 ),
24766 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24767 import_components32.SelectControl,
24768 {
24769 className: "dataviews-controls__relative-date-unit",
24770 label: (0, import_i18n32.__)("Unit"),
24771 value: unit,
24772 options,
24773 onChange: onChangeUnit,
24774 hideLabelFromVision: true,
24775 disabled: disabled2
24776 }
24777 )
24778 ] })
24779 }
24780 );
24781 }
24782
24783 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
24784 var import_element75 = __toESM(require_element(), 1);
24785 function useDisabledDateMatchers(isValid2, parseDateFn) {
24786 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
24787 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
24788 const disabledMatchers = (0, import_element75.useMemo)(() => {
24789 const matchers = [];
24790 if (minConstraint) {
24791 const minDate = parseDateFn(minConstraint);
24792 if (minDate) {
24793 matchers.push({ before: minDate });
24794 }
24795 }
24796 if (maxConstraint) {
24797 const maxDate = parseDateFn(maxConstraint);
24798 if (maxDate) {
24799 matchers.push({ after: maxDate });
24800 }
24801 }
24802 return matchers.length > 0 ? matchers : void 0;
24803 }, [minConstraint, maxConstraint, parseDateFn]);
24804 return { minConstraint, maxConstraint, disabledMatchers };
24805 }
24806
24807 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
24808 var import_date2 = __toESM(require_date(), 1);
24809 function parseDateTime(dateTimeString) {
24810 if (!dateTimeString) {
24811 return null;
24812 }
24813 const parsed = (0, import_date2.getDate)(dateTimeString);
24814 return parsed && isValid(parsed) ? parsed : null;
24815 }
24816
24817 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
24818 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24819 var { DateCalendar, ValidatedInputControl } = unlock2(import_components33.privateApis);
24820 var formatDateTime = (value) => {
24821 if (!value) {
24822 return "";
24823 }
24824 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
24825 };
24826 function CalendarDateTimeControl({
24827 data,
24828 field,
24829 onChange,
24830 hideLabelFromVision,
24831 markWhenOptional,
24832 validity,
24833 config
24834 }) {
24835 const { compact } = config || {};
24836 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
24837 const disabled2 = field.isDisabled({ item: data, field });
24838 const fieldValue = getValue({ item: data });
24839 const value = typeof fieldValue === "string" ? fieldValue : void 0;
24840 const [calendarMonth, setCalendarMonth] = (0, import_element76.useState)(() => {
24841 const parsedDate = parseDateTime(value);
24842 return parsedDate || /* @__PURE__ */ new Date();
24843 });
24844 const inputControlRef = (0, import_element76.useRef)(null);
24845 const validationTimeoutRef = (0, import_element76.useRef)(void 0);
24846 const previousFocusRef = (0, import_element76.useRef)(null);
24847 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
24848 const onChangeCallback = (0, import_element76.useCallback)(
24849 (newValue) => onChange(setValue({ item: data, value: newValue })),
24850 [data, onChange, setValue]
24851 );
24852 (0, import_element76.useEffect)(() => {
24853 return () => {
24854 if (validationTimeoutRef.current) {
24855 clearTimeout(validationTimeoutRef.current);
24856 }
24857 };
24858 }, []);
24859 const onSelectDate = (0, import_element76.useCallback)(
24860 (newDate) => {
24861 let dateTimeValue;
24862 if (newDate) {
24863 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
24864 let wpTime;
24865 if (value) {
24866 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
24867 } else {
24868 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
24869 }
24870 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
24871 dateTimeValue = finalDateTime.toISOString();
24872 onChangeCallback(dateTimeValue);
24873 if (validationTimeoutRef.current) {
24874 clearTimeout(validationTimeoutRef.current);
24875 }
24876 } else {
24877 onChangeCallback(void 0);
24878 }
24879 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
24880 validationTimeoutRef.current = setTimeout(() => {
24881 if (inputControlRef.current) {
24882 inputControlRef.current.focus();
24883 inputControlRef.current.blur();
24884 onChangeCallback(dateTimeValue);
24885 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
24886 previousFocusRef.current.focus();
24887 }
24888 }
24889 }, 0);
24890 },
24891 [onChangeCallback, value]
24892 );
24893 const handleManualDateTimeChange = (0, import_element76.useCallback)(
24894 (newValue) => {
24895 if (newValue) {
24896 const dateTime = (0, import_date3.getDate)(newValue);
24897 onChangeCallback(dateTime.toISOString());
24898 const parsedDate = parseDateTime(dateTime.toISOString());
24899 if (parsedDate) {
24900 setCalendarMonth(parsedDate);
24901 }
24902 } else {
24903 onChangeCallback(void 0);
24904 }
24905 },
24906 [onChangeCallback]
24907 );
24908 const { format: fieldFormat } = field;
24909 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
24910 const {
24911 timezone: { string: timezoneString }
24912 } = (0, import_date3.getSettings)();
24913 let displayLabel = label;
24914 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
24915 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
24916 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
24917 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
24918 }
24919 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24920 import_components33.BaseControl,
24921 {
24922 id,
24923 label: displayLabel,
24924 help: description,
24925 hideLabelFromVision,
24926 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "column", gap: "lg", children: [
24927 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24928 ValidatedInputControl,
24929 {
24930 ref: inputControlRef,
24931 required: !!isValid2?.required,
24932 customValidity: getCustomValidity(isValid2, validity),
24933 type: "datetime-local",
24934 label: (0, import_i18n33.__)("Date time"),
24935 hideLabelFromVision: true,
24936 value: formatDateTime(value),
24937 onChange: handleManualDateTimeChange,
24938 disabled: disabled2,
24939 min: minConstraint ? formatDateTime(minConstraint) : void 0,
24940 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
24941 }
24942 ),
24943 !compact && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24944 DateCalendar,
24945 {
24946 style: { width: "100%" },
24947 selected: value ? parseDateTime(value) || void 0 : void 0,
24948 onSelect: onSelectDate,
24949 month: calendarMonth,
24950 onMonthChange: setCalendarMonth,
24951 timeZone: timezoneString || void 0,
24952 weekStartsOn,
24953 disabled: disabled2 || disabledMatchers
24954 }
24955 )
24956 ] })
24957 }
24958 );
24959 }
24960 function DateTime({
24961 data,
24962 field,
24963 onChange,
24964 hideLabelFromVision,
24965 markWhenOptional,
24966 operator,
24967 validity,
24968 config
24969 }) {
24970 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
24971 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24972 RelativeDateControl,
24973 {
24974 className: "dataviews-controls__datetime",
24975 data,
24976 field,
24977 onChange,
24978 hideLabelFromVision,
24979 operator
24980 }
24981 );
24982 }
24983 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24984 CalendarDateTimeControl,
24985 {
24986 data,
24987 field,
24988 onChange,
24989 hideLabelFromVision,
24990 markWhenOptional,
24991 validity,
24992 config
24993 }
24994 );
24995 }
24996
24997 // packages/dataviews/build-module/components/dataform-controls/date.mjs
24998 var import_components34 = __toESM(require_components(), 1);
24999 var import_element77 = __toESM(require_element(), 1);
25000 var import_i18n34 = __toESM(require_i18n(), 1);
25001 var import_date4 = __toESM(require_date(), 1);
25002 import { speak } from "@wordpress/a11y";
25003 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
25004 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components34.privateApis);
25005 var DATE_PRESETS = [
25006 {
25007 id: "today",
25008 label: (0, import_i18n34.__)("Today"),
25009 getValue: () => (0, import_date4.getDate)(null)
25010 },
25011 {
25012 id: "yesterday",
25013 label: (0, import_i18n34.__)("Yesterday"),
25014 getValue: () => {
25015 const today = (0, import_date4.getDate)(null);
25016 return subDays(today, 1);
25017 }
25018 },
25019 {
25020 id: "past-week",
25021 label: (0, import_i18n34.__)("Past week"),
25022 getValue: () => {
25023 const today = (0, import_date4.getDate)(null);
25024 return subDays(today, 7);
25025 }
25026 },
25027 {
25028 id: "past-month",
25029 label: (0, import_i18n34.__)("Past month"),
25030 getValue: () => {
25031 const today = (0, import_date4.getDate)(null);
25032 return subMonths(today, 1);
25033 }
25034 }
25035 ];
25036 var DATE_RANGE_PRESETS = [
25037 {
25038 id: "last-7-days",
25039 label: (0, import_i18n34.__)("Last 7 days"),
25040 getValue: () => {
25041 const today = (0, import_date4.getDate)(null);
25042 return [subDays(today, 7), today];
25043 }
25044 },
25045 {
25046 id: "last-30-days",
25047 label: (0, import_i18n34.__)("Last 30 days"),
25048 getValue: () => {
25049 const today = (0, import_date4.getDate)(null);
25050 return [subDays(today, 30), today];
25051 }
25052 },
25053 {
25054 id: "month-to-date",
25055 label: (0, import_i18n34.__)("Month to date"),
25056 getValue: () => {
25057 const today = (0, import_date4.getDate)(null);
25058 return [startOfMonth(today), today];
25059 }
25060 },
25061 {
25062 id: "last-year",
25063 label: (0, import_i18n34.__)("Last year"),
25064 getValue: () => {
25065 const today = (0, import_date4.getDate)(null);
25066 return [subYears(today, 1), today];
25067 }
25068 },
25069 {
25070 id: "year-to-date",
25071 label: (0, import_i18n34.__)("Year to date"),
25072 getValue: () => {
25073 const today = (0, import_date4.getDate)(null);
25074 return [startOfYear(today), today];
25075 }
25076 }
25077 ];
25078 var parseDate = (dateString) => {
25079 if (!dateString) {
25080 return null;
25081 }
25082 const parsed = (0, import_date4.getDate)(dateString);
25083 return parsed && isValid(parsed) ? parsed : null;
25084 };
25085 var formatDate = (date) => {
25086 if (!date) {
25087 return "";
25088 }
25089 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
25090 };
25091 function ValidatedDateControl({
25092 field,
25093 validity,
25094 inputRefs,
25095 isTouched,
25096 setIsTouched,
25097 children
25098 }) {
25099 const { isValid: isValid2 } = field;
25100 const [customValidity, setCustomValidity] = (0, import_element77.useState)(void 0);
25101 const validateRefs = (0, import_element77.useCallback)(() => {
25102 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25103 for (const ref of refs) {
25104 const input = ref.current;
25105 if (input && !input.validity.valid) {
25106 setCustomValidity({
25107 type: "invalid",
25108 message: input.validationMessage
25109 });
25110 return;
25111 }
25112 }
25113 setCustomValidity(void 0);
25114 }, [inputRefs]);
25115 (0, import_element77.useEffect)(() => {
25116 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25117 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25118 for (const ref of refs) {
25119 const input = ref.current;
25120 if (input) {
25121 input.setCustomValidity(
25122 result?.type === "invalid" && result.message ? result.message : ""
25123 );
25124 }
25125 }
25126 }, [inputRefs, isValid2, validity]);
25127 (0, import_element77.useEffect)(() => {
25128 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25129 const handleInvalid = (event) => {
25130 event.preventDefault();
25131 setIsTouched(true);
25132 };
25133 for (const ref of refs) {
25134 ref.current?.addEventListener("invalid", handleInvalid);
25135 }
25136 return () => {
25137 for (const ref of refs) {
25138 ref.current?.removeEventListener("invalid", handleInvalid);
25139 }
25140 };
25141 }, [inputRefs, setIsTouched]);
25142 (0, import_element77.useEffect)(() => {
25143 if (!isTouched) {
25144 return;
25145 }
25146 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25147 if (result) {
25148 setCustomValidity(result);
25149 } else {
25150 validateRefs();
25151 }
25152 }, [isTouched, isValid2, validity, validateRefs]);
25153 (0, import_element77.useEffect)(() => {
25154 if (isTouched && customValidity?.message) {
25155 speak(customValidity.message);
25156 }
25157 }, [isTouched, customValidity?.message]);
25158 const onBlur = (event) => {
25159 if (isTouched) {
25160 return;
25161 }
25162 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
25163 setIsTouched(true);
25164 }
25165 };
25166 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { onBlur, children: [
25167 children,
25168 customValidity && /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
25169 "p",
25170 {
25171 className: clsx_default(
25172 "components-validated-control__indicator",
25173 customValidity.type === "invalid" ? "is-invalid" : void 0
25174 ),
25175 children: [
25176 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25177 import_components34.Icon,
25178 {
25179 className: "components-validated-control__indicator-icon",
25180 icon: error_default,
25181 size: 16,
25182 fill: "currentColor"
25183 }
25184 ),
25185 customValidity.message
25186 ]
25187 }
25188 )
25189 ] });
25190 }
25191 function CalendarDateControl({
25192 data,
25193 field,
25194 onChange,
25195 hideLabelFromVision,
25196 markWhenOptional,
25197 validity
25198 }) {
25199 const {
25200 id,
25201 label,
25202 description,
25203 setValue,
25204 getValue,
25205 isValid: isValid2,
25206 format: fieldFormat
25207 } = field;
25208 const disabled2 = field.isDisabled({ item: data, field });
25209 const [selectedPresetId, setSelectedPresetId] = (0, import_element77.useState)(
25210 null
25211 );
25212 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
25213 const fieldValue = getValue({ item: data });
25214 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25215 const [calendarMonth, setCalendarMonth] = (0, import_element77.useState)(() => {
25216 const parsedDate = parseDate(value);
25217 return parsedDate || /* @__PURE__ */ new Date();
25218 });
25219 const [isTouched, setIsTouched] = (0, import_element77.useState)(false);
25220 const validityTargetRef = (0, import_element77.useRef)(null);
25221 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
25222 const onChangeCallback = (0, import_element77.useCallback)(
25223 (newValue) => onChange(setValue({ item: data, value: newValue })),
25224 [data, onChange, setValue]
25225 );
25226 const onSelectDate = (0, import_element77.useCallback)(
25227 (newDate) => {
25228 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
25229 onChangeCallback(dateValue);
25230 setSelectedPresetId(null);
25231 setIsTouched(true);
25232 },
25233 [onChangeCallback]
25234 );
25235 const handlePresetClick = (0, import_element77.useCallback)(
25236 (preset) => {
25237 const presetDate = preset.getValue();
25238 const dateValue = formatDate(presetDate);
25239 setCalendarMonth(presetDate);
25240 onChangeCallback(dateValue);
25241 setSelectedPresetId(preset.id);
25242 setIsTouched(true);
25243 },
25244 [onChangeCallback]
25245 );
25246 const handleManualDateChange = (0, import_element77.useCallback)(
25247 (newValue) => {
25248 onChangeCallback(newValue);
25249 if (newValue) {
25250 const parsedDate = parseDate(newValue);
25251 if (parsedDate) {
25252 setCalendarMonth(parsedDate);
25253 }
25254 }
25255 setSelectedPresetId(null);
25256 setIsTouched(true);
25257 },
25258 [onChangeCallback]
25259 );
25260 const {
25261 timezone: { string: timezoneString }
25262 } = (0, import_date4.getSettings)();
25263 let displayLabel = label;
25264 if (isValid2?.required && !markWhenOptional) {
25265 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
25266 } else if (!isValid2?.required && markWhenOptional) {
25267 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
25268 }
25269 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25270 ValidatedDateControl,
25271 {
25272 field,
25273 validity,
25274 inputRefs: validityTargetRef,
25275 isTouched,
25276 setIsTouched,
25277 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25278 import_components34.BaseControl,
25279 {
25280 id,
25281 className: "dataviews-controls__date",
25282 label: displayLabel,
25283 help: description,
25284 hideLabelFromVision,
25285 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25286 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
25287 Stack,
25288 {
25289 direction: "row",
25290 gap: "sm",
25291 wrap: "wrap",
25292 justify: "flex-start",
25293 children: [
25294 DATE_PRESETS.map((preset) => {
25295 const isSelected2 = selectedPresetId === preset.id;
25296 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25297 import_components34.Button,
25298 {
25299 className: "dataviews-controls__date-preset",
25300 variant: "tertiary",
25301 isPressed: isSelected2,
25302 size: "small",
25303 disabled: disabled2,
25304 accessibleWhenDisabled: true,
25305 onClick: () => handlePresetClick(preset),
25306 children: preset.label
25307 },
25308 preset.id
25309 );
25310 }),
25311 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25312 import_components34.Button,
25313 {
25314 className: "dataviews-controls__date-preset",
25315 variant: "tertiary",
25316 isPressed: !selectedPresetId,
25317 size: "small",
25318 disabled: !!selectedPresetId || disabled2,
25319 accessibleWhenDisabled: true,
25320 children: (0, import_i18n34.__)("Custom")
25321 }
25322 )
25323 ]
25324 }
25325 ),
25326 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25327 import_components34.__experimentalInputControl,
25328 {
25329 ref: validityTargetRef,
25330 type: "date",
25331 label: (0, import_i18n34.__)("Date"),
25332 hideLabelFromVision: true,
25333 value,
25334 onChange: handleManualDateChange,
25335 required: !!field.isValid?.required,
25336 disabled: disabled2,
25337 min: minConstraint,
25338 max: maxConstraint
25339 }
25340 ),
25341 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25342 DateCalendar2,
25343 {
25344 style: { width: "100%" },
25345 selected: value ? parseDate(value) || void 0 : void 0,
25346 onSelect: onSelectDate,
25347 month: calendarMonth,
25348 onMonthChange: setCalendarMonth,
25349 timeZone: timezoneString || void 0,
25350 weekStartsOn,
25351 disabled: disabled2 || disabledMatchers,
25352 disableNavigation: disabled2
25353 }
25354 )
25355 ] })
25356 }
25357 )
25358 }
25359 );
25360 }
25361 function CalendarDateRangeControl({
25362 data,
25363 field,
25364 onChange,
25365 hideLabelFromVision,
25366 markWhenOptional,
25367 validity
25368 }) {
25369 const {
25370 id,
25371 label,
25372 description,
25373 getValue,
25374 setValue,
25375 isValid: isValid2,
25376 format: fieldFormat
25377 } = field;
25378 const disabled2 = field.isDisabled({ item: data, field });
25379 let value;
25380 const fieldValue = getValue({ item: data });
25381 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
25382 value = fieldValue;
25383 }
25384 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
25385 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
25386 const onChangeCallback = (0, import_element77.useCallback)(
25387 (newValue) => {
25388 onChange(
25389 setValue({
25390 item: data,
25391 value: newValue
25392 })
25393 );
25394 },
25395 [data, onChange, setValue]
25396 );
25397 const [selectedPresetId, setSelectedPresetId] = (0, import_element77.useState)(
25398 null
25399 );
25400 const selectedRange = (0, import_element77.useMemo)(() => {
25401 if (!value) {
25402 return { from: void 0, to: void 0 };
25403 }
25404 const [from, to] = value;
25405 return {
25406 from: parseDate(from) || void 0,
25407 to: parseDate(to) || void 0
25408 };
25409 }, [value]);
25410 const [calendarMonth, setCalendarMonth] = (0, import_element77.useState)(() => {
25411 return selectedRange.from || /* @__PURE__ */ new Date();
25412 });
25413 const [isTouched, setIsTouched] = (0, import_element77.useState)(false);
25414 const fromInputRef = (0, import_element77.useRef)(null);
25415 const toInputRef = (0, import_element77.useRef)(null);
25416 const updateDateRange = (0, import_element77.useCallback)(
25417 (fromDate, toDate2) => {
25418 if (fromDate && toDate2) {
25419 onChangeCallback([
25420 formatDate(fromDate),
25421 formatDate(toDate2)
25422 ]);
25423 } else if (!fromDate && !toDate2) {
25424 onChangeCallback(void 0);
25425 }
25426 },
25427 [onChangeCallback]
25428 );
25429 const onSelectCalendarRange = (0, import_element77.useCallback)(
25430 (newRange) => {
25431 updateDateRange(newRange?.from, newRange?.to);
25432 setSelectedPresetId(null);
25433 setIsTouched(true);
25434 },
25435 [updateDateRange]
25436 );
25437 const handlePresetClick = (0, import_element77.useCallback)(
25438 (preset) => {
25439 const [startDate, endDate] = preset.getValue();
25440 setCalendarMonth(startDate);
25441 updateDateRange(startDate, endDate);
25442 setSelectedPresetId(preset.id);
25443 setIsTouched(true);
25444 },
25445 [updateDateRange]
25446 );
25447 const handleManualDateChange = (0, import_element77.useCallback)(
25448 (fromOrTo, newValue) => {
25449 const [currentFrom, currentTo] = value || [
25450 void 0,
25451 void 0
25452 ];
25453 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
25454 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
25455 updateDateRange(updatedFrom, updatedTo);
25456 if (newValue) {
25457 const parsedDate = parseDate(newValue);
25458 if (parsedDate) {
25459 setCalendarMonth(parsedDate);
25460 }
25461 }
25462 setSelectedPresetId(null);
25463 setIsTouched(true);
25464 },
25465 [value, updateDateRange]
25466 );
25467 const { timezone } = (0, import_date4.getSettings)();
25468 let displayLabel = label;
25469 if (field.isValid?.required && !markWhenOptional) {
25470 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
25471 } else if (!field.isValid?.required && markWhenOptional) {
25472 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
25473 }
25474 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25475 ValidatedDateControl,
25476 {
25477 field,
25478 validity,
25479 inputRefs: [fromInputRef, toInputRef],
25480 isTouched,
25481 setIsTouched,
25482 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25483 import_components34.BaseControl,
25484 {
25485 id,
25486 className: "dataviews-controls__date",
25487 label: displayLabel,
25488 help: description,
25489 hideLabelFromVision,
25490 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25491 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
25492 Stack,
25493 {
25494 direction: "row",
25495 gap: "sm",
25496 wrap: "wrap",
25497 justify: "flex-start",
25498 children: [
25499 DATE_RANGE_PRESETS.map((preset) => {
25500 const isSelected2 = selectedPresetId === preset.id;
25501 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25502 import_components34.Button,
25503 {
25504 className: "dataviews-controls__date-preset",
25505 variant: "tertiary",
25506 isPressed: isSelected2,
25507 size: "small",
25508 disabled: disabled2,
25509 accessibleWhenDisabled: true,
25510 onClick: () => handlePresetClick(preset),
25511 children: preset.label
25512 },
25513 preset.id
25514 );
25515 }),
25516 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25517 import_components34.Button,
25518 {
25519 className: "dataviews-controls__date-preset",
25520 variant: "tertiary",
25521 isPressed: !selectedPresetId,
25522 size: "small",
25523 accessibleWhenDisabled: true,
25524 disabled: !!selectedPresetId || disabled2,
25525 children: (0, import_i18n34.__)("Custom")
25526 }
25527 )
25528 ]
25529 }
25530 ),
25531 /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
25532 Stack,
25533 {
25534 direction: "row",
25535 gap: "sm",
25536 justify: "space-between",
25537 className: "dataviews-controls__date-range-inputs",
25538 children: [
25539 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25540 import_components34.__experimentalInputControl,
25541 {
25542 ref: fromInputRef,
25543 type: "date",
25544 label: (0, import_i18n34.__)("From"),
25545 hideLabelFromVision: true,
25546 value: value?.[0],
25547 onChange: (newValue) => handleManualDateChange("from", newValue),
25548 required: !!field.isValid?.required,
25549 disabled: disabled2,
25550 min: minConstraint,
25551 max: maxConstraint
25552 }
25553 ),
25554 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25555 import_components34.__experimentalInputControl,
25556 {
25557 ref: toInputRef,
25558 type: "date",
25559 label: (0, import_i18n34.__)("To"),
25560 hideLabelFromVision: true,
25561 value: value?.[1],
25562 onChange: (newValue) => handleManualDateChange("to", newValue),
25563 required: !!field.isValid?.required,
25564 disabled: disabled2,
25565 min: minConstraint,
25566 max: maxConstraint
25567 }
25568 )
25569 ]
25570 }
25571 ),
25572 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25573 DateRangeCalendar,
25574 {
25575 style: { width: "100%" },
25576 selected: selectedRange,
25577 onSelect: onSelectCalendarRange,
25578 month: calendarMonth,
25579 onMonthChange: setCalendarMonth,
25580 timeZone: timezone.string || void 0,
25581 weekStartsOn,
25582 disabled: disabled2 || disabledMatchers
25583 }
25584 )
25585 ] })
25586 }
25587 )
25588 }
25589 );
25590 }
25591 function DateControl({
25592 data,
25593 field,
25594 onChange,
25595 hideLabelFromVision,
25596 markWhenOptional,
25597 operator,
25598 validity
25599 }) {
25600 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
25601 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25602 RelativeDateControl,
25603 {
25604 className: "dataviews-controls__date",
25605 data,
25606 field,
25607 onChange,
25608 hideLabelFromVision,
25609 operator
25610 }
25611 );
25612 }
25613 if (operator === OPERATOR_BETWEEN) {
25614 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25615 CalendarDateRangeControl,
25616 {
25617 data,
25618 field,
25619 onChange,
25620 hideLabelFromVision,
25621 markWhenOptional,
25622 validity
25623 }
25624 );
25625 }
25626 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25627 CalendarDateControl,
25628 {
25629 data,
25630 field,
25631 onChange,
25632 hideLabelFromVision,
25633 markWhenOptional,
25634 validity
25635 }
25636 );
25637 }
25638
25639 // packages/dataviews/build-module/components/dataform-controls/select.mjs
25640 var import_components35 = __toESM(require_components(), 1);
25641 var import_element78 = __toESM(require_element(), 1);
25642 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
25643 var { ValidatedSelectControl } = unlock2(import_components35.privateApis);
25644 function Select({
25645 data,
25646 field,
25647 onChange,
25648 hideLabelFromVision,
25649 markWhenOptional,
25650 validity
25651 }) {
25652 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
25653 const disabled2 = field.isDisabled({ item: data, field });
25654 const isMultiple = type === "array";
25655 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
25656 const onChangeControl = (0, import_element78.useCallback)(
25657 (newValue) => onChange(setValue({ item: data, value: newValue })),
25658 [data, onChange, setValue]
25659 );
25660 const { elements, isLoading } = useElements({
25661 elements: field.elements,
25662 getElements: field.getElements
25663 });
25664 if (isLoading) {
25665 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components35.Spinner, {});
25666 }
25667 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
25668 ValidatedSelectControl,
25669 {
25670 required: !!field.isValid?.required,
25671 markWhenOptional,
25672 customValidity: getCustomValidity(isValid2, validity),
25673 label,
25674 value,
25675 help: description,
25676 options: elements,
25677 onChange: onChangeControl,
25678 hideLabelFromVision,
25679 multiple: isMultiple,
25680 disabled: disabled2
25681 }
25682 );
25683 }
25684
25685 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
25686 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
25687 var ELEMENTS_THRESHOLD = 10;
25688 function AdaptiveSelect(props) {
25689 const { field } = props;
25690 const { elements } = useElements({
25691 elements: field.elements,
25692 getElements: field.getElements
25693 });
25694 if (elements.length >= ELEMENTS_THRESHOLD) {
25695 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Combobox3, { ...props });
25696 }
25697 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Select, { ...props });
25698 }
25699
25700 // packages/dataviews/build-module/components/dataform-controls/email.mjs
25701 var import_components37 = __toESM(require_components(), 1);
25702
25703 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
25704 var import_components36 = __toESM(require_components(), 1);
25705 var import_element79 = __toESM(require_element(), 1);
25706 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25707 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components36.privateApis);
25708 function ValidatedText({
25709 data,
25710 field,
25711 onChange,
25712 hideLabelFromVision,
25713 markWhenOptional,
25714 type,
25715 prefix,
25716 suffix,
25717 validity
25718 }) {
25719 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25720 const value = getValue({ item: data });
25721 const disabled2 = field.isDisabled({ item: data, field });
25722 const onChangeControl = (0, import_element79.useCallback)(
25723 (newValue) => onChange(
25724 setValue({
25725 item: data,
25726 value: newValue
25727 })
25728 ),
25729 [data, setValue, onChange]
25730 );
25731 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25732 ValidatedInputControl2,
25733 {
25734 required: !!isValid2.required,
25735 markWhenOptional,
25736 customValidity: getCustomValidity(isValid2, validity),
25737 label,
25738 placeholder,
25739 value: value ?? "",
25740 help: description,
25741 onChange: onChangeControl,
25742 hideLabelFromVision,
25743 type,
25744 prefix,
25745 suffix,
25746 disabled: disabled2,
25747 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
25748 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
25749 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
25750 }
25751 );
25752 }
25753
25754 // packages/dataviews/build-module/components/dataform-controls/email.mjs
25755 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25756 function Email({
25757 data,
25758 field,
25759 onChange,
25760 hideLabelFromVision,
25761 markWhenOptional,
25762 validity
25763 }) {
25764 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25765 ValidatedText,
25766 {
25767 ...{
25768 data,
25769 field,
25770 onChange,
25771 hideLabelFromVision,
25772 markWhenOptional,
25773 validity,
25774 type: "email",
25775 prefix: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components37.Icon, { icon: envelope_default }) })
25776 }
25777 }
25778 );
25779 }
25780
25781 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
25782 var import_components38 = __toESM(require_components(), 1);
25783 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25784 function Telephone({
25785 data,
25786 field,
25787 onChange,
25788 hideLabelFromVision,
25789 markWhenOptional,
25790 validity
25791 }) {
25792 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25793 ValidatedText,
25794 {
25795 ...{
25796 data,
25797 field,
25798 onChange,
25799 hideLabelFromVision,
25800 markWhenOptional,
25801 validity,
25802 type: "tel",
25803 prefix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components38.Icon, { icon: mobile_default }) })
25804 }
25805 }
25806 );
25807 }
25808
25809 // packages/dataviews/build-module/components/dataform-controls/url.mjs
25810 var import_components39 = __toESM(require_components(), 1);
25811 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25812 function Url({
25813 data,
25814 field,
25815 onChange,
25816 hideLabelFromVision,
25817 markWhenOptional,
25818 validity
25819 }) {
25820 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25821 ValidatedText,
25822 {
25823 ...{
25824 data,
25825 field,
25826 onChange,
25827 hideLabelFromVision,
25828 markWhenOptional,
25829 validity,
25830 type: "url",
25831 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components39.Icon, { icon: link_default }) })
25832 }
25833 }
25834 );
25835 }
25836
25837 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
25838 var import_components40 = __toESM(require_components(), 1);
25839 var import_element80 = __toESM(require_element(), 1);
25840 var import_i18n35 = __toESM(require_i18n(), 1);
25841 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25842 var { ValidatedNumberControl } = unlock2(import_components40.privateApis);
25843 function toNumberOrEmpty(value) {
25844 if (value === "" || value === void 0) {
25845 return "";
25846 }
25847 const number = Number(value);
25848 return Number.isFinite(number) ? number : "";
25849 }
25850 function BetweenControls({
25851 value,
25852 onChange,
25853 hideLabelFromVision,
25854 step
25855 }) {
25856 const [min2 = "", max2 = ""] = value;
25857 const onChangeMin = (0, import_element80.useCallback)(
25858 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
25859 [onChange, max2]
25860 );
25861 const onChangeMax = (0, import_element80.useCallback)(
25862 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
25863 [onChange, min2]
25864 );
25865 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25866 import_components40.BaseControl,
25867 {
25868 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
25869 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [
25870 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25871 import_components40.__experimentalNumberControl,
25872 {
25873 label: (0, import_i18n35.__)("Min."),
25874 value: min2,
25875 max: max2 ? Number(max2) - step : void 0,
25876 onChange: onChangeMin,
25877 hideLabelFromVision,
25878 step
25879 }
25880 ),
25881 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25882 import_components40.__experimentalNumberControl,
25883 {
25884 label: (0, import_i18n35.__)("Max."),
25885 value: max2,
25886 min: min2 ? Number(min2) + step : void 0,
25887 onChange: onChangeMax,
25888 hideLabelFromVision,
25889 step
25890 }
25891 )
25892 ] })
25893 }
25894 );
25895 }
25896 function ValidatedNumber({
25897 data,
25898 field,
25899 onChange,
25900 hideLabelFromVision,
25901 markWhenOptional,
25902 operator,
25903 validity
25904 }) {
25905 const decimals = field.format?.decimals ?? 0;
25906 const step = Math.pow(10, Math.abs(decimals) * -1);
25907 const { label, description, getValue, setValue, isValid: isValid2 } = field;
25908 const value = getValue({ item: data }) ?? "";
25909 const disabled2 = field.isDisabled({ item: data, field });
25910 const onChangeControl = (0, import_element80.useCallback)(
25911 (newValue) => {
25912 onChange(
25913 setValue({
25914 item: data,
25915 // Do not convert an empty string or undefined to a number,
25916 // otherwise there's a mismatch between the UI control (empty)
25917 // and the data relied by onChange (0).
25918 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
25919 })
25920 );
25921 },
25922 [data, onChange, setValue]
25923 );
25924 const onChangeBetweenControls = (0, import_element80.useCallback)(
25925 (newValue) => {
25926 onChange(
25927 setValue({
25928 item: data,
25929 value: newValue
25930 })
25931 );
25932 },
25933 [data, onChange, setValue]
25934 );
25935 if (operator === OPERATOR_BETWEEN) {
25936 let valueBetween = ["", ""];
25937 if (Array.isArray(value) && value.length === 2 && value.every(
25938 (element) => typeof element === "number" || element === ""
25939 )) {
25940 valueBetween = value;
25941 }
25942 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25943 BetweenControls,
25944 {
25945 value: valueBetween,
25946 onChange: onChangeBetweenControls,
25947 hideLabelFromVision,
25948 step
25949 }
25950 );
25951 }
25952 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25953 ValidatedNumberControl,
25954 {
25955 required: !!isValid2.required,
25956 markWhenOptional,
25957 customValidity: getCustomValidity(isValid2, validity),
25958 label,
25959 help: description,
25960 value,
25961 onChange: onChangeControl,
25962 hideLabelFromVision,
25963 step,
25964 min: isValid2.min ? isValid2.min.constraint : void 0,
25965 max: isValid2.max ? isValid2.max.constraint : void 0,
25966 disabled: disabled2
25967 }
25968 );
25969 }
25970
25971 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
25972 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25973 function Integer(props) {
25974 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(ValidatedNumber, { ...props });
25975 }
25976
25977 // packages/dataviews/build-module/components/dataform-controls/number.mjs
25978 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25979 function Number2(props) {
25980 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(ValidatedNumber, { ...props });
25981 }
25982
25983 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
25984 var import_components41 = __toESM(require_components(), 1);
25985 var import_element81 = __toESM(require_element(), 1);
25986 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25987 var { ValidatedRadioControl } = unlock2(import_components41.privateApis);
25988 function Radio({
25989 data,
25990 field,
25991 onChange,
25992 hideLabelFromVision,
25993 markWhenOptional,
25994 validity
25995 }) {
25996 const { label, description, getValue, setValue, isValid: isValid2 } = field;
25997 const disabled2 = field.isDisabled({ item: data, field });
25998 const { elements, isLoading } = useElements({
25999 elements: field.elements,
26000 getElements: field.getElements
26001 });
26002 const value = getValue({ item: data });
26003 const onChangeControl = (0, import_element81.useCallback)(
26004 (newValue) => onChange(setValue({ item: data, value: newValue })),
26005 [data, onChange, setValue]
26006 );
26007 if (isLoading) {
26008 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components41.Spinner, {});
26009 }
26010 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26011 ValidatedRadioControl,
26012 {
26013 required: !!field.isValid?.required,
26014 markWhenOptional,
26015 customValidity: getCustomValidity(isValid2, validity),
26016 label,
26017 help: description,
26018 onChange: onChangeControl,
26019 options: elements,
26020 selected: value,
26021 hideLabelFromVision,
26022 disabled: disabled2
26023 }
26024 );
26025 }
26026
26027 // packages/dataviews/build-module/components/dataform-controls/text.mjs
26028 var import_element82 = __toESM(require_element(), 1);
26029 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
26030 function Text3({
26031 data,
26032 field,
26033 onChange,
26034 hideLabelFromVision,
26035 markWhenOptional,
26036 config,
26037 validity
26038 }) {
26039 const { prefix, suffix } = config || {};
26040 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26041 ValidatedText,
26042 {
26043 ...{
26044 data,
26045 field,
26046 onChange,
26047 hideLabelFromVision,
26048 markWhenOptional,
26049 validity,
26050 prefix: prefix ? (0, import_element82.createElement)(prefix) : void 0,
26051 suffix: suffix ? (0, import_element82.createElement)(suffix) : void 0
26052 }
26053 }
26054 );
26055 }
26056
26057 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
26058 var import_components42 = __toESM(require_components(), 1);
26059 var import_element83 = __toESM(require_element(), 1);
26060 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
26061 var { ValidatedToggleControl } = unlock2(import_components42.privateApis);
26062 function Toggle({
26063 field,
26064 onChange,
26065 data,
26066 hideLabelFromVision,
26067 markWhenOptional,
26068 validity
26069 }) {
26070 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26071 const disabled2 = field.isDisabled({ item: data, field });
26072 const onChangeControl = (0, import_element83.useCallback)(() => {
26073 onChange(
26074 setValue({ item: data, value: !getValue({ item: data }) })
26075 );
26076 }, [onChange, setValue, data, getValue]);
26077 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26078 ValidatedToggleControl,
26079 {
26080 required: !!isValid2.required,
26081 markWhenOptional,
26082 customValidity: getCustomValidity(isValid2, validity),
26083 hidden: hideLabelFromVision,
26084 label,
26085 help: description,
26086 checked: getValue({ item: data }),
26087 onChange: onChangeControl,
26088 disabled: disabled2
26089 }
26090 );
26091 }
26092
26093 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
26094 var import_components43 = __toESM(require_components(), 1);
26095 var import_element84 = __toESM(require_element(), 1);
26096 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26097 var { ValidatedTextareaControl } = unlock2(import_components43.privateApis);
26098 function Textarea({
26099 data,
26100 field,
26101 onChange,
26102 hideLabelFromVision,
26103 markWhenOptional,
26104 config,
26105 validity
26106 }) {
26107 const { rows = 4 } = config || {};
26108 const disabled2 = field.isDisabled({ item: data, field });
26109 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26110 const value = field.getValue({ item: data });
26111 const onChangeControl = (0, import_element84.useCallback)(
26112 (newValue) => onChange(setValue({ item: data, value: newValue })),
26113 [data, onChange, setValue]
26114 );
26115 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26116 ValidatedTextareaControl,
26117 {
26118 required: !!isValid2.required,
26119 markWhenOptional,
26120 customValidity: getCustomValidity(isValid2, validity),
26121 label,
26122 placeholder,
26123 value: value ?? "",
26124 help: description,
26125 onChange: onChangeControl,
26126 rows,
26127 disabled: disabled2,
26128 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26129 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
26130 __next40pxDefaultSize: true,
26131 hideLabelFromVision
26132 }
26133 );
26134 }
26135
26136 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
26137 var import_element86 = __toESM(require_element(), 1);
26138
26139 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
26140 var import_components44 = __toESM(require_components(), 1);
26141 var import_compose12 = __toESM(require_compose(), 1);
26142 var import_element85 = __toESM(require_element(), 1);
26143 var import_rich_text2 = __toESM(require_rich_text(), 1);
26144
26145 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
26146 var EMPTY_ARRAY6 = [];
26147 function getAllowedFormats({
26148 allowedFormats,
26149 disableFormats
26150 }) {
26151 if (disableFormats) {
26152 return EMPTY_ARRAY6;
26153 }
26154 return allowedFormats;
26155 }
26156
26157 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
26158 var import_rich_text = __toESM(require_rich_text(), 1);
26159 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26160 var import_react29 = __toESM(require_react(), 1);
26161 var EMPTY_CONTEXT = {};
26162 function Edit({
26163 onChange,
26164 onFocus,
26165 value,
26166 forwardedRef,
26167 settings,
26168 isVisible: isVisible2
26169 }) {
26170 const { name, edit: EditFunction } = settings;
26171 if (!EditFunction) {
26172 return null;
26173 }
26174 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
26175 const isActive = activeFormat !== void 0;
26176 const activeObject = (0, import_rich_text.getActiveObject)(value);
26177 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
26178 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26179 EditFunction,
26180 {
26181 isActive,
26182 isVisible: isVisible2,
26183 activeAttributes: isActive ? activeFormat.attributes || {} : {},
26184 isObjectActive,
26185 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
26186 value,
26187 onChange,
26188 onFocus,
26189 contentRef: forwardedRef,
26190 context: EMPTY_CONTEXT
26191 },
26192 name
26193 );
26194 }
26195 function FormatEdit({
26196 formatTypes,
26197 ...props
26198 }) {
26199 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react29.createElement)(Edit, { settings, ...props, key: settings.name }));
26200 }
26201
26202 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
26203 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26204 var {
26205 ValidatedContentEditableControl: RichTextControlShell,
26206 withIgnoreIMEEvents
26207 } = unlock2(import_components44.privateApis);
26208 var {
26209 useRichText,
26210 KeyboardShortcutContext,
26211 InputEventContext,
26212 shortcutsListener,
26213 inputEventsListener
26214 } = unlock2(import_rich_text2.privateApis);
26215 var EMPTY_COMPLETERS = [];
26216 function RichTextControl({
26217 label,
26218 value: attrValue,
26219 onChange,
26220 placeholder,
26221 id,
26222 clientId,
26223 className,
26224 hideLabelFromVision,
26225 help,
26226 disabled: disabled2,
26227 required,
26228 markWhenOptional,
26229 customValidity,
26230 allowedFormats,
26231 disableFormats,
26232 withoutInteractiveFormatting,
26233 preserveWhiteSpace,
26234 disableLineBreaks,
26235 focusOnMount,
26236 completers = EMPTY_COMPLETERS
26237 }) {
26238 const [selection, setSelection] = (0, import_element85.useState)({
26239 start: void 0,
26240 end: void 0
26241 });
26242 const [isSelected2, setIsSelected] = (0, import_element85.useState)(false);
26243 const anchorRef = (0, import_element85.useRef)(void 0);
26244 const inputEvents = (0, import_element85.useRef)(/* @__PURE__ */ new Set());
26245 const keyboardShortcuts = (0, import_element85.useRef)(
26246 /* @__PURE__ */ new Set()
26247 );
26248 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
26249 const adjustedAllowedFormats = getAllowedFormats({
26250 allowedFormats,
26251 disableFormats
26252 });
26253 const {
26254 value,
26255 onChange: onRichTextChange,
26256 ref: richTextRef,
26257 formatTypes,
26258 getValue
26259 } = useRichText({
26260 value: attrValue,
26261 onChange,
26262 selectionStart: selection.start,
26263 selectionEnd: selection.end,
26264 onSelectionChange: (start, end) => setSelection({ start, end }),
26265 __unstableIsSelected: isSelected2,
26266 preserveWhiteSpace: !!preserveWhiteSpace,
26267 placeholder,
26268 __unstableDisableFormats: disableFormats,
26269 allowedFormats: adjustedAllowedFormats,
26270 withoutInteractiveFormatting,
26271 __unstableFormatTypeHandlerContext: (0, import_element85.useMemo)(
26272 () => ({
26273 richTextIdentifier: id,
26274 blockClientId: clientId
26275 }),
26276 [id, clientId]
26277 )
26278 });
26279 function onFocus() {
26280 anchorRef.current?.focus();
26281 }
26282 const eventListenersPropsRef = (0, import_element85.useRef)({
26283 keyboardShortcuts,
26284 inputEvents
26285 });
26286 const inputRulePropsRef = (0, import_element85.useRef)({
26287 formatTypes,
26288 getValue,
26289 onChange: onRichTextChange
26290 });
26291 (0, import_element85.useInsertionEffect)(() => {
26292 inputRulePropsRef.current = {
26293 formatTypes,
26294 getValue,
26295 onChange: onRichTextChange
26296 };
26297 });
26298 const enterRef = (0, import_compose12.useRefEffect)(
26299 (element) => {
26300 if (disabled2) {
26301 return;
26302 }
26303 const onKeyDown = withIgnoreIMEEvents((event) => {
26304 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
26305 return;
26306 }
26307 event.preventDefault();
26308 if (disableLineBreaks) {
26309 return;
26310 }
26311 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
26312 const current = getCurrentValue2();
26313 handleChange(
26314 (0, import_rich_text2.insert)(
26315 current,
26316 "\n",
26317 current.start ?? current.text.length,
26318 current.end ?? current.text.length
26319 )
26320 );
26321 });
26322 element.addEventListener("keydown", onKeyDown);
26323 return () => element.removeEventListener("keydown", onKeyDown);
26324 },
26325 [disableLineBreaks, disabled2]
26326 );
26327 const eventListenersRef = (0, import_compose12.useRefEffect)(
26328 (element) => {
26329 if (!isSelected2) {
26330 return;
26331 }
26332 const cleanupShortcuts = shortcutsListener(
26333 eventListenersPropsRef
26334 )(element);
26335 const cleanupInputEvents = inputEventsListener(
26336 eventListenersPropsRef
26337 )(element);
26338 function onFormatInput(event) {
26339 if (event.inputType !== "insertText" && event.type !== "compositionend") {
26340 return;
26341 }
26342 const {
26343 formatTypes: types,
26344 getValue: getCurrentValue2,
26345 onChange: handleChange
26346 } = inputRulePropsRef.current;
26347 const current = getCurrentValue2();
26348 const transformed = types.reduce(
26349 (accumulator, {
26350 __unstableInputRule
26351 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
26352 current
26353 );
26354 if (transformed !== current) {
26355 handleChange({
26356 ...transformed,
26357 activeFormats: current.activeFormats
26358 });
26359 }
26360 }
26361 element.addEventListener("input", onFormatInput);
26362 element.addEventListener("compositionend", onFormatInput);
26363 return () => {
26364 cleanupShortcuts();
26365 cleanupInputEvents();
26366 element.removeEventListener("input", onFormatInput);
26367 element.removeEventListener("compositionend", onFormatInput);
26368 };
26369 },
26370 [isSelected2]
26371 );
26372 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components44.__unstableUseAutocompleteProps)(
26373 {
26374 completers,
26375 record: value,
26376 onChange: onRichTextChange,
26377 // This control's completers insert their completion into the value;
26378 // none replace the whole value, so the required `onReplace` is a
26379 // no-op here.
26380 onReplace: () => {
26381 }
26382 }
26383 );
26384 const focusOnMountRef = (0, import_compose12.useRefEffect)(
26385 (element) => {
26386 if (focusOnMount && !disabled2) {
26387 element.focus();
26388 }
26389 },
26390 [focusOnMount, disabled2]
26391 );
26392 const editableRef = (0, import_compose12.useMergeRefs)([
26393 richTextRef,
26394 anchorRef,
26395 eventListenersRef,
26396 enterRef,
26397 focusOnMountRef,
26398 autocompleteRef
26399 ]);
26400 return (
26401 // Focus boundary for the field's selection: `onFocus` selects on entry;
26402 // the spread `useFocusOutside` handlers deselect once focus leaves.
26403 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26404 "div",
26405 {
26406 ...focusOutside,
26407 onFocus: (event) => {
26408 setIsSelected(true);
26409 focusOutside.onFocus(event);
26410 },
26411 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components44.SlotFillProvider, { children: [
26412 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26413 RichTextControlShell,
26414 {
26415 label,
26416 id,
26417 className: clsx_default(
26418 "dataviews-controls__richtext",
26419 className
26420 ),
26421 placeholder,
26422 hideLabelFromVision,
26423 help,
26424 disabled: disabled2,
26425 required,
26426 markWhenOptional,
26427 customValidity,
26428 value: value.text,
26429 "aria-multiline": !disableLineBreaks,
26430 ...autocompleteProps,
26431 ref: editableRef
26432 }
26433 ),
26434 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26435 KeyboardShortcutContext.Provider,
26436 {
26437 value: keyboardShortcuts,
26438 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26439 FormatEdit,
26440 {
26441 value,
26442 onChange: onRichTextChange,
26443 onFocus,
26444 formatTypes,
26445 forwardedRef: anchorRef,
26446 isVisible: true
26447 }
26448 ) })
26449 }
26450 )
26451 ] })
26452 }
26453 )
26454 );
26455 }
26456
26457 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
26458 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
26459 function RichText({
26460 data,
26461 field,
26462 onChange,
26463 hideLabelFromVision,
26464 markWhenOptional,
26465 config,
26466 validity
26467 }) {
26468 const {
26469 className,
26470 clientId,
26471 allowedFormats,
26472 disableFormats,
26473 withoutInteractiveFormatting,
26474 preserveWhiteSpace,
26475 disableLineBreaks
26476 } = config || {};
26477 const disabled2 = field.isDisabled({ item: data, field });
26478 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
26479 const value = field.getValue({ item: data }) ?? "";
26480 const onChangeControl = (0, import_element86.useCallback)(
26481 (newValue) => onChange(setValue({ item: data, value: newValue })),
26482 [data, onChange, setValue]
26483 );
26484 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
26485 RichTextControl,
26486 {
26487 label,
26488 value,
26489 onChange: onChangeControl,
26490 placeholder,
26491 id,
26492 hideLabelFromVision,
26493 help: description,
26494 disabled: disabled2,
26495 required: !!isValid2.required,
26496 markWhenOptional,
26497 customValidity: getCustomValidity(isValid2, validity),
26498 className,
26499 clientId,
26500 allowedFormats,
26501 disableFormats,
26502 withoutInteractiveFormatting,
26503 preserveWhiteSpace,
26504 disableLineBreaks
26505 }
26506 );
26507 }
26508
26509 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
26510 var import_components45 = __toESM(require_components(), 1);
26511 var import_element87 = __toESM(require_element(), 1);
26512 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
26513 var { ValidatedToggleGroupControl } = unlock2(import_components45.privateApis);
26514 function ToggleGroup({
26515 data,
26516 field,
26517 onChange,
26518 hideLabelFromVision,
26519 markWhenOptional,
26520 validity
26521 }) {
26522 const { getValue, setValue, isValid: isValid2 } = field;
26523 const disabled2 = field.isDisabled({ item: data, field });
26524 const value = getValue({ item: data });
26525 const onChangeControl = (0, import_element87.useCallback)(
26526 (newValue) => onChange(setValue({ item: data, value: newValue })),
26527 [data, onChange, setValue]
26528 );
26529 const { elements, isLoading } = useElements({
26530 elements: field.elements,
26531 getElements: field.getElements
26532 });
26533 if (isLoading) {
26534 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components45.Spinner, {});
26535 }
26536 if (elements.length === 0) {
26537 return null;
26538 }
26539 const selectedOption = elements.find((el) => el.value === value);
26540 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26541 ValidatedToggleGroupControl,
26542 {
26543 required: !!field.isValid?.required,
26544 markWhenOptional,
26545 customValidity: getCustomValidity(isValid2, validity),
26546 isBlock: true,
26547 label: field.label,
26548 help: selectedOption?.description || field.description,
26549 onChange: onChangeControl,
26550 value,
26551 hideLabelFromVision,
26552 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26553 import_components45.__experimentalToggleGroupControlOption,
26554 {
26555 label: el.label,
26556 value: el.value,
26557 disabled: disabled2
26558 },
26559 el.value
26560 ))
26561 }
26562 );
26563 }
26564
26565 // packages/dataviews/build-module/components/dataform-controls/array.mjs
26566 var import_components46 = __toESM(require_components(), 1);
26567 var import_element88 = __toESM(require_element(), 1);
26568 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
26569 var { ValidatedFormTokenField } = unlock2(import_components46.privateApis);
26570 function ArrayControl({
26571 data,
26572 field,
26573 onChange,
26574 hideLabelFromVision,
26575 markWhenOptional,
26576 validity
26577 }) {
26578 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
26579 const value = getValue({ item: data });
26580 const disabled2 = field.isDisabled({ item: data, field });
26581 const { elements, isLoading } = useElements({
26582 elements: field.elements,
26583 getElements: field.getElements
26584 });
26585 const arrayValueAsElements = (0, import_element88.useMemo)(
26586 () => Array.isArray(value) ? value.map((token) => {
26587 const element = elements?.find(
26588 (suggestion) => suggestion.value === token
26589 );
26590 return element || { value: token, label: token };
26591 }) : [],
26592 [value, elements]
26593 );
26594 const onChangeControl = (0, import_element88.useCallback)(
26595 (tokens) => {
26596 const valueTokens = tokens.map((token) => {
26597 if (typeof token === "object" && "value" in token) {
26598 return token.value;
26599 }
26600 return token;
26601 });
26602 onChange(setValue({ item: data, value: valueTokens }));
26603 },
26604 [onChange, setValue, data]
26605 );
26606 if (isLoading) {
26607 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components46.Spinner, {});
26608 }
26609 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
26610 ValidatedFormTokenField,
26611 {
26612 required: !!isValid2?.required,
26613 markWhenOptional,
26614 customValidity: getCustomValidity(isValid2, validity),
26615 label: hideLabelFromVision ? void 0 : label,
26616 value: arrayValueAsElements,
26617 onChange: onChangeControl,
26618 placeholder,
26619 suggestions: elements?.map((element) => element.value),
26620 disabled: disabled2,
26621 __experimentalValidateInput: (token) => {
26622 if (field.isValid?.elements && elements) {
26623 return elements.some(
26624 (element) => element.value === token || element.label === token
26625 );
26626 }
26627 return true;
26628 },
26629 __experimentalExpandOnFocus: elements && elements.length > 0,
26630 help: description ?? (field.isValid?.elements ? "" : void 0),
26631 displayTransform: (token) => {
26632 if (typeof token === "object" && "label" in token) {
26633 return token.label;
26634 }
26635 if (typeof token === "string" && elements) {
26636 const element = elements.find(
26637 (el) => el.value === token
26638 );
26639 return element?.label || token;
26640 }
26641 return token;
26642 },
26643 __experimentalRenderItem: ({ item }) => {
26644 if (typeof item === "string" && elements) {
26645 const element = elements.find(
26646 (el) => el.value === item
26647 );
26648 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { children: element?.label || item });
26649 }
26650 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { children: item });
26651 }
26652 }
26653 );
26654 }
26655
26656 // node_modules/colord/index.mjs
26657 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
26658 var t = function(r3) {
26659 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
26660 };
26661 var n = function(r3, t2, n2) {
26662 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
26663 };
26664 var e = function(r3, t2, n2) {
26665 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
26666 };
26667 var u = function(r3) {
26668 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
26669 };
26670 var a = function(r3) {
26671 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
26672 };
26673 var o = function(r3) {
26674 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
26675 };
26676 var i = /^#([0-9a-f]{3,8})$/i;
26677 var s = function(r3) {
26678 var t2 = r3.toString(16);
26679 return t2.length < 2 ? "0" + t2 : t2;
26680 };
26681 var h = function(r3) {
26682 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;
26683 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
26684 };
26685 var b = function(r3) {
26686 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
26687 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
26688 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;
26689 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 };
26690 };
26691 var g = function(r3) {
26692 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
26693 };
26694 var d = function(r3) {
26695 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
26696 };
26697 var f = function(r3) {
26698 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 }));
26699 var t2, n2, e2;
26700 };
26701 var c = function(r3) {
26702 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 };
26703 var t2, n2, e2, u2;
26704 };
26705 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26706 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26707 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26708 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26709 var y = { string: [[function(r3) {
26710 var t2 = i.exec(r3);
26711 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;
26712 }, "hex"], [function(r3) {
26713 var t2 = v.exec(r3) || m.exec(r3);
26714 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;
26715 }, "rgb"], [function(t2) {
26716 var n2 = l.exec(t2) || p.exec(t2);
26717 if (!n2) return null;
26718 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) });
26719 return f(a2);
26720 }, "hsl"]], object: [[function(r3) {
26721 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
26722 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
26723 }, "rgb"], [function(r3) {
26724 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
26725 if (!t(n2) || !t(e2) || !t(u2)) return null;
26726 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
26727 return f(i2);
26728 }, "hsl"], [function(r3) {
26729 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
26730 if (!t(n2) || !t(a2) || !t(o2)) return null;
26731 var h2 = (function(r4) {
26732 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
26733 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
26734 return b(h2);
26735 }, "hsv"]] };
26736 var N = function(r3, t2) {
26737 for (var n2 = 0; n2 < t2.length; n2++) {
26738 var e2 = t2[n2][0](r3);
26739 if (e2) return [e2, t2[n2][1]];
26740 }
26741 return [null, void 0];
26742 };
26743 var x = function(r3) {
26744 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
26745 };
26746 var M = function(r3, t2) {
26747 var n2 = c(r3);
26748 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
26749 };
26750 var H = function(r3) {
26751 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
26752 };
26753 var $ = function(r3, t2) {
26754 var n2 = c(r3);
26755 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
26756 };
26757 var j = (function() {
26758 function r3(r4) {
26759 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
26760 }
26761 return r3.prototype.isValid = function() {
26762 return null !== this.parsed;
26763 }, r3.prototype.brightness = function() {
26764 return n(H(this.rgba), 2);
26765 }, r3.prototype.isDark = function() {
26766 return H(this.rgba) < 0.5;
26767 }, r3.prototype.isLight = function() {
26768 return H(this.rgba) >= 0.5;
26769 }, r3.prototype.toHex = function() {
26770 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;
26771 var r4, t2, e2, u2, a2, i2;
26772 }, r3.prototype.toRgb = function() {
26773 return o(this.rgba);
26774 }, r3.prototype.toRgbString = function() {
26775 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 + ")";
26776 var r4, t2, n2, e2, u2;
26777 }, r3.prototype.toHsl = function() {
26778 return d(c(this.rgba));
26779 }, r3.prototype.toHslString = function() {
26780 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 + "%)";
26781 var r4, t2, n2, e2, u2;
26782 }, r3.prototype.toHsv = function() {
26783 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
26784 var r4;
26785 }, r3.prototype.invert = function() {
26786 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
26787 var r4;
26788 }, r3.prototype.saturate = function(r4) {
26789 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
26790 }, r3.prototype.desaturate = function(r4) {
26791 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
26792 }, r3.prototype.grayscale = function() {
26793 return w(M(this.rgba, -1));
26794 }, r3.prototype.lighten = function(r4) {
26795 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
26796 }, r3.prototype.darken = function(r4) {
26797 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
26798 }, r3.prototype.rotate = function(r4) {
26799 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
26800 }, r3.prototype.alpha = function(r4) {
26801 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
26802 var t2;
26803 }, r3.prototype.hue = function(r4) {
26804 var t2 = c(this.rgba);
26805 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
26806 }, r3.prototype.isEqual = function(r4) {
26807 return this.toHex() === w(r4).toHex();
26808 }, r3;
26809 })();
26810 var w = function(r3) {
26811 return r3 instanceof j ? r3 : new j(r3);
26812 };
26813
26814 // packages/dataviews/build-module/components/dataform-controls/color.mjs
26815 var import_components47 = __toESM(require_components(), 1);
26816 var import_element89 = __toESM(require_element(), 1);
26817 var import_i18n36 = __toESM(require_i18n(), 1);
26818 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
26819 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components47.privateApis);
26820 var ColorPickerDropdown = ({
26821 color,
26822 onColorChange,
26823 disabled: disabled2
26824 }) => {
26825 const validColor = color && w(color).isValid() ? color : "#ffffff";
26826 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26827 import_components47.Dropdown,
26828 {
26829 className: "dataviews-controls__color-picker-dropdown",
26830 popoverProps: { resize: false },
26831 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26832 import_components47.Button,
26833 {
26834 onClick: onToggle,
26835 "aria-label": (0, import_i18n36.__)("Open color picker"),
26836 size: "small",
26837 disabled: disabled2,
26838 accessibleWhenDisabled: true,
26839 icon: () => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components47.ColorIndicator, { colorValue: validColor })
26840 }
26841 ),
26842 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components47.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26843 import_components47.ColorPicker,
26844 {
26845 color: validColor,
26846 onChange: onColorChange,
26847 enableAlpha: true
26848 }
26849 ) })
26850 }
26851 );
26852 };
26853 function Color({
26854 data,
26855 field,
26856 onChange,
26857 hideLabelFromVision,
26858 markWhenOptional,
26859 validity
26860 }) {
26861 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26862 const disabled2 = field.isDisabled({ item: data, field });
26863 const value = field.getValue({ item: data }) || "";
26864 const handleColorChange = (0, import_element89.useCallback)(
26865 (newColor) => {
26866 onChange(setValue({ item: data, value: newColor }));
26867 },
26868 [data, onChange, setValue]
26869 );
26870 const handleInputChange = (0, import_element89.useCallback)(
26871 (newValue) => {
26872 onChange(setValue({ item: data, value: newValue || "" }));
26873 },
26874 [data, onChange, setValue]
26875 );
26876 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26877 ValidatedInputControl3,
26878 {
26879 required: !!field.isValid?.required,
26880 markWhenOptional,
26881 customValidity: getCustomValidity(isValid2, validity),
26882 label,
26883 placeholder,
26884 value,
26885 help: description,
26886 onChange: handleInputChange,
26887 hideLabelFromVision,
26888 type: "text",
26889 disabled: disabled2,
26890 prefix: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components47.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26891 ColorPickerDropdown,
26892 {
26893 color: value,
26894 onColorChange: handleColorChange,
26895 disabled: disabled2
26896 }
26897 ) })
26898 }
26899 );
26900 }
26901
26902 // packages/dataviews/build-module/components/dataform-controls/password.mjs
26903 var import_components48 = __toESM(require_components(), 1);
26904 var import_element90 = __toESM(require_element(), 1);
26905 var import_i18n37 = __toESM(require_i18n(), 1);
26906 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
26907 function Password({
26908 data,
26909 field,
26910 onChange,
26911 hideLabelFromVision,
26912 markWhenOptional,
26913 validity
26914 }) {
26915 const [isVisible2, setIsVisible] = (0, import_element90.useState)(false);
26916 const disabled2 = field.isDisabled({ item: data, field });
26917 const toggleVisibility = (0, import_element90.useCallback)(() => {
26918 setIsVisible((prev) => !prev);
26919 }, []);
26920 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
26921 ValidatedText,
26922 {
26923 ...{
26924 data,
26925 field,
26926 onChange,
26927 hideLabelFromVision,
26928 markWhenOptional,
26929 validity,
26930 type: isVisible2 ? "text" : "password",
26931 suffix: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components48.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
26932 import_components48.Button,
26933 {
26934 icon: isVisible2 ? unseen_default : seen_default,
26935 onClick: toggleVisibility,
26936 size: "small",
26937 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
26938 disabled: disabled2,
26939 accessibleWhenDisabled: true
26940 }
26941 ) })
26942 }
26943 }
26944 );
26945 }
26946
26947 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
26948 function hasElements(field) {
26949 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
26950 }
26951
26952 // packages/dataviews/build-module/components/dataform-controls/index.mjs
26953 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
26954 var FORM_CONTROLS = {
26955 adaptiveSelect: AdaptiveSelect,
26956 array: ArrayControl,
26957 checkbox: Checkbox,
26958 color: Color,
26959 combobox: Combobox3,
26960 datetime: DateTime,
26961 date: DateControl,
26962 email: Email,
26963 telephone: Telephone,
26964 url: Url,
26965 integer: Integer,
26966 number: Number2,
26967 password: Password,
26968 radio: Radio,
26969 select: Select,
26970 text: Text3,
26971 toggle: Toggle,
26972 textarea: Textarea,
26973 richtext: RichText,
26974 toggleGroup: ToggleGroup
26975 };
26976 function isEditConfig(value) {
26977 return value && typeof value === "object" && typeof value.control === "string";
26978 }
26979 function createConfiguredControl(config) {
26980 const { control, ...controlConfig } = config;
26981 const BaseControlType = getControlByType(control);
26982 if (BaseControlType === null) {
26983 return null;
26984 }
26985 return function ConfiguredControl(props) {
26986 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(BaseControlType, { ...props, config: controlConfig });
26987 };
26988 }
26989 function getControl(field, fallback) {
26990 if (typeof field.Edit === "function") {
26991 return field.Edit;
26992 }
26993 if (typeof field.Edit === "string") {
26994 return getControlByType(field.Edit);
26995 }
26996 if (isEditConfig(field.Edit)) {
26997 return createConfiguredControl(field.Edit);
26998 }
26999 if (hasElements(field) && field.type !== "array") {
27000 return getControlByType("adaptiveSelect");
27001 }
27002 if (fallback === null) {
27003 return null;
27004 }
27005 return getControlByType(fallback);
27006 }
27007 function getControlByType(type) {
27008 if (Object.keys(FORM_CONTROLS).includes(type)) {
27009 return FORM_CONTROLS[type];
27010 }
27011 return null;
27012 }
27013
27014 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
27015 function getFilterBy(field, defaultOperators, validOperators) {
27016 if (field.filterBy === false) {
27017 return false;
27018 }
27019 const operators = field.filterBy?.operators?.filter(
27020 (op) => validOperators.includes(op)
27021 ) ?? defaultOperators;
27022 if (operators.length === 0) {
27023 return false;
27024 }
27025 return {
27026 isPrimary: !!field.filterBy?.isPrimary,
27027 operators
27028 };
27029 }
27030 var get_filter_by_default = getFilterBy;
27031
27032 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
27033 var getValueFromId = (id) => ({ item }) => {
27034 const path = id.split(".");
27035 let value = item;
27036 for (const segment of path) {
27037 if (value.hasOwnProperty(segment)) {
27038 value = value[segment];
27039 } else {
27040 value = void 0;
27041 }
27042 }
27043 return value;
27044 };
27045 var get_value_from_id_default = getValueFromId;
27046
27047 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
27048 var setValueFromId = (id) => ({ value }) => {
27049 const path = id.split(".");
27050 const result = {};
27051 let current = result;
27052 for (const segment of path.slice(0, -1)) {
27053 current[segment] = {};
27054 current = current[segment];
27055 }
27056 current[path.at(-1)] = value;
27057 return result;
27058 };
27059 var set_value_from_id_default = setValueFromId;
27060
27061 // packages/dataviews/build-module/field-types/email.mjs
27062 var import_i18n38 = __toESM(require_i18n(), 1);
27063
27064 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
27065 function RenderFromElements({
27066 item,
27067 field
27068 }) {
27069 const { elements, isLoading } = useElements({
27070 elements: field.elements,
27071 getElements: field.getElements
27072 });
27073 const value = field.getValue({ item });
27074 if (isLoading) {
27075 return value;
27076 }
27077 if (elements.length === 0) {
27078 return value;
27079 }
27080 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
27081 }
27082
27083 // packages/dataviews/build-module/field-types/utils/render-default.mjs
27084 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
27085 function render({
27086 item,
27087 field
27088 }) {
27089 if (field.hasElements) {
27090 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(RenderFromElements, { item, field });
27091 }
27092 return field.getValueFormatted({ item, field });
27093 }
27094
27095 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
27096 var sort_text_default = (a2, b2, direction) => {
27097 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
27098 };
27099
27100 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
27101 function isValidRequired(item, field) {
27102 const value = field.getValue({ item });
27103 return ![void 0, "", null].includes(value);
27104 }
27105
27106 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
27107 function isValidMinLength(item, field) {
27108 if (typeof field.isValid.minLength?.constraint !== "number") {
27109 return false;
27110 }
27111 const value = field.getValue({ item });
27112 if ([void 0, "", null].includes(value)) {
27113 return true;
27114 }
27115 return String(value).length >= field.isValid.minLength.constraint;
27116 }
27117
27118 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
27119 function isValidMaxLength(item, field) {
27120 if (typeof field.isValid.maxLength?.constraint !== "number") {
27121 return false;
27122 }
27123 const value = field.getValue({ item });
27124 if ([void 0, "", null].includes(value)) {
27125 return true;
27126 }
27127 return String(value).length <= field.isValid.maxLength.constraint;
27128 }
27129
27130 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
27131 function isValidPattern(item, field) {
27132 if (field.isValid.pattern?.constraint === void 0) {
27133 return true;
27134 }
27135 try {
27136 const regexp = new RegExp(field.isValid.pattern.constraint);
27137 const value = field.getValue({ item });
27138 if ([void 0, "", null].includes(value)) {
27139 return true;
27140 }
27141 return regexp.test(String(value));
27142 } catch {
27143 return false;
27144 }
27145 }
27146
27147 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
27148 function isValidElements(item, field) {
27149 const elements = field.elements ?? [];
27150 const validValues = elements.map((el) => el.value);
27151 if (validValues.length === 0) {
27152 return true;
27153 }
27154 const value = field.getValue({ item });
27155 return [].concat(value).every((v2) => validValues.includes(v2));
27156 }
27157
27158 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
27159 function getValueFormatted({
27160 item,
27161 field
27162 }) {
27163 return field.getValue({ item });
27164 }
27165 var get_value_formatted_default_default = getValueFormatted;
27166
27167 // packages/dataviews/build-module/field-types/email.mjs
27168 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])?)*$/;
27169 function isValidCustom(item, field) {
27170 const value = field.getValue({ item });
27171 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
27172 return (0, import_i18n38.__)("Value must be a valid email address.");
27173 }
27174 return null;
27175 }
27176 var email_default = {
27177 type: "email",
27178 render,
27179 Edit: "email",
27180 sort: sort_text_default,
27181 enableSorting: true,
27182 enableGlobalSearch: false,
27183 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27184 validOperators: [
27185 OPERATOR_IS,
27186 OPERATOR_IS_NOT,
27187 OPERATOR_CONTAINS,
27188 OPERATOR_NOT_CONTAINS,
27189 OPERATOR_STARTS_WITH,
27190 // Multiple selection
27191 OPERATOR_IS_ANY,
27192 OPERATOR_IS_NONE,
27193 OPERATOR_IS_ALL,
27194 OPERATOR_IS_NOT_ALL
27195 ],
27196 format: {},
27197 getValueFormatted: get_value_formatted_default_default,
27198 validate: {
27199 required: isValidRequired,
27200 pattern: isValidPattern,
27201 minLength: isValidMinLength,
27202 maxLength: isValidMaxLength,
27203 elements: isValidElements,
27204 custom: isValidCustom
27205 }
27206 };
27207
27208 // packages/dataviews/build-module/field-types/integer.mjs
27209 var import_i18n39 = __toESM(require_i18n(), 1);
27210
27211 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
27212 var sort_number_default = (a2, b2, direction) => {
27213 return direction === "asc" ? a2 - b2 : b2 - a2;
27214 };
27215
27216 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
27217 function isValidMin(item, field) {
27218 if (typeof field.isValid.min?.constraint !== "number") {
27219 return false;
27220 }
27221 const value = field.getValue({ item });
27222 if ([void 0, "", null].includes(value)) {
27223 return true;
27224 }
27225 return Number(value) >= field.isValid.min.constraint;
27226 }
27227
27228 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
27229 function isValidMax(item, field) {
27230 if (typeof field.isValid.max?.constraint !== "number") {
27231 return false;
27232 }
27233 const value = field.getValue({ item });
27234 if ([void 0, "", null].includes(value)) {
27235 return true;
27236 }
27237 return Number(value) <= field.isValid.max.constraint;
27238 }
27239
27240 // packages/dataviews/build-module/field-types/integer.mjs
27241 var format2 = {
27242 separatorThousand: ","
27243 };
27244 function getValueFormatted2({
27245 item,
27246 field
27247 }) {
27248 let value = field.getValue({ item });
27249 if (value === null || value === void 0) {
27250 return "";
27251 }
27252 value = Number(value);
27253 if (!Number.isFinite(value)) {
27254 return String(value);
27255 }
27256 let formatInteger;
27257 if (field.type !== "integer") {
27258 formatInteger = format2;
27259 } else {
27260 formatInteger = field.format;
27261 }
27262 const { separatorThousand } = formatInteger;
27263 const integerValue = Math.trunc(value);
27264 if (!separatorThousand) {
27265 return String(integerValue);
27266 }
27267 return String(integerValue).replace(
27268 /\B(?=(\d{3})+(?!\d))/g,
27269 separatorThousand
27270 );
27271 }
27272 function isValidCustom2(item, field) {
27273 const value = field.getValue({ item });
27274 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
27275 return (0, import_i18n39.__)("Value must be an integer.");
27276 }
27277 return null;
27278 }
27279 var integer_default = {
27280 type: "integer",
27281 render,
27282 Edit: "integer",
27283 sort: sort_number_default,
27284 enableSorting: true,
27285 enableGlobalSearch: false,
27286 defaultOperators: [
27287 OPERATOR_IS,
27288 OPERATOR_IS_NOT,
27289 OPERATOR_LESS_THAN,
27290 OPERATOR_GREATER_THAN,
27291 OPERATOR_LESS_THAN_OR_EQUAL,
27292 OPERATOR_GREATER_THAN_OR_EQUAL,
27293 OPERATOR_BETWEEN
27294 ],
27295 validOperators: [
27296 // Single-selection
27297 OPERATOR_IS,
27298 OPERATOR_IS_NOT,
27299 OPERATOR_LESS_THAN,
27300 OPERATOR_GREATER_THAN,
27301 OPERATOR_LESS_THAN_OR_EQUAL,
27302 OPERATOR_GREATER_THAN_OR_EQUAL,
27303 OPERATOR_BETWEEN,
27304 // Multiple-selection
27305 OPERATOR_IS_ANY,
27306 OPERATOR_IS_NONE,
27307 OPERATOR_IS_ALL,
27308 OPERATOR_IS_NOT_ALL
27309 ],
27310 format: format2,
27311 getValueFormatted: getValueFormatted2,
27312 validate: {
27313 required: isValidRequired,
27314 min: isValidMin,
27315 max: isValidMax,
27316 elements: isValidElements,
27317 custom: isValidCustom2
27318 }
27319 };
27320
27321 // packages/dataviews/build-module/field-types/number.mjs
27322 var import_i18n40 = __toESM(require_i18n(), 1);
27323 var format3 = {
27324 separatorThousand: ",",
27325 separatorDecimal: ".",
27326 decimals: 2
27327 };
27328 function getValueFormatted3({
27329 item,
27330 field
27331 }) {
27332 let value = field.getValue({ item });
27333 if (value === null || value === void 0) {
27334 return "";
27335 }
27336 value = Number(value);
27337 if (!Number.isFinite(value)) {
27338 return String(value);
27339 }
27340 let formatNumber;
27341 if (field.type !== "number") {
27342 formatNumber = format3;
27343 } else {
27344 formatNumber = field.format;
27345 }
27346 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
27347 const fixedValue = value.toFixed(decimals);
27348 const [integerPart, decimalPart] = fixedValue.split(".");
27349 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
27350 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
27351 }
27352 function isEmpty(value) {
27353 return value === "" || value === void 0 || value === null;
27354 }
27355 function isValidCustom3(item, field) {
27356 const value = field.getValue({ item });
27357 if (!isEmpty(value) && !Number.isFinite(value)) {
27358 return (0, import_i18n40.__)("Value must be a number.");
27359 }
27360 return null;
27361 }
27362 var number_default = {
27363 type: "number",
27364 render,
27365 Edit: "number",
27366 sort: sort_number_default,
27367 enableSorting: true,
27368 enableGlobalSearch: false,
27369 defaultOperators: [
27370 OPERATOR_IS,
27371 OPERATOR_IS_NOT,
27372 OPERATOR_LESS_THAN,
27373 OPERATOR_GREATER_THAN,
27374 OPERATOR_LESS_THAN_OR_EQUAL,
27375 OPERATOR_GREATER_THAN_OR_EQUAL,
27376 OPERATOR_BETWEEN
27377 ],
27378 validOperators: [
27379 // Single-selection
27380 OPERATOR_IS,
27381 OPERATOR_IS_NOT,
27382 OPERATOR_LESS_THAN,
27383 OPERATOR_GREATER_THAN,
27384 OPERATOR_LESS_THAN_OR_EQUAL,
27385 OPERATOR_GREATER_THAN_OR_EQUAL,
27386 OPERATOR_BETWEEN,
27387 // Multiple-selection
27388 OPERATOR_IS_ANY,
27389 OPERATOR_IS_NONE,
27390 OPERATOR_IS_ALL,
27391 OPERATOR_IS_NOT_ALL
27392 ],
27393 format: format3,
27394 getValueFormatted: getValueFormatted3,
27395 validate: {
27396 required: isValidRequired,
27397 min: isValidMin,
27398 max: isValidMax,
27399 elements: isValidElements,
27400 custom: isValidCustom3
27401 }
27402 };
27403
27404 // packages/dataviews/build-module/field-types/text.mjs
27405 var text_default = {
27406 type: "text",
27407 render,
27408 Edit: "text",
27409 sort: sort_text_default,
27410 enableSorting: true,
27411 enableGlobalSearch: false,
27412 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27413 validOperators: [
27414 // Single selection
27415 OPERATOR_IS,
27416 OPERATOR_IS_NOT,
27417 OPERATOR_CONTAINS,
27418 OPERATOR_NOT_CONTAINS,
27419 OPERATOR_STARTS_WITH,
27420 // Multiple selection
27421 OPERATOR_IS_ANY,
27422 OPERATOR_IS_NONE,
27423 OPERATOR_IS_ALL,
27424 OPERATOR_IS_NOT_ALL
27425 ],
27426 format: {},
27427 getValueFormatted: get_value_formatted_default_default,
27428 validate: {
27429 required: isValidRequired,
27430 pattern: isValidPattern,
27431 minLength: isValidMinLength,
27432 maxLength: isValidMaxLength,
27433 elements: isValidElements
27434 }
27435 };
27436
27437 // packages/dataviews/build-module/field-types/datetime.mjs
27438 var import_date7 = __toESM(require_date(), 1);
27439
27440 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
27441 var import_date6 = __toESM(require_date(), 1);
27442 function parseDateLike(value) {
27443 if (!value) {
27444 return null;
27445 }
27446 if (!isValid(new Date(value))) {
27447 return null;
27448 }
27449 const parsed = (0, import_date6.getDate)(value);
27450 return parsed && isValid(parsed) ? parsed : null;
27451 }
27452 function validateDateLikeBoundary(item, field, boundary) {
27453 const constraint = field.isValid[boundary]?.constraint;
27454 if (typeof constraint !== "string") {
27455 return false;
27456 }
27457 const value = field.getValue({ item });
27458 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
27459 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
27460 return true;
27461 }
27462 const parsedConstraint = parseDateLike(constraint);
27463 const parsedValue = parseDateLike(String(boundaryValue));
27464 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
27465 }
27466 function isValidMinDate(item, field) {
27467 return validateDateLikeBoundary(item, field, "min");
27468 }
27469 function isValidMaxDate(item, field) {
27470 return validateDateLikeBoundary(item, field, "max");
27471 }
27472
27473 // packages/dataviews/build-module/field-types/datetime.mjs
27474 var format4 = {
27475 datetime: (0, import_date7.getSettings)().formats.datetime,
27476 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
27477 };
27478 function getValueFormatted4({
27479 item,
27480 field
27481 }) {
27482 const value = field.getValue({ item });
27483 if (["", void 0, null].includes(value)) {
27484 return "";
27485 }
27486 let formatDatetime;
27487 if (field.type !== "datetime") {
27488 formatDatetime = format4;
27489 } else {
27490 formatDatetime = field.format;
27491 }
27492 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
27493 }
27494 var sort = (a2, b2, direction) => {
27495 const timeA = new Date(a2).getTime();
27496 const timeB = new Date(b2).getTime();
27497 return direction === "asc" ? timeA - timeB : timeB - timeA;
27498 };
27499 var datetime_default = {
27500 type: "datetime",
27501 render,
27502 Edit: "datetime",
27503 sort,
27504 enableSorting: true,
27505 enableGlobalSearch: false,
27506 defaultOperators: [
27507 OPERATOR_ON,
27508 OPERATOR_NOT_ON,
27509 OPERATOR_BEFORE,
27510 OPERATOR_AFTER,
27511 OPERATOR_BEFORE_INC,
27512 OPERATOR_AFTER_INC,
27513 OPERATOR_IN_THE_PAST,
27514 OPERATOR_OVER
27515 ],
27516 validOperators: [
27517 OPERATOR_ON,
27518 OPERATOR_NOT_ON,
27519 OPERATOR_BEFORE,
27520 OPERATOR_AFTER,
27521 OPERATOR_BEFORE_INC,
27522 OPERATOR_AFTER_INC,
27523 OPERATOR_IN_THE_PAST,
27524 OPERATOR_OVER
27525 ],
27526 format: format4,
27527 getValueFormatted: getValueFormatted4,
27528 validate: {
27529 required: isValidRequired,
27530 elements: isValidElements,
27531 min: isValidMinDate,
27532 max: isValidMaxDate
27533 }
27534 };
27535
27536 // packages/dataviews/build-module/field-types/date.mjs
27537 var import_date8 = __toESM(require_date(), 1);
27538 var format5 = {
27539 date: (0, import_date8.getSettings)().formats.date,
27540 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
27541 };
27542 function getValueFormatted5({
27543 item,
27544 field
27545 }) {
27546 const value = field.getValue({ item });
27547 if (["", void 0, null].includes(value)) {
27548 return "";
27549 }
27550 let formatDate2;
27551 if (field.type !== "date") {
27552 formatDate2 = format5;
27553 } else {
27554 formatDate2 = field.format;
27555 }
27556 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
27557 }
27558 var sort2 = (a2, b2, direction) => {
27559 const timeA = new Date(a2).getTime();
27560 const timeB = new Date(b2).getTime();
27561 return direction === "asc" ? timeA - timeB : timeB - timeA;
27562 };
27563 var date_default = {
27564 type: "date",
27565 render,
27566 Edit: "date",
27567 sort: sort2,
27568 enableSorting: true,
27569 enableGlobalSearch: false,
27570 defaultOperators: [
27571 OPERATOR_ON,
27572 OPERATOR_NOT_ON,
27573 OPERATOR_BEFORE,
27574 OPERATOR_AFTER,
27575 OPERATOR_BEFORE_INC,
27576 OPERATOR_AFTER_INC,
27577 OPERATOR_IN_THE_PAST,
27578 OPERATOR_OVER,
27579 OPERATOR_BETWEEN
27580 ],
27581 validOperators: [
27582 OPERATOR_ON,
27583 OPERATOR_NOT_ON,
27584 OPERATOR_BEFORE,
27585 OPERATOR_AFTER,
27586 OPERATOR_BEFORE_INC,
27587 OPERATOR_AFTER_INC,
27588 OPERATOR_IN_THE_PAST,
27589 OPERATOR_OVER,
27590 OPERATOR_BETWEEN
27591 ],
27592 format: format5,
27593 getValueFormatted: getValueFormatted5,
27594 validate: {
27595 required: isValidRequired,
27596 elements: isValidElements,
27597 min: isValidMinDate,
27598 max: isValidMaxDate
27599 }
27600 };
27601
27602 // packages/dataviews/build-module/field-types/boolean.mjs
27603 var import_i18n41 = __toESM(require_i18n(), 1);
27604
27605 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
27606 function isValidRequiredForBool(item, field) {
27607 const value = field.getValue({ item });
27608 return value === true;
27609 }
27610
27611 // packages/dataviews/build-module/field-types/boolean.mjs
27612 function getValueFormatted6({
27613 item,
27614 field
27615 }) {
27616 const value = field.getValue({ item });
27617 if (value === true) {
27618 return (0, import_i18n41.__)("True");
27619 }
27620 if (value === false) {
27621 return (0, import_i18n41.__)("False");
27622 }
27623 return "";
27624 }
27625 function isValidCustom4(item, field) {
27626 const value = field.getValue({ item });
27627 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
27628 return (0, import_i18n41.__)("Value must be true, false, or undefined");
27629 }
27630 return null;
27631 }
27632 var sort3 = (a2, b2, direction) => {
27633 const boolA = Boolean(a2);
27634 const boolB = Boolean(b2);
27635 if (boolA === boolB) {
27636 return 0;
27637 }
27638 if (direction === "asc") {
27639 return boolA ? 1 : -1;
27640 }
27641 return boolA ? -1 : 1;
27642 };
27643 var boolean_default = {
27644 type: "boolean",
27645 render,
27646 Edit: "checkbox",
27647 sort: sort3,
27648 validate: {
27649 required: isValidRequiredForBool,
27650 elements: isValidElements,
27651 custom: isValidCustom4
27652 },
27653 enableSorting: true,
27654 enableGlobalSearch: false,
27655 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27656 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27657 format: {},
27658 getValueFormatted: getValueFormatted6
27659 };
27660
27661 // packages/dataviews/build-module/field-types/media.mjs
27662 var media_default = {
27663 type: "media",
27664 render: () => null,
27665 Edit: null,
27666 sort: () => 0,
27667 enableSorting: false,
27668 enableGlobalSearch: false,
27669 defaultOperators: [],
27670 validOperators: [],
27671 format: {},
27672 getValueFormatted: get_value_formatted_default_default,
27673 // cannot validate any constraint, so
27674 // the only available validation for the field author
27675 // would be providing a custom validator.
27676 validate: {}
27677 };
27678
27679 // packages/dataviews/build-module/field-types/array.mjs
27680 var import_i18n42 = __toESM(require_i18n(), 1);
27681
27682 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
27683 function isValidRequiredForArray(item, field) {
27684 const value = field.getValue({ item });
27685 return Array.isArray(value) && value.length > 0 && value.every(
27686 (element) => ![void 0, "", null].includes(element)
27687 );
27688 }
27689
27690 // packages/dataviews/build-module/field-types/array.mjs
27691 function getValueFormatted7({
27692 item,
27693 field
27694 }) {
27695 const value = field.getValue({ item });
27696 const arr = Array.isArray(value) ? value : [];
27697 return arr.join(", ");
27698 }
27699 function render2({ item, field }) {
27700 return getValueFormatted7({ item, field });
27701 }
27702 function isValidCustom5(item, field) {
27703 const value = field.getValue({ item });
27704 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
27705 return (0, import_i18n42.__)("Value must be an array.");
27706 }
27707 if (!value.every((v2) => typeof v2 === "string")) {
27708 return (0, import_i18n42.__)("Every value must be a string.");
27709 }
27710 return null;
27711 }
27712 var sort4 = (a2, b2, direction) => {
27713 const arrA = Array.isArray(a2) ? a2 : [];
27714 const arrB = Array.isArray(b2) ? b2 : [];
27715 if (arrA.length !== arrB.length) {
27716 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
27717 }
27718 const joinedA = arrA.join(",");
27719 const joinedB = arrB.join(",");
27720 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
27721 };
27722 var array_default = {
27723 type: "array",
27724 render: render2,
27725 Edit: "array",
27726 sort: sort4,
27727 enableSorting: true,
27728 enableGlobalSearch: false,
27729 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27730 validOperators: [
27731 OPERATOR_IS_ANY,
27732 OPERATOR_IS_NONE,
27733 OPERATOR_IS_ALL,
27734 OPERATOR_IS_NOT_ALL
27735 ],
27736 format: {},
27737 getValueFormatted: getValueFormatted7,
27738 validate: {
27739 required: isValidRequiredForArray,
27740 elements: isValidElements,
27741 custom: isValidCustom5
27742 }
27743 };
27744
27745 // packages/dataviews/build-module/field-types/password.mjs
27746 function getValueFormatted8({
27747 item,
27748 field
27749 }) {
27750 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
27751 }
27752 var password_default = {
27753 type: "password",
27754 render,
27755 Edit: "password",
27756 sort: () => 0,
27757 // Passwords should not be sortable for security reasons
27758 enableSorting: false,
27759 enableGlobalSearch: false,
27760 defaultOperators: [],
27761 validOperators: [],
27762 format: {},
27763 getValueFormatted: getValueFormatted8,
27764 validate: {
27765 required: isValidRequired,
27766 pattern: isValidPattern,
27767 minLength: isValidMinLength,
27768 maxLength: isValidMaxLength,
27769 elements: isValidElements
27770 }
27771 };
27772
27773 // packages/dataviews/build-module/field-types/telephone.mjs
27774 var telephone_default = {
27775 type: "telephone",
27776 render,
27777 Edit: "telephone",
27778 sort: sort_text_default,
27779 enableSorting: true,
27780 enableGlobalSearch: false,
27781 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27782 validOperators: [
27783 OPERATOR_IS,
27784 OPERATOR_IS_NOT,
27785 OPERATOR_CONTAINS,
27786 OPERATOR_NOT_CONTAINS,
27787 OPERATOR_STARTS_WITH,
27788 // Multiple selection
27789 OPERATOR_IS_ANY,
27790 OPERATOR_IS_NONE,
27791 OPERATOR_IS_ALL,
27792 OPERATOR_IS_NOT_ALL
27793 ],
27794 format: {},
27795 getValueFormatted: get_value_formatted_default_default,
27796 validate: {
27797 required: isValidRequired,
27798 pattern: isValidPattern,
27799 minLength: isValidMinLength,
27800 maxLength: isValidMaxLength,
27801 elements: isValidElements
27802 }
27803 };
27804
27805 // packages/dataviews/build-module/field-types/color.mjs
27806 var import_i18n43 = __toESM(require_i18n(), 1);
27807 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
27808 function render3({ item, field }) {
27809 if (field.hasElements) {
27810 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(RenderFromElements, { item, field });
27811 }
27812 const value = get_value_formatted_default_default({ item, field });
27813 if (!value || !w(value).isValid()) {
27814 return value;
27815 }
27816 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
27817 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
27818 "div",
27819 {
27820 style: {
27821 width: "16px",
27822 height: "16px",
27823 borderRadius: "50%",
27824 backgroundColor: value,
27825 border: "1px solid #ddd",
27826 flexShrink: 0
27827 }
27828 }
27829 ),
27830 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: value })
27831 ] });
27832 }
27833 function isValidCustom6(item, field) {
27834 const value = field.getValue({ item });
27835 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
27836 return (0, import_i18n43.__)("Value must be a valid color.");
27837 }
27838 return null;
27839 }
27840 var sort5 = (a2, b2, direction) => {
27841 const colorA = w(a2);
27842 const colorB = w(b2);
27843 if (!colorA.isValid() && !colorB.isValid()) {
27844 return 0;
27845 }
27846 if (!colorA.isValid()) {
27847 return direction === "asc" ? 1 : -1;
27848 }
27849 if (!colorB.isValid()) {
27850 return direction === "asc" ? -1 : 1;
27851 }
27852 const hslA = colorA.toHsl();
27853 const hslB = colorB.toHsl();
27854 if (hslA.h !== hslB.h) {
27855 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
27856 }
27857 if (hslA.s !== hslB.s) {
27858 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
27859 }
27860 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
27861 };
27862 var color_default = {
27863 type: "color",
27864 render: render3,
27865 Edit: "color",
27866 sort: sort5,
27867 enableSorting: true,
27868 enableGlobalSearch: false,
27869 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27870 validOperators: [
27871 OPERATOR_IS,
27872 OPERATOR_IS_NOT,
27873 OPERATOR_IS_ANY,
27874 OPERATOR_IS_NONE
27875 ],
27876 format: {},
27877 getValueFormatted: get_value_formatted_default_default,
27878 validate: {
27879 required: isValidRequired,
27880 elements: isValidElements,
27881 custom: isValidCustom6
27882 }
27883 };
27884
27885 // packages/dataviews/build-module/field-types/url.mjs
27886 var url_default = {
27887 type: "url",
27888 render,
27889 Edit: "url",
27890 sort: sort_text_default,
27891 enableSorting: true,
27892 enableGlobalSearch: false,
27893 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27894 validOperators: [
27895 OPERATOR_IS,
27896 OPERATOR_IS_NOT,
27897 OPERATOR_CONTAINS,
27898 OPERATOR_NOT_CONTAINS,
27899 OPERATOR_STARTS_WITH,
27900 // Multiple selection
27901 OPERATOR_IS_ANY,
27902 OPERATOR_IS_NONE,
27903 OPERATOR_IS_ALL,
27904 OPERATOR_IS_NOT_ALL
27905 ],
27906 format: {},
27907 getValueFormatted: get_value_formatted_default_default,
27908 validate: {
27909 required: isValidRequired,
27910 pattern: isValidPattern,
27911 minLength: isValidMinLength,
27912 maxLength: isValidMaxLength,
27913 elements: isValidElements
27914 }
27915 };
27916
27917 // packages/dataviews/build-module/field-types/no-type.mjs
27918 var sort6 = (a2, b2, direction) => {
27919 if (typeof a2 === "number" && typeof b2 === "number") {
27920 return sort_number_default(a2, b2, direction);
27921 }
27922 return sort_text_default(a2, b2, direction);
27923 };
27924 var no_type_default = {
27925 // type: no type for this one
27926 render,
27927 Edit: null,
27928 sort: sort6,
27929 enableSorting: true,
27930 enableGlobalSearch: false,
27931 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27932 validOperators: getAllOperatorNames(),
27933 format: {},
27934 getValueFormatted: get_value_formatted_default_default,
27935 validate: {
27936 required: isValidRequired,
27937 elements: isValidElements
27938 }
27939 };
27940
27941 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
27942 function supportsNumericRangeConstraint(type) {
27943 return type === "integer" || type === "number";
27944 }
27945 function supportsDateRangeConstraint(type) {
27946 return type === "date" || type === "datetime";
27947 }
27948 function normalizeRangeRule(value, fieldType, key) {
27949 const validator = fieldType.validate[key];
27950 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
27951 return { constraint: value, validate: validator };
27952 }
27953 return void 0;
27954 }
27955 function getIsValid(field, fieldType) {
27956 const rules = field.isValid;
27957 let required;
27958 if (rules?.required === true && fieldType.validate.required !== void 0) {
27959 required = {
27960 constraint: true,
27961 validate: fieldType.validate.required
27962 };
27963 }
27964 let elements;
27965 if ((rules?.elements === true || // elements is enabled unless the field opts-out
27966 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
27967 elements = {
27968 constraint: true,
27969 validate: fieldType.validate.elements
27970 };
27971 }
27972 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
27973 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
27974 const minLengthValue = rules?.minLength;
27975 let minLength;
27976 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
27977 minLength = {
27978 constraint: minLengthValue,
27979 validate: fieldType.validate.minLength
27980 };
27981 }
27982 const maxLengthValue = rules?.maxLength;
27983 let maxLength;
27984 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
27985 maxLength = {
27986 constraint: maxLengthValue,
27987 validate: fieldType.validate.maxLength
27988 };
27989 }
27990 const patternValue = rules?.pattern;
27991 let pattern;
27992 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
27993 pattern = {
27994 constraint: patternValue,
27995 validate: fieldType.validate.pattern
27996 };
27997 }
27998 const custom = rules?.custom ?? fieldType.validate.custom;
27999 return {
28000 required,
28001 elements,
28002 min: min2,
28003 max: max2,
28004 minLength,
28005 maxLength,
28006 pattern,
28007 custom
28008 };
28009 }
28010
28011 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
28012 function getFilter(fieldType) {
28013 return fieldType.validOperators.reduce((accumulator, operator) => {
28014 const operatorObj = getOperatorByName(operator);
28015 if (operatorObj?.filter) {
28016 accumulator[operator] = operatorObj.filter;
28017 }
28018 return accumulator;
28019 }, {});
28020 }
28021
28022 // packages/dataviews/build-module/field-types/utils/get-format.mjs
28023 function getFormat(field, fieldType) {
28024 return {
28025 ...fieldType.format,
28026 ...field.format
28027 };
28028 }
28029 var get_format_default = getFormat;
28030
28031 // packages/dataviews/build-module/field-types/index.mjs
28032 function getFieldTypeByName(type) {
28033 const found = [
28034 email_default,
28035 integer_default,
28036 number_default,
28037 text_default,
28038 datetime_default,
28039 date_default,
28040 boolean_default,
28041 media_default,
28042 array_default,
28043 password_default,
28044 telephone_default,
28045 color_default,
28046 url_default
28047 ].find((fieldType) => fieldType?.type === type);
28048 if (!!found) {
28049 return found;
28050 }
28051 return no_type_default;
28052 }
28053 function normalizeFields(fields2) {
28054 return fields2.map((field) => {
28055 const fieldType = getFieldTypeByName(field.type);
28056 const getValue = field.getValue || get_value_from_id_default(field.id);
28057 const sort7 = function(a2, b2, direction) {
28058 const aValue = getValue({ item: a2 });
28059 const bValue = getValue({ item: b2 });
28060 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
28061 };
28062 return {
28063 id: field.id,
28064 label: field.label || field.id,
28065 header: field.header || field.label || field.id,
28066 description: field.description,
28067 placeholder: field.placeholder,
28068 getValue,
28069 setValue: field.setValue || set_value_from_id_default(field.id),
28070 elements: field.elements,
28071 getElements: field.getElements,
28072 hasElements: hasElements(field),
28073 isVisible: field.isVisible,
28074 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
28075 enableHiding: field.enableHiding ?? true,
28076 readOnly: field.readOnly ?? false,
28077 // The type provides defaults for the following props
28078 type: fieldType.type,
28079 render: field.render ?? fieldType.render,
28080 Edit: getControl(field, fieldType.Edit),
28081 sort: sort7,
28082 enableSorting: field.enableSorting ?? fieldType.enableSorting,
28083 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
28084 isValid: getIsValid(field, fieldType),
28085 filterBy: get_filter_by_default(
28086 field,
28087 fieldType.defaultOperators,
28088 fieldType.validOperators
28089 ),
28090 filter: getFilter(fieldType),
28091 format: get_format_default(field, fieldType),
28092 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
28093 };
28094 });
28095 }
28096
28097 // packages/dataviews/build-module/hooks/use-data.mjs
28098 var import_element91 = __toESM(require_element(), 1);
28099 function useData({
28100 view,
28101 data: shownData,
28102 getItemId,
28103 isLoading,
28104 paginationInfo,
28105 selection
28106 }) {
28107 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
28108 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element91.useState)(
28109 !isLoading
28110 );
28111 (0, import_element91.useEffect)(() => {
28112 if (!isLoading) {
28113 setHasInitiallyLoaded(true);
28114 }
28115 }, [isLoading]);
28116 const previousDataRef = (0, import_element91.useRef)(shownData);
28117 const previousPaginationInfoRef = (0, import_element91.useRef)(paginationInfo);
28118 (0, import_element91.useEffect)(() => {
28119 if (!isLoading) {
28120 previousDataRef.current = shownData;
28121 previousPaginationInfoRef.current = paginationInfo;
28122 }
28123 }, [shownData, isLoading, paginationInfo]);
28124 const [visibleEntries, setVisibleEntries] = (0, import_element91.useState)([]);
28125 const positionMapRef = (0, import_element91.useRef)(/* @__PURE__ */ new Map());
28126 const allLoadedRecordsRef = (0, import_element91.useRef)([]);
28127 const prevViewParamsRef = (0, import_element91.useRef)({
28128 search: void 0,
28129 filters: void 0,
28130 perPage: void 0
28131 });
28132 const scrollDirectionRef = (0, import_element91.useRef)(void 0);
28133 const prevStartPositionRef = (0, import_element91.useRef)(void 0);
28134 const hasInitializedRef = (0, import_element91.useRef)(false);
28135 const allLoadedRecords = (0, import_element91.useMemo)(() => {
28136 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
28137 if (view.startPosition < prevStartPositionRef.current) {
28138 scrollDirectionRef.current = "up";
28139 } else if (view.startPosition > prevStartPositionRef.current) {
28140 scrollDirectionRef.current = "down";
28141 }
28142 }
28143 prevStartPositionRef.current = view.startPosition;
28144 const currentFiltersKey = JSON.stringify(view.filters ?? []);
28145 const prevFiltersKey = prevViewParamsRef.current.filters;
28146 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
28147 hasInitializedRef.current = true;
28148 prevViewParamsRef.current = {
28149 search: view.search,
28150 filters: currentFiltersKey,
28151 perPage: view.perPage
28152 };
28153 if (shouldReset) {
28154 positionMapRef.current.clear();
28155 scrollDirectionRef.current = void 0;
28156 const startPosition = view.search ? 1 : view.startPosition ?? 1;
28157 const records = shownData.map((record, index2) => {
28158 const position = startPosition + index2;
28159 positionMapRef.current.set(getItemId(record), position);
28160 return {
28161 ...record,
28162 position
28163 };
28164 });
28165 allLoadedRecordsRef.current = records;
28166 return records;
28167 }
28168 const prev = allLoadedRecordsRef.current;
28169 const shownDataIds = new Set(shownData.map(getItemId));
28170 const scrollDirection = scrollDirectionRef.current;
28171 const basePosition = view.search ? 1 : view.startPosition ?? 1;
28172 const newRecords = shownData.map((record, index2) => {
28173 const itemId = getItemId(record);
28174 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
28175 if (position !== void 0) {
28176 positionMapRef.current.set(itemId, position);
28177 }
28178 return {
28179 ...record,
28180 position
28181 };
28182 });
28183 if (newRecords.length === 0) {
28184 return prev;
28185 }
28186 const prevWithoutDuplicates = prev.filter(
28187 (record) => !shownDataIds.has(getItemId(record))
28188 );
28189 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
28190 allRecords.sort((a2, b2) => {
28191 const posA = a2.position;
28192 const posB = b2.position;
28193 return posA - posB;
28194 });
28195 let result = allRecords;
28196 if (visibleEntries.length > 0) {
28197 const visibleMin = Math.min(...visibleEntries);
28198 const visibleMax = Math.max(...visibleEntries);
28199 const buffer = 20;
28200 const recordPositions = allRecords.map(
28201 (r3) => r3.position
28202 );
28203 const minRecordPos = Math.min(...recordPositions);
28204 const maxRecordPos = Math.max(...recordPositions);
28205 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
28206 if (hasOverlap) {
28207 result = allRecords.filter((record) => {
28208 const itemId = getItemId(record);
28209 const isSelected2 = selection?.includes(itemId);
28210 if (isSelected2) {
28211 return true;
28212 }
28213 const itemPosition = record.position;
28214 if (scrollDirection === "up") {
28215 return itemPosition <= visibleMax + buffer;
28216 } else if (scrollDirection === "down") {
28217 return itemPosition >= visibleMin - buffer;
28218 }
28219 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
28220 });
28221 }
28222 }
28223 allLoadedRecordsRef.current = result;
28224 return result;
28225 }, [
28226 shownData,
28227 view.search,
28228 view.filters,
28229 view.perPage,
28230 view.startPosition,
28231 view.infiniteScrollEnabled,
28232 visibleEntries,
28233 selection,
28234 getItemId
28235 ]);
28236 if (!isInfiniteScrollEnabled) {
28237 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
28238 return {
28239 data: dataToReturn.map((item) => ({
28240 ...item,
28241 position: void 0
28242 })),
28243 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
28244 hasInitiallyLoaded,
28245 setVisibleEntries: void 0
28246 };
28247 }
28248 return {
28249 data: allLoadedRecords,
28250 paginationInfo,
28251 hasInitiallyLoaded,
28252 setVisibleEntries
28253 };
28254 }
28255
28256 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
28257 var import_element92 = __toESM(require_element(), 1);
28258 var import_compose13 = __toESM(require_compose(), 1);
28259 function captureAnchorElement(container, anchorElementRef, direction) {
28260 const containerRect = container.getBoundingClientRect();
28261 const centerY = containerRect.top + containerRect.height / 2;
28262 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
28263 if (items.length === 0) {
28264 return false;
28265 }
28266 const bestAnchor = items.reduce((best, item) => {
28267 const itemRect = item.getBoundingClientRect();
28268 const itemCenterY = itemRect.top + itemRect.height / 2;
28269 const distance = Math.abs(itemCenterY - centerY);
28270 const bestRect = best.getBoundingClientRect();
28271 const bestCenterY = bestRect.top + bestRect.height / 2;
28272 const bestDistance = Math.abs(bestCenterY - centerY);
28273 return distance < bestDistance ? item : best;
28274 });
28275 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
28276 const anchorRect = bestAnchor.getBoundingClientRect();
28277 anchorElementRef.current = {
28278 posinset,
28279 viewportOffset: anchorRect.top - containerRect.top,
28280 scrollTop: container.scrollTop,
28281 direction
28282 };
28283 return true;
28284 }
28285 function useInfiniteScroll({
28286 view,
28287 onChangeView,
28288 isLoading,
28289 paginationInfo,
28290 containerRef,
28291 setVisibleEntries
28292 }) {
28293 const anchorElementRef = (0, import_element92.useRef)(null);
28294 const viewRef = (0, import_element92.useRef)(view);
28295 const isLoadingRef = (0, import_element92.useRef)(isLoading);
28296 const onChangeViewRef = (0, import_element92.useRef)(onChangeView);
28297 const totalItemsRef = (0, import_element92.useRef)(paginationInfo.totalItems);
28298 (0, import_element92.useLayoutEffect)(() => {
28299 viewRef.current = view;
28300 isLoadingRef.current = isLoading;
28301 onChangeViewRef.current = onChangeView;
28302 totalItemsRef.current = paginationInfo.totalItems;
28303 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
28304 const intersectionObserverCallback = (0, import_element92.useCallback)(
28305 (entries) => {
28306 if (!setVisibleEntries) {
28307 return;
28308 }
28309 setVisibleEntries((prev) => {
28310 const newVisibleEntries = new Set(prev);
28311 let hasChanged = false;
28312 entries.forEach((entry) => {
28313 const posInSet = Number(
28314 entry.target?.attributes?.getNamedItem(
28315 "aria-posinset"
28316 )?.value
28317 );
28318 if (isNaN(posInSet)) {
28319 return;
28320 }
28321 if (entry.isIntersecting) {
28322 if (!newVisibleEntries.has(posInSet)) {
28323 newVisibleEntries.add(posInSet);
28324 hasChanged = true;
28325 }
28326 } else if (newVisibleEntries.has(posInSet)) {
28327 newVisibleEntries.delete(posInSet);
28328 hasChanged = true;
28329 }
28330 });
28331 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
28332 });
28333 },
28334 [setVisibleEntries]
28335 );
28336 (0, import_element92.useLayoutEffect)(() => {
28337 const container = containerRef.current;
28338 const anchor = anchorElementRef.current;
28339 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
28340 return;
28341 }
28342 const anchorElement = container.querySelector(
28343 `[aria-posinset="${anchor.posinset}"]`
28344 );
28345 if (anchorElement) {
28346 const containerRect = container.getBoundingClientRect();
28347 const anchorRect = anchorElement.getBoundingClientRect();
28348 const currentOffset = anchorRect.top - containerRect.top;
28349 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
28350 if (Math.abs(scrollAdjustment) > 1) {
28351 container.scrollTop += scrollAdjustment;
28352 }
28353 }
28354 anchorElementRef.current = null;
28355 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
28356 const intersectionObserverRef = (0, import_element92.useRef)(
28357 null
28358 );
28359 (0, import_element92.useEffect)(() => {
28360 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
28361 if (intersectionObserverRef.current) {
28362 intersectionObserverRef.current.disconnect();
28363 intersectionObserverRef.current = null;
28364 }
28365 return;
28366 }
28367 intersectionObserverRef.current = new IntersectionObserver(
28368 intersectionObserverCallback,
28369 { root: null, rootMargin: "0px", threshold: 0.1 }
28370 );
28371 return () => {
28372 if (intersectionObserverRef.current) {
28373 intersectionObserverRef.current.disconnect();
28374 intersectionObserverRef.current = null;
28375 }
28376 };
28377 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
28378 (0, import_element92.useEffect)(() => {
28379 if (!view.infiniteScrollEnabled || !containerRef.current) {
28380 return;
28381 }
28382 let lastScrollTop = 0;
28383 const BOTTOM_THRESHOLD = 600;
28384 const TOP_THRESHOLD = 800;
28385 const handleScroll = (0, import_compose13.throttle)((event) => {
28386 const currentView = viewRef.current;
28387 const totalItems = totalItemsRef.current;
28388 const target = event.target;
28389 const scrollTop = target.scrollTop;
28390 const scrollHeight = target.scrollHeight;
28391 const clientHeight = target.clientHeight;
28392 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
28393 lastScrollTop = scrollTop;
28394 if (isLoadingRef.current) {
28395 return;
28396 }
28397 const currentStartPosition = currentView.startPosition || 1;
28398 const batchSize = currentView.perPage || 10;
28399 const currentEndPosition = Math.min(
28400 currentStartPosition + batchSize,
28401 totalItems
28402 );
28403 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
28404 if (currentEndPosition < totalItems) {
28405 const newStartPosition = currentEndPosition;
28406 captureAnchorElement(target, anchorElementRef, "down");
28407 onChangeViewRef.current({
28408 ...currentView,
28409 startPosition: newStartPosition
28410 });
28411 }
28412 }
28413 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
28414 if (currentStartPosition > 1) {
28415 const calculatedStartPosition = currentStartPosition - batchSize;
28416 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
28417 captureAnchorElement(target, anchorElementRef, "up");
28418 onChangeViewRef.current({
28419 ...currentView,
28420 startPosition: newStartPosition
28421 });
28422 }
28423 }
28424 }, 50);
28425 const container = containerRef.current;
28426 container.addEventListener("scroll", handleScroll);
28427 return () => {
28428 container.removeEventListener("scroll", handleScroll);
28429 handleScroll.cancel();
28430 };
28431 }, [containerRef, view.infiniteScrollEnabled]);
28432 return {
28433 intersectionObserver: intersectionObserverRef.current
28434 };
28435 }
28436
28437 // packages/dataviews/build-module/dataviews/index.mjs
28438 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28439 var defaultGetItemId = (item) => item.id;
28440 var defaultIsItemClickable = () => true;
28441 var EMPTY_ARRAY7 = [];
28442 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
28443 var dataViewsLayouts = VIEW_LAYOUTS.filter(
28444 (viewLayout) => !viewLayout.isPicker
28445 );
28446 function DefaultUI({
28447 header,
28448 search = true,
28449 searchLabel = void 0
28450 }) {
28451 const { view } = (0, import_element93.useContext)(dataviews_context_default);
28452 const isInfiniteScroll = view.infiniteScrollEnabled;
28453 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
28454 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28455 Stack,
28456 {
28457 direction: "row",
28458 align: "top",
28459 justify: "space-between",
28460 className: clsx_default("dataviews__view-actions", {
28461 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
28462 }),
28463 gap: "xs",
28464 children: [
28465 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28466 Stack,
28467 {
28468 direction: "row",
28469 justify: "start",
28470 gap: "sm",
28471 className: "dataviews__search",
28472 children: [
28473 search && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_search_default, { label: searchLabel }),
28474 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(toggle_default, {})
28475 ]
28476 }
28477 ),
28478 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28479 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_view_config_default, {}),
28480 header
28481 ] })
28482 ]
28483 }
28484 ),
28485 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
28486 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(DataViewsLayout, {}),
28487 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(DataViewsFooter, {})
28488 ] });
28489 }
28490 function DataViews({
28491 view,
28492 onChangeView,
28493 fields: fields2,
28494 search = true,
28495 searchLabel = void 0,
28496 actions = EMPTY_ARRAY7,
28497 data,
28498 getItemId = defaultGetItemId,
28499 getItemLevel,
28500 isLoading = false,
28501 paginationInfo,
28502 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
28503 selection: selectionProperty,
28504 onChangeSelection,
28505 onClickItem,
28506 renderItemLink,
28507 isItemClickable = defaultIsItemClickable,
28508 header,
28509 children,
28510 config = { perPageSizes: [10, 20, 50, 100] },
28511 empty,
28512 onReset
28513 }) {
28514 const [selectionState, setSelectionState] = (0, import_element93.useState)([]);
28515 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
28516 const selection = isUncontrolled ? selectionState : selectionProperty;
28517 const {
28518 data: displayData,
28519 paginationInfo: displayPaginationInfo,
28520 hasInitiallyLoaded,
28521 setVisibleEntries
28522 } = useData({
28523 view,
28524 data,
28525 getItemId,
28526 isLoading,
28527 selection,
28528 paginationInfo
28529 });
28530 const containerRef = (0, import_element93.useRef)(null);
28531 const [containerWidth, setContainerWidth] = (0, import_element93.useState)(0);
28532 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
28533 (resizeObserverEntries) => {
28534 setContainerWidth(
28535 resizeObserverEntries[0].borderBoxSize[0].inlineSize
28536 );
28537 },
28538 { box: "border-box" }
28539 );
28540 const [openedFilter, setOpenedFilter] = (0, import_element93.useState)(null);
28541 function setSelectionWithChange(value) {
28542 const newValue = typeof value === "function" ? value(selection) : value;
28543 if (isUncontrolled) {
28544 setSelectionState(newValue);
28545 }
28546 if (onChangeSelection) {
28547 onChangeSelection(newValue);
28548 }
28549 }
28550 const _fields = (0, import_element93.useMemo)(() => normalizeFields(fields2), [fields2]);
28551 const _selection = (0, import_element93.useMemo)(() => {
28552 if (view.infiniteScrollEnabled) {
28553 return selection;
28554 }
28555 return selection.filter(
28556 (id) => data.some((item) => getItemId(item) === id)
28557 );
28558 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
28559 const filters = use_filters_default(_fields, view);
28560 const hasPrimaryOrLockedFilters = (0, import_element93.useMemo)(
28561 () => (filters || []).some(
28562 (filter) => filter.isPrimary || filter.isLocked
28563 ),
28564 [filters]
28565 );
28566 const [isShowingFilter, setIsShowingFilter] = (0, import_element93.useState)(
28567 hasPrimaryOrLockedFilters
28568 );
28569 const { intersectionObserver } = useInfiniteScroll({
28570 view,
28571 onChangeView,
28572 isLoading,
28573 paginationInfo,
28574 containerRef,
28575 setVisibleEntries
28576 });
28577 (0, import_element93.useEffect)(() => {
28578 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
28579 setIsShowingFilter(true);
28580 }
28581 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
28582 const defaultLayouts = (0, import_element93.useMemo)(
28583 () => Object.fromEntries(
28584 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
28585 return dataViewsLayouts.some(
28586 (viewLayout) => viewLayout.type === layoutType
28587 );
28588 }).map(([key, value]) => [
28589 key,
28590 value === true ? {} : value
28591 ])
28592 ),
28593 [defaultLayoutsProperty]
28594 );
28595 if (!defaultLayouts[view.type]) {
28596 return null;
28597 }
28598 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28599 dataviews_context_default.Provider,
28600 {
28601 value: {
28602 view,
28603 onChangeView,
28604 fields: _fields,
28605 actions,
28606 data: displayData,
28607 isLoading,
28608 paginationInfo: displayPaginationInfo,
28609 selection: _selection,
28610 onChangeSelection: setSelectionWithChange,
28611 openedFilter,
28612 setOpenedFilter,
28613 getItemId,
28614 getItemLevel,
28615 isItemClickable,
28616 onClickItem,
28617 renderItemLink,
28618 containerWidth,
28619 containerRef,
28620 resizeObserverRef,
28621 defaultLayouts,
28622 filters,
28623 isShowingFilter,
28624 setIsShowingFilter,
28625 config,
28626 empty,
28627 hasInitiallyLoaded,
28628 onReset,
28629 intersectionObserver
28630 },
28631 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28632 DefaultUI,
28633 {
28634 header,
28635 search,
28636 searchLabel
28637 }
28638 ) })
28639 }
28640 );
28641 }
28642 var DataViewsSubComponents = DataViews;
28643 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
28644 DataViewsSubComponents.Filters = filters_default;
28645 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
28646 DataViewsSubComponents.FiltersToggle = toggle_default;
28647 DataViewsSubComponents.Layout = DataViewsLayout;
28648 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
28649 DataViewsSubComponents.Pagination = DataViewsPagination;
28650 DataViewsSubComponents.Search = dataviews_search_default;
28651 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
28652 DataViewsSubComponents.Footer = DataViewsFooter;
28653 var dataviews_default = DataViewsSubComponents;
28654
28655 // packages/dataviews/build-module/dataform/index.mjs
28656 var import_element105 = __toESM(require_element(), 1);
28657
28658 // packages/dataviews/build-module/components/dataform-context/index.mjs
28659 var import_element94 = __toESM(require_element(), 1);
28660 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
28661 var DataFormContext = (0, import_element94.createContext)({
28662 fields: []
28663 });
28664 DataFormContext.displayName = "DataFormContext";
28665 function DataFormProvider({
28666 fields: fields2,
28667 children
28668 }) {
28669 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children });
28670 }
28671 var dataform_context_default = DataFormContext;
28672
28673 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
28674 var import_element104 = __toESM(require_element(), 1);
28675
28676 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
28677 var import_element95 = __toESM(require_element(), 1);
28678 var import_components49 = __toESM(require_components(), 1);
28679
28680 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
28681 var import_i18n44 = __toESM(require_i18n(), 1);
28682 var DEFAULT_LAYOUT = {
28683 type: "regular",
28684 labelPosition: "top"
28685 };
28686 var normalizeCardSummaryField = (sum) => {
28687 if (typeof sum === "string") {
28688 return [{ id: sum, visibility: "when-collapsed" }];
28689 }
28690 return sum.map((item) => {
28691 if (typeof item === "string") {
28692 return { id: item, visibility: "when-collapsed" };
28693 }
28694 return { id: item.id, visibility: item.visibility };
28695 });
28696 };
28697 function normalizeLayout(layout) {
28698 let normalizedLayout = DEFAULT_LAYOUT;
28699 if (layout?.type === "regular") {
28700 normalizedLayout = {
28701 type: "regular",
28702 labelPosition: layout?.labelPosition ?? "top"
28703 };
28704 } else if (layout?.type === "panel") {
28705 const summary = layout.summary ?? [];
28706 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
28707 const openAs = layout?.openAs;
28708 let normalizedOpenAs;
28709 if (typeof openAs === "object" && openAs.type === "modal") {
28710 normalizedOpenAs = {
28711 type: "modal",
28712 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n44.__)("Apply"),
28713 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n44.__)("Cancel")
28714 };
28715 } else if (openAs === "modal") {
28716 normalizedOpenAs = {
28717 type: "modal",
28718 applyLabel: (0, import_i18n44.__)("Apply"),
28719 cancelLabel: (0, import_i18n44.__)("Cancel")
28720 };
28721 } else {
28722 normalizedOpenAs = { type: "dropdown" };
28723 }
28724 normalizedLayout = {
28725 type: "panel",
28726 labelPosition: layout?.labelPosition ?? "side",
28727 openAs: normalizedOpenAs,
28728 summary: normalizedSummary,
28729 editVisibility: layout?.editVisibility ?? "on-hover"
28730 };
28731 } else if (layout?.type === "card") {
28732 if (layout.withHeader === false) {
28733 normalizedLayout = {
28734 type: "card",
28735 withHeader: false,
28736 isOpened: true,
28737 summary: [],
28738 isCollapsible: false
28739 };
28740 } else {
28741 const summary = layout.summary ?? [];
28742 normalizedLayout = {
28743 type: "card",
28744 withHeader: true,
28745 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
28746 summary: normalizeCardSummaryField(summary),
28747 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
28748 };
28749 }
28750 } else if (layout?.type === "row") {
28751 normalizedLayout = {
28752 type: "row",
28753 alignment: layout?.alignment ?? "center",
28754 styles: layout?.styles ?? {}
28755 };
28756 } else if (layout?.type === "details") {
28757 normalizedLayout = {
28758 type: "details",
28759 summary: layout?.summary ?? ""
28760 };
28761 }
28762 return normalizedLayout;
28763 }
28764 function normalizeForm(form) {
28765 const normalizedFormLayout = normalizeLayout(form?.layout);
28766 const normalizedFields = (form.fields ?? []).map(
28767 (field) => {
28768 if (typeof field === "string") {
28769 return {
28770 id: field,
28771 layout: normalizedFormLayout
28772 };
28773 }
28774 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
28775 return {
28776 id: field.id,
28777 layout: fieldLayout,
28778 ...!!field.label && { label: field.label },
28779 ...!!field.description && {
28780 description: field.description
28781 },
28782 ..."children" in field && Array.isArray(field.children) && {
28783 children: normalizeForm({
28784 fields: field.children,
28785 layout: DEFAULT_LAYOUT
28786 }).fields
28787 }
28788 };
28789 }
28790 );
28791 return {
28792 layout: normalizedFormLayout,
28793 fields: normalizedFields
28794 };
28795 }
28796 var normalize_form_default = normalizeForm;
28797
28798 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
28799 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
28800 function Header4({ title }) {
28801 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28802 Stack,
28803 {
28804 direction: "column",
28805 className: "dataforms-layouts-regular__header",
28806 gap: "lg",
28807 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components49.__experimentalHeading, { level: 2, size: 13, children: title }) })
28808 }
28809 );
28810 }
28811 function FormRegularField({
28812 data,
28813 field,
28814 onChange,
28815 hideLabelFromVision,
28816 markWhenOptional,
28817 validity
28818 }) {
28819 const { fields: fields2 } = (0, import_element95.useContext)(dataform_context_default);
28820 const layout = field.layout;
28821 const form = (0, import_element95.useMemo)(
28822 () => ({
28823 layout: DEFAULT_LAYOUT,
28824 fields: !!field.children ? field.children : []
28825 }),
28826 [field]
28827 );
28828 if (!!field.children) {
28829 return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
28830 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Header4, { title: field.label }),
28831 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28832 DataFormLayout,
28833 {
28834 data,
28835 form,
28836 onChange,
28837 validity: validity?.children
28838 }
28839 )
28840 ] });
28841 }
28842 const labelPosition = layout.labelPosition;
28843 const fieldDefinition = fields2.find(
28844 (fieldDef) => fieldDef.id === field.id
28845 );
28846 if (!fieldDefinition || !fieldDefinition.Edit) {
28847 return null;
28848 }
28849 if (labelPosition === "side") {
28850 return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
28851 Stack,
28852 {
28853 direction: "row",
28854 className: "dataforms-layouts-regular__field",
28855 gap: "sm",
28856 children: [
28857 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28858 "div",
28859 {
28860 className: clsx_default(
28861 "dataforms-layouts-regular__field-label",
28862 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
28863 ),
28864 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components49.BaseControl.VisualLabel, { children: fieldDefinition.label })
28865 }
28866 ),
28867 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28868 fieldDefinition.render,
28869 {
28870 item: data,
28871 field: fieldDefinition
28872 }
28873 ) : /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28874 fieldDefinition.Edit,
28875 {
28876 data,
28877 field: fieldDefinition,
28878 onChange,
28879 hideLabelFromVision: true,
28880 markWhenOptional,
28881 validity
28882 },
28883 fieldDefinition.id
28884 ) })
28885 ]
28886 }
28887 );
28888 }
28889 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
28890 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components49.BaseControl.VisualLabel, { children: fieldDefinition.label }),
28891 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28892 fieldDefinition.render,
28893 {
28894 item: data,
28895 field: fieldDefinition
28896 }
28897 )
28898 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28899 fieldDefinition.Edit,
28900 {
28901 data,
28902 field: fieldDefinition,
28903 onChange,
28904 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
28905 markWhenOptional,
28906 validity
28907 }
28908 ) });
28909 }
28910
28911 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
28912 var import_deepmerge2 = __toESM(require_cjs(), 1);
28913 var import_components52 = __toESM(require_components(), 1);
28914 var import_element100 = __toESM(require_element(), 1);
28915 var import_compose16 = __toESM(require_compose(), 1);
28916
28917 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
28918 var import_components51 = __toESM(require_components(), 1);
28919 var import_i18n45 = __toESM(require_i18n(), 1);
28920 var import_compose15 = __toESM(require_compose(), 1);
28921 var import_element96 = __toESM(require_element(), 1);
28922
28923 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
28924 function getLabelClassName(labelPosition, showError) {
28925 return clsx_default(
28926 "dataforms-layouts-panel__field-label",
28927 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
28928 { "has-error": showError }
28929 );
28930 }
28931 var get_label_classname_default = getLabelClassName;
28932
28933 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
28934 var import_components50 = __toESM(require_components(), 1);
28935 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
28936 function getLabelContent(showError, errorMessage, fieldLabel) {
28937 return showError ? /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(tooltip_exports.Root, { children: [
28938 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28939 tooltip_exports.Trigger,
28940 {
28941 render: /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
28942 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components50.Icon, { icon: error_default, size: 16 }),
28943 /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(VisuallyHidden, { children: [
28944 errorMessage,
28945 ": "
28946 ] }),
28947 fieldLabel
28948 ] })
28949 }
28950 ),
28951 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(tooltip_exports.Popup, { children: errorMessage })
28952 ] }) : fieldLabel;
28953 }
28954 var get_label_content_default = getLabelContent;
28955
28956 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
28957 function getFirstValidationError(validity) {
28958 if (!validity) {
28959 return void 0;
28960 }
28961 const validityRules = Object.keys(validity).filter(
28962 (key) => key !== "children"
28963 );
28964 for (const key of validityRules) {
28965 const rule = validity[key];
28966 if (rule === void 0) {
28967 continue;
28968 }
28969 if (rule.type === "invalid") {
28970 if (rule.message) {
28971 return rule.message;
28972 }
28973 if (key === "required") {
28974 return "A required field is empty";
28975 }
28976 return "Unidentified validation error";
28977 }
28978 }
28979 if (validity.children) {
28980 for (const childValidity of Object.values(validity.children)) {
28981 const childError = getFirstValidationError(childValidity);
28982 if (childError) {
28983 return childError;
28984 }
28985 }
28986 }
28987 return void 0;
28988 }
28989 var get_first_validation_error_default = getFirstValidationError;
28990
28991 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
28992 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28993 function SummaryButton({
28994 data,
28995 field,
28996 fieldLabel,
28997 summaryFields,
28998 validity,
28999 touched,
29000 disabled: disabled2,
29001 isOpen,
29002 onClick
29003 }) {
29004 const { labelPosition, editVisibility } = field.layout;
29005 const errorMessage = get_first_validation_error_default(validity);
29006 const showError = touched && !!errorMessage;
29007 const labelClassName = get_label_classname_default(labelPosition, showError);
29008 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
29009 const className = clsx_default(
29010 "dataforms-layouts-panel__field-trigger",
29011 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
29012 {
29013 "is-disabled": disabled2,
29014 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
29015 }
29016 );
29017 const controlId = (0, import_compose15.useInstanceId)(
29018 SummaryButton,
29019 "dataforms-layouts-panel__field-control"
29020 );
29021 const ariaLabel = showError ? (0, import_i18n45.sprintf)(
29022 // translators: %s: Field name.
29023 (0, import_i18n45._x)("Edit %s (has errors)", "field"),
29024 fieldLabel || ""
29025 ) : (0, import_i18n45.sprintf)(
29026 // translators: %s: Field name.
29027 (0, import_i18n45._x)("Edit %s", "field"),
29028 fieldLabel || ""
29029 );
29030 const rowRef = (0, import_element96.useRef)(null);
29031 const editButtonRef = (0, import_element96.useRef)(null);
29032 const handleRowClick = (event) => {
29033 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) {
29034 return;
29035 }
29036 onClick();
29037 };
29038 const handleKeyDown = (event) => {
29039 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
29040 event.preventDefault();
29041 onClick();
29042 }
29043 };
29044 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
29045 "div",
29046 {
29047 ref: rowRef,
29048 className,
29049 onClick: !disabled2 ? handleRowClick : void 0,
29050 onKeyDown: !disabled2 ? handleKeyDown : void 0,
29051 children: [
29052 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { className: labelClassName, children: labelContent }),
29053 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(tooltip_exports.Root, { children: [
29054 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29055 tooltip_exports.Trigger,
29056 {
29057 render: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29058 "span",
29059 {
29060 className: "dataforms-layouts-panel__field-label-error-content",
29061 role: "img",
29062 "aria-label": errorMessage,
29063 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components51.Icon, { icon: error_default, size: 16 })
29064 }
29065 )
29066 }
29067 ),
29068 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(tooltip_exports.Popup, { children: errorMessage })
29069 ] }),
29070 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29071 "span",
29072 {
29073 id: `${controlId}`,
29074 className: "dataforms-layouts-panel__field-control",
29075 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29076 "span",
29077 {
29078 style: {
29079 display: "flex",
29080 flexDirection: "column",
29081 alignItems: "flex-start",
29082 width: "100%",
29083 gap: "2px"
29084 },
29085 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29086 "span",
29087 {
29088 style: { width: "100%" },
29089 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29090 summaryField.render,
29091 {
29092 item: data,
29093 field: summaryField
29094 }
29095 )
29096 },
29097 summaryField.id
29098 ))
29099 }
29100 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29101 summaryField.render,
29102 {
29103 item: data,
29104 field: summaryField
29105 },
29106 summaryField.id
29107 ))
29108 }
29109 ),
29110 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
29111 import_components51.Button,
29112 {
29113 ref: editButtonRef,
29114 className: "dataforms-layouts-panel__field-trigger-icon",
29115 label: ariaLabel,
29116 icon: pencil_default,
29117 size: "small",
29118 "aria-expanded": isOpen,
29119 "aria-haspopup": "dialog",
29120 "aria-describedby": `${controlId}`
29121 }
29122 )
29123 ]
29124 }
29125 );
29126 }
29127
29128 // packages/dataviews/build-module/hooks/use-form-validity.mjs
29129 var import_deepmerge = __toESM(require_cjs(), 1);
29130 var import_es62 = __toESM(require_es6(), 1);
29131 var import_element97 = __toESM(require_element(), 1);
29132 var import_i18n46 = __toESM(require_i18n(), 1);
29133 function isFormValid(formValidity) {
29134 if (!formValidity) {
29135 return true;
29136 }
29137 return Object.values(formValidity).every((fieldValidation) => {
29138 return Object.entries(fieldValidation).every(
29139 ([key, validation]) => {
29140 if (key === "children" && validation && typeof validation === "object") {
29141 return isFormValid(validation);
29142 }
29143 return validation.type !== "invalid" && validation.type !== "validating";
29144 }
29145 );
29146 });
29147 }
29148 function getFormFieldsToValidate(form, fields2) {
29149 const normalizedForm = normalize_form_default(form);
29150 if (normalizedForm.fields.length === 0) {
29151 return [];
29152 }
29153 const fieldsMap = /* @__PURE__ */ new Map();
29154 fields2.forEach((field) => {
29155 fieldsMap.set(field.id, field);
29156 });
29157 function processFormField(formField) {
29158 if ("children" in formField && Array.isArray(formField.children)) {
29159 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
29160 if (processedChildren.length === 0) {
29161 return null;
29162 }
29163 const fieldDef2 = fieldsMap.get(formField.id);
29164 if (fieldDef2) {
29165 const [normalizedField2] = normalizeFields([
29166 fieldDef2
29167 ]);
29168 return {
29169 id: formField.id,
29170 children: processedChildren,
29171 field: normalizedField2
29172 };
29173 }
29174 return {
29175 id: formField.id,
29176 children: processedChildren
29177 };
29178 }
29179 const fieldDef = fieldsMap.get(formField.id);
29180 if (!fieldDef) {
29181 return null;
29182 }
29183 const [normalizedField] = normalizeFields([fieldDef]);
29184 return {
29185 id: formField.id,
29186 children: [],
29187 field: normalizedField
29188 };
29189 }
29190 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
29191 return toValidate;
29192 }
29193 function setValidityAtPath(formValidity, fieldValidity, path) {
29194 if (!formValidity) {
29195 formValidity = {};
29196 }
29197 if (path.length === 0) {
29198 return formValidity;
29199 }
29200 const result = { ...formValidity };
29201 let current = result;
29202 for (let i2 = 0; i2 < path.length - 1; i2++) {
29203 const segment = path[i2];
29204 if (!current[segment]) {
29205 current[segment] = {};
29206 }
29207 current[segment] = { ...current[segment] };
29208 current = current[segment];
29209 }
29210 const finalKey = path[path.length - 1];
29211 current[finalKey] = {
29212 ...current[finalKey] || {},
29213 ...fieldValidity
29214 };
29215 return result;
29216 }
29217 function removeValidationProperty(formValidity, path, property) {
29218 if (!formValidity || path.length === 0) {
29219 return formValidity;
29220 }
29221 const result = { ...formValidity };
29222 let current = result;
29223 for (let i2 = 0; i2 < path.length - 1; i2++) {
29224 const segment = path[i2];
29225 if (!current[segment]) {
29226 return formValidity;
29227 }
29228 current[segment] = { ...current[segment] };
29229 current = current[segment];
29230 }
29231 const finalKey = path[path.length - 1];
29232 if (!current[finalKey]) {
29233 return formValidity;
29234 }
29235 const fieldValidity = { ...current[finalKey] };
29236 delete fieldValidity[property];
29237 if (Object.keys(fieldValidity).length === 0) {
29238 delete current[finalKey];
29239 } else {
29240 current[finalKey] = fieldValidity;
29241 }
29242 if (Object.keys(result).length === 0) {
29243 return void 0;
29244 }
29245 return result;
29246 }
29247 function handleElementsValidationAsync(promise, formField, promiseHandler) {
29248 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
29249 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
29250 elementsCounterRef.current[formField.id] = currentToken;
29251 promise.then((result) => {
29252 if (currentToken !== elementsCounterRef.current[formField.id]) {
29253 return;
29254 }
29255 if (!Array.isArray(result)) {
29256 setFormValidity((prev) => {
29257 const newFormValidity = setValidityAtPath(
29258 prev,
29259 {
29260 elements: {
29261 type: "invalid",
29262 message: (0, import_i18n46.__)("Could not validate elements.")
29263 }
29264 },
29265 [...path, formField.id]
29266 );
29267 return newFormValidity;
29268 });
29269 return;
29270 }
29271 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
29272 ...formField.field,
29273 elements: result
29274 })) {
29275 setFormValidity((prev) => {
29276 const newFormValidity = setValidityAtPath(
29277 prev,
29278 {
29279 elements: {
29280 type: "invalid",
29281 message: (0, import_i18n46.__)(
29282 "Value must be one of the elements."
29283 )
29284 }
29285 },
29286 [...path, formField.id]
29287 );
29288 return newFormValidity;
29289 });
29290 } else {
29291 setFormValidity((prev) => {
29292 return removeValidationProperty(
29293 prev,
29294 [...path, formField.id],
29295 "elements"
29296 );
29297 });
29298 }
29299 }).catch((error2) => {
29300 if (currentToken !== elementsCounterRef.current[formField.id]) {
29301 return;
29302 }
29303 let errorMessage;
29304 if (error2 instanceof Error) {
29305 errorMessage = error2.message;
29306 } else {
29307 errorMessage = String(error2) || (0, import_i18n46.__)(
29308 "Unknown error when running elements validation asynchronously."
29309 );
29310 }
29311 setFormValidity((prev) => {
29312 const newFormValidity = setValidityAtPath(
29313 prev,
29314 {
29315 elements: {
29316 type: "invalid",
29317 message: errorMessage
29318 }
29319 },
29320 [...path, formField.id]
29321 );
29322 return newFormValidity;
29323 });
29324 });
29325 }
29326 function handleCustomValidationAsync(promise, formField, promiseHandler) {
29327 const { customCounterRef, setFormValidity, path } = promiseHandler;
29328 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
29329 customCounterRef.current[formField.id] = currentToken;
29330 promise.then((result) => {
29331 if (currentToken !== customCounterRef.current[formField.id]) {
29332 return;
29333 }
29334 if (result === null) {
29335 setFormValidity((prev) => {
29336 return removeValidationProperty(
29337 prev,
29338 [...path, formField.id],
29339 "custom"
29340 );
29341 });
29342 return;
29343 }
29344 if (typeof result === "string") {
29345 setFormValidity((prev) => {
29346 const newFormValidity = setValidityAtPath(
29347 prev,
29348 {
29349 custom: {
29350 type: "invalid",
29351 message: result
29352 }
29353 },
29354 [...path, formField.id]
29355 );
29356 return newFormValidity;
29357 });
29358 return;
29359 }
29360 setFormValidity((prev) => {
29361 const newFormValidity = setValidityAtPath(
29362 prev,
29363 {
29364 custom: {
29365 type: "invalid",
29366 message: (0, import_i18n46.__)("Validation could not be processed.")
29367 }
29368 },
29369 [...path, formField.id]
29370 );
29371 return newFormValidity;
29372 });
29373 }).catch((error2) => {
29374 if (currentToken !== customCounterRef.current[formField.id]) {
29375 return;
29376 }
29377 let errorMessage;
29378 if (error2 instanceof Error) {
29379 errorMessage = error2.message;
29380 } else {
29381 errorMessage = String(error2) || (0, import_i18n46.__)(
29382 "Unknown error when running custom validation asynchronously."
29383 );
29384 }
29385 setFormValidity((prev) => {
29386 const newFormValidity = setValidityAtPath(
29387 prev,
29388 {
29389 custom: {
29390 type: "invalid",
29391 message: errorMessage
29392 }
29393 },
29394 [...path, formField.id]
29395 );
29396 return newFormValidity;
29397 });
29398 });
29399 }
29400 function validateFormField(item, formField, promiseHandler) {
29401 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
29402 return {
29403 required: { type: "invalid" }
29404 };
29405 }
29406 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
29407 return {
29408 pattern: {
29409 type: "invalid",
29410 message: (0, import_i18n46.__)("Value does not match the required pattern.")
29411 }
29412 };
29413 }
29414 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
29415 return {
29416 min: {
29417 type: "invalid",
29418 message: (0, import_i18n46.__)("Value is below the minimum.")
29419 }
29420 };
29421 }
29422 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
29423 return {
29424 max: {
29425 type: "invalid",
29426 message: (0, import_i18n46.__)("Value is above the maximum.")
29427 }
29428 };
29429 }
29430 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
29431 return {
29432 minLength: {
29433 type: "invalid",
29434 message: (0, import_i18n46.__)("Value is too short.")
29435 }
29436 };
29437 }
29438 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
29439 return {
29440 maxLength: {
29441 type: "invalid",
29442 message: (0, import_i18n46.__)("Value is too long.")
29443 }
29444 };
29445 }
29446 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
29447 return {
29448 elements: {
29449 type: "invalid",
29450 message: (0, import_i18n46.__)("Value must be one of the elements.")
29451 }
29452 };
29453 }
29454 let customError;
29455 if (!!formField.field && formField.field.isValid.custom) {
29456 try {
29457 const value = formField.field.getValue({ item });
29458 customError = formField.field.isValid.custom(
29459 (0, import_deepmerge.default)(
29460 item,
29461 formField.field.setValue({
29462 item,
29463 value
29464 })
29465 ),
29466 formField.field
29467 );
29468 } catch (error2) {
29469 let errorMessage;
29470 if (error2 instanceof Error) {
29471 errorMessage = error2.message;
29472 } else {
29473 errorMessage = String(error2) || (0, import_i18n46.__)("Unknown error when running custom validation.");
29474 }
29475 return {
29476 custom: {
29477 type: "invalid",
29478 message: errorMessage
29479 }
29480 };
29481 }
29482 }
29483 if (typeof customError === "string") {
29484 return {
29485 custom: {
29486 type: "invalid",
29487 message: customError
29488 }
29489 };
29490 }
29491 const fieldValidity = {};
29492 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
29493 handleElementsValidationAsync(
29494 formField.field.getElements(),
29495 formField,
29496 promiseHandler
29497 );
29498 fieldValidity.elements = {
29499 type: "validating",
29500 message: (0, import_i18n46.__)("Validating\u2026")
29501 };
29502 }
29503 if (customError instanceof Promise) {
29504 handleCustomValidationAsync(customError, formField, promiseHandler);
29505 fieldValidity.custom = {
29506 type: "validating",
29507 message: (0, import_i18n46.__)("Validating\u2026")
29508 };
29509 }
29510 if (Object.keys(fieldValidity).length > 0) {
29511 return fieldValidity;
29512 }
29513 if (formField.children.length > 0) {
29514 const result = {};
29515 formField.children.forEach((child) => {
29516 result[child.id] = validateFormField(item, child, {
29517 ...promiseHandler,
29518 path: [...promiseHandler.path, formField.id, "children"]
29519 });
29520 });
29521 const filteredResult = {};
29522 Object.entries(result).forEach(([key, value]) => {
29523 if (value !== void 0) {
29524 filteredResult[key] = value;
29525 }
29526 });
29527 if (Object.keys(filteredResult).length === 0) {
29528 return void 0;
29529 }
29530 return {
29531 children: filteredResult
29532 };
29533 }
29534 return void 0;
29535 }
29536 function getFormFieldValue(formField, item) {
29537 const fieldValue = formField?.field?.getValue({ item });
29538 if (formField.children.length === 0) {
29539 return fieldValue;
29540 }
29541 const childrenValues = formField.children.map(
29542 (child) => getFormFieldValue(child, item)
29543 );
29544 if (!childrenValues) {
29545 return fieldValue;
29546 }
29547 return {
29548 value: fieldValue,
29549 children: childrenValues
29550 };
29551 }
29552 function useFormValidity(item, fields2, form) {
29553 const [formValidity, setFormValidity] = (0, import_element97.useState)();
29554 const customCounterRef = (0, import_element97.useRef)({});
29555 const elementsCounterRef = (0, import_element97.useRef)({});
29556 const previousValuesRef = (0, import_element97.useRef)({});
29557 const validate = (0, import_element97.useCallback)(() => {
29558 const promiseHandler = {
29559 customCounterRef,
29560 elementsCounterRef,
29561 setFormValidity,
29562 path: [],
29563 item
29564 };
29565 const formFieldsToValidate = getFormFieldsToValidate(form, fields2);
29566 if (formFieldsToValidate.length === 0) {
29567 setFormValidity(void 0);
29568 return;
29569 }
29570 const newFormValidity = {};
29571 const untouchedFields = [];
29572 formFieldsToValidate.forEach((formField) => {
29573 const value = getFormFieldValue(formField, item);
29574 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
29575 previousValuesRef.current[formField.id],
29576 value
29577 )) {
29578 untouchedFields.push(formField.id);
29579 return;
29580 }
29581 previousValuesRef.current[formField.id] = value;
29582 const fieldValidity = validateFormField(
29583 item,
29584 formField,
29585 promiseHandler
29586 );
29587 if (fieldValidity !== void 0) {
29588 newFormValidity[formField.id] = fieldValidity;
29589 }
29590 });
29591 setFormValidity((existingFormValidity) => {
29592 let validity = {
29593 ...existingFormValidity,
29594 ...newFormValidity
29595 };
29596 const fieldsToKeep = [
29597 ...untouchedFields,
29598 ...Object.keys(newFormValidity)
29599 ];
29600 Object.keys(validity).forEach((key) => {
29601 if (validity && !fieldsToKeep.includes(key)) {
29602 delete validity[key];
29603 }
29604 });
29605 if (Object.keys(validity).length === 0) {
29606 validity = void 0;
29607 }
29608 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
29609 if (areEqual) {
29610 return existingFormValidity;
29611 }
29612 return validity;
29613 });
29614 }, [item, fields2, form]);
29615 (0, import_element97.useEffect)(() => {
29616 validate();
29617 }, [validate]);
29618 return {
29619 validity: formValidity,
29620 isValid: isFormValid(formValidity)
29621 };
29622 }
29623 var use_form_validity_default = useFormValidity;
29624
29625 // packages/dataviews/build-module/hooks/use-report-validity.mjs
29626 var import_element98 = __toESM(require_element(), 1);
29627 function useReportValidity(ref, shouldReport) {
29628 (0, import_element98.useEffect)(() => {
29629 if (shouldReport && ref.current) {
29630 const inputs = ref.current.querySelectorAll(
29631 "input, textarea, select"
29632 );
29633 inputs.forEach((input) => {
29634 input.reportValidity();
29635 });
29636 }
29637 }, [shouldReport, ref]);
29638 }
29639
29640 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
29641 var import_element99 = __toESM(require_element(), 1);
29642
29643 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
29644 function extractSummaryIds(summary) {
29645 if (Array.isArray(summary)) {
29646 return summary.map(
29647 (item) => typeof item === "string" ? item : item.id
29648 );
29649 }
29650 return [];
29651 }
29652 var getSummaryFields = (summaryField, fields2) => {
29653 if (Array.isArray(summaryField) && summaryField.length > 0) {
29654 const summaryIds = extractSummaryIds(summaryField);
29655 return summaryIds.map(
29656 (summaryId) => fields2.find((_field) => _field.id === summaryId)
29657 ).filter((_field) => _field !== void 0);
29658 }
29659 return [];
29660 };
29661
29662 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
29663 var getFieldDefinition = (field, fields2) => {
29664 const fieldDefinition = fields2.find((_field) => _field.id === field.id);
29665 if (!fieldDefinition) {
29666 return fields2.find((_field) => {
29667 if (!!field.children) {
29668 const simpleChildren = field.children.filter(
29669 (child) => !child.children
29670 );
29671 if (simpleChildren.length === 0) {
29672 return false;
29673 }
29674 return _field.id === simpleChildren[0].id;
29675 }
29676 return _field.id === field.id;
29677 });
29678 }
29679 return fieldDefinition;
29680 };
29681 function useFieldFromFormField(field) {
29682 const { fields: fields2 } = (0, import_element99.useContext)(dataform_context_default);
29683 const layout = field.layout;
29684 const summaryFields = getSummaryFields(layout.summary, fields2);
29685 const fieldDefinition = getFieldDefinition(field, fields2);
29686 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
29687 if (summaryFields.length === 0) {
29688 return {
29689 summaryFields: fieldDefinition ? [fieldDefinition] : [],
29690 fieldDefinition,
29691 fieldLabel
29692 };
29693 }
29694 return {
29695 summaryFields,
29696 fieldDefinition,
29697 fieldLabel
29698 };
29699 }
29700 var use_field_from_form_field_default = useFieldFromFormField;
29701
29702 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
29703 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
29704 function ModalContent({
29705 data,
29706 field,
29707 onChange,
29708 fieldLabel,
29709 onClose,
29710 touched
29711 }) {
29712 const { openAs } = field.layout;
29713 const { applyLabel, cancelLabel } = openAs;
29714 const { fields: fields2 } = (0, import_element100.useContext)(dataform_context_default);
29715 const [changes, setChanges] = (0, import_element100.useState)({});
29716 const modalData = (0, import_element100.useMemo)(() => {
29717 return (0, import_deepmerge2.default)(data, changes, {
29718 arrayMerge: (target, source) => source
29719 });
29720 }, [data, changes]);
29721 const form = (0, import_element100.useMemo)(
29722 () => ({
29723 layout: DEFAULT_LAYOUT,
29724 fields: !!field.children ? field.children : (
29725 // If not explicit children return the field id itself.
29726 [{ id: field.id, layout: DEFAULT_LAYOUT }]
29727 )
29728 }),
29729 [field]
29730 );
29731 const fieldsAsFieldType = fields2.map((f2) => ({
29732 ...f2,
29733 Edit: f2.Edit === null ? void 0 : f2.Edit,
29734 isValid: {
29735 required: f2.isValid.required?.constraint,
29736 elements: f2.isValid.elements?.constraint,
29737 min: f2.isValid.min?.constraint,
29738 max: f2.isValid.max?.constraint,
29739 pattern: f2.isValid.pattern?.constraint,
29740 minLength: f2.isValid.minLength?.constraint,
29741 maxLength: f2.isValid.maxLength?.constraint
29742 }
29743 }));
29744 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
29745 const onApply = () => {
29746 onChange(changes);
29747 onClose();
29748 };
29749 const handleOnChange = (newValue) => {
29750 setChanges(
29751 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
29752 arrayMerge: (target, source) => source
29753 })
29754 );
29755 };
29756 const focusOnMountRef = (0, import_compose16.useFocusOnMount)("firstInputElement");
29757 const contentRef = (0, import_element100.useRef)(null);
29758 const mergedRef = (0, import_compose16.useMergeRefs)([focusOnMountRef, contentRef]);
29759 useReportValidity(contentRef, touched);
29760 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
29761 import_components52.Modal,
29762 {
29763 className: "dataforms-layouts-panel__modal",
29764 onRequestClose: onClose,
29765 isFullScreen: false,
29766 title: fieldLabel,
29767 size: "medium",
29768 children: [
29769 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29770 DataFormLayout,
29771 {
29772 data: modalData,
29773 form,
29774 onChange: handleOnChange,
29775 validity,
29776 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29777 FieldLayout,
29778 {
29779 data: modalData,
29780 field: childField,
29781 onChange: handleOnChange,
29782 hideLabelFromVision: form.fields.length < 2,
29783 markWhenOptional,
29784 validity: childFieldValidity
29785 },
29786 childField.id
29787 )
29788 }
29789 ) }),
29790 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
29791 Stack,
29792 {
29793 direction: "row",
29794 className: "dataforms-layouts-panel__modal-footer",
29795 gap: "md",
29796 children: [
29797 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components52.__experimentalSpacer, { style: { flex: 1 } }),
29798 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29799 import_components52.Button,
29800 {
29801 variant: "tertiary",
29802 onClick: onClose,
29803 __next40pxDefaultSize: true,
29804 children: cancelLabel
29805 }
29806 ),
29807 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29808 import_components52.Button,
29809 {
29810 variant: "primary",
29811 onClick: onApply,
29812 __next40pxDefaultSize: true,
29813 children: applyLabel
29814 }
29815 )
29816 ]
29817 }
29818 )
29819 ]
29820 }
29821 );
29822 }
29823 function PanelModal({
29824 data,
29825 field,
29826 onChange,
29827 validity
29828 }) {
29829 const [touched, setTouched] = (0, import_element100.useState)(false);
29830 const [isOpen, setIsOpen] = (0, import_element100.useState)(false);
29831 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
29832 if (!fieldDefinition) {
29833 return null;
29834 }
29835 const handleClose = () => {
29836 setIsOpen(false);
29837 setTouched(true);
29838 };
29839 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
29840 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29841 SummaryButton,
29842 {
29843 data,
29844 field,
29845 fieldLabel,
29846 summaryFields,
29847 validity,
29848 touched,
29849 disabled: fieldDefinition.readOnly === true,
29850 onClick: () => setIsOpen(true),
29851 isOpen
29852 }
29853 ),
29854 isOpen && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
29855 ModalContent,
29856 {
29857 data,
29858 field,
29859 onChange,
29860 fieldLabel: fieldLabel ?? "",
29861 onClose: handleClose,
29862 touched
29863 }
29864 )
29865 ] });
29866 }
29867 var modal_default = PanelModal;
29868
29869 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
29870 var import_components53 = __toESM(require_components(), 1);
29871 var import_i18n47 = __toESM(require_i18n(), 1);
29872 var import_element101 = __toESM(require_element(), 1);
29873 var import_compose17 = __toESM(require_compose(), 1);
29874 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
29875 function DropdownHeader({
29876 title,
29877 onClose
29878 }) {
29879 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29880 Stack,
29881 {
29882 direction: "column",
29883 className: "dataforms-layouts-panel__dropdown-header",
29884 gap: "lg",
29885 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
29886 title && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalHeading, { level: 2, size: 13, children: title }),
29887 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components53.__experimentalSpacer, { style: { flex: 1 } }),
29888 onClose && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29889 import_components53.Button,
29890 {
29891 label: (0, import_i18n47.__)("Close"),
29892 icon: close_small_default,
29893 onClick: onClose,
29894 size: "small"
29895 }
29896 )
29897 ] })
29898 }
29899 );
29900 }
29901 function DropdownContentWithValidation({
29902 touched,
29903 children
29904 }) {
29905 const ref = (0, import_element101.useRef)(null);
29906 useReportValidity(ref, touched);
29907 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)("div", { ref, children });
29908 }
29909 function PanelDropdown({
29910 data,
29911 field,
29912 onChange,
29913 validity
29914 }) {
29915 const [touched, setTouched] = (0, import_element101.useState)(false);
29916 const [popoverAnchor, setPopoverAnchor] = (0, import_element101.useState)(
29917 null
29918 );
29919 const popoverProps = (0, import_element101.useMemo)(
29920 () => ({
29921 // Anchor the popover to the middle of the entire row so that it doesn't
29922 // move around when the label changes.
29923 anchor: popoverAnchor,
29924 placement: "left-start",
29925 offset: 36,
29926 shift: true
29927 }),
29928 [popoverAnchor]
29929 );
29930 const [dialogRef, dialogProps] = (0, import_compose17.__experimentalUseDialog)({
29931 focusOnMount: "firstInputElement"
29932 });
29933 const form = (0, import_element101.useMemo)(
29934 () => ({
29935 layout: DEFAULT_LAYOUT,
29936 fields: !!field.children ? field.children : (
29937 // If not explicit children return the field id itself.
29938 [{ id: field.id, layout: DEFAULT_LAYOUT }]
29939 )
29940 }),
29941 [field]
29942 );
29943 const formValidity = (0, import_element101.useMemo)(() => {
29944 if (validity === void 0) {
29945 return void 0;
29946 }
29947 if (!!field.children) {
29948 return validity?.children;
29949 }
29950 return { [field.id]: validity };
29951 }, [validity, field]);
29952 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
29953 if (!fieldDefinition) {
29954 return null;
29955 }
29956 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29957 "div",
29958 {
29959 ref: setPopoverAnchor,
29960 className: "dataforms-layouts-panel__field-dropdown-anchor",
29961 children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29962 import_components53.Dropdown,
29963 {
29964 contentClassName: "dataforms-layouts-panel__field-dropdown",
29965 popoverProps,
29966 focusOnMount: false,
29967 onToggle: (willOpen) => {
29968 if (!willOpen) {
29969 setTouched(true);
29970 }
29971 },
29972 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29973 SummaryButton,
29974 {
29975 data,
29976 field,
29977 fieldLabel,
29978 summaryFields,
29979 validity,
29980 touched,
29981 disabled: fieldDefinition.readOnly === true,
29982 isOpen,
29983 onClick: onToggle
29984 }
29985 ),
29986 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
29987 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29988 DropdownHeader,
29989 {
29990 title: fieldLabel,
29991 onClose
29992 }
29993 ),
29994 /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
29995 DataFormLayout,
29996 {
29997 data,
29998 form,
29999 onChange,
30000 validity: formValidity,
30001 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
30002 FieldLayout,
30003 {
30004 data,
30005 field: childField,
30006 onChange,
30007 hideLabelFromVision: (form?.fields ?? []).length < 2,
30008 markWhenOptional,
30009 validity: childFieldValidity
30010 },
30011 childField.id
30012 )
30013 }
30014 )
30015 ] }) })
30016 }
30017 )
30018 }
30019 );
30020 }
30021 var dropdown_default = PanelDropdown;
30022
30023 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
30024 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
30025 function FormPanelField({
30026 data,
30027 field,
30028 onChange,
30029 validity
30030 }) {
30031 const layout = field.layout;
30032 if (layout.openAs.type === "modal") {
30033 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
30034 modal_default,
30035 {
30036 data,
30037 field,
30038 onChange,
30039 validity
30040 }
30041 );
30042 }
30043 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
30044 dropdown_default,
30045 {
30046 data,
30047 field,
30048 onChange,
30049 validity
30050 }
30051 );
30052 }
30053
30054 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30055 var import_element102 = __toESM(require_element(), 1);
30056
30057 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
30058 var import_i18n48 = __toESM(require_i18n(), 1);
30059 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
30060 function countInvalidFields(validity) {
30061 if (!validity) {
30062 return 0;
30063 }
30064 let count = 0;
30065 const validityRules = Object.keys(validity).filter(
30066 (key) => key !== "children"
30067 );
30068 for (const key of validityRules) {
30069 const rule = validity[key];
30070 if (rule?.type === "invalid") {
30071 count++;
30072 }
30073 }
30074 if (validity.children) {
30075 for (const childValidity of Object.values(validity.children)) {
30076 count += countInvalidFields(childValidity);
30077 }
30078 }
30079 return count;
30080 }
30081 function ValidationBadge({
30082 validity
30083 }) {
30084 const invalidCount = countInvalidFields(validity);
30085 if (invalidCount === 0) {
30086 return null;
30087 }
30088 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(Badge, { intent: "high", children: (0, import_i18n48.sprintf)(
30089 /* translators: %d: Number of fields that need attention */
30090 (0, import_i18n48._n)(
30091 "%d field needs attention",
30092 "%d fields need attention",
30093 invalidCount
30094 ),
30095 invalidCount
30096 ) });
30097 }
30098
30099 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30100 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
30101 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
30102 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
30103 return false;
30104 }
30105 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
30106 const fieldConfig = summaryConfigArray.find((config) => {
30107 if (typeof config === "string") {
30108 return config === summaryField.id;
30109 }
30110 if (typeof config === "object" && "id" in config) {
30111 return config.id === summaryField.id;
30112 }
30113 return false;
30114 });
30115 if (!fieldConfig) {
30116 return false;
30117 }
30118 if (typeof fieldConfig === "string") {
30119 return true;
30120 }
30121 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
30122 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
30123 }
30124 return true;
30125 }
30126 function HeaderContent({
30127 data,
30128 fields: fields2,
30129 label,
30130 layout,
30131 isOpen,
30132 touched,
30133 validity
30134 }) {
30135 const summaryFields = getSummaryFields(layout.summary, fields2);
30136 const visibleSummaryFields = summaryFields.filter(
30137 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
30138 );
30139 const hasBadge = touched && layout.isCollapsible;
30140 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
30141 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
30142 Stack,
30143 {
30144 align: "center",
30145 justify: "space-between",
30146 className: "dataforms-layouts-card__field-header-content",
30147 children: [
30148 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(card_exports.Title, { children: label }),
30149 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
30150 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(ValidationBadge, { validity }),
30151 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30152 summaryField.render,
30153 {
30154 item: data,
30155 field: summaryField
30156 },
30157 summaryField.id
30158 )) })
30159 ] })
30160 ]
30161 }
30162 );
30163 }
30164 function BodyContent({
30165 data,
30166 field,
30167 form,
30168 onChange,
30169 hideLabelFromVision,
30170 markWhenOptional,
30171 validity,
30172 withHeader
30173 }) {
30174 if (field.children) {
30175 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_jsx_runtime139.Fragment, { children: [
30176 field.description && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
30177 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30178 DataFormLayout,
30179 {
30180 data,
30181 form,
30182 onChange,
30183 validity: validity?.children
30184 }
30185 )
30186 ] });
30187 }
30188 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
30189 if (!SingleFieldLayout) {
30190 return null;
30191 }
30192 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30193 SingleFieldLayout,
30194 {
30195 data,
30196 field,
30197 onChange,
30198 hideLabelFromVision: hideLabelFromVision || withHeader,
30199 markWhenOptional,
30200 validity
30201 }
30202 );
30203 }
30204 function FormCardField({
30205 data,
30206 field,
30207 onChange,
30208 hideLabelFromVision,
30209 markWhenOptional,
30210 validity
30211 }) {
30212 const { fields: fields2 } = (0, import_element102.useContext)(dataform_context_default);
30213 const layout = field.layout;
30214 const contentRef = (0, import_element102.useRef)(null);
30215 const form = (0, import_element102.useMemo)(
30216 () => ({
30217 layout: DEFAULT_LAYOUT,
30218 fields: field.children ?? []
30219 }),
30220 [field]
30221 );
30222 const { isOpened, isCollapsible } = layout;
30223 const [isOpen, setIsOpen] = (0, import_element102.useState)(isOpened);
30224 const [touched, setTouched] = (0, import_element102.useState)(false);
30225 (0, import_element102.useEffect)(() => {
30226 setIsOpen(isOpened);
30227 }, [isOpened]);
30228 const handleOpenChange = (0, import_element102.useCallback)((open) => {
30229 if (!open) {
30230 setTouched(true);
30231 }
30232 setIsOpen(open);
30233 }, []);
30234 const handleBlur = (0, import_element102.useCallback)(() => {
30235 setTouched(true);
30236 }, []);
30237 useReportValidity(
30238 contentRef,
30239 (isCollapsible ? isOpen : true) && touched
30240 );
30241 let label = field.label;
30242 let withHeader;
30243 if (field.children) {
30244 withHeader = !!label && layout.withHeader;
30245 } else {
30246 const fieldDefinition = fields2.find(
30247 (fieldDef) => fieldDef.id === field.id
30248 );
30249 if (!fieldDefinition || !fieldDefinition.Edit) {
30250 return null;
30251 }
30252 label = fieldDefinition.label;
30253 withHeader = !!label && layout.withHeader;
30254 }
30255 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30256 BodyContent,
30257 {
30258 data,
30259 field,
30260 form,
30261 onChange,
30262 hideLabelFromVision,
30263 markWhenOptional,
30264 validity,
30265 withHeader
30266 }
30267 );
30268 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30269 HeaderContent,
30270 {
30271 data,
30272 fields: fields2,
30273 label,
30274 layout,
30275 isOpen: isCollapsible ? !!isOpen : true,
30276 touched,
30277 validity
30278 }
30279 );
30280 if (withHeader && isCollapsible) {
30281 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
30282 collapsible_card_exports.Root,
30283 {
30284 className: "dataforms-layouts-card__field",
30285 open: isOpen,
30286 onOpenChange: handleOpenChange,
30287 children: [
30288 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(collapsible_card_exports.Header, { children: headerContent }),
30289 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
30290 collapsible_card_exports.Content,
30291 {
30292 ref: contentRef,
30293 onBlur: handleBlur,
30294 children: bodyContent
30295 }
30296 )
30297 ]
30298 }
30299 );
30300 }
30301 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
30302 withHeader && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(card_exports.Header, { children: headerContent }),
30303 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
30304 ] });
30305 }
30306
30307 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
30308 var import_components54 = __toESM(require_components(), 1);
30309 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
30310 function Header5({ title }) {
30311 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30312 Stack,
30313 {
30314 direction: "column",
30315 className: "dataforms-layouts-row__header",
30316 gap: "lg",
30317 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components54.__experimentalHeading, { level: 2, size: 13, children: title }) })
30318 }
30319 );
30320 }
30321 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_jsx_runtime140.Fragment, { children });
30322 function FormRowField({
30323 data,
30324 field,
30325 onChange,
30326 hideLabelFromVision,
30327 markWhenOptional,
30328 validity
30329 }) {
30330 const layout = field.layout;
30331 if (!!field.children) {
30332 const form = {
30333 layout: DEFAULT_LAYOUT,
30334 fields: field.children
30335 };
30336 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
30337 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Header5, { title: field.label }),
30338 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30339 DataFormLayout,
30340 {
30341 data,
30342 form,
30343 onChange,
30344 validity: validity?.children,
30345 as: EMPTY_WRAPPER,
30346 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30347 "div",
30348 {
30349 className: "dataforms-layouts-row__field-control",
30350 style: layout.styles[childField.id],
30351 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30352 FieldLayout,
30353 {
30354 data,
30355 field: childField,
30356 onChange,
30357 hideLabelFromVision,
30358 markWhenOptional,
30359 validity: childFieldValidity
30360 }
30361 )
30362 },
30363 childField.id
30364 )
30365 }
30366 ) })
30367 ] });
30368 }
30369 const RegularLayout = getFormFieldLayout("regular")?.component;
30370 if (!RegularLayout) {
30371 return null;
30372 }
30373 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_jsx_runtime140.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
30374 RegularLayout,
30375 {
30376 data,
30377 field,
30378 onChange,
30379 markWhenOptional,
30380 validity
30381 }
30382 ) }) });
30383 }
30384
30385 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
30386 var import_element103 = __toESM(require_element(), 1);
30387 var import_i18n49 = __toESM(require_i18n(), 1);
30388 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
30389 function FormDetailsField({
30390 data,
30391 field,
30392 onChange,
30393 validity
30394 }) {
30395 const { fields: fields2 } = (0, import_element103.useContext)(dataform_context_default);
30396 const detailsRef = (0, import_element103.useRef)(null);
30397 const contentRef = (0, import_element103.useRef)(null);
30398 const [touched, setTouched] = (0, import_element103.useState)(false);
30399 const [isOpen, setIsOpen] = (0, import_element103.useState)(false);
30400 const form = (0, import_element103.useMemo)(
30401 () => ({
30402 layout: DEFAULT_LAYOUT,
30403 fields: field.children ?? []
30404 }),
30405 [field]
30406 );
30407 (0, import_element103.useEffect)(() => {
30408 const details = detailsRef.current;
30409 if (!details) {
30410 return;
30411 }
30412 const handleToggle = () => {
30413 const nowOpen = details.open;
30414 if (!nowOpen) {
30415 setTouched(true);
30416 }
30417 setIsOpen(nowOpen);
30418 };
30419 details.addEventListener("toggle", handleToggle);
30420 return () => {
30421 details.removeEventListener("toggle", handleToggle);
30422 };
30423 }, []);
30424 useReportValidity(contentRef, isOpen && touched);
30425 const handleBlur = (0, import_element103.useCallback)(() => {
30426 setTouched(true);
30427 }, []);
30428 if (!field.children) {
30429 return null;
30430 }
30431 const summaryFieldId = field.layout.summary ?? "";
30432 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
30433 let summaryContent;
30434 if (summaryField && summaryField.render) {
30435 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(summaryField.render, { item: data, field: summaryField });
30436 } else {
30437 summaryContent = field.label || (0, import_i18n49.__)("More details");
30438 }
30439 return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
30440 "details",
30441 {
30442 ref: detailsRef,
30443 className: "dataforms-layouts-details__details",
30444 children: [
30445 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
30446 Stack,
30447 {
30448 direction: "row",
30449 align: "center",
30450 gap: "md",
30451 className: "dataforms-layouts-details__summary-content",
30452 children: [
30453 summaryContent,
30454 touched && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(ValidationBadge, { validity })
30455 ]
30456 }
30457 ) }),
30458 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30459 "div",
30460 {
30461 ref: contentRef,
30462 className: "dataforms-layouts-details__content",
30463 onBlur: handleBlur,
30464 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
30465 DataFormLayout,
30466 {
30467 data,
30468 form,
30469 onChange,
30470 validity: validity?.children
30471 }
30472 )
30473 }
30474 )
30475 ]
30476 }
30477 );
30478 }
30479
30480 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
30481 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
30482 var FORM_FIELD_LAYOUTS = [
30483 {
30484 type: "regular",
30485 component: FormRegularField,
30486 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30487 Stack,
30488 {
30489 direction: "column",
30490 className: "dataforms-layouts__wrapper",
30491 gap: "lg",
30492 children
30493 }
30494 )
30495 },
30496 {
30497 type: "panel",
30498 component: FormPanelField,
30499 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30500 Stack,
30501 {
30502 direction: "column",
30503 className: "dataforms-layouts__wrapper",
30504 gap: "md",
30505 children
30506 }
30507 )
30508 },
30509 {
30510 type: "card",
30511 component: FormCardField,
30512 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30513 Stack,
30514 {
30515 direction: "column",
30516 className: "dataforms-layouts__wrapper",
30517 gap: "xl",
30518 children
30519 }
30520 )
30521 },
30522 {
30523 type: "row",
30524 component: FormRowField,
30525 wrapper: ({
30526 children,
30527 layout
30528 }) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30529 Stack,
30530 {
30531 direction: "column",
30532 className: "dataforms-layouts__wrapper",
30533 gap: "lg",
30534 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30535 Stack,
30536 {
30537 direction: "row",
30538 gap: "lg",
30539 align: layout.alignment,
30540 children
30541 }
30542 ) })
30543 }
30544 )
30545 },
30546 {
30547 type: "details",
30548 component: FormDetailsField
30549 }
30550 ];
30551 function getFormFieldLayout(type) {
30552 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
30553 }
30554
30555 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
30556 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
30557 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
30558 function DataFormLayout({
30559 data,
30560 form,
30561 onChange,
30562 validity,
30563 children,
30564 as
30565 }) {
30566 const { fields: fieldDefinitions } = (0, import_element104.useContext)(dataform_context_default);
30567 const markWhenOptional = (0, import_element104.useMemo)(() => {
30568 const requiredCount = fieldDefinitions.filter(
30569 (f2) => !!f2.isValid?.required
30570 ).length;
30571 const optionalCount = fieldDefinitions.length - requiredCount;
30572 return requiredCount > optionalCount;
30573 }, [fieldDefinitions]);
30574 function getFieldDefinition2(field) {
30575 return fieldDefinitions.find(
30576 (fieldDefinition) => fieldDefinition.id === field.id
30577 );
30578 }
30579 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
30580 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
30581 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
30582 if (!FieldLayout) {
30583 return null;
30584 }
30585 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
30586 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
30587 return null;
30588 }
30589 if (children) {
30590 return children(
30591 FieldLayout,
30592 formField,
30593 validity?.[formField.id],
30594 markWhenOptional
30595 );
30596 }
30597 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30598 FieldLayout,
30599 {
30600 data,
30601 field: formField,
30602 onChange,
30603 markWhenOptional,
30604 validity: validity?.[formField.id]
30605 },
30606 formField.id
30607 );
30608 }) });
30609 }
30610
30611 // packages/dataviews/build-module/dataform/index.mjs
30612 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
30613 function DataForm({
30614 data,
30615 form,
30616 fields: fields2,
30617 onChange,
30618 validity
30619 }) {
30620 const normalizedForm = (0, import_element105.useMemo)(() => normalize_form_default(form), [form]);
30621 const normalizedFields = (0, import_element105.useMemo)(
30622 () => normalizeFields(fields2),
30623 [fields2]
30624 );
30625 if (!form.fields) {
30626 return null;
30627 }
30628 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30629 DataFormLayout,
30630 {
30631 data,
30632 form: normalizedForm,
30633 onChange,
30634 validity
30635 }
30636 ) });
30637 }
30638
30639 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
30640 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
30641 var import_deprecated = __toESM(require_deprecated(), 1);
30642 function normalizeSearchInput2(input = "") {
30643 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
30644 }
30645 var EMPTY_ARRAY8 = [];
30646 function filterSortAndPaginate(data, view, fields2) {
30647 if (!data) {
30648 return {
30649 data: EMPTY_ARRAY8,
30650 paginationInfo: { totalItems: 0, totalPages: 0 }
30651 };
30652 }
30653 const _fields = normalizeFields(fields2);
30654 let filteredData = [...data];
30655 if (view.search) {
30656 const normalizedSearch = normalizeSearchInput2(view.search);
30657 filteredData = filteredData.filter((item) => {
30658 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
30659 const fieldValue = field.getValue({ item });
30660 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
30661 return values.some(
30662 (value) => normalizeSearchInput2(String(value)).includes(
30663 normalizedSearch
30664 )
30665 );
30666 });
30667 });
30668 }
30669 if (view.filters && view.filters?.length > 0) {
30670 view.filters.forEach((filter) => {
30671 const field = _fields.find(
30672 (_field) => _field.id === filter.field
30673 );
30674 if (field) {
30675 if (filter.operator === OPERATOR_IS_NOT_ALL) {
30676 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
30677 since: "7.0",
30678 alternative: "'isNone'"
30679 });
30680 }
30681 const handler = field.filter[filter.operator];
30682 if (handler) {
30683 filteredData = filteredData.filter(
30684 (item) => handler(item, field, filter.value)
30685 );
30686 }
30687 }
30688 });
30689 }
30690 const sortByField = view.sort?.field ? _fields.find((field) => {
30691 return field.enableSorting !== false && field.id === view.sort?.field;
30692 }) : null;
30693 const groupByField = view.groupBy?.field ? _fields.find((field) => {
30694 return field.enableSorting !== false && field.id === view.groupBy?.field;
30695 }) : null;
30696 if (sortByField || groupByField) {
30697 filteredData.sort((a2, b2) => {
30698 if (groupByField) {
30699 const groupCompare = groupByField.sort(
30700 a2,
30701 b2,
30702 view.groupBy?.direction ?? "asc"
30703 );
30704 if (groupCompare !== 0) {
30705 return groupCompare;
30706 }
30707 }
30708 if (sortByField) {
30709 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
30710 }
30711 return 0;
30712 });
30713 }
30714 let totalItems = filteredData.length;
30715 let totalPages = 1;
30716 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
30717 const start = view.startPosition - 1;
30718 const end = Math.min(start + view.perPage, totalItems);
30719 filteredData = filteredData?.slice(start, end);
30720 } else if (view.page !== void 0 && view.perPage !== void 0) {
30721 const start = (view.page - 1) * view.perPage;
30722 totalItems = filteredData?.length || 0;
30723 totalPages = Math.ceil(totalItems / view.perPage);
30724 filteredData = filteredData?.slice(start, start + view.perPage);
30725 }
30726 return {
30727 data: filteredData,
30728 paginationInfo: {
30729 totalItems,
30730 totalPages
30731 }
30732 };
30733 }
30734
30735 // routes/guidelines/components/guideline-accordion-form.tsx
30736 var import_i18n50 = __toESM(require_i18n());
30737 var import_element107 = __toESM(require_element());
30738 var import_data7 = __toESM(require_data());
30739 var import_notices = __toESM(require_notices());
30740
30741 // routes/guidelines/data.ts
30742 var import_element106 = __toESM(require_element());
30743 var import_data6 = __toESM(require_data());
30744 var import_core_data = __toESM(require_core_data());
30745 var import_blocks = __toESM(require_blocks());
30746
30747 // routes/lock-unlock/index.ts
30748 var import_private_apis3 = __toESM(require_private_apis());
30749 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
30750 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
30751 "@wordpress/routes"
30752 );
30753
30754 // routes/guidelines/data.ts
30755 var { isContentBlock } = unlock3(import_blocks.privateApis);
30756 var KNOWLEDGE_KIND = "postType";
30757 var KNOWLEDGE_NAME = "wp_knowledge";
30758 var SCOPE_PREFIX = "guideline-";
30759 var BLOCK_PREFIX = "guideline-block-";
30760 var BLOCKS_SCOPE = "blocks";
30761 var NO_MATCH_SLUG = "guideline-__none__";
30762 function scopeSlug(scope) {
30763 return `${SCOPE_PREFIX}${scope}`;
30764 }
30765 function blockSlug(blockName) {
30766 return `${BLOCK_PREFIX}${blockName.replace("/", "_")}`;
30767 }
30768 function useContentBlocks() {
30769 return (0, import_data6.useSelect)(
30770 (s2) => (
30771 // @ts-ignore - getBlockTypes is untyped in this context.
30772 s2(import_blocks.store).getBlockTypes().filter(
30773 (block) => isContentBlock(block.name)
30774 )
30775 ),
30776 []
30777 );
30778 }
30779 function useGuidelineData() {
30780 const { records: scopeRecords, hasResolved: scopesResolved } = (0, import_core_data.useEntityRecords)("root", "guidelineScope");
30781 const contentBlocks = useContentBlocks();
30782 const scopes = (0, import_element106.useMemo)(
30783 () => (scopeRecords ?? []).map((s2) => ({
30784 slug: s2.slug,
30785 title: s2.title,
30786 description: s2.description,
30787 order: s2.order ?? 0
30788 })).sort((a2, b2) => a2.order - b2.order),
30789 [scopeRecords]
30790 );
30791 const slugs = (0, import_element106.useMemo)(() => {
30792 const hasBlocksScope = scopes.some((s2) => s2.slug === BLOCKS_SCOPE);
30793 const list = [
30794 // The Blocks scope has no single row; its per-block rows are added below.
30795 ...scopes.filter((s2) => s2.slug !== BLOCKS_SCOPE).map((s2) => scopeSlug(s2.slug)),
30796 ...hasBlocksScope ? contentBlocks.map((b2) => blockSlug(b2.name)) : []
30797 ];
30798 return list.length > 0 ? list : [NO_MATCH_SLUG];
30799 }, [scopes, contentBlocks]);
30800 const query = (0, import_element106.useMemo)(
30801 () => ({
30802 slug: slugs,
30803 // The published row is the canonical one. Private/draft/suffixed
30804 // rows with the same slug are placeholders the page ignores; a save
30805 // reclaims them (see saveGuidelineRow) rather than showing them.
30806 status: ["publish"],
30807 per_page: -1
30808 }),
30809 [slugs]
30810 );
30811 const { records: rowRecords, hasResolved: rowsResolved } = (0, import_core_data.useEntityRecords)(
30812 KNOWLEDGE_KIND,
30813 KNOWLEDGE_NAME,
30814 query
30815 );
30816 const bySlug = (0, import_element106.useMemo)(() => {
30817 const map = {};
30818 for (const row of rowRecords ?? []) {
30819 map[row.slug] = {
30820 id: row.id,
30821 content: row.content?.raw ?? ""
30822 };
30823 }
30824 return map;
30825 }, [rowRecords]);
30826 return {
30827 scopes,
30828 contentBlocks,
30829 bySlug,
30830 query,
30831 // Use hasResolved (not isResolving): isResolving is briefly false before
30832 // the rows query starts, which would let the page render with empty
30833 // content and clobber freshly-typed text once the rows arrive.
30834 isLoading: !scopesResolved || !rowsResolved
30835 };
30836 }
30837 async function findReclaimableRow(slug) {
30838 const rows = await (0, import_data6.resolveSelect)(import_core_data.store).getEntityRecords(
30839 KNOWLEDGE_KIND,
30840 KNOWLEDGE_NAME,
30841 {
30842 slug,
30843 status: ["publish", "private", "draft", "pending", "future"],
30844 per_page: 1
30845 }
30846 );
30847 return rows?.[0];
30848 }
30849 async function saveGuidelineRow(slug, title, content, existingId, query) {
30850 const {
30851 editEntityRecord,
30852 saveEditedEntityRecord,
30853 saveEntityRecord,
30854 invalidateResolution
30855 } = (0, import_data6.dispatch)(import_core_data.store);
30856 const reclaimable = existingId ? void 0 : await findReclaimableRow(slug);
30857 const targetId = existingId ?? reclaimable?.id;
30858 if (targetId) {
30859 const edits = {
30860 title,
30861 content,
30862 status: "publish"
30863 };
30864 if (reclaimable) {
30865 const currentUser = await (0, import_data6.resolveSelect)(import_core_data.store).getCurrentUser();
30866 if (currentUser?.id && reclaimable.author !== currentUser.id) {
30867 edits.author = currentUser.id;
30868 }
30869 }
30870 await editEntityRecord(
30871 KNOWLEDGE_KIND,
30872 KNOWLEDGE_NAME,
30873 targetId,
30874 edits
30875 );
30876 await saveEditedEntityRecord(
30877 KNOWLEDGE_KIND,
30878 KNOWLEDGE_NAME,
30879 targetId,
30880 {
30881 throwOnError: true
30882 }
30883 );
30884 } else {
30885 await saveEntityRecord(
30886 KNOWLEDGE_KIND,
30887 KNOWLEDGE_NAME,
30888 { slug, title, content, status: "publish" },
30889 { throwOnError: true }
30890 );
30891 }
30892 if (!existingId) {
30893 invalidateResolution("getEntityRecords", [
30894 KNOWLEDGE_KIND,
30895 KNOWLEDGE_NAME,
30896 query
30897 ]);
30898 await (0, import_data6.resolveSelect)(import_core_data.store).getEntityRecords(
30899 KNOWLEDGE_KIND,
30900 KNOWLEDGE_NAME,
30901 query
30902 );
30903 }
30904 }
30905 async function deleteGuidelineRow(id) {
30906 await (0, import_data6.dispatch)(import_core_data.store).deleteEntityRecord(
30907 KNOWLEDGE_KIND,
30908 KNOWLEDGE_NAME,
30909 id,
30910 { force: true },
30911 { throwOnError: true }
30912 );
30913 }
30914
30915 // routes/guidelines/components/guideline-accordion-form.tsx
30916 function GuidelineAccordionForm({
30917 scope,
30918 existingId,
30919 content,
30920 query
30921 }) {
30922 const { createSuccessNotice } = (0, import_data7.useDispatch)(import_notices.store);
30923 const [loading, setLoading] = (0, import_element107.useState)(false);
30924 const [error2, setError] = (0, import_element107.useState)(null);
30925 const [showClearConfirmation, setShowClearConfirmation] = (0, import_element107.useState)(false);
30926 const [draft, setDraft] = (0, import_element107.useState)(content);
30927 (0, import_element107.useEffect)(() => setDraft(content), [content]);
30928 const data = (0, import_element107.useMemo)(() => ({ guidelines: draft }), [draft]);
30929 const fields2 = (0, import_element107.useMemo)(
30930 () => [
30931 {
30932 id: "guidelines",
30933 label: (0, import_i18n50.sprintf)(
30934 /* translators: %s: Guideline section title. */
30935 (0, import_i18n50.__)("%s guidelines"),
30936 scope.title
30937 ),
30938 type: "text",
30939 Edit: "textarea"
30940 }
30941 ],
30942 [scope.title]
30943 );
30944 const form = (0, import_element107.useMemo)(
30945 () => ({
30946 layout: { type: "regular", labelPosition: "none" },
30947 fields: ["guidelines"]
30948 }),
30949 []
30950 );
30951 const handleSave = (event) => {
30952 event.preventDefault();
30953 setLoading(true);
30954 saveGuidelineRow(
30955 scopeSlug(scope.slug),
30956 scope.title,
30957 draft,
30958 existingId,
30959 query
30960 ).then(() => {
30961 setError(null);
30962 createSuccessNotice((0, import_i18n50.__)("Guidelines saved."), {
30963 type: "snackbar"
30964 });
30965 }).catch(
30966 (e2) => setError(
30967 (0, import_i18n50.sprintf)(
30968 /* translators: %s: Error message. */
30969 (0, import_i18n50.__)("Error saving guidelines: %s"),
30970 e2.message
30971 )
30972 )
30973 ).finally(() => setLoading(false));
30974 };
30975 const handleClearClick = () => setShowClearConfirmation(true);
30976 const handleClearConfirm = () => {
30977 if (!existingId) {
30978 setShowClearConfirmation(false);
30979 return;
30980 }
30981 setLoading(true);
30982 deleteGuidelineRow(existingId).then(() => {
30983 setError(null);
30984 createSuccessNotice((0, import_i18n50.__)("Guidelines cleared."), {
30985 type: "snackbar"
30986 });
30987 }).catch(
30988 (e2) => setError(
30989 (0, import_i18n50.sprintf)(
30990 /* translators: %s: Error message. */
30991 (0, import_i18n50.__)("Error clearing guidelines: %s"),
30992 e2.message
30993 )
30994 )
30995 ).finally(() => {
30996 setLoading(false);
30997 setShowClearConfirmation(false);
30998 });
30999 };
31000 return /* @__PURE__ */ React.createElement("form", { onSubmit: handleSave }, /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(
31001 DataForm,
31002 {
31003 data,
31004 fields: fields2,
31005 form,
31006 onChange: (edits) => setDraft(edits.guidelines ?? draft)
31007 }
31008 ), error2 && /* @__PURE__ */ React.createElement(import_components55.Notice, { status: "error", onRemove: () => setError(null) }, error2), /* @__PURE__ */ React.createElement(import_components55.__experimentalHStack, { spacing: 4, alignment: "left" }, /* @__PURE__ */ React.createElement(
31009 import_components55.Button,
31010 {
31011 variant: "primary",
31012 type: "submit",
31013 disabled: loading || !draft,
31014 accessibleWhenDisabled: true,
31015 isBusy: loading,
31016 __next40pxDefaultSize: true
31017 },
31018 (0, import_i18n50.__)("Save guidelines")
31019 ), /* @__PURE__ */ React.createElement(
31020 import_components55.Button,
31021 {
31022 variant: "tertiary",
31023 type: "button",
31024 disabled: loading || !existingId,
31025 accessibleWhenDisabled: true,
31026 isBusy: loading,
31027 onClick: handleClearClick,
31028 __next40pxDefaultSize: true
31029 },
31030 (0, import_i18n50.__)("Clear guidelines")
31031 ))), /* @__PURE__ */ React.createElement(
31032 import_components55.__experimentalConfirmDialog,
31033 {
31034 isOpen: showClearConfirmation,
31035 title: (0, import_i18n50.sprintf)(
31036 /* translators: %s: Guideline section title. */
31037 (0, import_i18n50.__)("Clear %s guidelines"),
31038 scope.title
31039 ),
31040 __experimentalHideHeader: false,
31041 onConfirm: handleClearConfirm,
31042 onCancel: () => setShowClearConfirmation(false),
31043 confirmButtonText: (0, import_i18n50.__)("Clear guidelines"),
31044 isBusy: loading,
31045 size: "small"
31046 },
31047 (0, import_i18n50.sprintf)(
31048 /* translators: %s: Guideline section title. */
31049 (0, import_i18n50.__)("You are about to clear the %s guidelines."),
31050 scope.title
31051 )
31052 ));
31053 }
31054
31055 // routes/guidelines/components/block-guidelines.tsx
31056 var import_components57 = __toESM(require_components());
31057 var import_i18n52 = __toESM(require_i18n());
31058 var import_element109 = __toESM(require_element());
31059 var import_data11 = __toESM(require_data());
31060 var import_notices3 = __toESM(require_notices());
31061
31062 // routes/guidelines/components/block-guideline-modal.tsx
31063 var import_components56 = __toESM(require_components());
31064 var import_i18n51 = __toESM(require_i18n());
31065 var import_element108 = __toESM(require_element());
31066 var import_data9 = __toESM(require_data());
31067 var import_notices2 = __toESM(require_notices());
31068
31069 // routes/guidelines/components/block-guideline-modal.scss
31070 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='7c0ecac6c9']")) {
31071 const style = document.createElement("style");
31072 style.setAttribute("data-wp-hash", "7c0ecac6c9");
31073 style.appendChild(document.createTextNode(".block-guideline-modal{width:min(100%,660px)}.block-guideline-modal__actions{margin-top:8px}"));
31074 document.head.appendChild(style);
31075 }
31076
31077 // routes/guidelines/components/block-guideline-modal.tsx
31078 function BlockGuidelineModal({
31079 closeModal,
31080 initialBlock,
31081 contentBlocks,
31082 bySlug,
31083 query
31084 }) {
31085 const [selectedBlock, setSelectedBlock] = (0, import_element108.useState)(
31086 initialBlock
31087 );
31088 const [isSaving, setIsSaving] = (0, import_element108.useState)(false);
31089 const [error2, setError] = (0, import_element108.useState)(null);
31090 const [showRemoveConfirmation, setShowRemoveConfirmation] = (0, import_element108.useState)(false);
31091 const isEditing = !!initialBlock;
31092 const currentGuideline = selectedBlock ? bySlug[blockSlug(selectedBlock)]?.content ?? "" : "";
31093 const [guidelineText, setGuidelineText] = (0, import_element108.useState)(currentGuideline);
31094 const availableBlockOptions = (0, import_element108.useMemo)(() => {
31095 return contentBlocks.filter(
31096 (block) => !bySlug[blockSlug(block.name)] || block.name === selectedBlock
31097 ).filter((block) => block.name !== initialBlock).map((block) => ({
31098 value: block.name,
31099 label: block.title
31100 }));
31101 }, [contentBlocks, bySlug, initialBlock, selectedBlock]);
31102 const selectedBlockLabel = (0, import_element108.useMemo)(
31103 () => contentBlocks.find((block) => block.name === selectedBlock)?.title || "",
31104 [contentBlocks, selectedBlock]
31105 );
31106 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices2.store);
31107 const handleSave = (value) => {
31108 value = value.trim();
31109 if (!selectedBlock) {
31110 return;
31111 }
31112 setIsSaving(true);
31113 const slug = blockSlug(selectedBlock);
31114 const existingId = bySlug[slug]?.id;
31115 let operation;
31116 if (value) {
31117 operation = saveGuidelineRow(
31118 slug,
31119 selectedBlock,
31120 value,
31121 existingId,
31122 query
31123 );
31124 } else if (existingId) {
31125 operation = deleteGuidelineRow(existingId);
31126 } else {
31127 operation = Promise.resolve();
31128 }
31129 operation.then(() => {
31130 setError(null);
31131 createSuccessNotice(
31132 value ? (0, import_i18n51.__)("Guidelines saved.") : (0, import_i18n51.__)("Guidelines removed."),
31133 { type: "snackbar" }
31134 );
31135 closeModal();
31136 }).catch((e2) => setError(e2.message)).finally(() => setIsSaving(false));
31137 };
31138 const canSubmit = selectedBlock && guidelineText.trim().length > 0;
31139 let submitButtonLabel = (0, import_i18n51.__)("Save guidelines");
31140 if (isSaving) {
31141 submitButtonLabel = (0, import_i18n51.__)("Saving\u2026");
31142 }
31143 return /* @__PURE__ */ React.createElement(
31144 import_components56.Modal,
31145 {
31146 className: "block-guideline-modal",
31147 title: isEditing ? (0, import_i18n51.__)("Edit guidelines") : (0, import_i18n51.__)("Add guidelines"),
31148 onRequestClose: closeModal
31149 },
31150 /* @__PURE__ */ React.createElement(import_components56.__experimentalVStack, { spacing: 4 }, isEditing ? /* @__PURE__ */ React.createElement(
31151 import_components56.TextControl,
31152 {
31153 label: (0, import_i18n51.__)("Block"),
31154 value: selectedBlockLabel,
31155 onChange: () => {
31156 },
31157 disabled: true
31158 }
31159 ) : /* @__PURE__ */ React.createElement(
31160 import_components56.ComboboxControl,
31161 {
31162 label: (0, import_i18n51.__)("Block"),
31163 options: availableBlockOptions,
31164 value: selectedBlock,
31165 onChange: (value) => setSelectedBlock(value ?? void 0),
31166 placeholder: (0, import_i18n51.__)("Search for a block\u2026")
31167 }
31168 ), /* @__PURE__ */ React.createElement(
31169 import_components56.TextareaControl,
31170 {
31171 label: (0, import_i18n51.__)("Guideline text"),
31172 value: guidelineText,
31173 onChange: setGuidelineText,
31174 placeholder: (0, import_i18n51.__)(
31175 "Enter guidelines for how this block should be used\u2026"
31176 ),
31177 rows: 6
31178 }
31179 ), error2 && /* @__PURE__ */ React.createElement(import_components56.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n51.sprintf)(
31180 /* translators: %s: Error message. */
31181 (0, import_i18n51.__)("Error: %s"),
31182 error2
31183 )), /* @__PURE__ */ React.createElement(
31184 import_components56.__experimentalHStack,
31185 {
31186 justify: "flex-end",
31187 spacing: 2,
31188 className: "block-guideline-modal__actions"
31189 },
31190 isEditing && /* @__PURE__ */ React.createElement(
31191 import_components56.Button,
31192 {
31193 variant: "tertiary",
31194 isDestructive: true,
31195 onClick: () => setShowRemoveConfirmation(true),
31196 disabled: isSaving,
31197 accessibleWhenDisabled: true,
31198 type: "button",
31199 __next40pxDefaultSize: true
31200 },
31201 (0, import_i18n51.__)("Remove")
31202 ),
31203 /* @__PURE__ */ React.createElement(
31204 import_components56.Button,
31205 {
31206 variant: "primary",
31207 onClick: () => handleSave(guidelineText),
31208 disabled: !canSubmit || isSaving,
31209 isBusy: isSaving,
31210 accessibleWhenDisabled: true,
31211 __next40pxDefaultSize: true
31212 },
31213 submitButtonLabel
31214 )
31215 )),
31216 /* @__PURE__ */ React.createElement(
31217 import_components56.__experimentalConfirmDialog,
31218 {
31219 isOpen: showRemoveConfirmation,
31220 title: (0, import_i18n51.__)("Remove block guidelines"),
31221 __experimentalHideHeader: false,
31222 onConfirm: () => {
31223 handleSave("");
31224 setShowRemoveConfirmation(false);
31225 },
31226 onCancel: () => setShowRemoveConfirmation(false),
31227 confirmButtonText: (0, import_i18n51.__)("Remove"),
31228 isBusy: isSaving,
31229 size: "small"
31230 },
31231 (0, import_i18n51.sprintf)(
31232 /* translators: %s: Block name. */
31233 (0, import_i18n51.__)(
31234 "You are about to remove the block guidelines for the %s block."
31235 ),
31236 selectedBlockLabel
31237 )
31238 )
31239 );
31240 }
31241
31242 // routes/guidelines/components/block-guidelines.scss
31243 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='68ec5761c9']")) {
31244 const style = document.createElement("style");
31245 style.setAttribute("data-wp-hash", "68ec5761c9");
31246 style.appendChild(document.createTextNode(".block-guidelines .block-guidelines__icon{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.block-guidelines .block-guidelines__icon svg{fill:currentColor;max-height:24px;max-width:24px;min-height:20px;min-width:20px}@media (forced-colors:active){.block-guidelines .block-guidelines__icon svg{fill:CanvasText}}.block-guidelines .dataviews-view-list__field-wrapper{display:flex;justify-content:center}.block-guidelines .dataviews-wrapper{margin-inline:-24px}.block-guidelines .dataviews-search{margin-inline:24px}"));
31247 document.head.appendChild(style);
31248 }
31249
31250 // routes/guidelines/components/block-guidelines.tsx
31251 var PER_PAGE = 5;
31252 var initialView = {
31253 type: "list",
31254 search: "",
31255 page: 1,
31256 perPage: PER_PAGE,
31257 filters: [],
31258 mediaField: "icon",
31259 showMedia: true,
31260 titleField: "label"
31261 // Default (non-compact) density: its 48px media tile gives block icons
31262 // padding around the canonical 24px render, without shrinking the icon
31263 // (which would crop icons that lack a viewBox, e.g. core/icon).
31264 };
31265 var fields = [
31266 {
31267 id: "icon",
31268 label: (0, import_i18n52.__)("Icon"),
31269 type: "media",
31270 // No `size` prop: block icons render at their native 24px, matching the
31271 // editor's `.block-editor-block-icon`. That keeps viewBox-less icons
31272 // (e.g. core/icon) centered and uncropped. Painted and clamped in
31273 // block-guidelines.scss.
31274 render: ({ item }) => /* @__PURE__ */ React.createElement("div", { className: "block-guidelines__icon" }, /* @__PURE__ */ React.createElement(import_components57.Icon, { icon: item.icon ?? block_default_default }))
31275 },
31276 {
31277 id: "label",
31278 label: (0, import_i18n52.__)("Label"),
31279 type: "text",
31280 enableGlobalSearch: true,
31281 getValue: ({ item }) => item.label,
31282 render: ({ item }) => item.label
31283 }
31284 ];
31285 function BlockGuidelines({
31286 contentBlocks,
31287 bySlug,
31288 query
31289 }) {
31290 const [isOpen, setIsOpen] = (0, import_element109.useState)(false);
31291 const [view, setView] = (0, import_element109.useState)(initialView);
31292 const [selectedItem, setSelectedItem] = (0, import_element109.useState)();
31293 const [error2, setError] = (0, import_element109.useState)(null);
31294 const [busy, setBusy] = (0, import_element109.useState)(false);
31295 const [itemToDelete, setItemToDelete] = (0, import_element109.useState)(
31296 null
31297 );
31298 const { createSuccessNotice } = (0, import_data11.useDispatch)(import_notices3.store);
31299 const rows = (0, import_element109.useMemo)(
31300 () => contentBlocks.filter((block) => bySlug[blockSlug(block.name)]).map((block) => ({
31301 id: block.name,
31302 label: block.title,
31303 guidelines: bySlug[blockSlug(block.name)]?.content ?? "",
31304 icon: block.icon?.src
31305 })),
31306 [contentBlocks, bySlug]
31307 );
31308 const handleRowClick = (id) => {
31309 setSelectedItem(id);
31310 setIsOpen(true);
31311 };
31312 const actions = (0, import_element109.useMemo)(
31313 () => [
31314 {
31315 id: "edit",
31316 label: (0, import_i18n52.__)("Edit"),
31317 callback: (items) => {
31318 handleRowClick(items[0].id);
31319 }
31320 },
31321 {
31322 id: "remove",
31323 label: (0, import_i18n52.__)("Remove"),
31324 callback: (items) => {
31325 setItemToDelete(items[0]);
31326 }
31327 }
31328 ],
31329 [setItemToDelete]
31330 );
31331 const handleDelete = () => {
31332 if (!itemToDelete) {
31333 return;
31334 }
31335 const row = bySlug[blockSlug(itemToDelete.id)];
31336 if (!row) {
31337 setItemToDelete(null);
31338 return;
31339 }
31340 setBusy(true);
31341 deleteGuidelineRow(row.id).then(() => {
31342 setError(null);
31343 createSuccessNotice((0, import_i18n52.__)("Guidelines removed."), {
31344 type: "snackbar"
31345 });
31346 }).catch((e2) => setError(e2.message)).finally(() => {
31347 setBusy(false);
31348 setItemToDelete(null);
31349 });
31350 };
31351 const { data: processedData, paginationInfo } = (0, import_element109.useMemo)(
31352 () => filterSortAndPaginate(rows, view, fields),
31353 [rows, view]
31354 );
31355 (0, import_element109.useEffect)(() => {
31356 const lastPage = Math.max(paginationInfo.totalPages, 1);
31357 if (view.page && view.page > lastPage) {
31358 setView(
31359 (currentView) => currentView.page && currentView.page > lastPage ? {
31360 ...currentView,
31361 page: lastPage
31362 } : currentView
31363 );
31364 }
31365 }, [paginationInfo.totalPages, view.page]);
31366 const closeModal = () => {
31367 setIsOpen(false);
31368 setSelectedItem(void 0);
31369 };
31370 const openModal = () => {
31371 setSelectedItem(void 0);
31372 setIsOpen(true);
31373 };
31374 const shouldShowDataViewControls = rows.length > PER_PAGE;
31375 return /* @__PURE__ */ React.createElement(import_components57.__experimentalVStack, { spacing: 4, className: "block-guidelines" }, error2 && /* @__PURE__ */ React.createElement(import_components57.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n52.sprintf)(
31376 /* translators: %s: Error message. */
31377 (0, import_i18n52.__)("Error: %s"),
31378 error2
31379 )), rows.length > 0 && /* @__PURE__ */ React.createElement(
31380 dataviews_default,
31381 {
31382 paginationInfo,
31383 data: processedData,
31384 view,
31385 onChangeView: setView,
31386 fields,
31387 actions,
31388 config: { perPageSizes: [PER_PAGE] },
31389 onChangeSelection: (items) => {
31390 handleRowClick(items[0]);
31391 },
31392 defaultLayouts: {
31393 list: true
31394 }
31395 },
31396 /* @__PURE__ */ React.createElement(import_components57.__experimentalVStack, { spacing: 4 }, shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Search, { label: (0, import_i18n52.__)("Search blocks") }), /* @__PURE__ */ React.createElement(dataviews_default.Layout, null), shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Footer, null))
31397 ), /* @__PURE__ */ React.createElement(import_components57.__experimentalHStack, null, /* @__PURE__ */ React.createElement(
31398 import_components57.Button,
31399 {
31400 variant: "primary",
31401 onClick: openModal,
31402 __next40pxDefaultSize: true
31403 },
31404 (0, import_i18n52.__)("Add guidelines")
31405 )), isOpen && /* @__PURE__ */ React.createElement(
31406 BlockGuidelineModal,
31407 {
31408 closeModal,
31409 initialBlock: selectedItem,
31410 contentBlocks,
31411 bySlug,
31412 query
31413 }
31414 ), /* @__PURE__ */ React.createElement(
31415 import_components57.__experimentalConfirmDialog,
31416 {
31417 isOpen: !!itemToDelete,
31418 title: (0, import_i18n52.__)("Remove block guidelines"),
31419 __experimentalHideHeader: false,
31420 onConfirm: handleDelete,
31421 onCancel: () => setItemToDelete(null),
31422 confirmButtonText: (0, import_i18n52.__)("Remove"),
31423 isBusy: busy,
31424 size: "small"
31425 },
31426 (0, import_i18n52.sprintf)(
31427 /* translators: %s: Block name. */
31428 (0, import_i18n52.__)(
31429 "You are about to remove the block guidelines for the %s block."
31430 ),
31431 itemToDelete?.label ?? ""
31432 )
31433 ));
31434 }
31435
31436 // routes/guidelines/components/guideline-actions-section.tsx
31437 var import_components59 = __toESM(require_components());
31438 var import_i18n54 = __toESM(require_i18n());
31439 var import_element110 = __toESM(require_element());
31440
31441 // routes/guidelines/components/guideline-actions-section.scss
31442 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='6d10be742e']")) {
31443 const style = document.createElement("style");
31444 style.setAttribute("data-wp-hash", "6d10be742e");
31445 style.appendChild(document.createTextNode('.guidelines__actions{margin:16px auto 0;width:min(680px,100%)}.guidelines__actions-card{overflow:hidden;padding:0}.guidelines__actions-list{list-style:none;margin:0;padding:0}.guidelines__action-list-item{margin-bottom:0;position:relative}.guidelines__action-list-item:not(:first-child):before{background-color:#f0f0f0;content:"";height:1px;position:absolute;top:0;inset-inline:24px}.guidelines__action-row{align-items:center;box-sizing:border-box;padding:16px 24px;width:100%}.guidelines__actions-card .guidelines__action-button{font-size:13px;font-weight:400;justify-content:center;min-width:100px}.guidelines__action-title{color:#1e1e1e}.guidelines__action-description{color:#757575}'));
31446 document.head.appendChild(style);
31447 }
31448
31449 // routes/guidelines/import-export.ts
31450 var import_blob = __toESM(require_blob());
31451 var import_data13 = __toESM(require_data());
31452 var import_i18n53 = __toESM(require_i18n());
31453 var import_notices4 = __toESM(require_notices());
31454 var BLOCK_NAME_RE = /^[a-z0-9-]+\/[a-z0-9-]+$/;
31455 function isValidImport(data) {
31456 return !!data && typeof data === "object" && "guideline_categories" in data && typeof data.guideline_categories === "object" && data.guideline_categories !== null;
31457 }
31458 function readGuidelines(value) {
31459 if (value && typeof value === "object" && "guidelines" in value) {
31460 const text = value.guidelines;
31461 return typeof text === "string" ? text : "";
31462 }
31463 return "";
31464 }
31465 function exportGuidelines(scopes, bySlug, contentBlocks) {
31466 const categories = {};
31467 for (const scope of scopes) {
31468 if (scope.slug === BLOCKS_SCOPE) {
31469 continue;
31470 }
31471 categories[scope.slug] = {
31472 guidelines: bySlug[scopeSlug(scope.slug)]?.content ?? ""
31473 };
31474 }
31475 const blocks = {};
31476 for (const block of contentBlocks) {
31477 const content = bySlug[blockSlug(block.name)]?.content;
31478 if (content) {
31479 blocks[block.name] = { guidelines: content };
31480 }
31481 }
31482 categories.blocks = blocks;
31483 const now = /* @__PURE__ */ new Date();
31484 const exportDate = [
31485 now.getFullYear(),
31486 String(now.getMonth() + 1).padStart(2, "0"),
31487 String(now.getDate()).padStart(2, "0")
31488 ].join("-");
31489 (0, import_blob.downloadBlob)(
31490 `guidelines-${exportDate}.json`,
31491 JSON.stringify({ guideline_categories: categories }, null, 2),
31492 "application/json"
31493 );
31494 (0, import_data13.dispatch)(import_notices4.store).createSuccessNotice(
31495 (0, import_i18n53.__)("Guidelines exported."),
31496 {
31497 type: "snackbar"
31498 }
31499 );
31500 }
31501 async function importGuidelines(file, scopes, bySlug, contentBlocks, query) {
31502 const parsed = JSON.parse(await file.text());
31503 if (!isValidImport(parsed)) {
31504 throw new Error(
31505 (0, import_i18n53.__)(
31506 "Check that your file contains valid JSON markup and try again."
31507 )
31508 );
31509 }
31510 const categories = parsed.guideline_categories;
31511 for (const scope of scopes) {
31512 if (scope.slug === BLOCKS_SCOPE) {
31513 continue;
31514 }
31515 const slug = scopeSlug(scope.slug);
31516 const value = readGuidelines(categories[scope.slug]);
31517 const existingId = bySlug[slug]?.id;
31518 if (value) {
31519 await saveGuidelineRow(
31520 slug,
31521 scope.title,
31522 value,
31523 existingId,
31524 query
31525 );
31526 } else if (existingId) {
31527 await deleteGuidelineRow(existingId);
31528 }
31529 }
31530 const importedBlocks = categories.blocks && typeof categories.blocks === "object" ? categories.blocks : {};
31531 for (const [name, value] of Object.entries(importedBlocks)) {
31532 if (!BLOCK_NAME_RE.test(name)) {
31533 continue;
31534 }
31535 const slug = blockSlug(name);
31536 const text = readGuidelines(value);
31537 const existingId = bySlug[slug]?.id;
31538 if (text) {
31539 await saveGuidelineRow(slug, name, text, existingId, query);
31540 } else if (existingId) {
31541 await deleteGuidelineRow(existingId);
31542 }
31543 }
31544 for (const block of contentBlocks) {
31545 const existingId = bySlug[blockSlug(block.name)]?.id;
31546 if (existingId && !(block.name in importedBlocks)) {
31547 await deleteGuidelineRow(existingId);
31548 }
31549 }
31550 (0, import_data13.dispatch)(import_notices4.store).createSuccessNotice(
31551 (0, import_i18n53.__)("Guidelines imported."),
31552 {
31553 type: "snackbar"
31554 }
31555 );
31556 }
31557
31558 // routes/guidelines/components/action-item.tsx
31559 var import_components58 = __toESM(require_components());
31560 function ActionItem({
31561 slug,
31562 title,
31563 description,
31564 buttonLabel,
31565 ariaLabel,
31566 onClick,
31567 disabled: disabled2,
31568 isBusy
31569 }) {
31570 const descriptionId = `guidelines-action-${slug}-description`;
31571 return /* @__PURE__ */ React.createElement(import_components58.__experimentalHStack, { justify: "space-between", className: "guidelines__action-row" }, /* @__PURE__ */ React.createElement(import_components58.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(
31572 import_components58.__experimentalHeading,
31573 {
31574 level: 3,
31575 size: 13,
31576 weight: 400,
31577 className: "guidelines__action-title"
31578 },
31579 title
31580 ), /* @__PURE__ */ React.createElement(
31581 import_components58.__experimentalText,
31582 {
31583 id: descriptionId,
31584 size: 13,
31585 weight: 400,
31586 variant: "muted",
31587 className: "guidelines__action-description"
31588 },
31589 description
31590 )), /* @__PURE__ */ React.createElement(
31591 import_components58.Button,
31592 {
31593 size: "compact",
31594 variant: "secondary",
31595 className: "guidelines__action-button",
31596 "aria-label": ariaLabel,
31597 "aria-describedby": descriptionId,
31598 onClick,
31599 isBusy,
31600 disabled: disabled2,
31601 accessibleWhenDisabled: true
31602 },
31603 buttonLabel
31604 ));
31605 }
31606
31607 // routes/guidelines/components/guideline-actions-section.tsx
31608 function getErrorMessage(err) {
31609 return err instanceof Error ? err.message : (0, import_i18n54.__)("Unknown error");
31610 }
31611 function GuidelineActionsSection({
31612 scopes,
31613 contentBlocks,
31614 bySlug,
31615 query
31616 }) {
31617 const fileInputRef = (0, import_element110.useRef)(null);
31618 const [isImporting, setIsImporting] = (0, import_element110.useState)(false);
31619 const [error2, setError] = (0, import_element110.useState)(null);
31620 const [pendingImport, setPendingImport] = (0, import_element110.useState)(null);
31621 function handleImportClick() {
31622 fileInputRef.current?.click();
31623 }
31624 function handleFileChange(event) {
31625 const file = event.target.files?.[0];
31626 event.target.value = "";
31627 if (!file) {
31628 return;
31629 }
31630 setPendingImport(file);
31631 }
31632 async function handleModalContinue() {
31633 if (!pendingImport) {
31634 return;
31635 }
31636 const file = pendingImport;
31637 setPendingImport(null);
31638 setIsImporting(true);
31639 try {
31640 await importGuidelines(
31641 file,
31642 scopes,
31643 bySlug,
31644 contentBlocks,
31645 query
31646 );
31647 setError(null);
31648 } catch (err) {
31649 setError(
31650 (0, import_i18n54.sprintf)(
31651 /* translators: %s: Error message. */
31652 (0, import_i18n54.__)("We ran into a problem importing your guidelines: %s"),
31653 getErrorMessage(err)
31654 )
31655 );
31656 } finally {
31657 setIsImporting(false);
31658 }
31659 }
31660 function handleExportClick() {
31661 try {
31662 exportGuidelines(scopes, bySlug, contentBlocks);
31663 setError(null);
31664 } catch (err) {
31665 setError(
31666 (0, import_i18n54.sprintf)(
31667 /* translators: %s: Error message. */
31668 (0, import_i18n54.__)("We ran into a problem exporting your guidelines: %s"),
31669 getErrorMessage(err)
31670 )
31671 );
31672 }
31673 }
31674 const ACTIONS = [
31675 {
31676 slug: "import",
31677 title: (0, import_i18n54.__)("Import"),
31678 description: (0, import_i18n54.__)("Upload a JSON file to import your guidelines."),
31679 buttonLabel: (0, import_i18n54.__)("Upload"),
31680 ariaLabel: (0, import_i18n54.__)("Import guidelines"),
31681 onClick: handleImportClick,
31682 isBusy: isImporting,
31683 disabled: isImporting || !!pendingImport
31684 },
31685 {
31686 slug: "export",
31687 title: (0, import_i18n54.__)("Export"),
31688 description: (0, import_i18n54.__)("Export your guidelines to a JSON file."),
31689 buttonLabel: (0, import_i18n54.__)("Download"),
31690 ariaLabel: (0, import_i18n54.__)("Export guidelines"),
31691 onClick: handleExportClick
31692 }
31693 ];
31694 return /* @__PURE__ */ React.createElement(import_components59.__experimentalVStack, { spacing: 4, className: "guidelines__actions" }, /* @__PURE__ */ React.createElement(import_components59.__experimentalHeading, { level: 3, size: 15 }, (0, import_i18n54.__)("Actions")), /* @__PURE__ */ React.createElement(
31695 "input",
31696 {
31697 type: "file",
31698 accept: ".json",
31699 ref: fileInputRef,
31700 onChange: handleFileChange,
31701 style: { display: "none" }
31702 }
31703 ), error2 && /* @__PURE__ */ React.createElement(
31704 import_components59.Notice,
31705 {
31706 status: "error",
31707 onRemove: () => setError(null),
31708 isDismissible: true
31709 },
31710 error2
31711 ), /* @__PURE__ */ React.createElement(import_components59.Card, { className: "guidelines__actions-card" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__actions-list" }, ACTIONS.map((action) => /* @__PURE__ */ React.createElement(
31712 "li",
31713 {
31714 key: action.slug,
31715 className: "guidelines__action-list-item"
31716 },
31717 /* @__PURE__ */ React.createElement(ActionItem, { ...action })
31718 )))), /* @__PURE__ */ React.createElement(
31719 import_components59.__experimentalConfirmDialog,
31720 {
31721 isOpen: !!pendingImport,
31722 __experimentalHideHeader: false,
31723 title: (0, import_i18n54.__)("Import guidelines"),
31724 confirmButtonText: (0, import_i18n54.__)("Continue"),
31725 onConfirm: handleModalContinue,
31726 onCancel: () => setPendingImport(null),
31727 size: "small"
31728 },
31729 (0, import_i18n54.__)(
31730 "Importing new guidelines will replace your current guidelines."
31731 )
31732 ));
31733 }
31734
31735 // routes/guidelines/stage.tsx
31736 function GuidelinesPage() {
31737 const { scopes, contentBlocks, bySlug, query, isLoading } = useGuidelineData();
31738 const [hasLoaded, setHasLoaded] = (0, import_element111.useState)(false);
31739 (0, import_element111.useEffect)(() => {
31740 if (!isLoading) {
31741 setHasLoaded(true);
31742 }
31743 }, [isLoading]);
31744 return /* @__PURE__ */ React.createElement(
31745 page_default,
31746 {
31747 title: (0, import_i18n55.__)("Guidelines"),
31748 subTitle: (0, import_i18n55.__)(
31749 "Set content standards that guide your team, inform plugins, and help AI tools generate content that matches your site's voice and requirements."
31750 )
31751 },
31752 !hasLoaded ? /* @__PURE__ */ React.createElement("div", { className: "guidelines__loading" }, /* @__PURE__ */ React.createElement(import_components60.Spinner, null)) : /* @__PURE__ */ React.createElement(import_components60.__experimentalVStack, { className: "guidelines__content" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__list" }, scopes.map((scope) => /* @__PURE__ */ React.createElement(
31753 "li",
31754 {
31755 key: scope.slug,
31756 className: "guidelines__list-item",
31757 "data-slug": scope.slug
31758 },
31759 /* @__PURE__ */ React.createElement(
31760 GuidelineAccordion,
31761 {
31762 title: scope.title,
31763 description: scope.description
31764 },
31765 scope.slug === BLOCKS_SCOPE ? /* @__PURE__ */ React.createElement(
31766 BlockGuidelines,
31767 {
31768 contentBlocks,
31769 bySlug,
31770 query
31771 }
31772 ) : /* @__PURE__ */ React.createElement(
31773 GuidelineAccordionForm,
31774 {
31775 scope,
31776 existingId: bySlug[scopeSlug(scope.slug)]?.id,
31777 content: bySlug[scopeSlug(scope.slug)]?.content ?? "",
31778 query
31779 }
31780 )
31781 )
31782 ))), /* @__PURE__ */ React.createElement(
31783 GuidelineActionsSection,
31784 {
31785 scopes,
31786 contentBlocks,
31787 bySlug,
31788 query
31789 }
31790 ))
31791 );
31792 }
31793 var stage = GuidelinesPage;
31794 export {
31795 stage
31796 };
31797 /*! Bundled license information:
31798
31799 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
31800 (**
31801 * @license React
31802 * use-sync-external-store-shim.development.js
31803 *
31804 * Copyright (c) Meta Platforms, Inc. and affiliates.
31805 *
31806 * This source code is licensed under the MIT license found in the
31807 * LICENSE file in the root directory of this source tree.
31808 *)
31809
31810 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
31811 (**
31812 * @license React
31813 * use-sync-external-store-shim/with-selector.development.js
31814 *
31815 * Copyright (c) Meta Platforms, Inc. and affiliates.
31816 *
31817 * This source code is licensed under the MIT license found in the
31818 * LICENSE file in the root directory of this source tree.
31819 *)
31820 */
31821